7 #include "StFtpcClusterDebug.hh"
8 #include "math_constants.h"
14 #include "StFtpcTrackMaker/StFtpcConfMapper.hh"
22 Float_t micropertimebin;
23 Float_t normalizedNowPressure, standardPressure;
24 Float_t baseTemperature, gasTemperatureWest, gasTemperatureEast;
25 Float_t deltapW,deltapE;
32 Float_t raderror,phierror;
37 Float_t timepos,padpos,timesigma,padsigma;
38 Float_t peakheight, charge;
40 Int_t padlength,timelength;
61 Int_t trow,tsec, tpadlength, ttimelength;
62 Float_t tpeakheight, tcharge;
64 Float_t padpos, timepos;
65 Float_t padpossigma, timepossigma;
72 Float_t globResX,globResY,globResPhi,globResR;
73 Float_t primResX,primResY,primResPhi,primResR;
100 Int_t sec,row,time,pad;
107 StFtpcClusterDebug::StFtpcClusterDebug()
108 : histofile(0), hardsecold(-1), hardrowold(-1)
109 , hardsecold2(-1), hardrowold2(-1)
110 , run(-1956), nevent(0), neventold(0)
111 , clusterhisto(new TH2F()), clusterhisto2(new TH2F())
112 , vertex_east(0),vertex_west(0),vertex_both(0)
113 , fileopen(false),dir(false),dir2(false)
114 , bRun(0),bhit(0), bevent(0), bcluster(0)
115 , bthit(0), btcluster(0), btevent(0)
116 , btrevent(0), btrack(0), btrvertex(0)
119 , histdir(0), histdir2(0), vertexdir(0), topdir(0)
120 , drtree (0), dtree(0), dttree(0), dtrtree(0), dtreeraw(0)
121 , drawclhisto(0), drawvertexhisto(0)
127 StFtpcClusterDebug::StFtpcClusterDebug(
int grun,
int gevent)
129 , hardsecold(-1), hardrowold(-1)
130 , hardsecold2(-1), hardrowold2(-1)
131 , run(grun), nevent(gevent), neventold(0)
132 , clusterhisto(new TH2F()), clusterhisto2(new TH2F())
133 , vertex_east(new TH1F()),vertex_west(new TH1F()),vertex_both(new TH1F())
135 , fileopen(false),dir(false),dir2(false)
137 , bRun(0),bhit(0), bevent(0), bcluster(0)
138 , bthit(0), btcluster(0), btevent(0)
139 , btrevent(0), btrack(0), btrvertex(0)
142 , histdir(0), histdir2(0), vertexdir(0), topdir(0)
143 , drtree (0), dtree(0), dttree(0), dtrtree(0), dtreeraw(0)
144 , drawclhisto(0), drawvertexhisto(0)
150 std::string fname=
"fdbg";
153 ini.open(
"./debug.ini",ios::in);
155 ini>>fname>>drawclhisto>>drawvertexhisto;
158 LOG_WARN <<
"debug.ini file missing - used default filename, drawclhisto = " << drawclhisto <<
" drawvertexhist0 = " << drawvertexhisto <<endm;
161 stringstream histodateis;
162 histodateis <<
"run_" <<run<<
"_" << fname <<
".root";
163 std::string histodateistring = histodateis.str();
164 const char *histodatei = histodateistring.c_str();
166 test=
new TFile(histodatei);
168 if (!(test->IsOpen()))
170 delete test; test = 0;
172 LOG_INFO <<
"histodatei = " << histodatei << endm;
173 histofile=
new TFile(histodatei,
"RECREATE",
"FTPC Cluster Finder histograms");
175 drtree=
new TTree(
"rinfo",
"Run calibration information");
176 drtree->Branch(
"Run",&Run,
"run/I:date/I:time/I:micropertimebin/F:normalizedNowPressure/F:standardPressure/F:baseTemperature/F:gasTemperatureWest/F:gasTemperatureEast/F:deltapW/F:deltapE/F");
178 dtree=
new TTree(
"cl",
"Cluster calibration informations");
179 dtree->Branch(
"hit",&
hit,
"x/F:y/F:z/F:rad/F:phi/F:raderror/F:phierror/F");
180 dtree->Branch(
"cluster",&cluster,
"timepos/F:padpos/F:timesigma/F:padsigma/F:peakheight/F:charge/F:timebin/I:pad/I:padlength/I:timelength/I:row/I:sec/I:flag/I:numpeaks/I");
181 dtree->Branch(
"event",&event,
"run/I:nevent/I");
183 dttree=
new TTree(
"clot",
"Cluster on tracks calibration information");
184 dttree->Branch(
"cluster",&tcluster,
"row/I:sec/I:padlength/I:timelength/I:peakheight/F:charge/F:ntracks/I:padpos/F:timepos/F:padsigma/F:timesigma/F");
185 dttree->Branch(
"hit",&thit,
"x/F:y/F:z/F:ex/F:ey/F:ez/F:globResX/F:globResY/F:globResR/F:globResPhi/F:primResX/F:primResY/F:primResR/F:primResPhi/F");
186 dttree->Branch(
"event",&tevent,
"run/I:nevent/I");
188 dtrtree=
new TTree(
"tr",
"Track calibration information");
189 dtrtree->Branch(
"event",&trevent,
"run/I:nevent/I");
190 dtrtree->Branch(
"track",&
track,
"px/F:py/F:pz/F:eta/F:p/F:pt/F:npoints/I:charge/I:type/I:sec/I");
191 dtrtree->Branch(
"vertex",&mvertex,
"x/F:y/F:z/F");
193 dtreeraw=
new TTree(
"raw",
"Cluster raw data");
194 dtreeraw->Branch(
"cl_raw",&raw,
"sec/I:row/I:time/I:pad/I:adc/F");
196 topdir=histofile->mkdir(
"histograms");
200 delete test; test = 0;
202 histofile=
new TFile(histodatei,
"UPDATE",
"histogramme fuer fcl");
204 drtree=(TTree*) histofile->Get(
"rinfo");
206 bRun=drtree->GetBranch(
"Run");
207 bRun->SetAddress(&Run);
208 dtree=(TTree*) histofile->Get(
"cl");
209 bhit=dtree->GetBranch(
"hit");
210 bhit->SetAddress(&
hit);
212 bcluster=dtree->GetBranch(
"cluster");
213 bcluster->SetAddress(&cluster);
215 bevent=dtree->GetBranch(
"event");
216 bevent->SetAddress(&event);
218 dttree=(TTree*) histofile->Get(
"clot");
219 btcluster=dttree->GetBranch(
"cluster");
220 btcluster->SetAddress(&tcluster);
222 bthit=dttree->GetBranch(
"hit");
223 bthit->SetAddress(&thit);
225 btevent=dttree->GetBranch(
"event");
226 btevent->SetAddress(&tevent);
228 dtrtree=(TTree*) histofile->Get(
"tr");
229 btrevent=dtrtree->GetBranch(
"event");
230 btrevent->SetAddress(&trevent);
232 btrack=dtrtree->GetBranch(
"track");
233 btrack->SetAddress(&
track);
235 btrvertex=dtrtree->GetBranch(
"vertex");
236 btrvertex->SetAddress(&mvertex);
238 dtreeraw=(TTree*) histofile->Get(
"raw");
239 bclusterraw=dtreeraw->GetBranch(
"cl_raw");
240 bclusterraw->SetAddress(&raw);
242 histofile->Delete(
"rinfo;1");
243 histofile->Delete(
"cl;1");
244 histofile->Delete(
"clot;1");
245 histofile->Delete(
"tr;1");
246 histofile->Delete(
"raw;1");
248 topdir=(TDirectory*) histofile->Get(
"histograms");
250 LOG_ERROR <<
"StFtpcClusterDebug::StFtpcClusterDebug():"
251 <<
" No \"rinfo\" object was found on <"
252 << histodatei <<
"> ROOT file" << endm;
259 StFtpcClusterDebug::~StFtpcClusterDebug()
265 delete vertex_west;
delete vertex_east;
delete vertex_both;
274 delete dtree;
delete dttree;
delete dtrtree;
280 void StFtpcClusterDebug::backup()
285 void StFtpcClusterDebug::drawgainhisto(
int hardsec,
int hardrow,
int iPad,
float gainfac,
TPCSequence HSequence)
292 sprintf(dirname,
"evt_%d_gain",nevent);
293 histdir2=topdir->mkdir(dirname);
297 if (hardsecold2!=hardsec || hardrowold2!=hardrow)
299 char histotitel[100],histoname[25];
305 sprintf(histotitel,
"(hardsec %d hardrow %d) & gainfactor",hardsec,hardrow);
306 sprintf(histoname,
"hsec%d_hrow%d_gain",hardsec,hardrow);
309 clusterhisto2=
new TH2F(histoname,histotitel,160,0,160,255,0,255);
311 hardsecold2=hardsec; hardrowold2=hardrow;
317 for(
int iIndex=0; iIndex<HSequence.Length; iIndex++)
319 if (((
float)(
unsigned int)(HSequence.FirstAdc[iIndex]))>0)
321 clusterhisto2->Fill(iPad,HSequence.startTimeBin+iIndex-1,(((
float)(
unsigned int)(HSequence.FirstAdc[iIndex]))*gainfac));
330 void StFtpcClusterDebug::drawhisto(
int hardsec,
int hardrow,
int iPad,
TPCSequence HSequence)
337 sprintf(dirname,
"evt_%d",nevent);
338 histdir=topdir->mkdir(dirname);
342 if (hardsecold!=hardsec || hardrowold!=hardrow)
344 char histotitel[100],histoname[25];
350 sprintf(histotitel,
"(hardsec %d hardrow %d)",hardsec,hardrow);
351 sprintf(histoname,
"hsec%d_hrow%d",hardsec,hardrow);
354 clusterhisto=
new TH2F(histoname,histotitel,160,0,160,255,0,255);
356 hardsecold=hardsec; hardrowold=hardrow;
360 for(
int iIndex=0; iIndex<HSequence.Length; iIndex++)
362 if (((
float)(
unsigned int)(HSequence.FirstAdc[iIndex]))>0)
364 clusterhisto->Fill(iPad,HSequence.startTimeBin+iIndex-1,((
float)(
unsigned int)(HSequence.FirstAdc[iIndex])));
372 void StFtpcClusterDebug::fillRun(Int_t grun, Int_t gdate, Int_t gtime, Float_t micropertimebin, Float_t normalizedNowPressure, Float_t standardPressure, Float_t baseTemperature, Float_t gasTemperatureWest, Float_t gasTemperatureEast, Float_t deltapW, Float_t deltapE)
377 Run.micropertimebin = micropertimebin;
378 Run.normalizedNowPressure = normalizedNowPressure;
379 Run.standardPressure = standardPressure;
380 Run.baseTemperature = baseTemperature;
381 Run.gasTemperatureWest = gasTemperatureWest;
382 Run.gasTemperatureEast = gasTemperatureEast;
383 Run.deltapW = deltapW;
384 Run.deltapE = deltapE;
388 void StFtpcClusterDebug::fillraw(
int hardsec,
int hardrow,
int iPad,
TPCSequence HSequence)
390 for(
int iIndex=0; iIndex<HSequence.Length; iIndex++)
392 if (((
float)(
unsigned int)(HSequence.FirstAdc[iIndex]))>0)
394 if (HSequence.startTimeBin+iIndex-1>10 && HSequence.startTimeBin+iIndex-1<200)
399 raw.time=HSequence.startTimeBin+iIndex-1;
400 raw.adc=((float)(
unsigned int)(HSequence.FirstAdc[iIndex]));
411 void StFtpcClusterDebug::drawvertex(TH1F *veast,TH1F *vwest, TH1F *v)
416 sprintf(dirname,
"vtx_%d",nevent);
417 vertexdir=topdir->mkdir(dirname);
420 vertex_west=(TH1F*) vwest->Clone();
421 vertex_east=(TH1F*) veast->Clone();
422 vertex_both=(TH1F*) v->Clone();
427 void StFtpcClusterDebug::fillclustertree(
TPeak *Peak,
TClusterUC *cl,Float_t charge, Int_t hsec, Int_t hrow, Float_t raderror, Float_t phierror, Int_t flag,
float getpressure,
int getnumpeaks)
434 hit.raderror=raderror;
435 hit.phierror=phierror;
436 cluster.timepos=Peak->TimePosition;
437 cluster.padpos=Peak->PadPosition;
438 if (Peak->TimeSigma<=10 && Peak->TimeSigma>=-10)
439 cluster.timesigma=Peak->TimeSigma;
440 if (Peak->PadSigma<=10 && Peak->PadSigma>=-10 )
441 cluster.padsigma=Peak->PadSigma;
442 cluster.peakheight=Peak->PeakHeight;
443 cluster.charge=charge;
444 cluster.timebin=Peak->Timebin;
445 cluster.pad=Peak->pad;
446 cluster.padlength=(cl->EndPad-cl->StartPad)+1;
447 cluster.timelength=Peak->Sequence.Length;
451 cluster.numpeaks=getnumpeaks;
458 void StFtpcClusterDebug::fillclustertree(
TPeak Peak,
TClusterUC *cl,Float_t charge, Int_t hsec, Int_t hrow, Float_t raderror, Float_t phierror,Int_t flag,
float getpressure,
int getnumpeaks)
465 hit.raderror=raderror;
466 hit.phierror=phierror;
467 cluster.timepos=Peak.TimePosition;
468 cluster.padpos=Peak.PadPosition;
469 cluster.timesigma=Peak.TimeSigma;
470 cluster.padsigma=Peak.PadSigma;
471 cluster.peakheight=Peak.PeakHeight;
472 cluster.charge=charge;
473 cluster.timebin=Peak.Timebin;
474 cluster.pad=Peak.pad;
475 cluster.padlength=(cl->EndPad-cl->StartPad)+1;
476 cluster.timelength=Peak.Sequence.Length;
480 cluster.numpeaks=getnumpeaks;
487 void StFtpcClusterDebug::clusteranalyse()
492 void StFtpcClusterDebug::fillgeanttree()
497 void StFtpcClusterDebug::filltracktree(TObjArray *foundtracks, Double_t vertexpos[3])
500 for (Int_t t_counter = 0; t_counter < foundtracks->GetEntriesFast(); t_counter++)
503 TObjArray *fhits = (TObjArray*) tracks->GetHits();
507 Double_t r1 = TMath::Sqrt(po1->GetX()*po1->GetX() + po1->GetY()*po1->GetY()),
508 r2 = TMath::Sqrt(po2->GetX()*po2->GetX() + po2->GetY()*po2->GetY());
509 Double_t r = TMath::Abs(r1-r2);
511 track.px=tracks->GetPx();
512 track.py=tracks->GetPy();
513 track.pz=tracks->GetPz();
514 track.eta=tracks->GetEta();
515 track.p=tracks->GetP();
516 track.pt=tracks->GetPt();
517 track.npoints=tracks->GetNumberOfPoints();
518 track.charge=tracks->GetCharge();
521 else if (r > 5. && r2<r1)
526 track.sec=po1->GetSector();
529 trevent.nevent=nevent;
531 mvertex.x=vertexpos[0];
532 mvertex.y=vertexpos[1];
533 mvertex.z=vertexpos[2];
536 for (Int_t h_counter = 0; h_counter < fhits->GetEntriesFast(); h_counter++)
540 tcluster.trow=mhit->GetPadRow();
541 tcluster.tsec=mhit->GetSector();
542 tcluster.tpadlength=mhit->GetNumberPads();
543 tcluster.ttimelength=mhit->GetNumberBins();
544 tcluster.tpeakheight=mhit->GetMaxADC();
546 tcluster.padpos=mhit->GetPadPos();
547 tcluster.timepos=mhit->GetTimePos();
548 tcluster.padpossigma=mhit->GetPadPosSigma();
549 tcluster.timepossigma=mhit->GetTimePosSigma();
551 thit.globResX=mhit->GetXGlobResidual();
552 thit.globResY=mhit->GetYGlobResidual();
553 thit.globResR=mhit->GetRGlobResidual();
554 thit.globResPhi=mhit->GetPhiGlobResidual();
556 thit.primResX=mhit->GetXPrimResidual();
557 thit.primResY=mhit->GetYPrimResidual();
558 thit.primResR=mhit->GetRPrimResidual();
559 thit.primResPhi=mhit->GetPhiPrimResidual();
561 tcluster.tcharge=mhit->GetCharge();
562 tcluster.ntracks=t_counter;
563 thit.tx=mhit->GetX();
564 thit.ty=mhit->GetY();
565 thit.tz=mhit->GetZ();
566 thit.ex=mhit->GetXerr();
567 thit.ey=mhit->GetYerr();
568 thit.ez=mhit->GetZerr();
570 tevent.nevent=nevent;