ATLAS Offline Software
Public Member Functions | Public Attributes | Private Attributes | List of all members
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 (TH1 **h, const Char_t *title="", bool kLogz=true)
 
TH2GetCaloPartitionLayerMap (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< std::unique_ptr< TH2I > > > m_HistCellmaps
 

Detailed Description

Definition at line 27 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),
43  m_ntotal(0),m_extrabins(0),
44  m_canvas_counts(0),
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];
66  m_HistCellmaps[ipl].resize (m_nHistCategories);
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 }

◆ ~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 ( TH1 **  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  TCanvas* c = new 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 }

◆ 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 }

◆ GetCaloPartitionLayerMap()

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  TH2* th2 = nullptr;
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 = 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());
259  } else {
260  th2 = (TH2F*)(m_HistCellmaps[index][0]->Clone(m_namebuf));
261  th2->Reset("M"); // reset content and statistics
262  }
263  }
264 
266 
267  return th2;
268 }

◆ GetNpl()

Int_t LArIdTranslatorHelper::GetNpl ( )
inline

Definition at line 54 of file LArIdTranslatorHelper.h.

54 { 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 }

◆ 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 }

◆ 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 47 of file LArIdTranslatorHelper.h.

47 { 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 = 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] = std::unique_ptr<TH2I> ((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 = new TFile(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 = new TFile(inputhistfile);
383  const Char_t* Pattern = "run_%d/CaloMonitoring/LArCellMon_NoTrigSel/2d_Occupancy/CellOccupancyVsEtaPhi_%s_4Sigma";
384  Char_t name[1024];
385  TH2F** h2 = new TH2F*[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  Double_t* xbins=nullptr,*ybins=nullptr;
395  TH2I*** h2map = new TH2I**[m_nPartitionLayers];
396  TH2I*** h2count = new TH2I**[m_nPartitionLayers];
397  for(i=0;i<m_nPartitionLayers;i++){
398  nbinsx = h2[i]->GetXaxis()->GetNbins();
399  nbinsy = h2[i]->GetYaxis()->GetNbins();
400  xbins = new Double_t[nbinsx+1];
401  for(ix=0;ix<nbinsx;ix++){
402  xbins[ix] = h2[i]->GetXaxis()->GetBinLowEdge(ix+1);
403  }
404  xbins[nbinsx] = h2[i]->GetXaxis()->GetBinUpEdge(nbinsx);
405  ybins = new Double_t[nbinsy+1];
406  for(iy=0;iy<nbinsy;iy++){
407  ybins[iy] = h2[i]->GetYaxis()->GetBinLowEdge(iy+1);
408  }
409  ybins[nbinsy] = h2[i]->GetYaxis()->GetBinUpEdge(nbinsy);
410 
411  h2map[i] = new TH2I*[m_nHistCategories];
412  h2count[i] = new TH2I*[m_nHistCategories];
413  for(j=0;j<m_nHistCategories;j++){
414  sprintf(name,"%s_%s",m_PartitionLayers[i].c_str(),m_HistCategories[j].c_str());
415  h2map[i][j] = new TH2I(name,"",nbinsx,xbins,nbinsy,ybins);
416  sprintf(name,"%s_%s_counts",m_PartitionLayers[i].c_str(),m_HistCategories[j].c_str());
417  h2count[i][j] = (TH2I*)h2map[i][j]->Clone(name);
418 
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 = TMath::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 
610  if(h2count[i][0]->GetBinContent(ix+1,iy+1)>1){
611  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));
612  dupl2+=1;
613  }
614 
615  if(h2count[i][0]->GetBinContent(ix+1,iy+1)==0) empt+=1;
616  }
617  }
618  }
619 
620  // write out
621  file->cd();
622  tree->Write();
623  for(i=0;i<m_nPartitionLayers;i++) for(j=0;j<m_nHistCategories;j++) h2map[i][j]->Write();
624  file->Close(); 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(); delete ifile;
633 
634  return;
635 }

◆ Tree()

TTree* LArIdTranslatorHelper::Tree ( )
inline

Definition at line 56 of file LArIdTranslatorHelper.h.

56 { return m_tree; }

Member Data Documentation

◆ bec

Int_t LArIdTranslatorHelper::bec

Definition at line 35 of file LArIdTranslatorHelper.h.

◆ binetadqm

Int_t LArIdTranslatorHelper::binetadqm

Definition at line 40 of file LArIdTranslatorHelper.h.

◆ binphidqm1

Int_t LArIdTranslatorHelper::binphidqm1

Definition at line 40 of file LArIdTranslatorHelper.h.

◆ binphidqm2

Int_t LArIdTranslatorHelper::binphidqm2

Definition at line 40 of file LArIdTranslatorHelper.h.

◆ ch

Int_t LArIdTranslatorHelper::ch

Definition at line 35 of file LArIdTranslatorHelper.h.

◆ entry

Long_t LArIdTranslatorHelper::entry

Definition at line 39 of file LArIdTranslatorHelper.h.

◆ eta

Float_t LArIdTranslatorHelper::eta

Definition at line 36 of file LArIdTranslatorHelper.h.

◆ ft

Int_t LArIdTranslatorHelper::ft

Definition at line 35 of file LArIdTranslatorHelper.h.

◆ hvid

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

Definition at line 38 of file LArIdTranslatorHelper.h.

◆ m_canvas_counts

Int_t LArIdTranslatorHelper::m_canvas_counts
private

Definition at line 65 of file LArIdTranslatorHelper.h.

◆ m_clonemap_counts

Int_t LArIdTranslatorHelper::m_clonemap_counts
private

Definition at line 65 of file LArIdTranslatorHelper.h.

◆ m_extrabins

Int_t LArIdTranslatorHelper::m_extrabins
private

Definition at line 63 of file LArIdTranslatorHelper.h.

◆ m_file

TFile* LArIdTranslatorHelper::m_file
private

Definition at line 62 of file LArIdTranslatorHelper.h.

◆ m_HistCategories

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

Definition at line 71 of file LArIdTranslatorHelper.h.

◆ m_HistCellmaps

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

Definition at line 72 of file LArIdTranslatorHelper.h.

◆ m_kInitialized

bool LArIdTranslatorHelper::m_kInitialized
private

Definition at line 60 of file LArIdTranslatorHelper.h.

◆ m_namebuf

Char_t LArIdTranslatorHelper::m_namebuf[128] {}
private

Definition at line 66 of file LArIdTranslatorHelper.h.

◆ m_nHistCategories

Int_t LArIdTranslatorHelper::m_nHistCategories
private

Definition at line 70 of file LArIdTranslatorHelper.h.

◆ m_nPartitionLayers

Int_t LArIdTranslatorHelper::m_nPartitionLayers
private

Definition at line 68 of file LArIdTranslatorHelper.h.

◆ m_ntotal

Int_t LArIdTranslatorHelper::m_ntotal
private

Definition at line 63 of file LArIdTranslatorHelper.h.

◆ m_PartitionLayers

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

Definition at line 69 of file LArIdTranslatorHelper.h.

◆ m_tree

TTree* LArIdTranslatorHelper::m_tree
private

Definition at line 61 of file LArIdTranslatorHelper.h.

◆ offlid

ULong64_t LArIdTranslatorHelper::offlid

Definition at line 37 of file LArIdTranslatorHelper.h.

◆ onlid

ULong64_t LArIdTranslatorHelper::onlid

Definition at line 37 of file LArIdTranslatorHelper.h.

◆ part

Int_t LArIdTranslatorHelper::part

Definition at line 35 of file LArIdTranslatorHelper.h.

◆ phi

Float_t LArIdTranslatorHelper::phi

Definition at line 36 of file LArIdTranslatorHelper.h.

◆ sa

Int_t LArIdTranslatorHelper::sa

Definition at line 35 of file LArIdTranslatorHelper.h.

◆ side

Int_t LArIdTranslatorHelper::side

Definition at line 35 of file LArIdTranslatorHelper.h.

◆ sl

Int_t LArIdTranslatorHelper::sl

Definition at line 35 of file LArIdTranslatorHelper.h.

◆ ttid

ULong64_t LArIdTranslatorHelper::ttid

Definition at line 37 of file LArIdTranslatorHelper.h.

◆ x

Float_t LArIdTranslatorHelper::x

Definition at line 36 of file LArIdTranslatorHelper.h.

◆ y

Float_t LArIdTranslatorHelper::y

Definition at line 36 of file LArIdTranslatorHelper.h.

◆ z

Float_t LArIdTranslatorHelper::z

Definition at line 36 of file LArIdTranslatorHelper.h.


The documentation for this class was generated from the following files:
TestSUSYToolsAlg.ifile
ifile
Definition: TestSUSYToolsAlg.py:92
LArIdTranslatorHelper::binphidqm2
Int_t binphidqm2
Definition: LArIdTranslatorHelper.h:40
StateLessPT_NewConfig.Partition
Partition
Definition: StateLessPT_NewConfig.py:240
LArIdTranslatorHelper::m_canvas_counts
Int_t m_canvas_counts
Definition: LArIdTranslatorHelper.h:65
LArIdTranslatorHelper::m_extrabins
Int_t m_extrabins
Definition: LArIdTranslatorHelper.h:63
TH2I::SetBinContent
void SetBinContent(int, double)
Definition: rootspy.cxx:416
LArIdTranslatorHelper::m_clonemap_counts
Int_t m_clonemap_counts
Definition: LArIdTranslatorHelper.h:65
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
LArIdTranslatorHelper::x
Float_t x
Definition: LArIdTranslatorHelper.h:36
TH2F
Definition: rootspy.cxx:420
PixelAthClusterMonAlgCfg.zmin
zmin
Definition: PixelAthClusterMonAlgCfg.py:176
index
Definition: index.py:1
LArIdTranslatorHelper::m_HistCellmaps
std::vector< std::vector< std::unique_ptr< TH2I > > > m_HistCellmaps
Definition: LArIdTranslatorHelper.h:72
LArIdTranslatorHelper::side
Int_t side
Definition: LArIdTranslatorHelper.h:35
LArIdTranslatorHelper::m_tree
TTree * m_tree
Definition: LArIdTranslatorHelper.h:61
tree
TChain * tree
Definition: tile_monitor.h:30
TProfile2D
Definition: rootspy.cxx:531
LArIdTranslatorHelper::hvid
std::vector< int > * hvid
Definition: LArIdTranslatorHelper.h:38
PixelAthClusterMonAlgCfg.ybins
ybins
Definition: PixelAthClusterMonAlgCfg.py:163
LArIdTranslatorHelper::eta
Float_t eta
Definition: LArIdTranslatorHelper.h:36
LArIdTranslatorHelper::offlid
ULong64_t offlid
Definition: LArIdTranslatorHelper.h:37
LArIdTranslatorHelper::bec
Int_t bec
Definition: LArIdTranslatorHelper.h:35
LArIdTranslatorHelper::m_kInitialized
bool m_kInitialized
Definition: LArIdTranslatorHelper.h:60
Phi
@ Phi
Definition: RPCdef.h:8
LArIdTranslatorHelper::m_namebuf
Char_t m_namebuf[128]
Definition: LArIdTranslatorHelper.h:66
LArIdTranslatorHelper::phi
Float_t phi
Definition: LArIdTranslatorHelper.h:36
LArIdTranslatorHelper::ch
Int_t ch
Definition: LArIdTranslatorHelper.h:35
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
LArIdTranslatorHelper::binetadqm
Int_t binetadqm
Definition: LArIdTranslatorHelper.h:40
dumpHVPathFromNtuple.hvline
hvline
Definition: dumpHVPathFromNtuple.py:72
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
TH2I
Definition: rootspy.cxx:410
LArIdTranslatorHelper::LoadIdTranslator
bool LoadIdTranslator(const TString &file)
Definition: LArIdTranslatorHelper.cxx:91
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
LArIdTranslatorHelper::m_nHistCategories
Int_t m_nHistCategories
Definition: LArIdTranslatorHelper.h:70
covarianceTool.title
title
Definition: covarianceTool.py:542
file
TFile * file
Definition: tile_monitor.h:29
LArIdTranslatorHelper::ft
Int_t ft
Definition: LArIdTranslatorHelper.h:35
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:176
LArIdTranslatorHelper::binphidqm1
Int_t binphidqm1
Definition: LArIdTranslatorHelper.h:40
LArIdTranslatorHelper::m_PartitionLayers
std::vector< std::string > m_PartitionLayers
Definition: LArIdTranslatorHelper.h:69
run
Definition: run.py:1
LArIdTranslatorHelper::entry
Long_t entry
Definition: LArIdTranslatorHelper.h:39
LArIdTranslatorHelper::m_file
TFile * m_file
Definition: LArIdTranslatorHelper.h:62
LArIdTranslatorHelper::m_nPartitionLayers
Int_t m_nPartitionLayers
Definition: LArIdTranslatorHelper.h:68
LArIdTranslatorHelper::y
Float_t y
Definition: LArIdTranslatorHelper.h:36
TH2
Definition: rootspy.cxx:373
calibdata.exit
exit
Definition: calibdata.py:236
grepfile.ic
int ic
Definition: grepfile.py:33
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArIdTranslatorHelper::z
Float_t z
Definition: LArIdTranslatorHelper.h:36
LArIdTranslatorHelper::m_ntotal
Int_t m_ntotal
Definition: LArIdTranslatorHelper.h:63
LArIdTranslatorHelper::ttid
ULong64_t ttid
Definition: LArIdTranslatorHelper.h:37
LArCellBinning.xbins
int xbins
Definition: LArCellBinning.py:163
Trk::iPhi
@ iPhi
Definition: ParamDefs.h:53
LArNewCalib_Delay_OFC_Cali.FT
FT
Definition: LArNewCalib_Delay_OFC_Cali.py:120
LArIdTranslatorHelper::onlid
ULong64_t onlid
Definition: LArIdTranslatorHelper.h:37
DeMoScan.index
string index
Definition: DeMoScan.py:362
Trk::Pattern
@ Pattern
Definition: ParametersCommon.h:29
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
h
LArIdTranslatorHelper::sa
Int_t sa
Definition: LArIdTranslatorHelper.h:35
StateLessPT_NewConfig.partition
partition
Definition: StateLessPT_NewConfig.py:49
LArIdTranslatorHelper::sl
Int_t sl
Definition: LArIdTranslatorHelper.h:35
LArIdTranslatorHelper::m_HistCategories
std::vector< std::string > m_HistCategories
Definition: LArIdTranslatorHelper.h:71
LArIdTranslatorHelper::part
Int_t part
Definition: LArIdTranslatorHelper.h:35
xAOD::iEta
setScale setgFexType iEta
Definition: gFexJetRoI_v1.cxx:74
python.compressB64.c
def c
Definition: compressB64.py:93
Eta
@ Eta
Definition: RPCdef.h:8
fitman.k
k
Definition: fitman.py:528