CMS 3D CMS Logo

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