StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcTimingMaker.cxx
1 #include "StEEmcTimingMaker.h"
2 
3 #include <TString.h>
4 #include <TH1F.h>
5 #include <TGraphErrors.h>
6 #include <TF1.h>
7 #include <TLine.h>
8 #include <TPaveStats.h>
9 #include <TTree.h>
10 #include <TPDF.h>
11 #include <TCanvas.h>
12 #include <TChain.h>
13 #include <TFile.h>
14 #include <TKey.h>
15 
16 #include <vector>
17 
18 #include "StMessMgr.h"
19 
20 #include "StEEmcUtil/database/StEEmcDb.h"
21 #include "StEEmcUtil/database/EEmcDbItem.h"
22 #include "StEEmcUtil/EEfeeRaw/EEname2Index.h"
23 
24 #include "StEEmcPool/StEEmcA2EMaker/StEEmcA2EMaker.h"
25 
26 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
27 #include "StarRoot/TH1Helper.h"
28 
29 ClassImp(StEEmcTimingMaker);
30 
31 // ----------------------------------------------------------------------------
32 StEEmcTimingMaker::StEEmcTimingMaker(const Char_t *name):StMaker(name)
33 {
34 
35  mTowerMin=25; // min number of ADC > ped
36  mTowerMax=125; // max number of ADC > ped
37  mMapmtMin=50;
38  mMapmtMax=150;
39  mSupressZero=false;
40  mOutputFile="timing.root";
41 
42  // TH1F *hTower[ MaxTwCrates ][ MaxTwCrateCh ];
43  // TH1F *hMapmt[ MaxMapmtCrates ][ MaxMapmtCrateCh ];
44  for ( Int_t i=0;i<MaxTwCrates;i++ )
45  for ( Int_t j=0;j<MaxTwCrateCh;j++ )
46  {
47  hTower[i][j]=0;
48  mTowerMask[i][j]=0;
49  }
50 
51  for ( Int_t i=0;i<MaxMapmtCrates;i++ )
52  for ( Int_t j=0;j<MaxMapmtCrateCh;j++ )
53  {
54  hMapmt[i][j]=0;
55  mMapmtMask[i][j]=0;
56  }
57 
58 
59  // init summary arrays to zero
60  for ( Int_t icrate=0;icrate<MaxTwCrates;icrate++ )
61  {
62  mTowerCrateYield[icrate]=0;
63  }
64  for ( Int_t icrate=0;icrate<MaxMapmtCrates;icrate++ )
65  {
66  mMapmtCrateYield[icrate]=0;
67  }
68 
69  for ( Int_t icrate=0;icrate<MaxTwCrates;icrate++ )
70  for ( Int_t ichan=0;ichan<MaxTwCrateCh;ichan++ )
71  {
72  mTowerChanYield[icrate][ichan]=0;
73  mTowerChanSlope[icrate][ichan]=0.;
74  }
75 
76  for ( Int_t icrate=0;icrate<MaxMapmtCrates;icrate++ )
77  for ( Int_t ichan=0;ichan<MaxMapmtCrateCh;ichan++ )
78  {
79  mMapmtChanYield[icrate][ichan]=0;
80  mMapmtChanSlope[icrate][ichan]=0.;
81  }
82 
83 
84 }
85 
86 void StEEmcTimingMaker::supressZeroAdc(){ mSupressZero=true; }
87 // ----------------------------------------------------------------------------
88 void StEEmcTimingMaker::setRunNumber( Int_t r )
89 {
90  mRunNumber=r;
91 }
92 
93 // once DB has been initialized, rename/title the histograms
94 Int_t StEEmcTimingMaker::InitRun(Int_t run){
95  assert(run==mRunNumber);
96 
97  StEEmcA2EMaker *adcmk = (StEEmcA2EMaker*)GetMaker("AandE");
98  if ( !adcmk ) {
99  std::cout << "No ADC to E maker" <<std::endl;
100  return kStWarn;
101  }
102 
103  StEEmcDb *dbmk = (StEEmcDb*)this->GetDataSet("StEEmcDb");
104  if ( !dbmk ) {
105  std::cout << "No database maker" << std::endl;
106  return kStFatal;
107  }
108 
109 
110  Int_t ilayer=0;
111  for ( Int_t itower=0;itower<720;itower++ )
112  {
113  StEEmcTower tow = adcmk->tower(itower,ilayer);
114  const EEmcDbItem *dbitem=dbmk->getByIndex( EEname2Index(tow.name()) );
115  assert(dbitem);
116  Int_t crate=dbitem->crate;
117  Int_t channel=dbitem->chan;
118  TString twname=dbitem->name;
119  TString tbname=dbitem->tube;
120  TString title=
121  Form("ADC spectrum run=%i, name=%s, cr/chan=%3.3d/%3.3d, tube=%s, ",run,twname.Data(),crate,channel,tbname.Data());
122  TString hname="h";hname+=twname;
123  hTower[crate-1][channel]->SetTitle(title);
124  hTower[crate-1][channel]->SetName(hname);
125  }
126 
127 #if 1
128  for ( ilayer=1; ilayer<4;ilayer++ ) {
129  for ( Int_t itower=0;itower<720;itower++ )
130  {
131  StEEmcTower tow = adcmk->tower(itower,ilayer);
132  const EEmcDbItem *dbitem=dbmk->getByIndex( EEname2Index(tow.name()) );
133  assert(dbitem);
134  Int_t crate=dbitem->crate;
135  Int_t channel=dbitem->chan;
136  TString twname=dbitem->name;
137  TString tbname=dbitem->tube;
138  TString title=Form("ADC spectrum run=%i, name=%s, cr/chan=%3.3d/%3.3d, tube=%s, ",run,twname.Data(),crate,channel,tbname.Data());
139  TString hname="h";hname+=twname;
140  hMapmt[crate-MinMapmtCrateID][channel]->SetTitle(title);
141  hMapmt[crate-MinMapmtCrateID][channel]->SetName(hname);
142  }
143  }
144 #endif
145 
146 #if 1
147  for ( Int_t isector=0;isector<12;isector++ )
148  for ( Int_t iplane=0;iplane<2;iplane++ )
149  {
150  for ( Int_t index=0;index<288;index++ ) {
151  StEEmcStrip strip=adcmk->strip(isector,iplane,index);
152  const EEmcDbItem *dbitem=dbmk->getByIndex( EEname2Index(strip.name()) );
153  if (!dbitem) continue;
154  Int_t crate=dbitem->crate;
155  Int_t channel=dbitem->chan;
156  TString twname=dbitem->name;
157  TString tbname=dbitem->tube;
158  TString title=
159  Form("ADC spectrum run=%i, name=%s, cr/chan=%3.3d/%3.3d, tube=%s, ",run,twname.Data(),crate,channel,tbname.Data());
160  TString hname="h";hname+=twname;
161  hMapmt[crate-MinMapmtCrateID][channel]->SetTitle(title);
162  hMapmt[crate-MinMapmtCrateID][channel]->SetName(hname);
163  }
164  }
165 #endif
166  LOG_INFO<<GetName()<<"::InitRun("<<run<<") histograms renamed"<<endm;
167 
168  return kStOK;
169 }
170 
171 // Initialize histograms. By default, names will be [Tw or Ma][crate][chn].
172 // Once DB has been initialized in InitRun, we rename using, eg, h01TA01
173 // naming convention. Note that hw channels which map to no detector will
174 // hold the old naming convention.
175 Int_t StEEmcTimingMaker::Init()
176 {
177 
178  hCounter=new TH1F("hCounter","Event counter;status",1,0.,1.);
179  TH1Helper::SetCanRebin(hCounter);
180 
181 #if 1
182 
183  for ( Int_t icrate=0;icrate<MaxTwCrates;icrate++ )
184  for ( Int_t ichan=0;ichan<MaxTwCrateCh;ichan++ )
185  {
186  TString name="hTwCr";name+=icrate+1;name+="Ch";name+=ichan;
187  TString title="ADC spectrum crate/chan=";
188  title += icrate+1;title+="/";title+=ichan;
189  hTower[icrate][ichan]=new TH1F(name,title,512,0.,512.);
190  }
191 
192  for ( Int_t icrate=0;icrate<MaxMapmtCrates;icrate++ )
193  for ( Int_t ichan=0;ichan<MaxMapmtCrateCh;ichan++ )
194  {
195  TString name="hMaCr";name+=MinMapmtCrateID+icrate;name+="Ch";name+=ichan;
196  TString title="ADC spectrum crate/chan=";
197  title += MinMapmtCrateID+icrate; title+="/";title+=ichan;
198  hMapmt[icrate][ichan]=new TH1F(name,title,512,0.,512.);
199  }
200 
201 
202  for ( Int_t icrate=0;icrate<MaxTwCrates;icrate++ )
203  {
204  mTowerCrateYield[icrate]=0;
205  }
206  for ( Int_t icrate=0;icrate<MaxMapmtCrates;icrate++ )
207  {
208  mMapmtCrateYield[icrate]=0;
209  }
210 
211  for ( Int_t icrate=0;icrate<MaxTwCrates;icrate++ )
212  for ( Int_t ichan=0;ichan<MaxTwCrateCh;ichan++ )
213  {
214  mTowerChanYield[icrate][ichan]=0;
215  mTowerChanSlope[icrate][ichan]=0.;
216  }
217 
218  for ( Int_t icrate=0;icrate<MaxMapmtCrates;icrate++ )
219  for ( Int_t ichan=0;ichan<MaxMapmtCrateCh;ichan++ )
220  {
221  mMapmtChanYield[icrate][ichan]=0;
222  mMapmtChanSlope[icrate][ichan]=0.;
223  }
224 
225 
226 #endif
227 
228  return kStOk;; /* moves histograms to .hist */
229 }
230 // ----------------------------------------------------------------------------
231 // fill raw ADC for each valid detector
233 {
234 
235  hCounter->Fill("Nevents",1.);
236 
237  StEEmcA2EMaker *adcmk = (StEEmcA2EMaker*)GetMaker("AandE");
238  if ( !adcmk ) {
239  std::cout << "No ADC to E maker" <<std::endl;
240  return kStWarn;
241  }
242 
243  hCounter->Fill("Nadc2e",1.0);
244 
245  StEEmcDb *dbmk = (StEEmcDb*)this->GetDataSet("StEEmcDb");
246  if ( !dbmk ) {
247  std::cout << "No database maker" << std::endl;
248  return kStWarn;
249  }
250 
251  hCounter->Fill("Ndb",1.0);
252 
253  mTotalYield++;
254 
255  Int_t ilayer=0;
256  for ( Int_t itower=0;itower<720;itower++ )
257  {
258  StEEmcTower tow = adcmk->tower(itower,ilayer);
259  const EEmcDbItem *dbitem=dbmk->getByIndex( EEname2Index(tow.name()) );
260  assert(dbitem);
261  Int_t crate=dbitem->crate;
262  Int_t channel=dbitem->chan;
263  hTower[crate-1][channel] -> Fill( tow.raw() );
264  }
265 
266  // pre/postshower layers go into mapmt structures
267  for ( ilayer=1;ilayer<4;ilayer++ )
268  {
269  for ( Int_t itower=0;itower<720;itower++ )
270  {
271  StEEmcTower tow = adcmk->tower(itower,ilayer);
272  const EEmcDbItem *dbitem=dbmk->getByIndex( EEname2Index(tow.name()) );
273  assert(dbitem);
274  Int_t crate=dbitem->crate;
275  Int_t channel=dbitem->chan;
276  hMapmt[crate-MinMapmtCrateID][channel]->Fill(tow.raw());
277  }
278  }
279 
280  for ( Int_t isector=0;isector<12;isector++ )
281  for ( Int_t iplane=0;iplane<2;iplane++ )
282  {
283  for ( Int_t index=0;index<288;index++ ) {
284  StEEmcStrip strip=adcmk->strip(isector,iplane,index);
285  const EEmcDbItem *dbitem=dbmk->getByIndex( EEname2Index(strip.name()) );
286  if (!dbitem) continue;
287  Int_t crate=dbitem->crate;
288  Int_t channel=dbitem->chan;
289  hMapmt[crate-MinMapmtCrateID][channel]->Fill(strip.raw());
290  }
291  }
292 
293  return kStOK;
294 }
295 
296 // ----------------------------------------------------------------------------
298 {
299 
300  static Int_t ncalled=0;
301  std::cout << Form("StEEmcTimingMaker::Finish() called for the %i-%s time",ncalled+1,(ncalled)?"nd":"st") << std::endl;
302  if ( ncalled ) return kStOK; // been there, done that
303  ncalled++;
304 
305  std::vector<TH1F*> histos;
306 
307  for ( Int_t icrate=0;icrate<MaxTwCrates;icrate++ )
308  for ( Int_t ichan=0;ichan<MaxTwCrateCh;ichan++ )
309  {
310 
311  if ( !hTower[icrate][ichan] ) continue; // skip null histograms
312  if ( hTower[icrate][ichan]->Integral()<10 ) continue;
313  histos.push_back( hTower[icrate][ichan] );
314  }
315 
316  for ( Int_t icrate=0;icrate<MaxMapmtCrates;icrate++ )
317  for ( Int_t ichan=0;ichan<MaxMapmtCrateCh;ichan++ )
318  {
319  if ( !hMapmt[icrate][ichan] ) continue; // skip null histograms
320  if ( hMapmt[icrate][ichan]->Integral()<10 ) continue;
321  histos.push_back(hMapmt[icrate][ichan]);
322  }
323 
324  for ( UInt_t ii=0;ii<histos.size();ii++ )
325  {
326  TF1 fit("fit","gaus");
327  Float_t xmax=(Float_t)histos[ii]->GetMaximumBin();
328  fit.SetParameter(0, histos[ii]->Integral() );
329  fit.SetParameter(1, xmax );
330  fit.SetParLimits(1, xmax-2.0, xmax+2.0 );
331  fit.SetParameter(2, 0.90 );
332  histos[ii]->GetXaxis()->SetRangeUser(xmax-10.,xmax+10.);
333  histos[ii]->Fit(&fit,"RQ","",xmax-10.0,xmax+10.0);
334 
335 #if 0
336  std::cout << Form("+ fit %s: ped=%5.2f sig=%5.3f",histos[ii]->GetName(),fit.GetParameter(1),fit.GetParameter(2)) << std::endl;
337  if ( ii == 0 ) {
338  histos[ii]->GetListOfFunctions()->Print();
339  return kStOK;
340  }
341 #endif
342 
343  }
344 
345 
346  // towers
347  for ( Int_t icrate=0;icrate<MaxTwCrates;icrate++ )
348  {
349 
350  TString hname="hCrate";hname+=(icrate+1);
351  TString htitle="Pedestal-subtracted spectrum for crate ";htitle+=(icrate+1);
352  TH1F *hSumTowers=new TH1F(hname,htitle,524,-12.,512.);
353 
354  for ( Int_t ichan=0;ichan<MaxTwCrateCh;ichan++ )
355  {
356 
357  TH1F *h=hTower[icrate][ichan];
358  if ( !h ) continue; // skip null channels
359 
360  TString htitle=h->GetTitle();
361  LOG_INFO<<"Fitting "<<htitle<<endl;
362 
363  TF1 *f=(TF1*)h->GetListOfFunctions()->At(0);
364  if ( !f ) continue;// no fit
365  if ( f->IsA() != TF1::Class() ) {
366  LOG_WARN<<" somebody inserted something into "<<h->GetName()<<"'s list of functions, and it's messing up the output"<<endm;
367 #if 0
368  std::cout << "Print out slot 0" << std::endl;
369  f->Print();
370  std::cout << "Print all functions" << std::endl;
371  h->GetListOfFunctions()->Print();
372  return kStOK;
373 #endif
374  continue;// object not a fit
375  }
376  Float_t xmean = f->GetParameter(1);
377  Float_t xwidth= f->GetParameter(2);
378  Float_t xmin = xmean+mTowerMin;
379  Float_t xmax = xmean+mTowerMax;
380  h->GetXaxis()->SetRangeUser(xmin,xmax);
381  Float_t sum=h->Integral();
382  if ( !mTowerMask[icrate][ichan] ) mTowerCrateYield[icrate]+=(Int_t)sum;
383  mTowerChanYield[icrate][ichan]+=(Int_t)sum;
384 
385  h->GetXaxis()->SetRangeUser(xmin-2.0*mTowerMin,xmax+mTowerMin);
386  h->Draw();
387 
388  TLine *l1=new TLine( xmin, -0.05*h->GetMaximum(), xmin, +0.05*h->GetMaximum() );l1->SetLineColor(2);
389  TLine *l2=new TLine( xmax, -0.05*h->GetMaximum(), xmax, +0.05*h->GetMaximum() );l2->SetLineColor(2);
390  h->GetListOfFunctions()->Add(l1);
391  h->GetListOfFunctions()->Add(l2);
392 
393  for ( Int_t ii=1;ii<=512;ii++ )
394  {
395  hSumTowers->Fill( ((Float_t)ii) - xmean, h->GetBinContent(ii) );
396  }
397 
398  TF1 *slope=new TF1("slope","expo",0.,512.);
399  slope->SetLineColor(2);
400  h->Fit(slope,"RQ+","",xmin,xmax);
401  if ( slope->GetParameter(1) != 0. )
402  mTowerChanSlope[icrate][ichan]=1.0/slope->GetParameter(1);
403 
404  htitle+=Form("ped=%6.2f, ",xmean);
405  htitle+=Form("width=%6.4f, ",xwidth);
406  htitle+=Form("xmin=%5.1f, xmax=%5.1f, Integral=%i, ",xmin,xmax,mTowerChanYield[icrate][ichan]);
407  htitle+=Form("inv. slope=%8.5g+/-%8.5g, ",slope->GetParameter(1),slope->GetParError(1));
408 
409  h->SetTitle(htitle);
410 
411  }
412  AddHist(hSumTowers,".hist");
413 
414  std::cout << "crate="<<icrate+1<<" sum="<<mTowerCrateYield[icrate]<<std::endl;
415  }
416 
417 
418  // mapmt
419  for ( Int_t icrate=0;icrate<MaxMapmtCrates;icrate++ )
420  {
421 
422  TString hname="hCrate";hname+=(icrate+MinMapmtCrateID);
423  TString htitle="Pedestal-subtracted spectrum for crate ";htitle+=(icrate+1);
424  TH1F *hSumMapmt=new TH1F(hname,htitle,524,-12.,512.);
425 
426  for ( Int_t ichan=0;ichan<MaxMapmtCrateCh;ichan++ )
427  {
428  TH1F *h=hMapmt[icrate][ichan];
429  if ( !h ) continue; // skip null channels
430 
431  TString htitle=h->GetTitle();
432  LOG_INFO<<"Fitting "<<htitle<<endl;
433 
434  TF1 *f=(TF1*)h->GetListOfFunctions()->At(0);
435  if ( !f ) continue;// no fit
436  if ( f->IsA() != TF1::Class() ) {
437  LOG_WARN<<" somebody inserted something into "<<h->GetName()<<"'s list of functions, and it's messing up the output"<<endm;
438  continue;// object not a fit
439  }
440 
441  Float_t xmean = f->GetParameter(1);
442  Float_t xwidth = f->GetParameter(2);
443  Float_t xmin = xmean+mMapmtMin;
444  Float_t xmax = xmean+mMapmtMax;
445  h->GetXaxis()->SetRangeUser(xmin,xmax);
446  Float_t sum=h->Integral();
447 
448 
449  if ( !mMapmtMask[icrate][ichan] ) mMapmtCrateYield[icrate]+=(Int_t)sum;
450  mMapmtChanYield[icrate][ichan]+=(Int_t)sum;
451  h->GetXaxis()->SetRangeUser(xmin-2.0*mMapmtMin,xmax+mMapmtMin);
452  h->Draw();
453 
454  Char_t buf[128];
455  sprintf(buf,"Integral [%5.1f,%5.1f] = %i",xmin,xmax,mMapmtChanYield[icrate][ichan]);
456  TString title=h->GetTitle();title+=" ";title+=buf;
457  h->SetTitle(title);
458 
459  TLine *l1=new TLine( xmin, -0.05*h->GetMaximum(), xmin, +0.05*h->GetMaximum() );l1->SetLineColor(2);
460  TLine *l2=new TLine( xmax, -0.05*h->GetMaximum(), xmax, +0.05*h->GetMaximum() );l2->SetLineColor(2);
461  h->GetListOfFunctions()->Add(l1);
462  h->GetListOfFunctions()->Add(l2);
463 
464  for ( Int_t ii=1;ii<=512;ii++ )
465  {
466  hSumMapmt->Fill( ((Float_t)ii) - xmean, h->GetBinContent(ii) );
467  }
468 
469  TF1 *slope=new TF1("slope","expo",0.,512.);
470  slope->SetLineColor(2);
471  h->Fit(slope,"RQ+","",xmin,xmax);
472  if ( slope->GetParameter(1) != 0. )
473  mMapmtChanSlope[icrate][ichan]=1.0/slope->GetParameter(1);
474 
475  htitle+=Form("ped=%6.2f, ",xmean);
476  htitle+=Form("width=%6.4f, ",xwidth);
477  htitle+=Form("xmin=%5.1f, xmax=%5.1f, Integral=%i, ",xmin,xmax,mMapmtChanYield[icrate][ichan]);
478  htitle+=Form("inv. slope=%8.5g+/-%8.5g, ",slope->GetParameter(1),slope->GetParError(1));
479  h->SetTitle(htitle);
480 
481  }
482  AddHist(hSumMapmt,".hist");
483 
484  std::cout << "crate="<<icrate+MinMapmtCrateID<<" sum="<<mMapmtCrateYield[icrate]<<std::endl;
485  }
486 
487 
488  // setup summary TTree
489 // TFile *ff = new TFile(mOutputFile,"RECREATE");
490 // ff->cd();
491  TTree *tree=new TTree("timing","EEmc timing scan TTree");
492  mTree=tree;
493 
494  tree->Branch("mRunNumber",&mRunNumber,"mRunNumber/I");
495  tree->Branch("mTowerDelay",&mTowerDelay,"mTowerDelay/F");
496  tree->Branch("mMapmtDelay",&mMapmtDelay,"mMapmtDelay/F");
497 
498  tree->Branch("mTotalYield",&mTotalYield,"mTotalYield/I");
499 
500  Int_t nTowerCrates = MaxTwCrates;
501  Int_t nMapmtCrates = MaxMapmtCrates;
502  Int_t nTowerCrateChannels = MaxTwCrateCh * MaxTwCrates;
503  Int_t nMapmtCrateChannels = MaxMapmtCrateCh * MaxMapmtCrates;
504 
505  tree->Branch("nTowerCrates",&nTowerCrates,"nTowerCrates/I");
506  tree->Branch("nMapmtCrates",&nMapmtCrates,"nMapmtCrates/I");
507  tree->Branch("nTowerCrateChannels",&nTowerCrateChannels,"nTowerCrateChannels/I");
508  tree->Branch("nMapmtCrateChannels",&nMapmtCrateChannels,"nMapmtCrateChannels/I");
509 
510  tree->Branch("mTowerCrateYield",mTowerCrateYield,"mTowerCrateYield[nTowerCrates]/I");
511  tree->Branch("mMapmtCrateYield",mMapmtCrateYield,"mMapmtCrateYield[nMapmtCrates]/I");
512 
513  tree->Branch("mTowerChanYield",mTowerChanYield,"mTowerChanYield[nTowerCrateChannels]/I");
514  tree->Branch("mMapmtChanYield",mMapmtChanYield,"mMapmtChanYield[nMapmtCrateChannels]/I");
515  // tree->Branch("mTowerChanSlope",mTowerChanSlope,"mTowerChanSlope[nTowerCrateChannels]/F");
516  // tree->Branch("mMapmtChanSlope",mMapmtChanSlope,"mMapmtChanSlope[nMapmtCrateChannels]/F");
517 
518  tree->Branch("mTowerMin",&mTowerMin,"mTowerMin/I");
519  tree->Branch("mTowerMax",&mTowerMax,"mTowerMax/I");
520  tree->Branch("mMapmtMin",&mMapmtMin,"mMapmtMin/I");
521  tree->Branch("mMapmtMax",&mMapmtMax,"mMapmtMax/I");
522 
523  tree->Fill();
524 
525  AddObj(tree,".hist");
526 // ff->Write();
527 
528  return kStOK;
529 }
530 // ----------------------------------------------------------------------------
531 void StEEmcTimingMaker::Clear(Option_t *opts)
532 {
533  return;
534 }
535 // ----------------------------------------------------------------------------
536 void StEEmcTimingMaker::setTiming( Float_t t, Float_t m )
537 {
538  mTowerDelay = t;
539  mMapmtDelay = m;
540 }
541 // ----------------------------------------------------------------------------
542 void StEEmcTimingMaker::setTowerCuts(Int_t min, Int_t max)
543 {
544  mTowerMin=min;mTowerMax=max;
545  LOG_INFO<<GetName()<<" set tower cuts: ped+"<<min<<",ped+"<<max<<endm;
546 }
547 void StEEmcTimingMaker::setMapmtCuts(Int_t min, Int_t max)
548 {
549  mMapmtMin=min;mMapmtMax=max;
550  LOG_INFO<<GetName()<<" set mapmt cuts: ped+"<<min<<",ped+"<<max<<endm;
551 }
552 
553 // ----------------------------------------------------------------------------
554 void StEEmcTimingMaker::dumpAsciiFile( const Char_t *fname )
555 {
556 
557 
558  LOG_INFO<<GetName()<<"::dumpAsciiFile("<<fname<<");"<<endm;
559 
560  ofstream ofile(fname);
561  ofile << "Run number: " << mRunNumber << endl;
562 
563 
564 #if 0
565  StMuDstMaker *mumk=(StMuDstMaker*)GetMaker("MuDst");
566  if ( mumk ) {
567  ofile << "Number of entries: " << mumk->chain()->GetEntries() << endl;
568  TObjArray *oa=mumk->chain()->GetListOfFiles();
569  Int_t n=oa->GetEntries();
570  for ( Int_t i=0;i<n;i++ ) {
571  TNamed *named=(TNamed*)oa->At(i);
572  if(named)
573  ofile << "+ "<<named->GetName()<<endl;
574  }
575  }
576  ofile<<endl;
577 
578  ofile<<"Tower cuts: "<<mTowerMin<<" "<<mTowerMax<<endl;
579  ofile<<"Mapmt cuts: "<<mMapmtMin<<" "<<mMapmtMax<<endl;
580  ofile<<endl;
581 #endif
582 
583 #if 1
584  const Char_t *sn[]={"01","02","03","04","05","06","07","08","09","10","11","12"};
585  const Char_t *ln[]={"T","P","Q","R"};
586  const Char_t *bn[]={"A","B","C","D","E"};
587 
588  for ( Int_t lay=0;lay<4;lay++ ){
589  for ( Int_t sec=0;sec<12;sec++ ){
590  for ( Int_t sub=0;sub<5;sub++ ){
591  {
592  for ( Int_t eta=0;eta<12;eta++ )
593  {
594  TString tname=sn[sec];tname+=ln[lay];tname+=bn[sub];tname+=sn[eta];
595  TString hname="h";hname+=tname;
596  TH1F *h=(TH1F*)GetHist(hname);
597  ofile << h->GetTitle() <<endl;
598  }
599  }
600  }
601  }
602  }
603 
604  const Char_t *pn[]={"U","V"};
605  for ( Int_t pln=0;pln<2;pln++ )
606  for ( Int_t sec=0;sec<12;sec++ )
607  {
608  for ( Int_t strip=0;strip<288;strip+=16 ) {
609  for ( Int_t i=0;i<16;i++ ) {
610  Int_t istrip=strip+i;
611  TString tname =sn[sec];
612  tname+=pn[pln];
613  if (istrip+1<100) tname+="0";
614  if (istrip+1<10) tname+="0";
615  tname+=(istrip+1);
616  TString hname="h";hname+=tname;
617  TH1F *h=(TH1F*)GetHist(hname);
618  ofile<<h->GetTitle()<<endl;
619  }
620  }
621  }
622 
623 
624 #endif
625 
626 }
627 
628 // ----------------------------------------------------------------------------
629 void StEEmcTimingMaker::dumpPDF( const Char_t *fname )
630 {
631 
632 
633 
634  TCanvas *c1=new TCanvas("c1","c1",850,1100);
635  c1->Divide(3,4);
636  c1->SetLogy();
637 
638  const Char_t *sn[]={"01","02","03","04","05","06","07","08","09","10","11","12"};
639  const Char_t *ln[]={"T","P","Q","R"};
640  const Char_t *bn[]={"A","B","C","D","E"};
641 
642  c1->Print(TString(fname)+"("); // print and leave open
643  for ( Int_t lay=0;lay<4;lay++ ){
644  for ( Int_t sec=0;sec<12;sec++ ){
645  for ( Int_t sub=0;sub<5;sub++ ){
646  {
647  for ( Int_t eta=0;eta<12;eta++ )
648  {
649  c1->cd(eta+1);
650  c1->cd(eta+1)->SetLogy();
651  TString tname=sn[sec];tname+=ln[lay];tname+=bn[sub];tname+=sn[eta];
652  TString hname="h";hname+=tname;
653  TH1F *h=0;
654  h=(TH1F*)GetHist(hname);
655  if (h) h->Draw();
656  else {
657  hname.ReplaceAll("h","a"); // from L2ped file
658  h=(TH1F*)GetHist(hname);
659  if ( h ) h->Draw();
660  }
661  }
662  c1->Print(TString(fname)+"("); // print and leave open
663 
664  }
665  }
666  }
667  }
668 
669  c1->Clear();
670  c1->Divide(4,4);
671  c1->SetLogy();
672 
673  const Char_t *pn[]={"U","V"};
674  for ( Int_t pln=0;pln<2;pln++ )
675  for ( Int_t sec=0;sec<12;sec++ )
676  {
677  for ( Int_t strip=0;strip<288;strip+=16 ) {
678  for ( Int_t i=0;i<16;i++ ) {
679  Int_t istrip=strip+i;
680  c1->cd(i+1);
681  c1->cd(i+1)->SetLogy();
682  TString tname =sn[sec];
683  tname+=pn[pln];
684  if (istrip+1<100) tname+="0";
685  if (istrip+1<10) tname+="0";
686  tname+=(istrip+1);
687  TString hname="h";hname+=tname;
688  TH1F *h=(TH1F*)GetHist(hname);
689  if(h)h->Draw();
690  }
691  c1->Print(TString(fname)+"("); // print and leave open
692  }
693  }
694  c1->Clear();
695  c1->Print(TString(fname)+")"); // print and close
696 
697 
698 
699 
700 #if 0
701 
702  TCanvas *c1=new TCanvas("c1","c1",850,1100);
703  TPDF *pdf=new TPDF(fname,111);
704  c1->Divide(3,4);
705  c1->SetLogy();
706 
707  const Char_t *sn[]={"01","02","03","04","05","06","07","08","09","10","11","12"};
708  const Char_t *ln[]={"T","P","Q","R"};
709  const Char_t *bn[]={"A","B","C","D","E"};
710 
711  // loop ovEr towers and write pdf file
712  Int_t i=1;
713 
714  for ( Int_t lay=0;lay<4;lay++ )
715  for ( Int_t sec=0;sec<12;sec++ )
716  for ( Int_t sub=0;sub<5;sub++ )
717  for ( Int_t eta=0;eta<12;eta++ )
718  {
719  if ( !(i%12) ) {
720  c1->Update();
721  pdf->NewPage();
722  }
723  TString tname=sn[sec];tname+=ln[lay];tname+=bn[sub];tname+=sn[eta];
724  TString hname="h";hname+=tname;
725  TH1F *h=(TH1F*)GetHist(hname);
726  c1->cd((i++ % 12));
727  if(h) h->Draw();
728 
729  }
730 
731  // loop over SMD
732  c1=new TCanvas("c1","c1",850,1100);
733  c1->Divide(4,4);
734  c1->SetLogy();
735 
736 
737  const Char_t *pn[]={"U","V"};
738 
739  i=1;
740  pdf->NewPage();
741  for ( Int_t sec=0;sec<12;sec++ )
742  for ( Int_t pln=0;pln<2;pln++ )
743  for ( Int_t strip=0;strip<288;strip++ )
744  {
745  if ( !(i%16) ) {
746  c1->Update();
747  pdf->NewPage();
748  }
749  TString tname =sn[sec];
750  tname+=pn[pln];
751  if (strip+1<100) tname+="0";
752  if (strip+1<10) tname+="0";
753  tname+=(strip+1);
754  TString hname="h";hname+=tname;
755  TH1F *h=(TH1F*)GetHist(hname);
756  c1->cd((i++ % 16));
757  if(h) h->Draw();
758 
759  }
760 #endif
761 
762 
763 }
764 
765 
766 
767 
768 
769 // ---------------------------------------------------
770 void StEEmcTimingMaker::processFromL2( const Char_t *fname, int nevents )
771 {
772 
773  /*
774  * Load in the L2ped histogram/root file and set pointers
775  * to each of the tower histograms
776  *
777  * o We rely on the title of the histogram to contain the crate and channel number
778  * (Jan likely gets this from the same place we would... the database).
779  *
780  * o Once tower histogram pointers are set, we should be able to call finish
781  * which will perform the fitting and yield extractions
782  *
783  */
784 
785 
786 
787  mTotalYield = nevents;
788  std::cout << Form("Timing from L2ped file: %s nevents: %i",fname,nevents) << std::endl;
789  TFile *f= new TFile(fname);
790  assert(f);
791  TList *l = f->GetListOfKeys();
792  TIter next(l);
793  TKey *key = 0;
794  while ((key = (TKey*)next()))
795  {
796  TObject *o = key->ReadObj();
797  TString name = o->GetName();
798  if ( !name.Contains("T") ) continue; // skip bemc towers
799  TH1F *h = (TH1F*)o;
800  TString title=h->GetTitle();
801  Int_t channel=-1;
802  Int_t crate = -1;
803 
804  // this line needs to change if L2ped histogram title changes
805  sscanf(title.Data(),"%*s cr/ch=%03d/%03d",&crate,&channel);
806 
807  std::cout << Form("+ name: %s title: %s crate: %i channel: %i",name.Data(),title.Data(),crate,channel) << std::endl;
808 
809  assert(crate>0); // crates count from 1
810  assert(channel>=0); // channels count from 0
811  hTower[crate-1][channel] = h; // add pointer
812 
813  }
814 
815 
816 }
EEmc ADC –&gt; energy maker.
void processFromL2(const Char_t *name, int nevents)
Process ready-made histograms from level 2.
const EEmcDbItem * getByIndex(int ikey) const
returns full DB info for one pixel
Definition: StEEmcDb.cxx:584
char name[StEEmcNameLen]
ASCII name of the channel, see Readme.
Definition: EEmcDbItem.h:20
StEEmcStrip & strip(Int_t sector, Int_t plane, Int_t strip)
void name(const Char_t *n)
Set the name for this element.
Definition: StEEmcElement.h:27
void raw(Float_t r)
Set the raw ADC for this element.
Definition: StEEmcElement.h:17
void supressZeroAdc()
Do not fill histograms with ADC=0.
Base class for representing tower, preshower and postshower elements.
Definition: StEEmcTower.h:11
char tube[StEEmcNameLen]
name of PMT or MAPMT pixel
Definition: EEmcDbItem.h:21
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
Definition: Stypes.h:42
Definition: Stypes.h:40
TChain * chain()
In read mode, returns pointer to the chain of .MuDst.root files that where selected.
Definition: StMuDstMaker.h:426
StEEmcTower & tower(Int_t index, Int_t layer=0)
void Clear(Option_t *opts="")
User defined functions.
Base class for describing an endcap SMD strip.
Definition: StEEmcStrip.h:8
int chan
hardware channel
Definition: EEmcDbItem.h:28
Definition: Stypes.h:41