CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MELaserPrim.cc
Go to the documentation of this file.
1 #define MELaserPrim_cxx
2 #include <cassert>
5 #include <cassert>
6 #include <cstdlib>
7 
9  "APD", "APDoPN", "APDoPNA", "APDoPNB", "APDoAPD", "APDoAPDA", "APDoAPDB", "Time"};
10 const TString MELaserPrim::apdpn_varName[MELaserPrim::iSize_apdpn] = {"Mean", "RMS", "M3", "Nevt", "Min", "Max"};
12 
13  {{" (ADC Counts)", " (ADC Counts)", " (ADC Counts)", "", " (ADC Counts)", " (ADC Counts)"},
14  {"", "", "", "", "", ""},
15  {"", "", "", "", "", ""},
16  {"", "", "", "", "", ""},
17  {"", "", "", "", "", ""},
18  {"", "", "", "", "", ""},
19  {" (25 ns)", " (25 ns)", " (25 ns)", "", " (25 ns)", " (25 ns)"}};
22 const TString MELaserPrim::ab_varName[MELaserPrim::iSize_ab] = {"alpha", "beta", "width", "chi2"};
24  "peak", "sigma", "fit", "ampl", "trise", "fwhm", "fw20", "fw80", "sliding"};
25 const TString MELaserPrim::mtq_varUnit[MELaserPrim::iSize_mtq] = {"(nanoseconds)",
26  "(nanoseconds)",
27  "(nanoseconds)",
28  "(ADC counts)",
29  "(nanoseconds)",
30  "(nanoseconds)",
31  "(nanoseconds)",
32  "(nanoseconds)",
33  "(ADC counts)"};
34 
35 const TString MELaserPrim::separator = "__";
36 
37 //ClassImp( MELaserPrim )
38 
39 MELaserPrim::MELaserPrim(ME::Header header, ME::Settings settings, const char* inpath, const char* outfile)
40  : init_ok(false), _isBarrel(true), _inpath(inpath), _outfile(outfile) {
41  apdpn_file = nullptr;
42  ab_file = nullptr;
43  mtq_file = nullptr;
44  tpapd_file = nullptr;
45  apdpn_tree = nullptr;
46  ab_tree = nullptr;
47  pn_tree = nullptr;
48  mtq_tree = nullptr;
49  tpapd_tree = nullptr;
50  tppn_tree = nullptr;
51  ixmin = 0;
52  ixmax = 0;
53  iymin = 0;
54  iymax = 0;
55 
56  _dcc = header.dcc;
57  _side = header.side;
58  _run = header.run;
59  _lb = header.lb;
60  _events = header.events;
61  _ts = header.ts_beg;
62  _ts_beg = header.ts_beg;
63  _ts_end = header.ts_end;
64 
65  _type = settings.type;
66  _color = settings.wavelength;
67  _power = settings.power;
68  _filter = settings.filter;
69  _delay = settings.delay;
70  _mgpagain = settings.mgpagain;
71  _memgain = settings.memgain;
72 
73  if (_type == ME::iLaser) {
77  } else if (_type == ME::iTestPulse) {
80  }
81 
82  _lmr = ME::lmr(_dcc, _side);
84  _isBarrel = (_reg == ME::iEBM || _reg == ME::iEBP);
87  _regionStr += "_";
88  _regionStr += _side;
89 
90  init();
92  //fillHistograms();
93  //writeHistograms();
94 }
95 
96 TString MELaserPrim::channelViewName(int iname) {
97  switch (iname) {
98  case iECAL:
99  return "ECAL";
100  case iECAL_LMR:
101  return "ECAL_LMR";
102  case iEB_crystal_number:
103  return "EB_crystal_number";
104  case iEB_LM_LMM:
105  return "EB_LM_LMM";
106  case iEB_LM_PN:
107  return "EB_LM_PN";
108  case iEE_crystal_number:
109  return "EE_crystal_number";
110  case iEE_LM_LMM:
111  return "EE_LM_LMM";
112  case iEE_LM_PN:
113  return "EE_LM_PN";
114  default:
115  abort();
116  }
117  return "";
118 }
119 
120 int MELaserPrim::logicId(int channelView, int id1, int id2) {
121  assert(channelView >= iECAL && channelView < iSize_cv);
122  return 1000000 * channelView + 10000 * id1 + id2;
123 }
124 
125 bool MELaserPrim::getViewIds(int logic_id, int& channelView, int& id1, int& id2) {
126  bool out = true;
127  int channelView_ = logic_id / 1000000;
128  if (channelView != 0 && channelView_ != channelView)
129  out = false;
130  channelView = channelView_;
131  id1 = (logic_id % 1000000) / 10000;
132  id2 = logic_id % 10000;
133  return out;
134 }
135 
137  bool verbose_ = false;
138 
139  if (_inpath == "0") {
140  if (verbose_)
141  std::cout << "no input file" << std::endl;
142  init_ok = true;
143  return; // GHM
144  }
145 
146  TString cur(_inpath);
147  if (!cur.EndsWith("/"))
148  cur += "/";
149 
150  if (_type == ME::iLaser) {
151  TString _APDPN_fname = cur;
152  _APDPN_fname += "APDPN_LASER.root";
153  TString _AB_fname = cur;
154  _AB_fname += "AB.root";
155  TString _MTQ_fname = cur;
156  _MTQ_fname += "MATACQ.root";
157 
158  bool apdpn_ok, ab_ok, pn_ok, mtq_ok;
159  apdpn_ok = false;
160  ab_ok = false;
161  pn_ok = false;
162  mtq_ok = false;
163 
164  FILE* test;
165  test = fopen(_APDPN_fname, "r");
166  if (test) {
167  apdpn_ok = true;
168  pn_ok = true;
169  fclose(test);
170  }
171  test = fopen(_AB_fname, "r");
172  if (test) {
173  ab_ok = true;
174  fclose(test);
175  }
176  test = fopen(_MTQ_fname, "r");
177  if (test) {
178  mtq_ok = true;
179  fclose(test);
180  }
181 
182  if (apdpn_ok)
183  apdpn_file = TFile::Open(_APDPN_fname);
184  if (ab_ok)
185  ab_file = TFile::Open(_AB_fname);
186  if (mtq_ok)
187  mtq_file = TFile::Open(_MTQ_fname);
188 
189  if (verbose_) {
190  std::cout << _APDPN_fname << " ok=" << apdpn_ok << std::endl;
191  std::cout << _AB_fname << " ok=" << ab_ok << std::endl;
192  std::cout << _MTQ_fname << " ok=" << mtq_ok << std::endl;
193  }
194  if (!apdpn_ok || !pn_ok)
195  return; // FIXME !
196 
197  TString apdpn_tree_name;
198  TString ab_tree_name;
199  TString pn_tree_name;
200  TString mtq_tree_name;
201 
202  apdpn_tree_name = "APDCol";
203  ab_tree_name = "ABCol";
204  pn_tree_name = "PNCol";
205  mtq_tree_name = "MatacqCol";
206 
207  apdpn_tree_name += _color;
208  ab_tree_name += _color;
209  pn_tree_name += _color;
210  mtq_tree_name += _color;
211 
212  if (mtq_ok) {
213  TTree* ckeckMtq = (TTree*)mtq_file->Get(mtq_tree_name);
214  if (ckeckMtq == nullptr)
215  mtq_ok = false;
216  }
217 
218  if (_color != ME::iIRed && _color != ME::iBlue) {
219  std::cout << "MELaserPrim::init() -- Fatal Error -- Wrong Laser Color : " << _color << " ---- Abort "
220  << std::endl;
221  return;
222  }
223 
224  apdpn_tree = (TTree*)apdpn_file->Get(apdpn_tree_name);
225  assert(apdpn_tree != nullptr);
226  apdpn_tree->SetMakeClass(1);
227  apdpn_tree->SetBranchAddress("dccID", &apdpn_dccID, &b_apdpn_dccID);
228  apdpn_tree->SetBranchAddress("towerID", &apdpn_towerID, &b_apdpn_towerID);
229  apdpn_tree->SetBranchAddress("channelID", &apdpn_channelID, &b_apdpn_channelID);
230  apdpn_tree->SetBranchAddress("moduleID", &apdpn_moduleID, &b_apdpn_moduleID);
231  apdpn_tree->SetBranchAddress("side", &apdpn_side, &b_apdpn_side);
232  apdpn_tree->SetBranchAddress("ieta", &apdpn_ieta, &b_apdpn_ieta);
233  apdpn_tree->SetBranchAddress("iphi", &apdpn_iphi, &b_apdpn_iphi);
234  apdpn_tree->SetBranchAddress("flag", &apdpn_flag, &b_apdpn_flag);
235  if (apdpn_tree->GetBranchStatus("ShapeCor"))
236  apdpn_tree->SetBranchAddress("ShapeCor", &apdpn_ShapeCor, &b_apdpn_ShapeCor);
237  else
238  apdpn_ShapeCor = 0.0;
239  for (int jj = 0; jj < iSizeArray_apdpn; jj++) {
240  TString name_ = apdpn_arrayName[jj];
241  apdpn_tree->SetBranchAddress(name_, apdpn_apdpn[jj], &b_apdpn_apdpn[jj]);
242  }
243 
244  if (ab_ok) {
245  ab_tree = (TTree*)ab_file->Get(ab_tree_name);
246  assert(ab_tree != nullptr);
247  ab_tree->SetMakeClass(1);
248  ab_tree->SetBranchAddress("dccID", &ab_dccID, &b_ab_dccID);
249  ab_tree->SetBranchAddress("towerID", &ab_towerID, &b_ab_towerID);
250  ab_tree->SetBranchAddress("channelID", &ab_channelID, &b_ab_channelID);
251  ab_tree->SetBranchAddress("ieta", &ab_ieta, &b_ab_ieta);
252  ab_tree->SetBranchAddress("iphi", &ab_iphi, &b_ab_iphi);
253  ab_tree->SetBranchAddress("flag", &ab_flag, &b_ab_flag);
254  for (int ii = 0; ii < iSize_ab; ii++) {
255  ab_tree->SetBranchAddress(ab_varName[ii], &ab_ab[ii], &b_ab_ab[ii]);
256  }
257  }
258 
259  pn_tree = (TTree*)apdpn_file->Get(pn_tree_name);
260  assert(pn_tree != nullptr);
261  pn_tree->SetMakeClass(1);
262  pn_tree->SetBranchAddress("side", &pn_side, &b_pn_side);
263  pn_tree->SetBranchAddress("pnID", &pn_pnID, &b_pn_pnID);
264  pn_tree->SetBranchAddress("moduleID", &pn_moduleID, &b_pn_moduleID);
265  pn_tree->SetBranchAddress("PN", pn_PN, &b_pn_PN);
266  pn_tree->SetBranchAddress("PNoPN", pn_PNoPN, &b_pn_PNoPN);
267  pn_tree->SetBranchAddress("PNoPNA", pn_PNoPNA, &b_pn_PNoPNA);
268  pn_tree->SetBranchAddress("PNoPNB", pn_PNoPNB, &b_pn_PNoPNB);
269 
270  if (mtq_ok) {
271  mtq_tree = (TTree*)mtq_file->Get(mtq_tree_name);
272  assert(mtq_tree != nullptr);
273  mtq_tree->SetMakeClass(1);
274  mtq_tree->SetBranchAddress("side", &mtq_side, &b_mtq_side);
275 
276  for (int ii = 0; ii < iSize_mtq; ii++) {
277  mtq_tree->SetBranchAddress(mtq_varName[ii], &mtq_mtq[ii], &b_mtq_mtq[ii]);
278  }
279  }
280  } else if (_type == ME::iTestPulse) {
281  TString _TPAPD_fname = cur;
282  _TPAPD_fname += "APDPN_TESTPULSE.root";
283 
284  bool tpapd_ok;
285  tpapd_ok = false;
286 
287  FILE* test;
288  test = fopen(_TPAPD_fname, "r");
289  if (test) {
290  tpapd_ok = true;
291  fclose(test);
292  }
293 
294  if (tpapd_ok)
295  tpapd_file = TFile::Open(_TPAPD_fname);
296 
297  if (verbose_) {
298  std::cout << _TPAPD_fname << " ok=" << tpapd_ok << std::endl;
299  }
300  if (!tpapd_ok)
301  return;
302 
303  TString tpapd_tree_name;
304  TString tppn_tree_name;
305 
306  tpapd_tree_name = "TPAPD";
307  tppn_tree_name = "TPPN";
308 
309  tpapd_tree = (TTree*)tpapd_file->Get(tpapd_tree_name);
310  assert(tpapd_tree != nullptr);
311  tpapd_tree->SetMakeClass(1);
312  tpapd_tree->SetBranchAddress("ieta", &tpapd_ieta, &b_tpapd_ieta);
313  tpapd_tree->SetBranchAddress("iphi", &tpapd_iphi, &b_tpapd_iphi);
314  tpapd_tree->SetBranchAddress("dccID", &tpapd_dccID, &b_tpapd_dccID);
315  tpapd_tree->SetBranchAddress("side", &tpapd_side, &b_tpapd_side);
316  tpapd_tree->SetBranchAddress("towerID", &tpapd_towerID, &b_tpapd_towerID);
317  tpapd_tree->SetBranchAddress("channelID", &tpapd_channelID, &b_tpapd_channelID);
318  tpapd_tree->SetBranchAddress("moduleID", &tpapd_moduleID, &b_tpapd_moduleID);
319  tpapd_tree->SetBranchAddress("flag", &tpapd_flag, &b_tpapd_flag);
320  tpapd_tree->SetBranchAddress("gain", &tpapd_gain, &b_tpapd_gain);
321  tpapd_tree->SetBranchAddress("APD", tpapd_APD, &b_tpapd_APD);
322 
323  tppn_tree = (TTree*)tpapd_file->Get(tppn_tree_name);
324  assert(tppn_tree != nullptr);
325  tppn_tree->SetMakeClass(1);
326  tppn_tree->SetBranchAddress("side", &tppn_side, &b_tppn_side);
327  tppn_tree->SetBranchAddress("pnID", &tppn_pnID, &b_tppn_pnID);
328  tppn_tree->SetBranchAddress("moduleID", &tppn_moduleID, &b_tppn_moduleID);
329  tppn_tree->SetBranchAddress("gain", &tppn_gain, &b_tppn_gain);
330  tppn_tree->SetBranchAddress("PN", tppn_PN, &b_tppn_PN);
331  }
332  init_ok = true;
333 }
334 
336  if (!init_ok)
337  return;
338  refresh();
339 
340  TString i_name, d_name;
341 
342  if (_isBarrel) {
343  ixmin = 0;
344  ixmax = 85;
345  nx = ixmax - ixmin;
346  iymin = 0;
347  iymax = 20;
348  ny = iymax - iymin;
349 
350  // for( int ilmod=1; ilmod<=9; ilmod++ )
351  // {
352  // _pn[ilmod] = MEEBGeom::pn( ilmod );
353  // }
354  } else // fixme --- to be implemented
355  {
356  ixmin = 1;
357  ixmax = 101;
358  nx = ixmax - ixmin;
359  iymin = 1;
360  iymax = 101;
361  ny = iymax - iymin;
362  // for( int ilmod=1; ilmod<=21; ilmod++ ) // modules 20 and 21 are fake...
363  // {
364  // _pn[ilmod] = MEEEGeom::pn( ilmod );
365  // }
366  // abort();
367  }
368 
369  TString t_name;
370 
371  //
372  // Laser Run
373  //
374  t_name = "LMF_RUN_DAT";
375  addBranchI(t_name, "LOGIC_ID");
376  addBranchI(t_name, "NEVENTS");
377  addBranchI(t_name, "QUALITY_FLAG");
378 
379  //
380  // Laser Run IOV
381  //
382  t_name = "LMF_RUN_IOV";
383  addBranchI(t_name, "TAG_ID");
384  addBranchI(t_name, "SUB_RUN_NUM");
385  addBranchI(t_name, "SUB_RUN_START_LOW");
386  addBranchI(t_name, "SUB_RUN_START_HIGH");
387  addBranchI(t_name, "SUB_RUN_END_LOW");
388  addBranchI(t_name, "SUB_RUN_END_HIGH");
389  addBranchI(t_name, "DB_TIMESTAMP_LOW");
390  addBranchI(t_name, "DB_TIMESTAMP_HIGH");
391  addBranchC(t_name, "SUB_RUN_TYPE");
392 
393  if (_type == ME::iLaser) {
394  //
395  // Laser ADC Primitives
396  //
397  bookHistoI(_primStr, "LOGIC_ID");
398  bookHistoI(_primStr, "FLAG");
399  bookHistoF(_primStr, "MEAN");
400  bookHistoF(_primStr, "RMS");
401  bookHistoF(_primStr, "M3");
402  bookHistoF(_primStr, "APD_OVER_PNA_MEAN");
403  bookHistoF(_primStr, "APD_OVER_PNA_RMS");
404  bookHistoF(_primStr, "APD_OVER_PNA_M3");
405  bookHistoF(_primStr, "APD_OVER_PNB_MEAN");
406  bookHistoF(_primStr, "APD_OVER_PNB_RMS");
407  bookHistoF(_primStr, "APD_OVER_PNB_M3");
408  bookHistoF(_primStr, "APD_OVER_PN_MEAN");
409  bookHistoF(_primStr, "APD_OVER_PN_RMS");
410  bookHistoF(_primStr, "APD_OVER_PN_M3");
411  bookHistoF(_primStr, "APD_OVER_APDA_MEAN");
412  bookHistoF(_primStr, "APD_OVER_APDA_RMS");
413  bookHistoF(_primStr, "APD_OVER_APDA_M3");
414  bookHistoF(_primStr, "APD_OVER_APDB_MEAN");
415  bookHistoF(_primStr, "APD_OVER_APDB_RMS");
416  bookHistoF(_primStr, "APD_OVER_APDB_M3");
417  bookHistoF(_primStr, "SHAPE_COR");
418  bookHistoF(_primStr, "ALPHA");
419  bookHistoF(_primStr, "BETA");
420  // NEW GHM 08/06 --> SCHEMA MODIFIED?
421  bookHistoF(_primStr, "TIME_MEAN");
422  bookHistoF(_primStr, "TIME_RMS");
423  bookHistoF(_primStr, "TIME_M3");
424  bookHistoF(_primStr, "TIME_NEVT");
425 
426  //
427  // Laser PN Primitives
428  //
430  addBranchI(t_name, "LOGIC_ID");
431  addBranchI(t_name, "FLAG");
432  addBranchF(t_name, "MEAN");
433  addBranchF(t_name, "RMS");
434  addBranchF(t_name, "M3");
435  addBranchF(t_name, "PNA_OVER_PNB_MEAN");
436  addBranchF(t_name, "PNA_OVER_PNB_RMS");
437  addBranchF(t_name, "PNA_OVER_PNB_M3");
438 
439  //
440  // Laser Pulse
441  //
443  addBranchI(t_name, "LOGIC_ID");
444  addBranchI(t_name, "FIT_METHOD");
445  addBranchF(t_name, "MTQ_AMPL");
446  addBranchF(t_name, "MTQ_TIME");
447  addBranchF(t_name, "MTQ_RISE");
448  addBranchF(t_name, "MTQ_FWHM");
449  addBranchF(t_name, "MTQ_FW20");
450  addBranchF(t_name, "MTQ_FW80");
451  addBranchF(t_name, "MTQ_SLIDING");
452 
453  //
454  // Laser Config
455  //
457  addBranchI(t_name, "LOGIC_ID");
458  addBranchI(t_name, "WAVELENGTH");
459  addBranchI(t_name, "VFE_GAIN");
460  addBranchI(t_name, "PN_GAIN");
461  addBranchI(t_name, "LSR_POWER");
462  addBranchI(t_name, "LSR_ATTENUATOR");
463  addBranchI(t_name, "LSR_CURRENT");
464  addBranchI(t_name, "LSR_DELAY_1");
465  addBranchI(t_name, "LSR_DELAY_2");
466 
467  //
468  // Laser LaserRun config dat
469  //
470  t_name = "RUN_LASERRUN_CONFIG_DAT";
471  addBranchI(t_name, "LOGIC_ID");
472  addBranchC(t_name, "LASER_SEQUENCE_TYPE");
473  addBranchC(t_name, "LASER_SEQUENCE_COND");
474 
475  } else if (_type == ME::iTestPulse) {
476  //
477  // Test Pulse ADC Primitives
478  //
479  bookHistoI(_tpPrimStr, "LOGIC_ID");
480  bookHistoI(_tpPrimStr, "FLAG");
481  bookHistoF(_tpPrimStr, "MEAN");
482  bookHistoF(_tpPrimStr, "RMS");
483  bookHistoF(_tpPrimStr, "M3");
484  bookHistoF(_tpPrimStr, "NEVT");
485 
486  //
487  // Test Pulse PN Primitives
488  //
490  addBranchI(t_name, "LOGIC_ID");
491  addBranchI(t_name, "FLAG");
492  addBranchI(t_name, "GAIN");
493  addBranchF(t_name, "MEAN");
494  addBranchF(t_name, "RMS");
495  addBranchF(t_name, "M3");
496 
497  //
498  // Test Pulse Config
499  //
501  addBranchI(t_name, "LOGIC_ID");
502  addBranchI(t_name, "VFE_GAIN");
503  addBranchI(t_name, "PN_GAIN");
504  }
505 }
506 
508  TString t_name;
509 
510  if (!init_ok)
511  return;
512 
513  Long64_t nentries = 0;
514  Long64_t ientry = 0;
515 
516  int channelView_(0);
517  int id1_(0), id2_(0);
518  int logic_id_(0);
519 
520  if (_type == ME::iLaser) {
521  nentries = apdpn_tree->GetEntriesFast();
522  for (Long64_t jentry = 0; jentry < nentries; jentry++) {
523  ientry = apdpn_tree->LoadTree(jentry);
524  assert(ientry >= 0);
525  apdpn_tree->GetEntry(jentry);
526 
527  if (ab_tree) {
528  ientry = ab_tree->LoadTree(jentry);
529  assert(ientry >= 0);
530  ab_tree->GetEntry(jentry);
531  }
532 
533  if (apdpn_iphi < 0)
534  continue;
535 
536  // fixme remove until coordinated are fine
537  //if(ab_tree) assert( apdpn_ieta==ab_ieta && apdpn_iphi==ab_iphi );
538 
539  int ix(0);
540  int iy(0);
541  if (_isBarrel) {
542  // Barrel, global coordinates
543  id1_ = _sm;
544  if (apdpn_side != _side)
545  continue;
546  int ieta = apdpn_ieta;
547  int iphi = apdpn_iphi;
548  MEEBGeom::XYCoord xy_ = MEEBGeom::localCoord(ieta, iphi);
549  ix = xy_.first;
550  iy = xy_.second;
551  id2_ = MEEBGeom::crystal_channel(ix, iy);
552  channelView_ = iEB_crystal_number;
553  } else {
554  // EndCaps, global coordinates
555  id1_ = apdpn_iphi;
556  id2_ = apdpn_ieta;
557  ix = id1_;
558  iy = id2_;
559  channelView_ = iEE_crystal_number;
560  }
561 
562  logic_id_ = logicId(channelView_, id1_, id2_);
563 
564  int flag = apdpn_flag;
565 
566  setInt("LOGIC_ID", ix, iy, logic_id_);
567  setInt("FLAG", ix, iy, flag);
568  setVal("MEAN", ix, iy, apdpn_apdpn[iAPD][iMean]);
569  setVal("RMS", ix, iy, apdpn_apdpn[iAPD][iRMS]);
570  setVal("M3", ix, iy, apdpn_apdpn[iAPD][iM3]); // fixme --- peak?
571  setVal("APD_OVER_PNA_MEAN", ix, iy, apdpn_apdpn[iAPDoPNA][iMean]);
572  setVal("APD_OVER_PNA_RMS", ix, iy, apdpn_apdpn[iAPDoPNA][iRMS]);
573  setVal("APD_OVER_PNA_M3", ix, iy, apdpn_apdpn[iAPDoPNA][iM3]); // fixme
574  setVal("APD_OVER_PNB_MEAN", ix, iy, apdpn_apdpn[iAPDoPNB][iMean]);
575  setVal("APD_OVER_PNB_RMS", ix, iy, apdpn_apdpn[iAPDoPNB][iRMS]);
576  setVal("APD_OVER_PNB_M3", ix, iy, apdpn_apdpn[iAPDoPNB][iM3]); // fixme
577  setVal("APD_OVER_PN_MEAN", ix, iy, apdpn_apdpn[iAPDoPN][iMean]);
578  setVal("APD_OVER_PN_RMS", ix, iy, apdpn_apdpn[iAPDoPN][iRMS]);
579  setVal("APD_OVER_PN_M3", ix, iy, apdpn_apdpn[iAPDoPN][iM3]); // fixme
580  // JM
581  setVal("APD_OVER_APD_MEAN", ix, iy, apdpn_apdpn[iAPDoAPDA][iMean]);
582  setVal("APD_OVER_APD_RMS", ix, iy, apdpn_apdpn[iAPDoAPDA][iRMS]);
583  setVal("APD_OVER_APD_M3", ix, iy, apdpn_apdpn[iAPDoAPDA][iM3]); // fixme
584  setVal("APD_OVER_APDA_MEAN", ix, iy, apdpn_apdpn[iAPDoAPDA][iMean]);
585  setVal("APD_OVER_APDA_RMS", ix, iy, apdpn_apdpn[iAPDoAPDA][iRMS]);
586  setVal("APD_OVER_APDA_M3", ix, iy, apdpn_apdpn[iAPDoAPDA][iM3]); // fixme
587  setVal("APD_OVER_APDB_MEAN", ix, iy, apdpn_apdpn[iAPDoAPDB][iMean]);
588  setVal("APD_OVER_APDB_RMS", ix, iy, apdpn_apdpn[iAPDoAPDB][iRMS]);
589  setVal("APD_OVER_APDB_M3", ix, iy, apdpn_apdpn[iAPDoAPDB][iM3]); // fixme
590  // JM
591  setVal("SHAPE_COR", ix, iy, apdpn_ShapeCor);
592  if (ab_tree) {
593  setVal("ALPHA", ix, iy, ab_ab[iAlpha]);
594  setVal("BETA", ix, iy, ab_ab[iBeta]);
595  } else {
596  setVal("ALPHA", ix, iy, 0.);
597  setVal("BETA", ix, iy, 0.);
598  }
599  // NEW GHM 08/06
600  setVal("TIME_MEAN", ix, iy, apdpn_apdpn[iTime][iMean]);
601  setVal("TIME_RMS", ix, iy, apdpn_apdpn[iTime][iRMS]);
602  setVal("TIME_M3", ix, iy, apdpn_apdpn[iTime][iM3]);
603  setVal("TIME_NEVT", ix, iy, apdpn_apdpn[iTime][iNevt]);
604  }
605 
606  //
607  // PN primitives
608  //
610 
611  nentries = pn_tree->GetEntriesFast();
612  assert(nentries % 2 == 0);
613  int module_(0);
614  id1_ = _sm;
615  id2_ = 0;
616 
617  Long64_t jentry = 0;
618 
619  while (jentry < nentries) {
620  for (int jj = 0; jj < 2; jj++) {
621  // jj=0 --> PNA
622  // jj=1 --> PNB
623 
624  int zentry = jentry + jj;
625  assert(zentry < nentries);
626 
627  ientry = pn_tree->LoadTree(zentry);
628  assert(ientry >= 0);
629  pn_tree->GetEntry(zentry);
630 
631  if (_side != pn_side)
632  break;
633 
634  if (jj == 1)
635  assert(pn_moduleID == module_);
636  module_ = pn_moduleID;
637  assert(pn_pnID == jj);
638 
639  // get the PN number
640  std::pair<int, int> memPn_ = ME::pn(_lmr, module_, (ME::PN)jj);
641  if (_isBarrel) {
642  // assert( memPn_.first%600==_dcc%600 );
643  id1_ = _sm;
644  id2_ = memPn_.second;
645  } else {
646  int dee_ = MEEEGeom::dee(_lmr);
647  // int mem_ = memPn_.first%600;
648  // if( dee_==1 )
649  // {
650  // if( jj==ME::iPNA ) assert( mem_==50 );
651  // else assert( mem_==51 );
652  // }
653  // else if( dee_==2 )
654  // {
655  // if( jj==ME::iPNA ) assert( mem_==47 ); // warning !
656  // else assert( mem_==46 );
657  // // assert( mem_==46 || mem_==47 );
658  // }
659  // else if( dee_==3 )
660  // {
661  // if( jj==ME::iPNA ) assert( mem_==1 );
662  // else assert( mem_==2 );
663  // }
664  // else if( dee_==4 )
665  // {
666  // if( jj==ME::iPNA ) assert( mem_==5 );
667  // else assert( mem_==6 );
668  // }
669  id1_ = dee_;
670  id2_ = (jj + 1) * 100 + memPn_.second;
671  }
672 
673  if (_isBarrel) {
674  channelView_ = iEB_LM_PN;
675  } else {
676  channelView_ = iEE_LM_PN;
677  }
678  logic_id_ = logicId(channelView_, id1_, id2_);
679 
680  i_t[t_name + separator + "LOGIC_ID"] = logic_id_;
681  f_t[t_name + separator + "MEAN"] = pn_PN[iMean];
682  f_t[t_name + separator + "RMS"] = pn_PN[iRMS];
683  f_t[t_name + separator + "M3"] = pn_PN[iM3];
684  f_t[t_name + separator + "PNA_OVER_PNB_MEAN"] = (jj == 0) ? pn_PNoPNB[iMean] : pn_PNoPNA[iMean];
685  f_t[t_name + separator + "PNA_OVER_PNB_RMS"] = (jj == 0) ? pn_PNoPNB[iRMS] : pn_PNoPNA[iRMS];
686  f_t[t_name + separator + "PNA_OVER_PNB_M3"] = (jj == 0) ? pn_PNoPNB[iM3] : pn_PNoPNA[iM3];
687 
688  t_t[t_name]->Fill();
689  }
690  // std::cout << "Module=" << module_ << "\tPNA=" << pn_[0] << "\tPNB=" << pn_[1] << std::endl;
691 
692  // if( _isBarrel )
693  // jentry += 4;
694  // else
695  // jentry += 2;
696  jentry += 2;
697  }
698 
699  logic_id_ = logicId(iECAL_LMR, _lmr);
700 
701  //
702  // MATACQ primitives
703  //
704 
705  if (mtq_tree) {
707 
708  nentries = mtq_tree->GetEntriesFast();
709  assert(nentries == 2);
710  for (Long64_t jentry = 0; jentry < nentries; jentry++) {
711  ientry = mtq_tree->LoadTree(jentry);
712  assert(ientry >= 0);
713  mtq_tree->GetEntry(jentry);
714 
715  if (mtq_side != _side)
716  continue;
717 
718  i_t[t_name + separator + "LOGIC_ID"] = logic_id_;
719  i_t[t_name + separator + "FIT_METHOD"] = 0; // fixme --- what's this? ? ?
720  f_t[t_name + separator + "MTQ_AMPL"] = mtq_mtq[iAmpl];
721  f_t[t_name + separator + "MTQ_TIME"] = mtq_mtq[iPeak];
722  f_t[t_name + separator + "MTQ_RISE"] = mtq_mtq[iTrise];
723  f_t[t_name + separator + "MTQ_FWHM"] = mtq_mtq[iFwhm];
724  f_t[t_name + separator + "MTQ_FW20"] = mtq_mtq[iFw20];
725  f_t[t_name + separator + "MTQ_FW80"] = mtq_mtq[iFw80];
726  f_t[t_name + separator + "MTQ_SLIDING"] =
727  mtq_mtq[iSlide]; // fixme --- sliding: max of average in sliding window
728 
729  t_t[t_name]->Fill();
730  }
731  } else {
733 
734  i_t[t_name + separator + "LOGIC_ID"] = logic_id_;
735  i_t[t_name + separator + "FIT_METHOD"] = 0; // fixme
736  f_t[t_name + separator + "MTQ_AMPL"] = 0.0;
737  f_t[t_name + separator + "MTQ_TIME"] = 0.0;
738  f_t[t_name + separator + "MTQ_RISE"] = 0.0;
739  f_t[t_name + separator + "MTQ_FWHM"] = 0.0;
740  f_t[t_name + separator + "MTQ_FW20"] = 0.0;
741  f_t[t_name + separator + "MTQ_FW80"] = 0.0;
742  f_t[t_name + separator + "MTQ_SLIDING"] = 0.0;
743 
744  t_t[t_name]->Fill();
745  }
746 
747  //
748  // Laser Run
749  //
751  //std::cout << "Fill "<< t_name << std::endl;
752  i_t[t_name + separator + "LOGIC_ID"] = logic_id_;
753  i_t[t_name + separator + "NEVENTS"] = _events;
754  i_t[t_name + separator + "QUALITY_FLAG"] = 1; // fixme
755  t_t[t_name]->Fill();
756 
757  //
758  // Laser Config
759  //
761  //std::cout << "Fill "<< t_name << std::endl;
762  i_t[t_name + separator + "LOGIC_ID"] = logic_id_;
763  i_t[t_name + separator + "WAVELENGTH"] = _color;
764  i_t[t_name + separator + "VFE_GAIN"] = _mgpagain; // fixme
765  i_t[t_name + separator + "PN_GAIN"] = _memgain; // fixme
766  i_t[t_name + separator + "LSR_POWER"] = _power; // will be available from MATACQ data
767  i_t[t_name + separator + "LSR_ATTENUATOR"] = _filter; // idem
768  i_t[t_name + separator + "LSR_CURRENT"] = 0; // idem
769  i_t[t_name + separator + "LSR_DELAY_1"] = _delay; // idem
770  i_t[t_name + separator + "LSR_DELAY_2"] = 0; // idem
771  t_t[t_name]->Fill();
772 
773  } else if (_type == ME::iTestPulse) {
774  // nentries = tpapd_tree->GetEntriesFast();
775  // for( Long64_t jentry=0; jentry<nentries; jentry++ )
776  // {
777  // ientry = tpapd_tree->LoadTree( jentry );
778  // assert( ientry>=0 );
779  // nb = tpapd_tree->GetEntry( jentry );
780 
781  // if( tpapd_iphi<0 ) continue;
782 
783  // const bool new_= true;
784 
785  // int ix;
786  // int iy;
787  // int id2;
788  // if( new_ )
789  // {
790  // // for Cruzet3 , global coordinates
791  // if ( tpapd_side != _side ) continue;
792  // int ieta=tpapd_ieta;
793  // int iphi=tpapd_iphi;
794  // MEEBGeom::XYCoord xy_ = MEEBGeom::localCoord( ieta, iphi );
795  // ix = xy_.first;
796  // iy = xy_.second;
797  // id2 = ix*20 + iy; // !!! TO BE CHECKED !!!
798  // }
799  // else
800  // {
801  // // for Cruzet2 , local coordinates
802  // ix = tpapd_ieta;
803  // iy = 19-tpapd_iphi;
804  // id2 = ix*20 + (20 - iy); // !!! TO BE CHECKED !!!
805  // }
806  // //
807 
808  // int id1 = _sm; // fixme --- this is for barrel
809  // int logic_id_ = 1011000000; // fixme
810  // logic_id_ += 10000*id1 + id2;
811 
812  // int flag = tpapd_flag;
813 
814  // setInt( "LOGIC_ID", ix, iy, logic_id_ );
815  // setInt( "FLAG", ix, iy, flag );
816  // setVal( "MEAN", ix, iy, tpapd_APD[iMean] );
817  // setVal( "RMS", ix, iy, tpapd_APD[iRMS] );
818  // setVal( "M3", ix, iy, tpapd_APD[iM3] );
819  // setVal( "NEVT", ix, iy, tpapd_APD[iNevt] );
820  // }
821 
822  // //
823  // // PN primitives
824  // //
825  // t_name = lmfLaserName( ME::iLmfTestPulsePnPrim, _type );
826 
827  // nentries = tppn_tree->GetEntriesFast();
828  // assert( nentries%2==0 );
829  // int module_, pn_[2];
830  // int id1_(_sm), id2_(0);
831  // int logic_id_(0);
832 
833  // Long64_t jentry=0;
834  // if( _side==1 ) jentry+=2; // fixme : true also for endcaps?
835  // while( jentry<nentries )
836  // {
837  // for( int jj=0; jj<2; jj++ )
838  // {
839  // // jj=0 --> PNA
840  // // jj=1 --> PNB
841 
842  // int zentry = jentry+jj;
843  // assert( zentry<nentries );
844 
845  // ientry = tppn_tree->LoadTree( zentry );
846  // assert( ientry>=0 );
847  // nb = tppn_tree->GetEntry( zentry );
848 
849  // if( jj==1 ) assert( tppn_moduleID==module_ );
850  // module_ = tppn_moduleID;
851  // assert( tppn_pnID==jj );
852 
853  // pn_[jj] = ( jj==0 ) ? _pn[module_].first : _pn[module_].second;
854  // id2_ = pn_[jj];
855  // logic_id_ = 1131000000 ;
856  // // logic_id_ = 0; // fixme
857  // logic_id_ += 10000*id1_ + id2_;
858 
859  // i_t[t_name+separator+"LOGIC_ID"] = logic_id_;
860  // i_t[t_name+separator+"GAIN"] = tppn_gain;
861  // f_t[t_name+separator+"MEAN"] = tppn_PN[iMean];
862  // f_t[t_name+separator+"RMS"] = tppn_PN[iRMS];
863  // f_t[t_name+separator+"M3"] = tppn_PN[iM3]; // fixme --- peak?
864 
865  // t_t[t_name]->Fill();
866 
867  // }
868 
869  // // std::cout << "Module=" << module_ << "\tPNA=" << pn_[0] << "\tPNB=" << pn_[1] << std::endl;
870 
871  // jentry += 4;
872  // }
873 
874  // logic_id_ = 1041000000;
875  // logic_id_ += 10000*id1_;
876  // logic_id_ += id1_;
877 
878  // //
879  // // Test Pulse Run
880  // //
881  // t_name = lmfLaserName( ME::iLmfTestPulseRun, _type );
882  // //std::cout << "Fill "<< t_name << std::endl;
883  // i_t[t_name+separator+"LOGIC_ID"] = logic_id_; // fixme --- is there a channelview for this?
884  // i_t[t_name+separator+"NEVENTS"] = _events;
885  // i_t[t_name+separator+"QUALITY_FLAG"] = 1; // fixme
886  // t_t[t_name]->Fill();
887 
888  // //
889  // // Test Pulse Config
890  // //
891  // t_name = lmfLaserName( ME::iLmfTestPulseConfig, _type );
892  // //std::cout << "Fill "<< t_name << std::endl;
893  // i_t[t_name+separator+"LOGIC_ID"] = logic_id_; // fixme
894  // i_t[t_name+separator+"VFE_GAIN"] = _mgpagain; // fixme
895  // i_t[t_name+separator+"PN_GAIN"] = _memgain; // fixme
896  // t_t[t_name]->Fill();
897  }
898 
899  //
900  // Laser Run IOV
901  //
902  t_name = "LMF_RUN_IOV";
903  //std::cout << "Fill "<< t_name << std::endl;
904  i_t[t_name + separator + "TAG_ID"] = 0; // fixme
905  i_t[t_name + separator + "SUB_RUN_NUM"] = _run; // fixme
906  i_t[t_name + separator + "SUB_RUN_START_LOW"] = ME::time_low(_ts_beg);
907  i_t[t_name + separator + "SUB_RUN_START_HIGH"] = ME::time_high(_ts_beg);
908  i_t[t_name + separator + "SUB_RUN_END_LOW"] = ME::time_low(_ts_end);
909  i_t[t_name + separator + "SUB_RUN_END_HIGH"] = ME::time_high(_ts_end);
910  i_t[t_name + separator + "DB_TIMESTAMP_LOW"] = ME::time_low(_ts);
911  i_t[t_name + separator + "DB_TIMESTAMP_HIGH"] = ME::time_high(_ts);
912  c_t[t_name + separator + "SUB_RUN_TYPE"] = "LASER TEST CRUZET"; //fixme
913  t_t[t_name]->Fill();
914 }
915 
917  if (!init_ok)
918  return;
919 
920  out_file = new TFile(_outfile, "RECREATE");
921  // out_file->cd();
922 
923  std::map<TString, TH2*>::iterator it;
924 
925  for (it = i_h.begin(); it != i_h.end(); ++it) {
926  it->second->Write();
927  delete it->second;
928  }
929 
930  for (it = f_h.begin(); it != f_h.end(); ++it) {
931  it->second->Write();
932  delete it->second;
933  }
934 
935  std::map<TString, TTree*>::iterator it_t;
936  for (it_t = t_t.begin(); it_t != t_t.end(); ++it_t) {
937  it_t->second->Write();
938  delete it_t->second;
939  }
940 
941  // std::cout << "Closing " << _outfile << std::endl;
942  out_file->Close();
943  delete out_file;
944  out_file = nullptr;
945 }
946 
948  delete apdpn_tree;
949  delete ab_tree;
950  delete pn_tree;
951  delete mtq_tree;
952  delete tpapd_tree;
953  delete tppn_tree;
954  if (apdpn_file != nullptr) {
955  // std::cout << "Closing apdpn_file " << std::endl;
956  apdpn_file->Close();
957  delete apdpn_file;
958  apdpn_file = nullptr;
959  }
960  if (ab_file != nullptr) {
961  // std::cout << "Closing ab_file " << std::endl;
962  ab_file->Close();
963  delete ab_file;
964  ab_file = nullptr;
965  }
966  if (mtq_file != nullptr) {
967  // std::cout << "Closing mtq_file " << std::endl;
968  mtq_file->Close();
969  delete mtq_file;
970  mtq_file = nullptr;
971  }
972  if (tpapd_file != nullptr) {
973  // std::cout << "Closing tpapd_file " << std::endl;
974  tpapd_file->Close();
975  delete tpapd_file;
976  tpapd_file = nullptr;
977  }
978 }
979 
980 void MELaserPrim::print(std::ostream& o) {
981  o << "DCC/SM/side/type/color/run/ts " << _dcc << "/" << _sm << "/" << _side << "/" << _type << "/" << _color << "/"
982  << _run << "/" << _ts << std::endl;
983 
984  // for( int ix=ixmin; ix<ixmax; ix++ )
985  // {
986  // for( int iy=iymin; iy<iymax; iy++ )
987  // {
988  // int flag = getInt( _primStr+"FLAG", ix, iy );
989  // if( flag==0 ) continue;
990  // int logic_id = getInt( _primStr+"LOGIC_ID", ix, iy );
991  // float apd = getVal( _primStr+"MEAN", ix, iy );
992  // o << "Crystal ieta=" << ix << "\tiphi=" << iy << "\tlogic_id=" << logic_id << "\tAPD=" << apd << endl;
993  // }
994  // }
995 }
996 
997 TString MELaserPrim::lmfLaserName(int table, int type, int color) {
998  TString str("LMF_ERROR");
999  if (table < 0 || table >= ME::iSizeLmf)
1000  return str;
1001  if (color < 0 || color >= ME::iSizeC)
1002  return str;
1003 
1004  if (type == ME::iLaser) {
1005  TString colstr;
1006  switch (color) {
1007  case ME::iBlue:
1008  colstr = "_BLUE";
1009  break;
1010  case ME::iGreen:
1011  colstr = "_GREEN";
1012  break;
1013  case ME::iRed:
1014  colstr = "_RED";
1015  break;
1016  case ME::iIRed:
1017  colstr = "_IRED";
1018  break;
1019  default:
1020  abort();
1021  }
1022  str = "LMF_LASER";
1023  switch (table) {
1024  case ME::iLmfLaserRun:
1025  str = "LMF_RUN";
1026  break;
1027  case ME::iLmfLaserConfig:
1028  str += "_CONFIG";
1029  break;
1030  case ME::iLmfLaserPulse:
1031  str += colstr;
1032  str += "_PULSE";
1033  break;
1034  case ME::iLmfLaserPrim:
1035  str += colstr;
1036  str += "_PRIM";
1037  break;
1038  case ME::iLmfLaserPnPrim:
1039  str += colstr;
1040  str += "_PN_PRIM";
1041  break;
1042  default:
1043  abort();
1044  }
1045  } else if (type == ME::iTestPulse) {
1046  str = "LMF_TEST_PULSE";
1047  switch (table) {
1048  case ME::iLmfTestPulseRun:
1049  str = "LMF_RUN";
1050  break;
1052  str += "_CONFIG";
1053  break;
1054  case ME::iLmfTestPulsePrim:
1055  str += "_PRIM";
1056  break;
1058  str += "_PN_PRIM";
1059  break;
1060  default:
1061  abort();
1062  }
1063  }
1064  str += "_DAT";
1065  return str;
1066 }
1067 
1068 void MELaserPrim::addBranchI(const char* t_name_, const char* v_name_) {
1069  TString slashI("/i"); // Warning: always unsigned
1070  TString t_name(t_name_);
1071  TString v_name(v_name_);
1072  if (t_t.count(t_name) == 0)
1073  t_t[t_name] = new TTree(t_name, t_name);
1074  t_t[t_name]->Branch(v_name, &i_t[t_name + separator + v_name], v_name + slashI);
1075 }
1076 
1077 void MELaserPrim::addBranchF(const char* t_name_, const char* v_name_) {
1078  TString slashF("/F");
1079  TString t_name(t_name_);
1080  TString v_name(v_name_);
1081  if (t_t.count(t_name) == 0)
1082  t_t[t_name] = new TTree(t_name, t_name);
1083  t_t[t_name]->Branch(v_name, &f_t[t_name + separator + v_name], v_name + slashF);
1084 }
1085 
1086 void MELaserPrim::addBranchC(const char* t_name_, const char* v_name_) {
1087  TString slashC("/C");
1088  TString t_name(t_name_);
1089  TString v_name(v_name_);
1090  if (t_t.count(t_name) == 0)
1091  t_t[t_name] = new TTree(t_name, t_name);
1092  t_t[t_name]->Branch(v_name, &c_t[t_name + separator + v_name], v_name + slashC);
1093 }
1094 
1095 void MELaserPrim::bookHistoI(const char* h_name_, const char* v_name_) {
1096  TString i_name = TString(h_name_) + TString(v_name_);
1097  TH2* h_ = new TH2I(i_name, i_name, nx, ixmin, ixmax, ny, iymin, iymax);
1098  setHistoStyle(h_);
1099  i_h[i_name] = h_;
1100 }
1101 
1102 void MELaserPrim::bookHistoF(const char* h_name_, const char* v_name_) {
1103  TString d_name = TString(h_name_) + TString(v_name_);
1104  TH2* h_ = new TH2F(d_name, d_name, nx, ixmin, ixmax, ny, iymin, iymax);
1105  setHistoStyle(h_);
1106  f_h[d_name] = h_;
1107 }
1108 
1109 bool MELaserPrim::setInt(const char* name, int ix, int iy, int ival) {
1110  TString name_;
1111  if (_type == ME::iLaser)
1112  name_ = _primStr + name;
1113  else if (_type == ME::iTestPulse)
1114  name_ = _tpPrimStr + name;
1115 
1116  int _ival = getInt(name_, ix, iy);
1117  assert(_ival != -99);
1118  if (_ival != 0)
1119  return false;
1120 
1121  TH2I* h_ = (TH2I*)i_h[name_];
1122  assert(h_ != nullptr);
1123  h_->Fill(ix + 0.5, iy + 0.5, ival);
1124 
1125  return true;
1126 }
1127 
1128 bool MELaserPrim::setVal(const char* name, int ix, int iy, float val) {
1129  TString name_;
1130  if (_type == ME::iLaser)
1131  name_ = _primStr + name;
1132  else if (_type == ME::iTestPulse)
1133  name_ = _tpPrimStr + name;
1134 
1135  float _val = getVal(name_, ix, iy);
1136  assert(_val != -99);
1137  if (_val != 0)
1138  return false;
1139 
1140  TH2F* h_ = (TH2F*)f_h[name_];
1141  assert(h_ != nullptr);
1142 
1143  h_->Fill(ix + 0.5, iy + 0.5, val);
1144 
1145  return true;
1146 }
1147 
1148 Int_t MELaserPrim::getInt(const char* name, int ix, int iy) {
1149  Int_t ival = -99;
1150  if (i_h.count(name) == 1) {
1151  TH2I* h_ = (TH2I*)i_h[name];
1152  assert(h_ != nullptr);
1153  int binx = h_->GetXaxis()->FindBin(ix + 0.5);
1154  int biny = h_->GetYaxis()->FindBin(iy + 0.5);
1155  ival = (Int_t)h_->GetCellContent(binx, biny);
1156  }
1157  return ival;
1158 }
1159 
1160 Float_t MELaserPrim::getVal(const char* name, int ix, int iy) {
1161  Float_t val = -99.;
1162  if (f_h.count(name) == 1) {
1163  TH2F* h_ = (TH2F*)f_h[name];
1164  assert(h_ != nullptr);
1165  int binx = h_->GetXaxis()->FindBin(ix + 0.5);
1166  int biny = h_->GetYaxis()->FindBin(iy + 0.5);
1167  val = h_->GetCellContent(binx, biny);
1168  }
1169  return val;
1170 }
1171 
1172 bool MELaserPrim::setInt(const char* tname, const char* vname, int ival) {
1173  TString key_(tname);
1174  key_ += separator;
1175  key_ += vname;
1176  assert(i_t.count(key_) == 1);
1177  i_t[key_] = ival;
1178  return true;
1179 }
1180 
1181 bool MELaserPrim::setVal(const char* tname, const char* vname, float val) {
1182  TString key_(tname);
1183  key_ += separator;
1184  key_ += vname;
1185 
1186  // ghm
1187  if (f_t.count(key_) != 1) {
1188  std::cout << key_ << std::endl;
1189  }
1190  assert(f_t.count(key_) == 1);
1191  f_t[key_] = val;
1192  return true;
1193 }
1194 
1195 bool MELaserPrim::fill(const char* tname) {
1196  TString key_(tname);
1197  assert(t_t.count(key_) == 1);
1198  t_t[key_]->Fill();
1199  return true;
1200 }
1201 
1203  if (h == nullptr)
1204  return;
1205 
1206  float _scale = 1;
1207 
1208  h->SetLineColor(4);
1209  h->SetLineWidth(1);
1210  h->SetFillColor(38);
1211  TAxis* axis[3];
1212  axis[0] = h->GetXaxis();
1213  axis[1] = h->GetYaxis();
1214  axis[2] = h->GetZaxis();
1215  for (int ii = 0; ii < 3; ii++) {
1216  TAxis* a = axis[ii];
1217  if (!a)
1218  continue;
1219  a->SetLabelFont(132);
1220  a->SetLabelOffset(_scale * 0.005);
1221  a->SetLabelSize(_scale * 0.04);
1222  a->SetTitleFont(132);
1223  a->SetTitleOffset(_scale * 1);
1224  a->SetTitleSize(_scale * 0.04);
1225  }
1226  h->SetStats(kTRUE);
1227 }
1228 
1230  std::map<TString, TH2*>::iterator it;
1231 
1232  for (it = i_h.begin(); it != i_h.end(); ++it) {
1233  delete it->second;
1234  it->second = nullptr;
1235  }
1236  i_h.clear();
1237 
1238  for (it = f_h.begin(); it != f_h.end(); ++it) {
1239  delete it->second;
1240  it->second = nullptr;
1241  }
1242  f_h.clear();
1243 
1244  std::map<TString, TTree*>::iterator it_t;
1245  for (it_t = t_t.begin(); it_t != t_t.end(); ++it_t) {
1246  delete it_t->second;
1247  it->second = nullptr;
1248  }
1249  t_t.clear();
1250 }
static const TString apdpn_varName[iSize_apdpn]
Definition: MELaserPrim.h:267
Int_t apdpn_dccID
Definition: MELaserPrim.h:157
static void regionAndSector(int ilmr, int &ireg, int &isect, int &idcc, int &iside)
Definition: ME.cc:333
Double_t tpapd_APD[iSize_apdpn]
Definition: MELaserPrim.h:202
static const char module_[]
static XYCoord localCoord(int icr)
Definition: MEEBGeom.cc:142
Int_t pn_pnID
Definition: MELaserPrim.h:180
TBranch * b_ab_channelID
Definition: MELaserPrim.h:227
int events
Definition: ME.h:78
bool _isBarrel
Definition: MELaserPrim.h:81
TBranch * b_tppn_moduleID
Definition: MELaserPrim.h:262
int dcc
Definition: ME.h:74
int mgpagain
Definition: ME.h:89
static const TString separator
Definition: MELaserPrim.h:76
TBranch * b_apdpn_apdpn[iSizeArray_apdpn]
Definition: MELaserPrim.h:222
TString _inpath
Definition: MELaserPrim.h:133
int wavelength
Definition: ME.h:85
TBranch * b_tppn_PN
Definition: MELaserPrim.h:264
TString _outfile
Definition: MELaserPrim.h:136
static bool getViewIds(int logicId, int &channelView, int &id1, int &id2)
Definition: MELaserPrim.cc:125
TBranch * b_tppn_pnID
Definition: MELaserPrim.h:261
TTree * apdpn_tree
Definition: MELaserPrim.h:125
TBranch * b_apdpn_channelID
Definition: MELaserPrim.h:214
Double_t pn_PN[iSize_apdpn]
Definition: MELaserPrim.h:182
TBranch * b_pn_pnID
Definition: MELaserPrim.h:235
TFile * mtq_file
Definition: MELaserPrim.h:120
void writeHistograms()
Definition: MELaserPrim.cc:916
TBranch * b_pn_PNoPNA
Definition: MELaserPrim.h:239
void fillHistograms()
Definition: MELaserPrim.cc:507
static const TString mtq_varName[iSize_mtq]
Definition: MELaserPrim.h:272
Double_t pn_PNoPNB[iSize_apdpn]
Definition: MELaserPrim.h:185
Int_t pn_moduleID
Definition: MELaserPrim.h:181
static int crystal_channel(EBLocalCoord ix, EBLocalCoord iy)
Definition: MEEBGeom.cc:319
TString _tpPrimStr
Definition: MELaserPrim.h:113
TTree * tppn_tree
Definition: MELaserPrim.h:130
Int_t tppn_moduleID
Definition: MELaserPrim.h:207
Definition: ME.h:14
TimeStamp ts_beg
Definition: ME.h:79
Int_t tpapd_ieta
Definition: MELaserPrim.h:194
TBranch * b_ab_ab[iSize_ab]
Definition: MELaserPrim.h:231
Double_t pn_PNoPN[iSize_apdpn]
Definition: MELaserPrim.h:183
TBranch * b_ab_towerID
Definition: MELaserPrim.h:226
Double_t ab_ab[iSize_ab]
Definition: MELaserPrim.h:176
Int_t getInt(const char *, int ix, int iy)
TBranch * b_tpapd_dccID
Definition: MELaserPrim.h:250
TBranch * b_mtq_side
Definition: MELaserPrim.h:243
std::map< TString, TTree * > t_t
Definition: MELaserPrim.h:151
bool setVal(const char *, int ix, int iy, float val)
Int_t ab_flag
Definition: MELaserPrim.h:175
int filter
Definition: ME.h:87
Int_t tppn_gain
Definition: MELaserPrim.h:208
Double_t mtq_mtq[iSize_mtq]
Definition: MELaserPrim.h:190
static std::pair< ME::DCCid, ME::PNid > pn(ME::LMRid ilmr, ME::LMMid ilmmod, ME::PN ipn)
Definition: ME.cc:597
int ii
Definition: cuy.py:589
TBranch * b_tpapd_gain
Definition: MELaserPrim.h:256
assert(be >=bs)
Int_t ab_towerID
Definition: MELaserPrim.h:171
TBranch * b_tpapd_APD
Definition: MELaserPrim.h:257
Int_t tpapd_dccID
Definition: MELaserPrim.h:195
Int_t ab_ieta
Definition: MELaserPrim.h:173
static Time time_low(TimeStamp t)
Definition: ME.cc:224
Int_t tppn_side
Definition: MELaserPrim.h:205
static TString channelViewName(int)
Definition: MELaserPrim.cc:96
TBranch * b_ab_ieta
Definition: MELaserPrim.h:228
TBranch * b_apdpn_ieta
Definition: MELaserPrim.h:218
Int_t tpapd_side
Definition: MELaserPrim.h:196
Int_t ab_channelID
Definition: MELaserPrim.h:172
Int_t apdpn_iphi
Definition: MELaserPrim.h:164
ME::TimeStamp _ts_end
Definition: MELaserPrim.h:98
Int_t tpapd_towerID
Definition: MELaserPrim.h:197
TBranch * b_pn_moduleID
Definition: MELaserPrim.h:236
TTree * ab_tree
Definition: MELaserPrim.h:126
Int_t tpapd_iphi
Definition: MELaserPrim.h:193
Definition: ME.h:64
bool init_ok
Definition: MELaserPrim.h:52
TTree * mtq_tree
Definition: MELaserPrim.h:128
Definition: ME.h:64
bool fill(const char *tname)
Definition: ME.h:63
static const TString apdpn_extraVarName[iSizeExtra_apdpn]
Definition: MELaserPrim.h:269
MELaserPrim(ME::Header header, ME::Settings settings, const char *inpath, const char *outfile)
Definition: MELaserPrim.cc:39
TBranch * b_pn_PN
Definition: MELaserPrim.h:237
Int_t pn_side
Definition: MELaserPrim.h:179
Float_t getVal(const char *, int ix, int iy)
void addBranchC(const char *t_name, const char *v_name)
void print(std::ostream &o)
Definition: MELaserPrim.cc:980
TBranch * b_pn_side
Definition: MELaserPrim.h:234
TBranch * b_tpapd_flag
Definition: MELaserPrim.h:255
TimeStamp ts_end
Definition: ME.h:80
void bookHistograms()
Definition: MELaserPrim.cc:335
TBranch * b_tppn_gain
Definition: MELaserPrim.h:263
TFile * apdpn_file
Definition: MELaserPrim.h:117
Int_t mtq_side
Definition: MELaserPrim.h:188
TBranch * b_ab_dccID
Definition: MELaserPrim.h:225
TBranch * b_apdpn_ShapeCor
Definition: MELaserPrim.h:221
bool setInt(const char *, int ix, int iy, int ival)
Definition: ME.h:64
TBranch * b_pn_PNoPN
Definition: MELaserPrim.h:238
Definition: ME.h:64
TString _primStr
Definition: MELaserPrim.h:110
Int_t tpapd_flag
Definition: MELaserPrim.h:200
static const TString ab_varName[iSize_ab]
Definition: MELaserPrim.h:271
static int logicId(int channelView, int id1, int id2=0)
Definition: MELaserPrim.cc:120
Int_t apdpn_moduleID
Definition: MELaserPrim.h:160
static const TString mtq_varUnit[iSize_mtq]
Definition: MELaserPrim.h:273
Definition: ME.h:14
TBranch * b_tpapd_towerID
Definition: MELaserPrim.h:252
std::pair< EBLocalCoord, EBLocalCoord > XYCoord
Definition: MEEBGeom.h:25
std::map< TString, float > f_t
Definition: MELaserPrim.h:153
Int_t apdpn_flag
Definition: MELaserPrim.h:165
int side
Definition: ME.h:75
static TString lmfLaserName(int table, int type, int color=ME::iBlue)
Definition: MELaserPrim.cc:997
int lb
Definition: ME.h:77
void refresh()
int run
Definition: ME.h:76
TBranch * b_tppn_side
Definition: MELaserPrim.h:260
Int_t ab_iphi
Definition: MELaserPrim.h:174
void addBranchI(const char *t_name, const char *v_name)
TBranch * b_pn_PNoPNB
Definition: MELaserPrim.h:240
TBranch * b_apdpn_flag
Definition: MELaserPrim.h:220
Int_t tpapd_gain
Definition: MELaserPrim.h:201
int power
Definition: ME.h:86
TBranch * b_ab_flag
Definition: MELaserPrim.h:230
TBranch * b_mtq_mtq[iSize_mtq]
Definition: MELaserPrim.h:245
TBranch * b_tpapd_side
Definition: MELaserPrim.h:251
Double_t apdpn_ShapeCor
Definition: MELaserPrim.h:166
Int_t tpapd_moduleID
Definition: MELaserPrim.h:199
Double_t pn_PNoPNA[iSize_apdpn]
Definition: MELaserPrim.h:184
static const TString apdpn_extraVarUnit[iSizeExtra_apdpn]
Definition: MELaserPrim.h:270
Int_t apdpn_channelID
Definition: MELaserPrim.h:159
std::map< TString, const char * > c_t
Definition: MELaserPrim.h:154
Int_t apdpn_ieta
Definition: MELaserPrim.h:163
Int_t ab_dccID
Definition: MELaserPrim.h:170
Definition: ME.h:72
int type
Definition: ME.h:84
TBranch * b_tpapd_iphi
Definition: MELaserPrim.h:248
static int lmr(int idcc, int iside)
Definition: ME.cc:243
Int_t tppn_pnID
Definition: MELaserPrim.h:206
std::map< TString, int > i_t
Definition: MELaserPrim.h:152
std::map< TString, TH2 * > f_h
Definition: MELaserPrim.h:148
TBranch * b_tpapd_channelID
Definition: MELaserPrim.h:253
TString _pnPrimStr
Definition: MELaserPrim.h:111
TTree * tpapd_tree
Definition: MELaserPrim.h:129
std::map< TString, TH2 * > i_h
Definition: MELaserPrim.h:147
TString _pulseStr
Definition: MELaserPrim.h:112
double a
Definition: hdecay.h:119
Definition: ME.h:64
static Time time_high(TimeStamp t)
Definition: ME.cc:226
TBranch * b_tpapd_moduleID
Definition: MELaserPrim.h:254
std::string tname(const std::string &tableName, const std::string &schemaVersion)
static int dee(SuperCrysCoord iX, SuperCrysCoord iY, int iz)
Definition: MEEEGeom.cc:292
Int_t apdpn_towerID
Definition: MELaserPrim.h:158
Int_t tpapd_channelID
Definition: MELaserPrim.h:198
ME::TimeStamp _ts_beg
Definition: MELaserPrim.h:97
PN
Definition: ME.h:42
TBranch * b_tpapd_ieta
Definition: MELaserPrim.h:249
TBranch * b_apdpn_iphi
Definition: MELaserPrim.h:219
int delay
Definition: ME.h:88
tuple cout
Definition: gather_cfg.py:144
virtual ~MELaserPrim()
Definition: MELaserPrim.cc:947
TFile * ab_file
Definition: MELaserPrim.h:118
TBranch * b_apdpn_towerID
Definition: MELaserPrim.h:213
void addBranchF(const char *t_name, const char *v_name)
TBranch * b_apdpn_side
Definition: MELaserPrim.h:217
ME::TimeStamp _ts
Definition: MELaserPrim.h:96
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
TFile * out_file
Definition: MELaserPrim.h:122
void setHistoStyle(TH1 *)
#define str(s)
Double_t apdpn_apdpn[iSizeArray_apdpn][iSize_apdpn]
Definition: MELaserPrim.h:167
static TString smName(int ilmr)
Definition: ME.cc:391
void bookHistoI(const char *t_name, const char *v_name)
TBranch * b_ab_iphi
Definition: MELaserPrim.h:229
TString _sectorStr
Definition: MELaserPrim.h:108
TString _regionStr
Definition: MELaserPrim.h:109
Double_t tppn_PN[iSize_apdpn]
Definition: MELaserPrim.h:209
static const TString apdpn_arrayName[iSizeArray_apdpn]
Definition: MELaserPrim.h:266
TString _tpPnPrimStr
Definition: MELaserPrim.h:114
int memgain
Definition: ME.h:90
TFile * tpapd_file
Definition: MELaserPrim.h:121
static const TString apdpn_varUnit[iSizeArray_apdpn][iSize_apdpn]
Definition: MELaserPrim.h:268
TBranch * b_apdpn_dccID
Definition: MELaserPrim.h:212
TTree * pn_tree
Definition: MELaserPrim.h:127
TBranch * b_apdpn_moduleID
Definition: MELaserPrim.h:215
Int_t apdpn_side
Definition: MELaserPrim.h:162
void bookHistoF(const char *t_name, const char *v_name)