00001 #include "StEEmcTimingMaker.h"
00002
00003 #include <TString.h>
00004 #include <TH1F.h>
00005 #include <TGraphErrors.h>
00006 #include <TF1.h>
00007 #include <TLine.h>
00008 #include <TPaveStats.h>
00009 #include <TTree.h>
00010 #include <TPDF.h>
00011 #include <TCanvas.h>
00012 #include <TChain.h>
00013 #include <TFile.h>
00014 #include <TKey.h>
00015
00016 #include <vector>
00017
00018 #include "StMessMgr.h"
00019
00020 #include "StEEmcUtil/database/StEEmcDb.h"
00021 #include "StEEmcUtil/database/EEmcDbItem.h"
00022 #include "StEEmcUtil/EEfeeRaw/EEname2Index.h"
00023
00024 #include "StEEmcPool/StEEmcA2EMaker/StEEmcA2EMaker.h"
00025
00026 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
00027
00028 ClassImp(StEEmcTimingMaker);
00029
00030
00031 StEEmcTimingMaker::StEEmcTimingMaker(const Char_t *name):StMaker(name)
00032 {
00033
00034 mTowerMin=25;
00035 mTowerMax=125;
00036 mMapmtMin=50;
00037 mMapmtMax=150;
00038 mSupressZero=false;
00039 mOutputFile="timing.root";
00040
00041
00042
00043 for ( Int_t i=0;i<MaxTwCrates;i++ )
00044 for ( Int_t j=0;j<MaxTwCrateCh;j++ )
00045 {
00046 hTower[i][j]=0;
00047 mTowerMask[i][j]=0;
00048 }
00049
00050 for ( Int_t i=0;i<MaxMapmtCrates;i++ )
00051 for ( Int_t j=0;j<MaxMapmtCrateCh;j++ )
00052 {
00053 hMapmt[i][j]=0;
00054 mMapmtMask[i][j]=0;
00055 }
00056
00057
00058
00059 for ( Int_t icrate=0;icrate<MaxTwCrates;icrate++ )
00060 {
00061 mTowerCrateYield[icrate]=0;
00062 }
00063 for ( Int_t icrate=0;icrate<MaxMapmtCrates;icrate++ )
00064 {
00065 mMapmtCrateYield[icrate]=0;
00066 }
00067
00068 for ( Int_t icrate=0;icrate<MaxTwCrates;icrate++ )
00069 for ( Int_t ichan=0;ichan<MaxTwCrateCh;ichan++ )
00070 {
00071 mTowerChanYield[icrate][ichan]=0;
00072 mTowerChanSlope[icrate][ichan]=0.;
00073 }
00074
00075 for ( Int_t icrate=0;icrate<MaxMapmtCrates;icrate++ )
00076 for ( Int_t ichan=0;ichan<MaxMapmtCrateCh;ichan++ )
00077 {
00078 mMapmtChanYield[icrate][ichan]=0;
00079 mMapmtChanSlope[icrate][ichan]=0.;
00080 }
00081
00082
00083 }
00084
00085 void StEEmcTimingMaker::supressZeroAdc(){ mSupressZero=true; }
00086
00087 void StEEmcTimingMaker::setRunNumber( Int_t r )
00088 {
00089 mRunNumber=r;
00090 }
00091
00092
00093 Int_t StEEmcTimingMaker::InitRun(Int_t run){
00094 assert(run==mRunNumber);
00095
00096 StEEmcA2EMaker *adcmk = (StEEmcA2EMaker*)GetMaker("AandE");
00097 if ( !adcmk ) {
00098 std::cout << "No ADC to E maker" <<std::endl;
00099 return kStWarn;
00100 }
00101
00102 StEEmcDb *dbmk = (StEEmcDb*)this->GetDataSet("StEEmcDb");
00103 if ( !dbmk ) {
00104 std::cout << "No database maker" << std::endl;
00105 return kStFatal;
00106 }
00107
00108
00109 Int_t ilayer=0;
00110 for ( Int_t itower=0;itower<720;itower++ )
00111 {
00112 StEEmcTower tow = adcmk->tower(itower,ilayer);
00113 const EEmcDbItem *dbitem=dbmk->getByIndex( EEname2Index(tow.name()) );
00114 assert(dbitem);
00115 Int_t crate=dbitem->crate;
00116 Int_t channel=dbitem->chan;
00117 TString twname=dbitem->name;
00118 TString tbname=dbitem->tube;
00119 TString title=
00120 Form("ADC spectrum run=%i, name=%s, cr/chan=%3.3d/%3.3d, tube=%s, ",run,twname.Data(),crate,channel,tbname.Data());
00121 TString hname="h";hname+=twname;
00122 hTower[crate-1][channel]->SetTitle(title);
00123 hTower[crate-1][channel]->SetName(hname);
00124 }
00125
00126 #if 1
00127 for ( ilayer=1; ilayer<4;ilayer++ ) {
00128 for ( Int_t itower=0;itower<720;itower++ )
00129 {
00130 StEEmcTower tow = adcmk->tower(itower,ilayer);
00131 const EEmcDbItem *dbitem=dbmk->getByIndex( EEname2Index(tow.name()) );
00132 assert(dbitem);
00133 Int_t crate=dbitem->crate;
00134 Int_t channel=dbitem->chan;
00135 TString twname=dbitem->name;
00136 TString tbname=dbitem->tube;
00137 TString title=Form("ADC spectrum run=%i, name=%s, cr/chan=%3.3d/%3.3d, tube=%s, ",run,twname.Data(),crate,channel,tbname.Data());
00138 TString hname="h";hname+=twname;
00139 hMapmt[crate-MinMapmtCrateID][channel]->SetTitle(title);
00140 hMapmt[crate-MinMapmtCrateID][channel]->SetName(hname);
00141 }
00142 }
00143 #endif
00144
00145 #if 1
00146 for ( Int_t isector=0;isector<12;isector++ )
00147 for ( Int_t iplane=0;iplane<2;iplane++ )
00148 {
00149 for ( Int_t index=0;index<288;index++ ) {
00150 StEEmcStrip strip=adcmk->strip(isector,iplane,index);
00151 const EEmcDbItem *dbitem=dbmk->getByIndex( EEname2Index(strip.name()) );
00152 if (!dbitem) continue;
00153 Int_t crate=dbitem->crate;
00154 Int_t channel=dbitem->chan;
00155 TString twname=dbitem->name;
00156 TString tbname=dbitem->tube;
00157 TString title=
00158 Form("ADC spectrum run=%i, name=%s, cr/chan=%3.3d/%3.3d, tube=%s, ",run,twname.Data(),crate,channel,tbname.Data());
00159 TString hname="h";hname+=twname;
00160 hMapmt[crate-MinMapmtCrateID][channel]->SetTitle(title);
00161 hMapmt[crate-MinMapmtCrateID][channel]->SetName(hname);
00162 }
00163 }
00164 #endif
00165 LOG_INFO<<GetName()<<"::InitRun("<<run<<") histograms renamed"<<endm;
00166
00167 return kStOK;
00168 }
00169
00170
00171
00172
00173
00174 Int_t StEEmcTimingMaker::Init()
00175 {
00176
00177 hCounter=new TH1F("hCounter","Event counter;status",1,0.,1.);
00178 hCounter->SetBit(TH1::kCanRebin);
00179
00180 #if 1
00181
00182 for ( Int_t icrate=0;icrate<MaxTwCrates;icrate++ )
00183 for ( Int_t ichan=0;ichan<MaxTwCrateCh;ichan++ )
00184 {
00185 TString name="hTwCr";name+=icrate+1;name+="Ch";name+=ichan;
00186 TString title="ADC spectrum crate/chan=";
00187 title += icrate+1;title+="/";title+=ichan;
00188 hTower[icrate][ichan]=new TH1F(name,title,512,0.,512.);
00189 }
00190
00191 for ( Int_t icrate=0;icrate<MaxMapmtCrates;icrate++ )
00192 for ( Int_t ichan=0;ichan<MaxMapmtCrateCh;ichan++ )
00193 {
00194 TString name="hMaCr";name+=MinMapmtCrateID+icrate;name+="Ch";name+=ichan;
00195 TString title="ADC spectrum crate/chan=";
00196 title += MinMapmtCrateID+icrate; title+="/";title+=ichan;
00197 hMapmt[icrate][ichan]=new TH1F(name,title,512,0.,512.);
00198 }
00199
00200
00201 for ( Int_t icrate=0;icrate<MaxTwCrates;icrate++ )
00202 {
00203 mTowerCrateYield[icrate]=0;
00204 }
00205 for ( Int_t icrate=0;icrate<MaxMapmtCrates;icrate++ )
00206 {
00207 mMapmtCrateYield[icrate]=0;
00208 }
00209
00210 for ( Int_t icrate=0;icrate<MaxTwCrates;icrate++ )
00211 for ( Int_t ichan=0;ichan<MaxTwCrateCh;ichan++ )
00212 {
00213 mTowerChanYield[icrate][ichan]=0;
00214 mTowerChanSlope[icrate][ichan]=0.;
00215 }
00216
00217 for ( Int_t icrate=0;icrate<MaxMapmtCrates;icrate++ )
00218 for ( Int_t ichan=0;ichan<MaxMapmtCrateCh;ichan++ )
00219 {
00220 mMapmtChanYield[icrate][ichan]=0;
00221 mMapmtChanSlope[icrate][ichan]=0.;
00222 }
00223
00224
00225 #endif
00226
00227 return kStOk;;
00228 }
00229
00230
00231 Int_t StEEmcTimingMaker::Make()
00232 {
00233
00234 hCounter->Fill("Nevents",1.);
00235
00236 StEEmcA2EMaker *adcmk = (StEEmcA2EMaker*)GetMaker("AandE");
00237 if ( !adcmk ) {
00238 std::cout << "No ADC to E maker" <<std::endl;
00239 return kStWarn;
00240 }
00241
00242 hCounter->Fill("Nadc2e",1.0);
00243
00244 StEEmcDb *dbmk = (StEEmcDb*)this->GetDataSet("StEEmcDb");
00245 if ( !dbmk ) {
00246 std::cout << "No database maker" << std::endl;
00247 return kStWarn;
00248 }
00249
00250 hCounter->Fill("Ndb",1.0);
00251
00252 mTotalYield++;
00253
00254 Int_t ilayer=0;
00255 for ( Int_t itower=0;itower<720;itower++ )
00256 {
00257 StEEmcTower tow = adcmk->tower(itower,ilayer);
00258 const EEmcDbItem *dbitem=dbmk->getByIndex( EEname2Index(tow.name()) );
00259 assert(dbitem);
00260 Int_t crate=dbitem->crate;
00261 Int_t channel=dbitem->chan;
00262 hTower[crate-1][channel] -> Fill( tow.raw() );
00263 }
00264
00265
00266 for ( ilayer=1;ilayer<4;ilayer++ )
00267 {
00268 for ( Int_t itower=0;itower<720;itower++ )
00269 {
00270 StEEmcTower tow = adcmk->tower(itower,ilayer);
00271 const EEmcDbItem *dbitem=dbmk->getByIndex( EEname2Index(tow.name()) );
00272 assert(dbitem);
00273 Int_t crate=dbitem->crate;
00274 Int_t channel=dbitem->chan;
00275 hMapmt[crate-MinMapmtCrateID][channel]->Fill(tow.raw());
00276 }
00277 }
00278
00279 for ( Int_t isector=0;isector<12;isector++ )
00280 for ( Int_t iplane=0;iplane<2;iplane++ )
00281 {
00282 for ( Int_t index=0;index<288;index++ ) {
00283 StEEmcStrip strip=adcmk->strip(isector,iplane,index);
00284 const EEmcDbItem *dbitem=dbmk->getByIndex( EEname2Index(strip.name()) );
00285 if (!dbitem) continue;
00286 Int_t crate=dbitem->crate;
00287 Int_t channel=dbitem->chan;
00288 hMapmt[crate-MinMapmtCrateID][channel]->Fill(strip.raw());
00289 }
00290 }
00291
00292 return kStOK;
00293 }
00294
00295
00296 Int_t StEEmcTimingMaker::Finish()
00297 {
00298
00299 static Int_t ncalled=0;
00300 std::cout << Form("StEEmcTimingMaker::Finish() called for the %i-%s time",ncalled+1,(ncalled)?"nd":"st") << std::endl;
00301 if ( ncalled ) return kStOK;
00302 ncalled++;
00303
00304 std::vector<TH1F*> histos;
00305
00306 for ( Int_t icrate=0;icrate<MaxTwCrates;icrate++ )
00307 for ( Int_t ichan=0;ichan<MaxTwCrateCh;ichan++ )
00308 {
00309
00310 if ( !hTower[icrate][ichan] ) continue;
00311 if ( hTower[icrate][ichan]->Integral()<10 ) continue;
00312 histos.push_back( hTower[icrate][ichan] );
00313 }
00314
00315 for ( Int_t icrate=0;icrate<MaxMapmtCrates;icrate++ )
00316 for ( Int_t ichan=0;ichan<MaxMapmtCrateCh;ichan++ )
00317 {
00318 if ( !hMapmt[icrate][ichan] ) continue;
00319 if ( hMapmt[icrate][ichan]->Integral()<10 ) continue;
00320 histos.push_back(hMapmt[icrate][ichan]);
00321 }
00322
00323 for ( UInt_t ii=0;ii<histos.size();ii++ )
00324 {
00325 TF1 fit("fit","gaus");
00326 Float_t xmax=(Float_t)histos[ii]->GetMaximumBin();
00327 fit.SetParameter(0, histos[ii]->Integral() );
00328 fit.SetParameter(1, xmax );
00329 fit.SetParLimits(1, xmax-2.0, xmax+2.0 );
00330 fit.SetParameter(2, 0.90 );
00331 histos[ii]->GetXaxis()->SetRangeUser(xmax-10.,xmax+10.);
00332 histos[ii]->Fit(&fit,"RQ","",xmax-10.0,xmax+10.0);
00333
00334 #if 0
00335 std::cout << Form("+ fit %s: ped=%5.2f sig=%5.3f",histos[ii]->GetName(),fit.GetParameter(1),fit.GetParameter(2)) << std::endl;
00336 if ( ii == 0 ) {
00337 histos[ii]->GetListOfFunctions()->Print();
00338 return kStOK;
00339 }
00340 #endif
00341
00342 }
00343
00344
00345
00346 for ( Int_t icrate=0;icrate<MaxTwCrates;icrate++ )
00347 {
00348
00349 TString hname="hCrate";hname+=(icrate+1);
00350 TString htitle="Pedestal-subtracted spectrum for crate ";htitle+=(icrate+1);
00351 TH1F *hSumTowers=new TH1F(hname,htitle,524,-12.,512.);
00352
00353 for ( Int_t ichan=0;ichan<MaxTwCrateCh;ichan++ )
00354 {
00355
00356 TH1F *h=hTower[icrate][ichan];
00357 if ( !h ) continue;
00358
00359 TString htitle=h->GetTitle();
00360 LOG_INFO<<"Fitting "<<htitle<<endl;
00361
00362 TF1 *f=(TF1*)h->GetListOfFunctions()->At(0);
00363 if ( !f ) continue;
00364 if ( f->IsA() != TF1::Class() ) {
00365 LOG_WARN<<" somebody inserted something into "<<h->GetName()<<"'s list of functions, and it's messing up the output"<<endm;
00366 #if 0
00367 std::cout << "Print out slot 0" << std::endl;
00368 f->Print();
00369 std::cout << "Print all functions" << std::endl;
00370 h->GetListOfFunctions()->Print();
00371 return kStOK;
00372 #endif
00373 continue;
00374 }
00375 Float_t xmean = f->GetParameter(1);
00376 Float_t xwidth= f->GetParameter(2);
00377 Float_t xmin = xmean+mTowerMin;
00378 Float_t xmax = xmean+mTowerMax;
00379 h->GetXaxis()->SetRangeUser(xmin,xmax);
00380 Float_t sum=h->Integral();
00381 if ( !mTowerMask[icrate][ichan] ) mTowerCrateYield[icrate]+=(Int_t)sum;
00382 mTowerChanYield[icrate][ichan]+=(Int_t)sum;
00383
00384 h->GetXaxis()->SetRangeUser(xmin-2.0*mTowerMin,xmax+mTowerMin);
00385 h->Draw();
00386
00387 TLine *l1=new TLine( xmin, -0.05*h->GetMaximum(), xmin, +0.05*h->GetMaximum() );l1->SetLineColor(2);
00388 TLine *l2=new TLine( xmax, -0.05*h->GetMaximum(), xmax, +0.05*h->GetMaximum() );l2->SetLineColor(2);
00389 h->GetListOfFunctions()->Add(l1);
00390 h->GetListOfFunctions()->Add(l2);
00391
00392 for ( Int_t ii=1;ii<=512;ii++ )
00393 {
00394 hSumTowers->Fill( ((Float_t)ii) - xmean, h->GetBinContent(ii) );
00395 }
00396
00397 TF1 *slope=new TF1("slope","expo",0.,512.);
00398 slope->SetLineColor(2);
00399 h->Fit(slope,"RQ+","",xmin,xmax);
00400 if ( slope->GetParameter(1) != 0. )
00401 mTowerChanSlope[icrate][ichan]=1.0/slope->GetParameter(1);
00402
00403 htitle+=Form("ped=%6.2f, ",xmean);
00404 htitle+=Form("width=%6.4f, ",xwidth);
00405 htitle+=Form("xmin=%5.1f, xmax=%5.1f, Integral=%i, ",xmin,xmax,mTowerChanYield[icrate][ichan]);
00406 htitle+=Form("inv. slope=%8.5g+/-%8.5g, ",slope->GetParameter(1),slope->GetParError(1));
00407
00408 h->SetTitle(htitle);
00409
00410 }
00411 AddHist(hSumTowers,".hist");
00412
00413 std::cout << "crate="<<icrate+1<<" sum="<<mTowerCrateYield[icrate]<<std::endl;
00414 }
00415
00416
00417
00418 for ( Int_t icrate=0;icrate<MaxMapmtCrates;icrate++ )
00419 {
00420
00421 TString hname="hCrate";hname+=(icrate+MinMapmtCrateID);
00422 TString htitle="Pedestal-subtracted spectrum for crate ";htitle+=(icrate+1);
00423 TH1F *hSumMapmt=new TH1F(hname,htitle,524,-12.,512.);
00424
00425 for ( Int_t ichan=0;ichan<MaxMapmtCrateCh;ichan++ )
00426 {
00427 TH1F *h=hMapmt[icrate][ichan];
00428 if ( !h ) continue;
00429
00430 TString htitle=h->GetTitle();
00431 LOG_INFO<<"Fitting "<<htitle<<endl;
00432
00433 TF1 *f=(TF1*)h->GetListOfFunctions()->At(0);
00434 if ( !f ) continue;
00435 if ( f->IsA() != TF1::Class() ) {
00436 LOG_WARN<<" somebody inserted something into "<<h->GetName()<<"'s list of functions, and it's messing up the output"<<endm;
00437 continue;
00438 }
00439
00440 Float_t xmean = f->GetParameter(1);
00441 Float_t xwidth = f->GetParameter(2);
00442 Float_t xmin = xmean+mMapmtMin;
00443 Float_t xmax = xmean+mMapmtMax;
00444 h->GetXaxis()->SetRangeUser(xmin,xmax);
00445 Float_t sum=h->Integral();
00446
00447
00448 if ( !mMapmtMask[icrate][ichan] ) mMapmtCrateYield[icrate]+=(Int_t)sum;
00449 mMapmtChanYield[icrate][ichan]+=(Int_t)sum;
00450 h->GetXaxis()->SetRangeUser(xmin-2.0*mMapmtMin,xmax+mMapmtMin);
00451 h->Draw();
00452
00453 Char_t buf[128];
00454 sprintf(buf,"Integral [%5.1f,%5.1f] = %i",xmin,xmax,mMapmtChanYield[icrate][ichan]);
00455 TString title=h->GetTitle();title+=" ";title+=buf;
00456 h->SetTitle(title);
00457
00458 TLine *l1=new TLine( xmin, -0.05*h->GetMaximum(), xmin, +0.05*h->GetMaximum() );l1->SetLineColor(2);
00459 TLine *l2=new TLine( xmax, -0.05*h->GetMaximum(), xmax, +0.05*h->GetMaximum() );l2->SetLineColor(2);
00460 h->GetListOfFunctions()->Add(l1);
00461 h->GetListOfFunctions()->Add(l2);
00462
00463 for ( Int_t ii=1;ii<=512;ii++ )
00464 {
00465 hSumMapmt->Fill( ((Float_t)ii) - xmean, h->GetBinContent(ii) );
00466 }
00467
00468 TF1 *slope=new TF1("slope","expo",0.,512.);
00469 slope->SetLineColor(2);
00470 h->Fit(slope,"RQ+","",xmin,xmax);
00471 if ( slope->GetParameter(1) != 0. )
00472 mMapmtChanSlope[icrate][ichan]=1.0/slope->GetParameter(1);
00473
00474 htitle+=Form("ped=%6.2f, ",xmean);
00475 htitle+=Form("width=%6.4f, ",xwidth);
00476 htitle+=Form("xmin=%5.1f, xmax=%5.1f, Integral=%i, ",xmin,xmax,mMapmtChanYield[icrate][ichan]);
00477 htitle+=Form("inv. slope=%8.5g+/-%8.5g, ",slope->GetParameter(1),slope->GetParError(1));
00478 h->SetTitle(htitle);
00479
00480 }
00481 AddHist(hSumMapmt,".hist");
00482
00483 std::cout << "crate="<<icrate+MinMapmtCrateID<<" sum="<<mMapmtCrateYield[icrate]<<std::endl;
00484 }
00485
00486
00487
00488
00489
00490 TTree *tree=new TTree("timing","EEmc timing scan TTree");
00491 mTree=tree;
00492
00493 tree->Branch("mRunNumber",&mRunNumber,"mRunNumber/I");
00494 tree->Branch("mTowerDelay",&mTowerDelay,"mTowerDelay/F");
00495 tree->Branch("mMapmtDelay",&mMapmtDelay,"mMapmtDelay/F");
00496
00497 tree->Branch("mTotalYield",&mTotalYield,"mTotalYield/I");
00498
00499 Int_t nTowerCrates = MaxTwCrates;
00500 Int_t nMapmtCrates = MaxMapmtCrates;
00501 Int_t nTowerCrateChannels = MaxTwCrateCh * MaxTwCrates;
00502 Int_t nMapmtCrateChannels = MaxMapmtCrateCh * MaxMapmtCrates;
00503
00504 tree->Branch("nTowerCrates",&nTowerCrates,"nTowerCrates/I");
00505 tree->Branch("nMapmtCrates",&nMapmtCrates,"nMapmtCrates/I");
00506 tree->Branch("nTowerCrateChannels",&nTowerCrateChannels,"nTowerCrateChannels/I");
00507 tree->Branch("nMapmtCrateChannels",&nMapmtCrateChannels,"nMapmtCrateChannels/I");
00508
00509 tree->Branch("mTowerCrateYield",mTowerCrateYield,"mTowerCrateYield[nTowerCrates]/I");
00510 tree->Branch("mMapmtCrateYield",mMapmtCrateYield,"mMapmtCrateYield[nMapmtCrates]/I");
00511
00512 tree->Branch("mTowerChanYield",mTowerChanYield,"mTowerChanYield[nTowerCrateChannels]/I");
00513 tree->Branch("mMapmtChanYield",mMapmtChanYield,"mMapmtChanYield[nMapmtCrateChannels]/I");
00514
00515
00516
00517 tree->Branch("mTowerMin",&mTowerMin,"mTowerMin/I");
00518 tree->Branch("mTowerMax",&mTowerMax,"mTowerMax/I");
00519 tree->Branch("mMapmtMin",&mMapmtMin,"mMapmtMin/I");
00520 tree->Branch("mMapmtMax",&mMapmtMax,"mMapmtMax/I");
00521
00522 tree->Fill();
00523
00524 AddObj(tree,".hist");
00525
00526
00527 return kStOK;
00528 }
00529
00530 void StEEmcTimingMaker::Clear(Option_t *opts)
00531 {
00532 return;
00533 }
00534
00535 void StEEmcTimingMaker::setTiming( Float_t t, Float_t m )
00536 {
00537 mTowerDelay = t;
00538 mMapmtDelay = m;
00539 }
00540
00541 void StEEmcTimingMaker::setTowerCuts(Int_t min, Int_t max)
00542 {
00543 mTowerMin=min;mTowerMax=max;
00544 LOG_INFO<<GetName()<<" set tower cuts: ped+"<<min<<",ped+"<<max<<endm;
00545 }
00546 void StEEmcTimingMaker::setMapmtCuts(Int_t min, Int_t max)
00547 {
00548 mMapmtMin=min;mMapmtMax=max;
00549 LOG_INFO<<GetName()<<" set mapmt cuts: ped+"<<min<<",ped+"<<max<<endm;
00550 }
00551
00552
00553 void StEEmcTimingMaker::dumpAsciiFile( const Char_t *fname )
00554 {
00555
00556
00557 LOG_INFO<<GetName()<<"::dumpAsciiFile("<<fname<<");"<<endm;
00558
00559 ofstream ofile(fname);
00560 ofile << "Run number: " << mRunNumber << endl;
00561
00562
00563 #if 0
00564 StMuDstMaker *mumk=(StMuDstMaker*)GetMaker("MuDst");
00565 if ( mumk ) {
00566 ofile << "Number of entries: " << mumk->chain()->GetEntries() << endl;
00567 TObjArray *oa=mumk->chain()->GetListOfFiles();
00568 Int_t n=oa->GetEntries();
00569 for ( Int_t i=0;i<n;i++ ) {
00570 TNamed *named=(TNamed*)oa->At(i);
00571 if(named)
00572 ofile << "+ "<<named->GetName()<<endl;
00573 }
00574 }
00575 ofile<<endl;
00576
00577 ofile<<"Tower cuts: "<<mTowerMin<<" "<<mTowerMax<<endl;
00578 ofile<<"Mapmt cuts: "<<mMapmtMin<<" "<<mMapmtMax<<endl;
00579 ofile<<endl;
00580 #endif
00581
00582 #if 1
00583 const Char_t *sn[]={"01","02","03","04","05","06","07","08","09","10","11","12"};
00584 const Char_t *ln[]={"T","P","Q","R"};
00585 const Char_t *bn[]={"A","B","C","D","E"};
00586
00587 for ( Int_t lay=0;lay<4;lay++ ){
00588 for ( Int_t sec=0;sec<12;sec++ ){
00589 for ( Int_t sub=0;sub<5;sub++ ){
00590 {
00591 for ( Int_t eta=0;eta<12;eta++ )
00592 {
00593 TString tname=sn[sec];tname+=ln[lay];tname+=bn[sub];tname+=sn[eta];
00594 TString hname="h";hname+=tname;
00595 TH1F *h=(TH1F*)GetHist(hname);
00596 ofile << h->GetTitle() <<endl;
00597 }
00598 }
00599 }
00600 }
00601 }
00602
00603 const Char_t *pn[]={"U","V"};
00604 for ( Int_t pln=0;pln<2;pln++ )
00605 for ( Int_t sec=0;sec<12;sec++ )
00606 {
00607 for ( Int_t strip=0;strip<288;strip+=16 ) {
00608 for ( Int_t i=0;i<16;i++ ) {
00609 Int_t istrip=strip+i;
00610 TString tname =sn[sec];
00611 tname+=pn[pln];
00612 if (istrip+1<100) tname+="0";
00613 if (istrip+1<10) tname+="0";
00614 tname+=(istrip+1);
00615 TString hname="h";hname+=tname;
00616 TH1F *h=(TH1F*)GetHist(hname);
00617 ofile<<h->GetTitle()<<endl;
00618 }
00619 }
00620 }
00621
00622
00623 #endif
00624
00625 }
00626
00627
00628 void StEEmcTimingMaker::dumpPDF( const Char_t *fname )
00629 {
00630
00631
00632
00633 TCanvas *c1=new TCanvas("c1","c1",850,1100);
00634 c1->Divide(3,4);
00635 c1->SetLogy();
00636
00637 const Char_t *sn[]={"01","02","03","04","05","06","07","08","09","10","11","12"};
00638 const Char_t *ln[]={"T","P","Q","R"};
00639 const Char_t *bn[]={"A","B","C","D","E"};
00640
00641 c1->Print(TString(fname)+"(");
00642 for ( Int_t lay=0;lay<4;lay++ ){
00643 for ( Int_t sec=0;sec<12;sec++ ){
00644 for ( Int_t sub=0;sub<5;sub++ ){
00645 {
00646 for ( Int_t eta=0;eta<12;eta++ )
00647 {
00648 c1->cd(eta+1);
00649 c1->cd(eta+1)->SetLogy();
00650 TString tname=sn[sec];tname+=ln[lay];tname+=bn[sub];tname+=sn[eta];
00651 TString hname="h";hname+=tname;
00652 TH1F *h=0;
00653 h=(TH1F*)GetHist(hname);
00654 if (h) h->Draw();
00655 else {
00656 hname.ReplaceAll("h","a");
00657 h=(TH1F*)GetHist(hname);
00658 if ( h ) h->Draw();
00659 }
00660 }
00661 c1->Print(TString(fname)+"(");
00662
00663 }
00664 }
00665 }
00666 }
00667
00668 c1->Clear();
00669 c1->Divide(4,4);
00670 c1->SetLogy();
00671
00672 const Char_t *pn[]={"U","V"};
00673 for ( Int_t pln=0;pln<2;pln++ )
00674 for ( Int_t sec=0;sec<12;sec++ )
00675 {
00676 for ( Int_t strip=0;strip<288;strip+=16 ) {
00677 for ( Int_t i=0;i<16;i++ ) {
00678 Int_t istrip=strip+i;
00679 c1->cd(i+1);
00680 c1->cd(i+1)->SetLogy();
00681 TString tname =sn[sec];
00682 tname+=pn[pln];
00683 if (istrip+1<100) tname+="0";
00684 if (istrip+1<10) tname+="0";
00685 tname+=(istrip+1);
00686 TString hname="h";hname+=tname;
00687 TH1F *h=(TH1F*)GetHist(hname);
00688 if(h)h->Draw();
00689 }
00690 c1->Print(TString(fname)+"(");
00691 }
00692 }
00693 c1->Clear();
00694 c1->Print(TString(fname)+")");
00695
00696
00697
00698
00699 #if 0
00700
00701 TCanvas *c1=new TCanvas("c1","c1",850,1100);
00702 TPDF *pdf=new TPDF(fname,111);
00703 c1->Divide(3,4);
00704 c1->SetLogy();
00705
00706 const Char_t *sn[]={"01","02","03","04","05","06","07","08","09","10","11","12"};
00707 const Char_t *ln[]={"T","P","Q","R"};
00708 const Char_t *bn[]={"A","B","C","D","E"};
00709
00710
00711 Int_t i=1;
00712
00713 for ( Int_t lay=0;lay<4;lay++ )
00714 for ( Int_t sec=0;sec<12;sec++ )
00715 for ( Int_t sub=0;sub<5;sub++ )
00716 for ( Int_t eta=0;eta<12;eta++ )
00717 {
00718 if ( !(i%12) ) {
00719 c1->Update();
00720 pdf->NewPage();
00721 }
00722 TString tname=sn[sec];tname+=ln[lay];tname+=bn[sub];tname+=sn[eta];
00723 TString hname="h";hname+=tname;
00724 TH1F *h=(TH1F*)GetHist(hname);
00725 c1->cd((i++ % 12));
00726 if(h) h->Draw();
00727
00728 }
00729
00730
00731 c1=new TCanvas("c1","c1",850,1100);
00732 c1->Divide(4,4);
00733 c1->SetLogy();
00734
00735
00736 const Char_t *pn[]={"U","V"};
00737
00738 i=1;
00739 pdf->NewPage();
00740 for ( Int_t sec=0;sec<12;sec++ )
00741 for ( Int_t pln=0;pln<2;pln++ )
00742 for ( Int_t strip=0;strip<288;strip++ )
00743 {
00744 if ( !(i%16) ) {
00745 c1->Update();
00746 pdf->NewPage();
00747 }
00748 TString tname =sn[sec];
00749 tname+=pn[pln];
00750 if (strip+1<100) tname+="0";
00751 if (strip+1<10) tname+="0";
00752 tname+=(strip+1);
00753 TString hname="h";hname+=tname;
00754 TH1F *h=(TH1F*)GetHist(hname);
00755 c1->cd((i++ % 16));
00756 if(h) h->Draw();
00757
00758 }
00759 #endif
00760
00761
00762 }
00763
00764
00765
00766
00767
00768
00769 void StEEmcTimingMaker::processFromL2( const Char_t *fname, int nevents )
00770 {
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786 mTotalYield = nevents;
00787 std::cout << Form("Timing from L2ped file: %s nevents: %i",fname,nevents) << std::endl;
00788 TFile *f= new TFile(fname);
00789 assert(f);
00790 TList *l = f->GetListOfKeys();
00791 TIter next(l);
00792 TKey *key = 0;
00793 while ((key = (TKey*)next()))
00794 {
00795 TObject *o = key->ReadObj();
00796 TString name = o->GetName();
00797 if ( !name.Contains("T") ) continue;
00798 TH1F *h = (TH1F*)o;
00799 TString title=h->GetTitle();
00800 Int_t channel=-1;
00801 Int_t crate = -1;
00802
00803
00804 sscanf(title.Data(),"%*s cr/ch=%03d/%03d",&crate,&channel);
00805
00806 std::cout << Form("+ name: %s title: %s crate: %i channel: %i",name.Data(),title.Data(),crate,channel) << std::endl;
00807
00808 assert(crate>0);
00809 assert(channel>=0);
00810 hTower[crate-1][channel] = h;
00811
00812 }
00813
00814
00815 }