BmnRoot
Loading...
Searching...
No Matches
BmnHistECAL.cxx
Go to the documentation of this file.
1/*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6
7/*
8 * File: BmnHistEcal.cxx
9 * Author: ilnur
10 *
11 * Created on March 17, 2017, 2:48 PM
12 */
13
14#include "TGaxis.h"
15
16#include "BmnHistECAL.h"
17
18BmnHistECAL::BmnHistECAL(TString title, TString path) : BmnHist() {
19 fTitle = title;
20 fName = title + "_cl";
21 TGaxis::SetMaxDigits(1);
22 TString name;
23 name = fTitle + "_h2d_Grid";
24 h2d_grid = new TH2D(name, fTitle + " Grid", 32, 0, 32, 32, 0, 32);
25 h2d_grid->GetXaxis()->SetTitle("iX");
26 h2d_grid->GetYaxis()->SetTitle("iY");
28 h2d_grid->GetZaxis()->SetNoExponent(kTRUE);
29 name = fTitle + "_h2d_Profile";
30 h2d_profile = new TH2D(name, fTitle + " Profile", 1200, 0, 1200, 1200, 0, 1200);
31 h2d_profile->GetXaxis()->SetTitle("X");
32 h2d_profile->GetYaxis()->SetTitle("Y");
33 BmnHist::SetHistStyleTH1(h2d_profile);
34 name = fTitle + "_X_Amplitude";
35 hx = new TH1D(name, fTitle + " X Amplitude", 1200, 0, 1200);
36 hx->GetYaxis()->SetNoExponent(kTRUE);
37 hx->GetYaxis()->SetMoreLogLabels(kFALSE);
38 name = fTitle + "_Y_Amplitude";
39 hy = new TH1D(name, fTitle + " Y Amplitude", 1200, 0, 1200);
40 hy->GetYaxis()->SetNoExponent(kFALSE);
41 hx->GetYaxis()->SetMoreLogLabels(kTRUE);
42 name = fTitle + "CanvasAmplitudes";
43 canAmps = new TCanvas(name, name, PAD_WIDTH * ECAL_ROWS, PAD_HEIGHT * ECAL_COLS);
44 canAmps->Divide(ECAL_ROWS, ECAL_COLS);
45 canAmpsPads.resize(ECAL_ROWS * ECAL_COLS);
46 NamesAmps.resize(ECAL_ROWS * ECAL_COLS);
47
48 PadInfo *p = new PadInfo();
49 p->current = hx;
50 canAmpsPads[0] = p;
51 PadInfo *p1 = new PadInfo();
52 p1->current = hy;
53 canAmpsPads[1] = p1;
54
55 for (Int_t rowIndex = 0; rowIndex < ECAL_ROWS; rowIndex++) {
56 for (Int_t colIndex = 0; colIndex < ECAL_COLS; colIndex++) {
57 Int_t iPad = rowIndex * ECAL_COLS + colIndex;
58 canAmps->GetPad(iPad + 1)->SetGrid();
59 NamesAmps[iPad] = canAmpsPads[iPad]->current->GetName();
60 TH1 *h = canAmpsPads[iPad]->current;
61 h->GetXaxis()->SetTitle("Coordinate");
62 h->GetYaxis()->SetTitle("Amplitude");
64 h->GetYaxis()->SetNoExponent(kFALSE);
65 }
66 }
67}
68
70 delete canAmps;
71 if (fDir != NULL)
72 return;
73 delete h2d_grid;
74 delete h2d_profile;
75 delete hx;
76 delete hy;
77 for (auto pad : canAmpsPads)
78 delete pad;
79}
80
81void BmnHistECAL::Register(THttpServer *serv) {
82 fServer = serv;
83 fServer->Register("/", this);
84 TString path = "/" + fTitle + "/";
85 fServer->Register(path, h2d_grid);
86 fServer->Register(path, h2d_profile);
87 fServer->Register(path, canAmps);
88 TString cmd = "/" + fName + "/->Reset()";
89 fServer->SetItemField(path.Data(), "_monitoring", "2000");
90 fServer->SetItemField(path.Data(), "_layout", "grid3x3");
91 TString cmdTitle = path + "Reset";
92 fServer->RegisterCommand(cmdTitle.Data(), cmd.Data(), "button;");
93 fServer->Restrict(cmdTitle, "visible=shift");
94 fServer->Restrict(cmdTitle, "allow=shift");
95 cmd = "/" + fName + "/->SetRefRun(%arg1%)";
96 cmdTitle = path + "SetRefRun";
97 fServer->RegisterCommand(cmdTitle.Data(), cmd.Data(), "button;");
98}
99
100void BmnHistECAL::SetDir(TFile *outFile = NULL, TTree *recoTree = NULL) {
101 frecoTree = recoTree;
102 fDir = NULL;
103 if (outFile != NULL)
104 fDir = outFile->mkdir(fTitle + "_hists");
105 h2d_grid->SetDirectory(fDir);
106 h2d_profile->SetDirectory(fDir);
107 hx->SetDirectory(fDir);
108 hy->SetDirectory(fDir);
109
110}
111
113 BmnHist::DrawRef(canAmps, &canAmpsPads);
114 return;
115}
116
118 TClonesArray * digits = fDigiArrays->ecal;
119 if (!digits)
120 return;
121 Double_t xAmp = 0;
122 Double_t yAmp = 0;
123 Double_t Amp = 0;
124 for (Int_t iDig = 0; iDig < digits->GetEntriesFast(); iDig++) {
125 BmnECALDigit* dig = (BmnECALDigit*) digits->At(iDig);
126 Int_t ix = dig->GetIX();
127 Int_t iy = dig->GetIY();
128 Double_t amp = dig->GetAmp();
129 Amp += amp;
130 h2d_grid->Fill(ix, iy, dig->GetAmp());
131 xAmp += amp * dig->GetX();
132 yAmp += amp * dig->GetY();
133 }
134 if (Amp == 0)
135 return;
136 xAmp /= Amp;
137 yAmp /= Amp;
138 h2d_profile->Fill(xAmp, yAmp, Amp);
139 hx->Fill(xAmp, Amp);
140 hy->Fill(yAmp, Amp);
141}
142
144 TString FileName = Form("bmn_run%04d_hist.root", id);
145 printf("SetRefRun: %s\n", FileName.Data());
146 if (refRunName != FileName) {
147 refRunName = FileName;
148 refID = id;
149 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canAmpsPads, NamesAmps);
150 DrawBoth();
151 }
152 return kBMNSUCCESS;
153}
154
156 for (auto pad : canAmpsPads) {
157 if (pad->ref) delete pad->ref;
158 pad->ref = NULL;
159 }
160 refID = 0;
161}
162
164 h2d_grid->Reset();
165 h2d_profile->Reset();
166 hx->Reset();
167 hy->Reset();
168}
#define PAD_WIDTH
Definition BmnAdcQA.cxx:3
#define PAD_HEIGHT
Definition BmnAdcQA.cxx:4
BmnStatus
Definition BmnEnums.h:24
@ kBMNSUCCESS
Definition BmnEnums.h:25
Float_t GetX() const
Float_t GetY() const
Float_t GetAmp() const
UChar_t GetIX() const
UChar_t GetIY() const
void ClearRefRun()
void FillFromDigi(DigiArrays *fDigiArrays)
BmnStatus SetRefRun(Int_t id)
BmnHistECAL(TString title, TString path="")
void SetDir(TFile *outFile, TTree *recoTree)
virtual ~BmnHistECAL()
void Register(THttpServer *serv)
TTree * frecoTree
Definition BmnHist.h:88
Int_t refID
Definition BmnHist.h:92
TString refPath
Definition BmnHist.h:90
TDirectory * fDir
Definition BmnHist.h:89
static void DrawRef(unique_ptr< TCanvas > &canGemStrip, vector< PadInfo * > *canGemStripPads)
Definition BmnHist.cxx:15
static void SetHistStyleTH1(TH1 *h)
Definition BmnHist.cxx:195
TString refRunName
Definition BmnHist.h:91
static BmnStatus LoadRefRun(Int_t refID, TString FullName, TString fTitle, vector< PadInfo * > canPads, vector< TString > Names)
Definition BmnHist.cxx:100
THttpServer * fServer
Definition BmnHist.h:87
TClonesArray * ecal
Definition DigiArrays.h:138
Storage for pad content and it's options.
Definition PadInfo.h:20
TH1 * current
Definition PadInfo.h:78
#define ECAL_ROWS
Definition BmnHistECAL.h:19
#define ECAL_COLS
Definition BmnHistECAL.h:20