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 (const LArIdTranslatorHelper &)=delete
LArIdTranslatorHelperoperator= (const LArIdTranslatorHelper &)=delete
 ~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 ()
std::unique_ptr< TCanvas > CaloPartitionLayerDisplay (TH2 **h, const Char_t *title="", bool kLogz=true)
std::unique_ptr< 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
std::unique_ptr< 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() [1/2]

LArIdTranslatorHelper::LArIdTranslatorHelper ( const TString & inputfile)

Definition at line 34 of file LArIdTranslatorHelper.cxx.

35 : bec(0),side(0),ft(0),sl(0),ch(0),sa(0),part(0),
36 eta(0),phi(0),x(-99999),y(-99999),z(-99999),
37 onlid(0),offlid(0),ttid(0),
38 hvid(nullptr),
39 entry(0),
41 m_kInitialized(false),
42 m_tree(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() [2/2]

LArIdTranslatorHelper::LArIdTranslatorHelper ( const LArIdTranslatorHelper & )
delete

◆ ~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(); }
88}
std::unique_ptr< TFile > m_file

Member Function Documentation

◆ CaloPartitionLayerDisplay()

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

Definition at line 270 of file LArIdTranslatorHelper.cxx.

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

◆ FindChannel()

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

Definition at line 196 of file LArIdTranslatorHelper.cxx.

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

◆ GetCaloPartitionLayerMap()

std::unique_ptr< TH2 > LArIdTranslatorHelper::GetCaloPartitionLayerMap ( const int index,
bool kProfile = false )

Definition at line 239 of file LArIdTranslatorHelper.cxx.

240{
241 // Returns a clone of the m_HistCellmaps histograms.
242 // The type is TH2F for monitoring purposes.
243 //
244 // This function returns a new histogram hence the user must be careful at cleaning up after usage.
245
246 if(index < 0 || index >= m_nPartitionLayers){
247 printf("LArIdTranslatorHelper::GetCaloPartitionLayerMap : Supplied index out of range: %d, [%d,%d].\n",index,0,m_nPartitionLayers-1);
248 return nullptr;
249 }
250
251 std::unique_ptr<TH2> th2;
252 if(!m_HistCellmaps[index][0]){
253 printf("LArIdTranslatorHelper::GetCaloPartitionLayerMap : Could not clone map for index %d. Check that maps were loaded from input rootfile.\n",index);
254 return nullptr;
255 } else {
256 sprintf(m_namebuf,"%s_Cloned_%d",m_PartitionLayers[index].c_str(),m_clonemap_counts);
257 if(kProfile){
258 th2 = std::make_unique<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());
259 } else {
260 th2.reset (static_cast<TH2F*>(m_HistCellmaps[index][0]->Clone(m_namebuf)));
261 th2->Reset("M"); // reset content and statistics
262 }
263 }
264
266
267 return th2;
268}
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 58 of file LArIdTranslatorHelper.h.

58{ return m_nPartitionLayers; }

◆ GetPartitionLayerIndex()

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

Definition at line 148 of file LArIdTranslatorHelper.cxx.

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

◆ GetPartitonLayerName()

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

Definition at line 228 of file LArIdTranslatorHelper.cxx.

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

◆ IsHVLine()

bool LArIdTranslatorHelper::IsHVLine ( const int hvline) const

Definition at line 217 of file LArIdTranslatorHelper.cxx.

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

◆ IsInitialized()

bool LArIdTranslatorHelper::IsInitialized ( )
inline

Definition at line 51 of file LArIdTranslatorHelper.h.

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

◆ MakeTranslatorMapping()

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

Definition at line 343 of file LArIdTranslatorHelper.cxx.

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

◆ operator=()

LArIdTranslatorHelper & LArIdTranslatorHelper::operator= ( const LArIdTranslatorHelper & )
delete

◆ Tree()

TTree * LArIdTranslatorHelper::Tree ( )
inline

Definition at line 60 of file LArIdTranslatorHelper.h.

60{ return m_tree; }

Member Data Documentation

◆ bec

Int_t LArIdTranslatorHelper::bec

Definition at line 39 of file LArIdTranslatorHelper.h.

◆ binetadqm

Int_t LArIdTranslatorHelper::binetadqm

Definition at line 44 of file LArIdTranslatorHelper.h.

◆ binphidqm1

Int_t LArIdTranslatorHelper::binphidqm1

Definition at line 44 of file LArIdTranslatorHelper.h.

◆ binphidqm2

Int_t LArIdTranslatorHelper::binphidqm2

Definition at line 44 of file LArIdTranslatorHelper.h.

◆ ch

Int_t LArIdTranslatorHelper::ch

Definition at line 39 of file LArIdTranslatorHelper.h.

◆ entry

Long_t LArIdTranslatorHelper::entry

Definition at line 43 of file LArIdTranslatorHelper.h.

◆ eta

Float_t LArIdTranslatorHelper::eta

Definition at line 40 of file LArIdTranslatorHelper.h.

◆ ft

Int_t LArIdTranslatorHelper::ft

Definition at line 39 of file LArIdTranslatorHelper.h.

◆ hvid

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

Definition at line 42 of file LArIdTranslatorHelper.h.

◆ m_canvas_counts

Int_t LArIdTranslatorHelper::m_canvas_counts
private

Definition at line 69 of file LArIdTranslatorHelper.h.

◆ m_clonemap_counts

Int_t LArIdTranslatorHelper::m_clonemap_counts
private

Definition at line 69 of file LArIdTranslatorHelper.h.

◆ m_extrabins

Int_t LArIdTranslatorHelper::m_extrabins
private

Definition at line 67 of file LArIdTranslatorHelper.h.

◆ m_file

std::unique_ptr<TFile> LArIdTranslatorHelper::m_file
private

Definition at line 66 of file LArIdTranslatorHelper.h.

◆ m_HistCategories

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

Definition at line 75 of file LArIdTranslatorHelper.h.

◆ m_HistCellmaps

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

Definition at line 76 of file LArIdTranslatorHelper.h.

◆ m_kInitialized

bool LArIdTranslatorHelper::m_kInitialized
private

Definition at line 64 of file LArIdTranslatorHelper.h.

◆ m_namebuf

Char_t LArIdTranslatorHelper::m_namebuf[128] {}
private

Definition at line 70 of file LArIdTranslatorHelper.h.

70{};

◆ m_nHistCategories

Int_t LArIdTranslatorHelper::m_nHistCategories
private

Definition at line 74 of file LArIdTranslatorHelper.h.

◆ m_nPartitionLayers

Int_t LArIdTranslatorHelper::m_nPartitionLayers
private

Definition at line 72 of file LArIdTranslatorHelper.h.

◆ m_ntotal

Int_t LArIdTranslatorHelper::m_ntotal
private

Definition at line 67 of file LArIdTranslatorHelper.h.

◆ m_PartitionLayers

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

Definition at line 73 of file LArIdTranslatorHelper.h.

◆ m_tree

TTree* LArIdTranslatorHelper::m_tree
private

Definition at line 65 of file LArIdTranslatorHelper.h.

◆ offlid

ULong64_t LArIdTranslatorHelper::offlid

Definition at line 41 of file LArIdTranslatorHelper.h.

◆ onlid

ULong64_t LArIdTranslatorHelper::onlid

Definition at line 41 of file LArIdTranslatorHelper.h.

◆ part

Int_t LArIdTranslatorHelper::part

Definition at line 39 of file LArIdTranslatorHelper.h.

◆ phi

Float_t LArIdTranslatorHelper::phi

Definition at line 40 of file LArIdTranslatorHelper.h.

◆ sa

Int_t LArIdTranslatorHelper::sa

Definition at line 39 of file LArIdTranslatorHelper.h.

◆ side

Int_t LArIdTranslatorHelper::side

Definition at line 39 of file LArIdTranslatorHelper.h.

◆ sl

Int_t LArIdTranslatorHelper::sl

Definition at line 39 of file LArIdTranslatorHelper.h.

◆ ttid

ULong64_t LArIdTranslatorHelper::ttid

Definition at line 41 of file LArIdTranslatorHelper.h.

◆ x

Float_t LArIdTranslatorHelper::x

Definition at line 40 of file LArIdTranslatorHelper.h.

◆ y

Float_t LArIdTranslatorHelper::y

Definition at line 40 of file LArIdTranslatorHelper.h.

◆ z

Float_t LArIdTranslatorHelper::z

Definition at line 40 of file LArIdTranslatorHelper.h.


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