ATLAS Offline Software
Loading...
Searching...
No Matches
LArIdTranslatorHelper Class Reference

#include <LArIdTranslatorHelper.h>

Collaboration diagram for LArIdTranslatorHelper:

Public Member Functions

 LArIdTranslatorHelper (const TString &inputfile)
 ~LArIdTranslatorHelper ()
int GetPartitionLayerIndex (const int partition, const int layer) const
bool FindChannel (const int index, float eta, float phi)
bool LoadIdTranslator (const TString &file)
bool IsInitialized ()
TCanvas * CaloPartitionLayerDisplay (TH2 **h, const Char_t *title="", bool kLogz=true)
TH2 * GetCaloPartitionLayerMap (const int index, bool kProfile=false)
const Char_t * GetPartitonLayerName (const int index)
void MakeTranslatorMapping (const char *inputtreefile, const char *inputhistfile, const int run)
bool IsHVLine (const int hvline) const
Int_t GetNpl ()
TTree * Tree ()

Public Attributes

Int_t bec
Int_t side
Int_t ft
Int_t sl
Int_t ch
Int_t sa
Int_t part
Float_t eta
Float_t phi
Float_t x
Float_t y
Float_t z
ULong64_t onlid
ULong64_t offlid
ULong64_t ttid
std::vector< int > * hvid
Long_t entry
Int_t binetadqm
Int_t binphidqm1
Int_t binphidqm2

Private Attributes

bool m_kInitialized
TTree * m_tree
TFile * m_file
Int_t m_ntotal
Int_t m_extrabins
Int_t m_canvas_counts
Int_t m_clonemap_counts
Char_t m_namebuf [128] {}
Int_t m_nPartitionLayers
std::vector< std::string > m_PartitionLayers
Int_t m_nHistCategories
std::vector< std::string > m_HistCategories
std::vector< std::vector< TH2I * > > m_HistCellmaps

Detailed Description

Definition at line 29 of file LArIdTranslatorHelper.h.

Constructor & Destructor Documentation

◆ LArIdTranslatorHelper()

LArIdTranslatorHelper::LArIdTranslatorHelper ( const TString & inputfile)

Definition at line 33 of file LArIdTranslatorHelper.cxx.

34 : bec(0),side(0),ft(0),sl(0),ch(0),sa(0),part(0),
35 eta(0),phi(0),x(-99999),y(-99999),z(-99999),
36 onlid(0),offlid(0),ttid(0),
37 hvid(nullptr),
38 entry(0),
40 m_kInitialized(false),
41 m_tree(nullptr),
42 m_file( nullptr),
48{
49 // some hardcoded identifiers
50 const Char_t* pl[30] = {
51 "EMBPA","EMB1A","EMB2A","EMB3A","EMBPC","EMB1C","EMB2C","EMB3C",
52 "EMECPA","EMEC1A","EMEC2A","EMEC3A","EMECPC","EMEC1C","EMEC2C","EMEC3C",
53 "HEC0A","HEC1A","HEC2A","HEC3A","HEC0C","HEC1C","HEC2C","HEC3C",
54 "FCAL1A","FCAL2A","FCAL3A","FCAL1C","FCAL2C","FCAL3C"
55 };
57
58 const Char_t* ch[5] = {
59 "FT","SL","CH","ONLID","Entry"
60 };
62
64 for(int ipl=0;ipl<m_nPartitionLayers;ipl++){
65 m_PartitionLayers[ipl] = pl[ipl];
67 }
68 for(int ic=0;ic<m_nHistCategories;ic++){
70 }
71
72 printf("Initialized LArIdTranslatorHelper object with %d Partition/Layers and %d histogram frame categories.\n",
74
75 // load file
76 bool loaded = LoadIdTranslator(file);
77 if(loaded){
78 printf("Loaded IdTranslator successfully with %d entries, and histograms with %d duplicate bins.\n",m_ntotal,m_extrabins);
79 m_kInitialized = true;
80 } else m_kInitialized = false;
81}
std::vector< std::string > m_HistCategories
bool LoadIdTranslator(const TString &file)
std::vector< int > * hvid
std::vector< std::string > m_PartitionLayers
std::vector< std::vector< TH2I * > > m_HistCellmaps
int ic
Definition grepfile.py:33
TFile * file

◆ ~LArIdTranslatorHelper()

LArIdTranslatorHelper::~LArIdTranslatorHelper ( )

Definition at line 83 of file LArIdTranslatorHelper.cxx.

84{
85 // class destructor - delete your created objects here
86
87 if(m_kInitialized && m_file && m_file->IsOpen()){ m_file->Close(); delete m_file; }
88}

Member Function Documentation

◆ CaloPartitionLayerDisplay()

TCanvas * LArIdTranslatorHelper::CaloPartitionLayerDisplay ( TH2 ** h,
const Char_t * title = "",
bool kLogz = true )

Definition at line 271 of file LArIdTranslatorHelper.cxx.

272{
273 // Produces a TCanvas with the partitionlayers arranged.
274 // This assumes some hardcoded settings:
275 // - m_nPartitionLayers = 30
276 //
277 // Once the IdTranslator histograms are loaded, one can reuse the frames and fill them with
278 // a different variable, and then pass them to this function with **h2 to make that display.
279 //
280
281 if(m_nPartitionLayers!=30){
282 printf("Error in LArIdTranslatorHelper::CaloPartitionLayerDisplay: dimension must be 30.\n");
283 return nullptr;
284 }
285
286 // create new name according to scheme
287 sprintf(m_namebuf,"calosnapshot_%d",m_canvas_counts);
288 TCanvas* c = new TCanvas(m_namebuf,title,1000,600);
289 c->Divide(8,4); // 32 subpads (2 unused)
290
291 // ordering:
292 // bottom-top is by sampling ([0,3] except for FCAL)
293 // left-right is by partition (following sign of eta, C/A)
294 int i,j;
295 const int n = 30;
296 Int_t cmapping[n] = {
297 1,2,3,4,5,6,7,8,
298 9,10,11,12,13,14,15,16,
299 17,18,19,20,21,22,23,24,
300 26,27,28,29,30,31
301 };
302 Int_t larmapping[n] = {
303 29,23,15,7,3,11,19,26,
304 28,22,14,6,2,10,18,25,
305 27,21,13,5,1,9,17,24,
306 20,12,4,0,8,16
307 };
308
309 // get min,max z-values
310 Double_t zmin=1e6,zmax=-1e6;
311 for(i=0;i<m_nPartitionLayers;i++){
312 if(h[i]->GetMinimum()<zmin) zmin = h[i]->GetMinimum();
313 if(h[i]->GetMaximum()>zmax) zmax = h[i]->GetMaximum();
314 }
315
316 // shift min for log-scale
317 if(kLogz && zmin<=0.) zmin = 0.1;
318 //printf("Object %s: Extrema: [%.1e,%.1e]\n",c->GetName(),zmin,zmax);
319
320 TPad* subpad = nullptr;
321 for(i=0;i<n;i++){
322 c->cd(cmapping[i]);
323 j = larmapping[i];
324 h[j]->SetTitle(m_PartitionLayers[j].c_str());
325 h[j]->SetStats(0);
326 subpad = (TPad*)c->GetPad(cmapping[i]);
327 // choose between dimensions
328 if(h[j]->GetDimension()==2){ // 2D objects (eta,phi)
329 h[j]->GetZaxis()->SetRangeUser(zmin,zmax); // apply scale to all partitions
330 h[j]->Draw("colz");
331 subpad->SetLogz(kLogz);
332 } else { // 1D objects (z becomes y)
333 h[j]->GetYaxis()->SetRangeUser(zmin,zmax); // apply scale to all partitions
334 h[j]->Draw();
335 subpad->SetLogy(kLogz);
336 }
337 }
338
339 m_canvas_counts += 1;
340 return c;
341}

◆ FindChannel()

bool LArIdTranslatorHelper::FindChannel ( const int index,
float eta,
float phi )

Definition at line 197 of file LArIdTranslatorHelper.cxx.

198{
199 // Selects the right entry from the Tree, given the partition index
200 // and (eta,phi) coordinates.
201 //
202 // Status bit returned: 1 is successful, 0 is not
203 //
204
205 if(index < 0 || index >= m_nPartitionLayers){
206 printf("LArIdTranslatorHelper::FindChannel : Supplied index out of range: %d, [%d,%d].\n",index,0,m_nPartitionLayers-1);
207 entry = 0; // return to tree top
208 return false; // bad status
209 }
210
211 // watch the hardcoded index for "Entry" in array 'm_HistCategories'
212 entry = (Long_t)m_HistCellmaps[index][4]->GetBinContent(
213 m_HistCellmaps[index][4]->GetXaxis()->FindBin(eta),m_HistCellmaps[index][4]->GetYaxis()->FindBin(phi));
214 m_tree->GetEntry(entry); // automatically positions the tree at this entry
215 return true; // found it
216}
Int_t FindBin(const TAxis *axis, const double x)

◆ GetCaloPartitionLayerMap()

TH2 * LArIdTranslatorHelper::GetCaloPartitionLayerMap ( const int index,
bool kProfile = false )

Definition at line 240 of file LArIdTranslatorHelper.cxx.

241{
242 // Returns a clone of the m_HistCellmaps histograms.
243 // The type is TH2F for monitoring purposes.
244 //
245 // This function returns a new histogram hence the user must be careful at cleaning up after usage.
246
247 if(index < 0 || index >= m_nPartitionLayers){
248 printf("LArIdTranslatorHelper::GetCaloPartitionLayerMap : Supplied index out of range: %d, [%d,%d].\n",index,0,m_nPartitionLayers-1);
249 return nullptr;
250 }
251
252 TH2* th2 = nullptr;
253 if(!m_HistCellmaps[index][0]){
254 printf("LArIdTranslatorHelper::GetCaloPartitionLayerMap : Could not clone map for index %d. Check that maps were loaded from input rootfile.\n",index);
255 return nullptr;
256 } else {
257 sprintf(m_namebuf,"%s_Cloned_%d",m_PartitionLayers[index].c_str(),m_clonemap_counts);
258 if(kProfile){
259 th2 = new TProfile2D(m_namebuf,"",m_HistCellmaps[index][0]->GetXaxis()->GetNbins(),(m_HistCellmaps[index][0]->GetXaxis()->GetXbins())->GetArray(),m_HistCellmaps[index][0]->GetYaxis()->GetNbins(),(m_HistCellmaps[index][0]->GetYaxis()->GetXbins())->GetArray());
260 } else {
261 th2 = (TH2F*)(m_HistCellmaps[index][0]->Clone(m_namebuf));
262 th2->Reset("M"); // reset content and statistics
263 }
264 }
265
267
268 return th2;
269}
TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)

◆ GetNpl()

Int_t LArIdTranslatorHelper::GetNpl ( )
inline

Definition at line 56 of file LArIdTranslatorHelper.h.

56{ return m_nPartitionLayers; }

◆ GetPartitionLayerIndex()

int LArIdTranslatorHelper::GetPartitionLayerIndex ( const int partition,
const int layer ) const

Definition at line 149 of file LArIdTranslatorHelper.cxx.

150{
151 // Mapping from the partition/layer to partitionlayers.
152 // This must agree with what is initialized in the contructor!
153 //
154
155 // Convention for 'partition' from LArSamplesMon ntuples:
156 // -----------------------------------------
157 // FCAL_A +5
158 // HEC_A +4
159 // EMEC_OUTER_A +3
160 // EMEC_INNER_A +2
161 // EMB_A +1
162 // EMB_C -1
163 // EMEC_INNER_C -2
164 // EMEC_OUTER_C -3
165 // HEC_C -4
166 // FCAL_C -5
167 // -----------------------------------------
168 //
169 // const Char_t* partitionlayers[npl] = {
170 // "EMBPA","EMB1A","EMB2A","EMB3A","EMBPC","EMB1C","EMB2C","EMB3C",
171 // "EMECPA","EMEC1A","EMEC2A","EMEC3A","EMECPC","EMEC1C","EMEC2C","EMEC3C",
172 // "HEC0A","HEC1A","HEC2A","HEC3A","HEC0C","HEC1C","HEC2C","HEC3C",
173 // "FCAL1A","FCAL2A","FCAL3A","FCAL1C","FCAL2C","FCAL3C"
174 // };
175
176 if(partition==1){ // EMBA
177 return layer;
178 } else if(partition == -1){ // EMBC
179 return layer+4;
180 } else if(partition == 2 || partition == 3){ // EMECA
181 return layer+8;
182 } else if(partition == -2 || partition == -3){ // EMECC
183 return layer+12;
184 } else if(partition == 4){ // HECA
185 return layer+16;
186 } else if(partition == -4){ // HECC
187 return layer+20;
188 } else if(partition == 5){ // FCALA
189 return layer+23;
190 } else if(partition == -5){ // FCALC
191 return layer+26;
192 }
193 return -1; // error value
194}
@ layer
Definition HitInfo.h:79

◆ GetPartitonLayerName()

const Char_t * LArIdTranslatorHelper::GetPartitonLayerName ( const int index)

Definition at line 229 of file LArIdTranslatorHelper.cxx.

230{
231 if(index < 0 || index >= m_nPartitionLayers){
232 printf("LArIdTranslatorHelper::GetPartitonLayerName : Supplied index out of range: %d, [%d,%d].\n",index,0,m_nPartitionLayers-1);
233 return nullptr;
234 }
235
236 return m_PartitionLayers[index].c_str();
237}
str index
Definition DeMoScan.py:362

◆ IsHVLine()

bool LArIdTranslatorHelper::IsHVLine ( const int hvline) const

Definition at line 218 of file LArIdTranslatorHelper.cxx.

219{
220 // Loops over the current entry hvline vector and determines if this corresponds
221 // to the input.
222 // The current hvid is set by a call to FindChannel(..) or similar.
223
224 for(unsigned int i=0;i<hvid->size();i++) if(hvid->at(i)==hvline) return true;
225 return false;
226}

◆ IsInitialized()

bool LArIdTranslatorHelper::IsInitialized ( )
inline

Definition at line 49 of file LArIdTranslatorHelper.h.

49{ return m_kInitialized; }

◆ LoadIdTranslator()

bool LArIdTranslatorHelper::LoadIdTranslator ( const TString & file)

Definition at line 91 of file LArIdTranslatorHelper.cxx.

92{
93 // Load Translator root file containing channel info and mapping.
94
95 // info from single cells
96 delete m_file;//Solve cppcheck warning
97 m_file = new TFile(file);
98 if(!m_file || !m_file->IsOpen()){
99 printf("LArIdTranslatorHelper::LoadIdTranslator : File %s could not be found (see above TFile message).\n",file.Data());
100 return false;
101 }
102
103 m_tree = (TTree*)m_file->Get("LarId");
104 m_tree->SetBranchAddress("BEC",&bec);
105 m_tree->SetBranchAddress("Region",&side);
106 m_tree->SetBranchAddress("FT",&ft);
107 m_tree->SetBranchAddress("SL",&sl);
108 m_tree->SetBranchAddress("CH",&ch);
109 m_tree->SetBranchAddress("Sampling",&sa);
110 m_tree->SetBranchAddress("Partition",&part);
111 m_tree->SetBranchAddress("F_Eta",&eta);
112 m_tree->SetBranchAddress("F_Phi",&phi);
113 m_tree->SetBranchAddress("X",&x);
114 m_tree->SetBranchAddress("Y",&y);
115 m_tree->SetBranchAddress("Z",&z);
116 m_tree->SetBranchAddress("onlid",&onlid);
117 m_tree->SetBranchAddress("offlid",&offlid);
118 m_tree->SetBranchAddress("ttid",&ttid);
119 m_tree->SetBranchAddress("hvid",&hvid);
120 m_tree->SetBranchAddress("binetadqm",&binetadqm);
121 m_tree->SetBranchAddress("binphidqm1",&binphidqm1);
122 m_tree->SetBranchAddress("binphidqm2",&binphidqm2);
123 m_ntotal = (int)m_tree->GetEntries();
124
125 // load mapping
126 Int_t i,j,ix,iy;
127 Int_t nbins = 0;
128 Char_t name[128];
129 for(i=0;i<m_nPartitionLayers;i++){
130 for(j=0;j<m_nHistCategories;j++){
131 sprintf(name,"%s_%s",m_PartitionLayers[i].c_str(),m_HistCategories[j].c_str());
132 m_HistCellmaps[i][j] = static_cast<TH2I*>(m_file->Get(name));
133 }
134
135 nbins += (m_HistCellmaps[i][0]->GetXaxis()->GetNbins())*(m_HistCellmaps[i][0]->GetYaxis()->GetNbins());
136 for(ix=1;ix<=m_HistCellmaps[i][0]->GetXaxis()->GetNbins();ix++){
137 for(iy=1;iy<=m_HistCellmaps[i][0]->GetYaxis()->GetNbins();iy++){
138 if(m_HistCellmaps[i][0]->GetBinContent(ix,iy)==-1) nbins--;
139 }
140 }
141 }
142 // duplicate bins
144
145 return true;
146}

◆ MakeTranslatorMapping()

void LArIdTranslatorHelper::MakeTranslatorMapping ( const char * inputtreefile,
const char * inputhistfile,
const int run )

Definition at line 344 of file LArIdTranslatorHelper.cxx.

345{
346 // Merges histogramming info and mapping histograms to existing LArId TTree.
347 // This needs a regular LArId TTree and one sample monitoring root file.
348
349 Int_t i,j,k;
350 int t_barrel_ec,t_pos_neg,t_emhad;
351 int t_FT,t_SL,t_CH,t_sampling,t_caloindex;
352 int t_Etai,t_Phii;
353 float t_Etaf,t_Phif,t_Eta_Rawf,t_Phi_Rawf,t_x,t_y,t_z;
354 ULong64_t t_onlid,t_offlid;
355 ULong64_t t_ttid;
356 std::vector<int>* t_hvid = nullptr;
357 TFile* ifile = new TFile(inputtreefile);
358 TTree* idtree = (TTree*)ifile->Get("LarId");
359 idtree->SetBranchAddress("BEC",&t_barrel_ec);
360 idtree->SetBranchAddress("Region",&t_pos_neg);
361 idtree->SetBranchAddress("EmHad",&t_emhad);
362 idtree->SetBranchAddress("FT",&t_FT);
363 idtree->SetBranchAddress("SL",&t_SL);
364 idtree->SetBranchAddress("CH",&t_CH);
365 idtree->SetBranchAddress("Sampling",&t_sampling);
366 idtree->SetBranchAddress("Partition",&t_caloindex);
367 idtree->SetBranchAddress("I_Eta",&t_Etai);
368 idtree->SetBranchAddress("I_Phi",&t_Phii);
369 idtree->SetBranchAddress("F_Eta",&t_Etaf);
370 idtree->SetBranchAddress("F_Phi",&t_Phif);
371 idtree->SetBranchAddress("R_Eta",&t_Eta_Rawf);
372 idtree->SetBranchAddress("R_Phi",&t_Phi_Rawf);
373 idtree->SetBranchAddress("X",&t_x);
374 idtree->SetBranchAddress("Y",&t_y);
375 idtree->SetBranchAddress("Z",&t_z);
376 idtree->SetBranchAddress("onlid",&t_onlid);
377 idtree->SetBranchAddress("offlid",&t_offlid);
378 idtree->SetBranchAddress("ttid",&t_ttid);
379 idtree->SetBranchAddress("hvid",&t_hvid);
380
381 // ------------------------------------------
382 // load DQM histogram style (any file)
383 TFile* fdqm = new TFile(inputhistfile);
384 const Char_t* Pattern = "run_%d/CaloMonitoring/LArCellMon_NoTrigSel/2d_Occupancy/CellOccupancyVsEtaPhi_%s_4Sigma";
385 Char_t name[1024];
386 TH2F** h2 = new TH2F*[m_nPartitionLayers];
387 for(i=0;i<m_nPartitionLayers;i++){
388 sprintf(name,Pattern,run,m_PartitionLayers[i].c_str());
389 h2[i] = (TH2F*)fdqm->Get(name);
390 if(!h2[i]){ printf("LArIdTranslatorHelper::MakeTranslatorMapping : Could not read input histograms.\n"); exit(-1); }
391 }
392 // ------------------------------------------
393
394 Int_t ix,iy,nbinsx,nbinsy;
395 Double_t* xbins=nullptr,*ybins=nullptr;
396 TH2I*** h2map = new TH2I**[m_nPartitionLayers];
397 TH2I*** h2count = new TH2I**[m_nPartitionLayers];
398 for(i=0;i<m_nPartitionLayers;i++){
399 nbinsx = h2[i]->GetXaxis()->GetNbins();
400 nbinsy = h2[i]->GetYaxis()->GetNbins();
401 xbins = new Double_t[nbinsx+1];
402 for(ix=0;ix<nbinsx;ix++){
403 xbins[ix] = h2[i]->GetXaxis()->GetBinLowEdge(ix+1);
404 }
405 xbins[nbinsx] = h2[i]->GetXaxis()->GetBinUpEdge(nbinsx);
406 ybins = new Double_t[nbinsy+1];
407 for(iy=0;iy<nbinsy;iy++){
408 ybins[iy] = h2[i]->GetYaxis()->GetBinLowEdge(iy+1);
409 }
410 ybins[nbinsy] = h2[i]->GetYaxis()->GetBinUpEdge(nbinsy);
411
412 h2map[i] = new TH2I*[m_nHistCategories];
413 h2count[i] = new TH2I*[m_nHistCategories];
414 for(j=0;j<m_nHistCategories;j++){
415 sprintf(name,"%s_%s",m_PartitionLayers[i].c_str(),m_HistCategories[j].c_str());
416 h2map[i][j] = new TH2I(name,"",nbinsx,xbins,nbinsy,ybins);
417 sprintf(name,"%s_%s_counts",m_PartitionLayers[i].c_str(),m_HistCategories[j].c_str());
418 h2count[i][j] = (TH2I*)h2map[i][j]->Clone(name);
419 // initialize to -1
420 for(ix=0;ix<nbinsx;ix++){
421 for(iy=0;iy<nbinsy;iy++) h2map[i][j]->SetBinContent(ix+1,iy+1,-1);
422 }
423 }
424 delete [] xbins;
425 delete [] ybins;
426 }
427
428 Int_t barrel_ec,region,emhad;
429 Int_t FT,SL,CH,Sampling,Partition;
430 Int_t iEta,iPhi;
431 Float_t Eta,Phi,Eta_Raw,Phi_Raw,x,y,z;
432 ULong64_t onlid,offlid,ttid;
433 std::vector<int>* hvid = nullptr;
435
436 // new file and TTree with appendices
437 TFile* file = new TFile("LarIdTree_new.root","RECREATE"); // default, different name
438 TTree* tree = new TTree("LarId","Channel IDs");
439 tree->Branch("BEC",&barrel_ec);
440 tree->Branch("Region",&region);
441 tree->Branch("EmHad",&emhad);
442 tree->Branch("FT",&FT);
443 tree->Branch("SL",&SL);
444 tree->Branch("CH",&CH);
445 tree->Branch("Sampling",&Sampling);
446 tree->Branch("Partition",&Partition);
447 tree->Branch("I_Eta",&iEta);
448 tree->Branch("I_Phi",&iPhi);
449 tree->Branch("F_Eta",&Eta);
450 tree->Branch("F_Phi",&Phi);
451 tree->Branch("R_Eta",&Eta_Raw);
452 tree->Branch("R_Phi",&Phi_Raw);
453 tree->Branch("X",&x);
454 tree->Branch("Y",&y);
455 tree->Branch("Z",&z);
456 tree->Branch("onlid",&onlid);
457 tree->Branch("offlid",&offlid);
458 tree->Branch("ttid",&ttid);
459 tree->Branch("hvid",&hvid);
460 tree->Branch("binetadqm",&binetadqm);
461 tree->Branch("binphidqm1",&binphidqm1);
462 tree->Branch("binphidqm2",&binphidqm2);
463
464 // counters
465 Int_t nchannels = 0;
466 Double_t emb1PhiGran = M_PI/(Double_t)32;
467 Int_t dupl = 0,dupl2 = 0;
468 Int_t empt = 0;
469 Int_t ntotal = 0;
470 Int_t phishifts = 0;
471
472 // loop over input entries
473 for(Int_t iline = 0 ; iline < idtree->GetEntries() ; iline++){
474 idtree->GetEntry(iline);
475
476 // copy these variables
477 barrel_ec = t_barrel_ec;
478 region = t_pos_neg;
479 emhad = t_emhad;
480 FT = t_FT;
481 SL = t_SL;
482 CH = t_CH;
483 Sampling = t_sampling;
484 Partition = t_caloindex;
485 iEta = t_Etai;
486 iPhi = t_Phii;
487 Eta = t_Etaf;
488 Phi = t_Phif;
489 x = t_x;
490 y = t_y;
491 z = t_z;
492 Eta_Raw = t_Eta_Rawf;
493 Phi_Raw = t_Phi_Rawf;
494 onlid = t_onlid;
495 offlid = t_offlid;
496 ttid = t_ttid;
497 hvid = t_hvid;
498
499 // store these new variables
501 // hacks to make sensible 2D histos
502 Double_t celleta = Eta_Raw;
503 Double_t cellphi = Phi_Raw;
504 Double_t phiMod = 0;
505
506 if(Partition < 0 || Partition >= m_nPartitionLayers){
507 printf("LArIdTranslatorHelper::MakeTranslatorMapping : Supplied index out of range: %d, [%d,%d]. Skipped entry %d.\n",Partition,0,m_nPartitionLayers-1,iline);
508 continue;
509 }
510
511 // taken from CaloMonitoring
512 //
513 // do a little shift in eta for EMB sampling 1 to facilitate filling cheat in eta and eta phi plot
514 if(Partition==1 || Partition==5){
515 if( ((Eta_Raw > 1.4) && (Eta_Raw < 1.475)) || ((Eta_Raw < -1.4) && (Eta_Raw > -1.475))) {
516 //this is the eta region where we mess around:
517 //take phi modulus the phi granularity we have in our histogram, then shift eta accordingly:
518 phiMod = fmod( fabs(Phi_Raw),emb1PhiGran);
519 celleta = Eta_Raw + (phiMod * 0.2551) - 0.0125;
520 }
521 }
522
523 // find bin indices in dqm histograms
524 j = Partition;
525 binetadqm = h2[j]->GetXaxis()->FindBin(celleta);
526 binphidqm1 = h2[j]->GetYaxis()->FindBin(cellphi);
527
528 // fill current bin and check for duplicates
529 Bool_t success = 0;
530 Double_t lodiff,updiff;
531
532 if(h2count[j][0]->GetBinContent(binetadqm,binphidqm1)==0){ // virgin bin
533 for(k=0;k<m_nHistCategories;k++) h2count[j][k]->SetBinContent(binetadqm,binphidqm1,1);
534 h2map[j][0]->SetBinContent(binetadqm,binphidqm1,FT);
535 h2map[j][1]->SetBinContent(binetadqm,binphidqm1,SL);
536 h2map[j][2]->SetBinContent(binetadqm,binphidqm1,CH);
537 h2map[j][3]->SetBinContent(binetadqm,binphidqm1,onlid);
538 h2map[j][4]->SetBinContent(binetadqm,binphidqm1,iline);
539 success=1;
540 }
541
542 // then add duplicates for weird phi binning in HEC-FCAL
543 if(emhad>=1){
544 lodiff = cellphi-h2map[j][0]->GetYaxis()->GetBinLowEdge(binphidqm1);
545 updiff = cellphi-h2map[j][0]->GetYaxis()->GetBinUpEdge(binphidqm1);
546 Bool_t loedge = (fabs(lodiff) < 1e-5) ? 1 : 0;
547 Bool_t upedge = (fabs(updiff) < 1e-5) ? 1 : 0;
548
549 if(loedge || upedge){ // bin edges are close enough
550 if(h2count[j][0]->GetBinContent(binetadqm,binphidqm1)==1){ // nominal bin
551 phishifts++;
552
553 // try upper edge
554 if(upedge){
555 if(h2count[j][0]->GetBinContent(binetadqm,binphidqm1+1)==0){
557 for(k=0;k<m_nHistCategories;k++) h2count[j][k]->SetBinContent(binetadqm,binphidqm2,1);
558 h2map[j][0]->SetBinContent(binetadqm,binphidqm2,FT);
559 h2map[j][1]->SetBinContent(binetadqm,binphidqm2,SL);
560 h2map[j][2]->SetBinContent(binetadqm,binphidqm2,CH);
561 h2map[j][3]->SetBinContent(binetadqm,binphidqm2,onlid);
562 h2map[j][4]->SetBinContent(binetadqm,binphidqm2,iline);
563 success=1;
564 } else success = 0;
565 } else if(loedge){
566 if(h2count[j][0]->GetBinContent(binetadqm,binphidqm1-1)==0){
568 for(k=0;k<m_nHistCategories;k++) h2count[j][k]->SetBinContent(binetadqm,binphidqm2,1);
569 h2map[j][0]->SetBinContent(binetadqm,binphidqm2,FT);
570 h2map[j][1]->SetBinContent(binetadqm,binphidqm2,SL);
571 h2map[j][2]->SetBinContent(binetadqm,binphidqm2,CH);
572 h2map[j][3]->SetBinContent(binetadqm,binphidqm2,onlid);
573 h2map[j][4]->SetBinContent(binetadqm,binphidqm2,iline);
574 success=1;
575 } else success = 0;
576 } else success = 0;
577 }
578 if(success) dupl+=1;
579 }
580 }
581
582 // check for bins out of range
583 if(binetadqm<=0 || binphidqm1<=0 || binetadqm > h2map[j][0]->GetXaxis()->GetNbins() || binphidqm1 > h2map[j][0]->GetYaxis()->GetNbins()) printf("Warning at entry %s, %d, %+.4f %+.4f, %d %d\n",m_PartitionLayers[j].c_str(),Sampling,celleta,cellphi,binetadqm,binphidqm1);
584
585 if(!success){
586 printf("LArIdTranslatorHelper::MakeTranslatorMapping : Orphan at %s %d %d (ft/sl/ch: %d %d %d) : eta,phi = %+.2f,%+.2f with bins [%+.2f,%+.2f] [%+.2f,%+.2f]. Prevented overwrite on ft/ch/sl %d %d %d\n",
587 m_PartitionLayers[j].c_str(),binetadqm,binphidqm1,FT,SL,CH,celleta,cellphi,
588 h2map[j][0]->GetXaxis()->GetBinLowEdge(binetadqm),h2map[j][0]->GetXaxis()->GetBinUpEdge(binetadqm),
589 h2map[j][0]->GetYaxis()->GetBinLowEdge(binphidqm1),h2map[j][0]->GetYaxis()->GetBinUpEdge(binphidqm1),
590 (int)h2map[j][0]->GetBinContent(binetadqm,binphidqm1),
591 (int)h2map[j][1]->GetBinContent(binetadqm,binphidqm1),
592 (int)h2map[j][2]->GetBinContent(binetadqm,binphidqm1)
593 );
594 }
595
596 // fill entries
597 tree->Fill();
598 nchannels+=1;
599 }
600
601
602 // out-of-loop checks
603 for(i=0;i<m_nPartitionLayers;i++){
604 nbinsx = h2map[i][0]->GetXaxis()->GetNbins();
605 nbinsy = h2map[i][0]->GetYaxis()->GetNbins();
606 ntotal += nbinsx*nbinsy;
607 for(ix=0;ix<nbinsx;ix++){
608 for(iy=0;iy<nbinsy;iy++){
609 if(h2count[i][0]->GetBinContent(ix+1,iy+1)>1){
610 printf("LArIdTranslatorHelper::MakeTranslatorMapping : Duplicate at %s %d %d (last ft/sl/ch: %d %d %d) : [%+.4f,%+.4f] [%+.4f,%+.4f]\n",m_PartitionLayers[i].c_str(),ix+1,iy+1,(int)h2map[i][0]->GetBinContent(ix+1,iy+1),(int)h2map[i][1]->GetBinContent(ix+1,iy+1),(int)h2map[i][2]->GetBinContent(ix+1,iy+1),h2map[i][0]->GetXaxis()->GetBinLowEdge(ix+1),h2map[i][0]->GetXaxis()->GetBinUpEdge(ix+1),h2map[i][0]->GetYaxis()->GetBinLowEdge(iy+1),h2map[i][0]->GetYaxis()->GetBinUpEdge(iy+1));
611 dupl2+=1;
612 }
613
614 if(h2count[i][0]->GetBinContent(ix+1,iy+1)==0) empt+=1;
615 }
616 }
617 }
618
619 // write out
620 file->cd();
621 tree->Write();
622 for(i=0;i<m_nPartitionLayers;i++) for(j=0;j<m_nHistCategories;j++) h2map[i][j]->Write();
623 file->Close();
624 delete file;
625
626 printf("-------------------------------------------------------------------\n");
627 printf("LArIdTranslatorHelper::MakeTranslatorMapping: Summary:\n");
628 printf("Info for %d channels (%d entries read).\n",nchannels,(int)idtree->GetEntries());
629 printf("There were %d duplicates, %d empty, %d (%d) phi-shifted (HEC-FCAL), %d physical.\n",dupl2,empt,dupl,phishifts,ntotal-empt-dupl);
630 printf("-------------------------------------------------------------------\n");
631
632 ifile->Close();
633 for(int i=0;i!=m_nPartitionLayers;++i){
634 for (int j=0;j!=m_nHistCategories;++j){
635 delete h2count[i][j];
636 delete h2map[i][j];
637 }
638 delete[] h2count[i];
639 delete[] h2map[i];
640 }
641 delete[] h2count;
642 delete[] h2map;
643 delete[] h2;
644 delete fdqm;
645 delete ifile;
646 return;
647}
#define M_PI
@ Phi
Definition RPCdef.h:8
@ Eta
Definition RPCdef.h:8
@ iPhi
Definition ParamDefs.h:47
setScale setgFexType iEta
TChain * tree

◆ Tree()

TTree * LArIdTranslatorHelper::Tree ( )
inline

Definition at line 58 of file LArIdTranslatorHelper.h.

58{ return m_tree; }

Member Data Documentation

◆ bec

Int_t LArIdTranslatorHelper::bec

Definition at line 37 of file LArIdTranslatorHelper.h.

◆ binetadqm

Int_t LArIdTranslatorHelper::binetadqm

Definition at line 42 of file LArIdTranslatorHelper.h.

◆ binphidqm1

Int_t LArIdTranslatorHelper::binphidqm1

Definition at line 42 of file LArIdTranslatorHelper.h.

◆ binphidqm2

Int_t LArIdTranslatorHelper::binphidqm2

Definition at line 42 of file LArIdTranslatorHelper.h.

◆ ch

Int_t LArIdTranslatorHelper::ch

Definition at line 37 of file LArIdTranslatorHelper.h.

◆ entry

Long_t LArIdTranslatorHelper::entry

Definition at line 41 of file LArIdTranslatorHelper.h.

◆ eta

Float_t LArIdTranslatorHelper::eta

Definition at line 38 of file LArIdTranslatorHelper.h.

◆ ft

Int_t LArIdTranslatorHelper::ft

Definition at line 37 of file LArIdTranslatorHelper.h.

◆ hvid

std::vector<int>* LArIdTranslatorHelper::hvid

Definition at line 40 of file LArIdTranslatorHelper.h.

◆ m_canvas_counts

Int_t LArIdTranslatorHelper::m_canvas_counts
private

Definition at line 67 of file LArIdTranslatorHelper.h.

◆ m_clonemap_counts

Int_t LArIdTranslatorHelper::m_clonemap_counts
private

Definition at line 67 of file LArIdTranslatorHelper.h.

◆ m_extrabins

Int_t LArIdTranslatorHelper::m_extrabins
private

Definition at line 65 of file LArIdTranslatorHelper.h.

◆ m_file

TFile* LArIdTranslatorHelper::m_file
private

Definition at line 64 of file LArIdTranslatorHelper.h.

◆ m_HistCategories

std::vector<std::string> LArIdTranslatorHelper::m_HistCategories
private

Definition at line 73 of file LArIdTranslatorHelper.h.

◆ m_HistCellmaps

std::vector<std::vector<TH2I*> > LArIdTranslatorHelper::m_HistCellmaps
private

Definition at line 74 of file LArIdTranslatorHelper.h.

◆ m_kInitialized

bool LArIdTranslatorHelper::m_kInitialized
private

Definition at line 62 of file LArIdTranslatorHelper.h.

◆ m_namebuf

Char_t LArIdTranslatorHelper::m_namebuf[128] {}
private

Definition at line 68 of file LArIdTranslatorHelper.h.

68{};

◆ m_nHistCategories

Int_t LArIdTranslatorHelper::m_nHistCategories
private

Definition at line 72 of file LArIdTranslatorHelper.h.

◆ m_nPartitionLayers

Int_t LArIdTranslatorHelper::m_nPartitionLayers
private

Definition at line 70 of file LArIdTranslatorHelper.h.

◆ m_ntotal

Int_t LArIdTranslatorHelper::m_ntotal
private

Definition at line 65 of file LArIdTranslatorHelper.h.

◆ m_PartitionLayers

std::vector<std::string> LArIdTranslatorHelper::m_PartitionLayers
private

Definition at line 71 of file LArIdTranslatorHelper.h.

◆ m_tree

TTree* LArIdTranslatorHelper::m_tree
private

Definition at line 63 of file LArIdTranslatorHelper.h.

◆ offlid

ULong64_t LArIdTranslatorHelper::offlid

Definition at line 39 of file LArIdTranslatorHelper.h.

◆ onlid

ULong64_t LArIdTranslatorHelper::onlid

Definition at line 39 of file LArIdTranslatorHelper.h.

◆ part

Int_t LArIdTranslatorHelper::part

Definition at line 37 of file LArIdTranslatorHelper.h.

◆ phi

Float_t LArIdTranslatorHelper::phi

Definition at line 38 of file LArIdTranslatorHelper.h.

◆ sa

Int_t LArIdTranslatorHelper::sa

Definition at line 37 of file LArIdTranslatorHelper.h.

◆ side

Int_t LArIdTranslatorHelper::side

Definition at line 37 of file LArIdTranslatorHelper.h.

◆ sl

Int_t LArIdTranslatorHelper::sl

Definition at line 37 of file LArIdTranslatorHelper.h.

◆ ttid

ULong64_t LArIdTranslatorHelper::ttid

Definition at line 39 of file LArIdTranslatorHelper.h.

◆ x

Float_t LArIdTranslatorHelper::x

Definition at line 38 of file LArIdTranslatorHelper.h.

◆ y

Float_t LArIdTranslatorHelper::y

Definition at line 38 of file LArIdTranslatorHelper.h.

◆ z

Float_t LArIdTranslatorHelper::z

Definition at line 38 of file LArIdTranslatorHelper.h.


The documentation for this class was generated from the following files: