11 #include "StTpcHitMaker.h"
12 #include "StTpcRTSHitMaker.h"
14 #include "StTpcRawData.h"
15 #include "StEvent/StTpcRawData.h"
16 #include "StEvent/StTpcHit.h"
17 #include "StEvent/StEvent.h"
18 #include "StEvent/StTpcHitCollection.h"
19 #include "StThreeVectorF.hh"
20 #include "StTpcDb/StTpcDb.h"
21 #include "StDbUtilities/StCoordinates.hh"
22 #include "StDetectorDbMaker/St_tss_tssparC.h"
23 #include "StDetectorDbMaker/St_tpcPadGainT0BC.h"
24 #include "StDetectorDbMaker/St_tpcAnodeHVavgC.h"
25 #include "StDetectorDbMaker/St_tpcMaxHitsC.h"
26 #include "StDetectorDbMaker/StDetectorDbTpcRDOMasks.h"
27 #include "StDetectorDbMaker/St_tpcPadPlanesC.h"
28 #include "StDetectorDbMaker/St_itpcPadPlanesC.h"
29 #include "StDetectorDbMaker/St_tpcPadConfigC.h"
30 #include "StDetectorDbMaker/St_tpcStatusC.h"
31 #include "StDetectorDbMaker/StPath2tpxGain.h"
32 #include "StDetectorDbMaker/StPath2itpcGain.h"
33 #include "StDetectorDbMaker/St_tpcPadConfigC.h"
34 #include "StMessMgr.h"
35 #include "StDAQMaker/StDAQReader.h"
36 #include "StRtsTable.h"
37 #include "DAQ_TPX/daq_tpx.h"
38 #include "DAQ_ITPC/daq_itpc.h"
39 #include "DAQ_READER/daq_dta.h"
40 #include "DAQ_READER/daq_det.h"
41 #include "DAQ_READER/daqReader.h"
42 #include "RTS/src/DAQ_TPX/tpxFCF_flags.h"
43 #include "RTS/src/DAQ_TPX/daq_tpx.h"
44 #include "RTS/src/DAQ_TPX/tpxCore.h"
45 #include "RTS/src/DAQ_TPX/tpxPed.h"
46 #include "RTS/src/DAQ_TPX/tpxGain.h"
47 #include "RTS/src/DAQ_TPX/tpxFCF.h"
48 #include "RTS/src/DAQ_TPX/tpxStat.h"
49 #include "RTS/src/DAQ_ITPC/itpcFCF.h"
50 #include "RTS/src/DAQ_TPC23/tpc23_base.h"
51 #include "RTS/src/DAQ_TPC23/tpx23.h"
52 #include "RTS/src/DAQ_TPC23/itpc23.h"
53 #include "TBenchmark.h"
56 #include "TPolyMarker.h"
61 #define PrPP(A,B) if (Debug()%10 > 1) {LOG_INFO << "StTpcRTSHitMaker::" << (#A) << "\t" << (#B) << " = \t" << (B) << endm;}
67 StTpcRTSHitMaker::~StTpcRTSHitMaker() {
74 Int_t StTpcRTSHitMaker::Init() {
75 memset(maxHits,0,
sizeof(maxHits));
78 return StMaker::Init();
81 Int_t StTpcRTSHitMaker::from_file(
daq_dta *gain_dta,
const Char_t *fname) {
83 FILE *f = fopen(fname,
"r") ;
85 LOG_ERROR <<
"Can't open gain file\t" << fname << endm;
97 Int_t sec,rdo,port,ch,row,pad ;
100 if(fgets(buff,
sizeof(buff),f)==0) continue ;
102 if(buff[0]==
'#') continue ;
103 if(strlen(buff)<1) continue ;
105 Int_t ret = sscanf(buff,
"%d %d %d %d %d %d %f %f",&sec,&rdo,&port,&ch,&row,&pad,&g,&t) ;
106 if(ret != 8) continue ;
108 if(g<0.01) bad_ch++ ;
111 g_s[sec][row][pad].g = g ;
112 g_s[sec][row][pad].t = t ;
114 LOG_INFO << Form(
"From gain file %s: %d/%d bad channels",fname,bad_ch,all_ch) << endm;
117 for(Int_t s=1;s<=24;s++) {
118 for(Int_t r=1;r<=40;r++) {
120 for(Int_t p=0;p<=120;p++) {
121 gain[p].gain = g_s[s][r][p].g ;
122 gain[p].t0 = g_s[s][r][p].t ;
124 gain_dta->finalize(121,s,r) ;
130 Int_t StTpcRTSHitMaker::FixGains(
tpc23_base *tpc23, Int_t sec, Int_t row, Int_t Npads) {
134 for (Int_t pad = 1; pad <= Npads; pad++) {
135 Float_t g = rp_gain[sec-1][row][pad].gain;
140 if(p2>Npads) p2 = Npads ;
141 rp_gain[sec-1][row][pad].flags |= FCF_DEAD_EDGE ;
142 rp_gain[sec-1][row][p1].flags |= FCF_DEAD_EDGE ;
143 rp_gain[sec-1][row][p2].flags |= FCF_DEAD_EDGE ;
146 rp_gain[sec-1][row][1].flags |= FCF_ROW_EDGE ;
147 rp_gain[sec-1][row][Npads].flags |= FCF_ROW_EDGE ;
151 Int_t StTpcRTSHitMaker::InitRun(Int_t runnumber) {
152 SetAttr(
"minSector",1);
153 SetAttr(
"maxSector",24);
155 if (IAttr(
"Cosmics")) StTpcHitMaker::SetCosmics();
156 SetAttr(
"maxRow",St_tpcPadConfigC::instance()->numberOfRows(20));
161 TString fnameTPX(
"none");
162 TString fnameITPC(
"none");
163 if (IAttr(
"USE_GAIN_FROM_FILE")) {
164 fnameTPX = StPath2tpxGain::instance()->GetPath();
165 LOG_INFO <<
"StTpcRTSHitMaker::InitRun: use " << fnameTPX.Data() <<
" for TPX" << endm;
166 fnameITPC = StPath2itpcGain::instance()->GetPath();
167 LOG_INFO <<
"StTpcRTSHitMaker::InitRun: use " << fnameITPC.Data() <<
" for iTPC" << endm;
169 if ( IAttr(
"TPC23")) {
170 LOG_INFO <<
"StTpcRTSHitMaker::InitRun:: use TPC23 mode" << endm;
171 Int_t log_level = 0 ;
176 fTpx23->online = online ;
177 fTpx23->run_type = run_type ;
178 fTpx23->log_level = log_level ;
179 if (fTpx23->gains_from_cache(fnameTPX) < 0 || fnameTPX ==
"none") {
181 Int_t NoPadsWithLoadedGain = 0;
182 for(Int_t sector=1;sector<=24;sector++) {
184 if (St_tpcPadConfigC::instance()->iTPC(sector)) rowMin = 14;
185 for(Int_t rowO = 1; rowO < rowMin; rowO++) {
186 Int_t Npads = St_tpcPadPlanesC::instance()->padsPerRow(rowO);
187 for(Int_t pad = 0; pad <= Npads; pad++) {
188 fTpx23->rp_gain[sector-1][rowO][pad].gain = 0.;
189 fTpx23->rp_gain[sector-1][rowO][pad].t0 = -9.99;
190 fTpx23->rp_gain[sector-1][rowO][pad].flags = 64;
193 for(Int_t rowO = rowMin; rowO <= 45; rowO++) {
194 Int_t Npads = St_tpcPadPlanesC::instance()->padsPerRow(rowO);
196 Int_t padMax = Npads;
197 Int_t NoPadsWithLoadedGainPerRow = 0;
198 for(Int_t pad = 0; pad <= Npads; pad++) {
199 fTpx23->rp_gain[sector-1][rowO][pad].gain = 0.;
200 fTpx23->rp_gain[sector-1][rowO][pad].t0 = 0.;
201 if (rowO >= rowMin && pad >= padMin && pad <= padMax) {
202 if (St_tpcPadGainT0C::instance()->
Gain(sector,rowO,pad) <= 0)
continue;
203 fTpx23->rp_gain[sector-1][rowO][pad].gain = St_tpcPadGainT0C::instance()->Gain(sector,rowO,pad);
204 fTpx23->rp_gain[sector-1][rowO][pad].t0 = St_tpcPadGainT0C::instance()->T0(sector,rowO,pad);
205 NoPadsWithLoadedGainPerRow++;
208 if (NoPadsWithLoadedGainPerRow > 0) {
209 NoPadsWithLoadedGain += NoPadsWithLoadedGainPerRow;
210 FixGains(fTpx23, sector, rowO, Npads);
214 LOG_INFO <<
"StTpcRTSHitMaker::InitRun:: loaded gains for " << NoPadsWithLoadedGain <<
" pads in TPX23" << endm;
218 #ifdef __DEBUG_GAIN__
219 LOG_INFO <<
"StTpcRTSHitMaker::InitRun:: Print gains for Tpx23" << endm;
220 for(Int_t sector=1;sector<=24;sector++) {
221 for(Int_t rowO = 1; rowO <= 45; rowO++) {
222 Int_t Npads = St_tpcPadPlanesC::instance()->padsPerRow(rowO);
223 for(Int_t pad = 1; pad <= Npads; pad++) {
224 cout << Form(
"Gain/T0 s/r/p %3i/%3i/%3i %7.3f %7.3f %i",sector,rowO,pad,fTpx23->rp_gain[sector-1][rowO][pad].gain,fTpx23->rp_gain[sector-1][rowO][pad].t0,fTpx23->rp_gain[sector-1][rowO][pad].flags) << endl;
229 fTpx23->run_start() ;
232 fiTpc23->online = online ;
233 fiTpc23->run_type = run_type ;
234 fiTpc23->log_level = log_level ;
235 Int_t ok = fiTpc23->gains_from_cache(fnameITPC);
236 if (ok < 0 || fnameITPC ==
"none") {
237 Int_t NoPadsWithLoadedGain = 0;
238 for(Int_t sector=1;sector<=24;sector++) {
239 if (! St_tpcPadConfigC::instance()->iTPC(sector))
continue;
240 for(Int_t row = 1; row <= 40; row++) {
241 Int_t Npads = St_itpcPadPlanesC::instance()->padsPerRow(row);
242 Int_t NoPadsWithLoadedGainPerRow = 0;
243 for(Int_t pad = 0; pad <= Npads; pad++) {
244 fiTpc23->rp_gain[sector-1][row][pad].gain = 0.;
245 fiTpc23->rp_gain[sector-1][row][pad].t0 = 0.;
246 if (pad < 1)
continue;
247 if (St_itpcPadGainT0C::instance()->
Gain(sector,row,pad) <= 0)
continue;
248 fiTpc23->rp_gain[sector-1][row][pad].gain = St_itpcPadGainT0C::instance()->Gain(sector,row,pad);
249 fiTpc23->rp_gain[sector-1][row][pad].t0 = St_itpcPadGainT0C::instance()->T0(sector,row,pad);
251 NoPadsWithLoadedGainPerRow++;
253 if (NoPadsWithLoadedGainPerRow > 0) {
254 NoPadsWithLoadedGain += NoPadsWithLoadedGainPerRow;
255 FixGains(fiTpc23, sector, row, Npads);
259 LOG_INFO <<
"StTpcRTSHitMaker::InitRun:: loaded gains for " << NoPadsWithLoadedGain <<
" pads in iTPC23" << endm;
261 #ifdef __DEBUG_GAIN__
262 LOG_INFO <<
"StTpcRTSHitMaker::InitRun:: Print gains for iTpc23" << endm;
263 for(Int_t sector=1;sector<=24;sector++) {
264 for(Int_t row = 1; row <= 40; row++) {
265 Int_t Npads = St_itpcPadPlanesC::instance()->padsPerRow(row);
266 for(Int_t pad = 1; pad <= Npads; pad++) {
267 cout << Form(
"Gain/T0 s/r/p %3i/%3i/%3i %7.3f %7.3f %i",sector,row,pad,fiTpc23->rp_gain[sector-1][row][pad].gain,fiTpc23->rp_gain[sector-1][row][pad].t0,fiTpc23->rp_gain[sector-1][row][pad].flags) << endl;
272 fiTpc23->run_start() ;
275 if (GetDate() >= 20091215) fTpx->fcf_run_compatibility = 10 ;
276 if (GetDate() >= 20191215) fTpx->fcf_run_compatibility = 22 ;
278 fTpx->fcf_do_cuts = 1;
280 if (GetDate() <= 20090101) fminCharge = 40;
283 tpxGain *gain = fTpx->gain_algo;
285 Int_t ok = gain->from_file(fnameTPX, 0);
286 if (ok < 0 &&fnameTPX ==
"none") {
287 for(Int_t sector=1;sector<=24;sector++) {
290 if (St_tpcPadConfigC::instance()->iTPC(sector)) rowMin = 14;
291 for(Int_t rowO = 1; rowO <= 45; rowO++) {
292 Int_t Npads = St_tpcPadPlanesC::instance()->padsPerRow(rowO);
294 Int_t padMax = Npads;
296 for(Int_t pad = 0; pad <= Npads; pad++) {
299 gain->set_gains(sector, rowO, pad, 0, 0);
300 if (rowO >= rowMin && pad >= padMin && pad <= padMax) {
301 if (St_tpcPadGainT0C::instance()->
Gain(sector,rowO,pad) <= 0)
continue;
304 gain->set_gains(sector, rowO, pad, St_tpcPadGainT0C::instance()->
Gain(sector,rowO,pad), St_tpcPadGainT0C::instance()->T0(sector,rowO,pad));
314 static Bool_t fNoiTPCLu = IAttr(
"NoiTPCLu");
316 for(Int_t sector=1;sector<=24;sector++) {
317 if (St_tpcPadConfigC::instance()->iTPC(sector)) {
325 daq_dta * dta_iTpc = fiTpc->put(
"gain");
326 Int_t ok = from_file(dta_iTpc, fnameITPC);
327 if (ok < 0 || fnameITPC ==
"none") {
328 for(Int_t sector=1;sector<=24;sector++) {
329 if (! St_tpcPadConfigC::instance()->iTPC(sector))
continue;
330 for(Int_t row = 1; row <= 40; row++) {
331 Int_t Npads = St_itpcPadPlanesC::instance()->padsPerRow(row);
333 for(Int_t pad = 0; pad <= Npads; pad++) {
336 if (pad < 1)
continue;
337 if (St_itpcPadGainT0C::instance()->
Gain(sector,row,pad) <= 0)
continue;
338 gain[pad].gain = St_itpcPadGainT0C::instance()->Gain(sector,row,pad);
339 gain[pad].t0 = St_itpcPadGainT0C::instance()->T0(sector,row,pad);
341 #ifdef __DEBUG_GAIN__
342 cout << Form(
"Gain/T0 s/r/p %3i/%3i/%3i %7.2f %7.2f",sector,row,pad,gain[pad].gain,gain[pad].t0) << endl;
346 dta_iTpc->finalize(Npads+1,sector,row);
360 Int_t maxHitsPerSector = St_tpcMaxHitsC::instance()->maxSectorHits();
361 Int_t maxBinZeroHits = St_tpcMaxHitsC::instance()->maxBinZeroHits();
362 if ( !(maxHitsPerSector > 0 || maxBinZeroHits > 0) )
return kStOK;
365 Float_t liveFrac = 1;
366 for(Int_t sector=1;sector<=24;sector++) {
367 Int_t liveSecPads = 0;
368 Int_t totalSecPads = 0;
372 if (St_tpcPadConfigC::instance()->iTPC(sector)) rowMin = 14;
373 for(Int_t row = rowMin; row <= 45; row++) {
374 Int_t Npads = St_tpcPadPlanesC::instance()->padsPerRow(row);
375 totalSecPads += Npads;
376 if (StDetectorDbTpcRDOMasks::instance()->isRowOn(sector,row) &&
377 St_tpcAnodeHVavgC::instance()->livePadrow(sector,row))
378 liveSecPads += Npads;
382 if (St_tpcPadConfigC::instance()->iTPC(sector)) {
383 for(Int_t row = 1; row <= 40; row++) {
384 Int_t Npads = St_itpcPadPlanesC::instance()->padsPerRow(row);
385 totalSecPads += Npads;
386 if (StDetectorDbTpcRDOMasks::instance()->isRowOn(sector,row) &&
387 St_tpcAnodeHVavgC::instance()->livePadrow(sector,row))
388 liveSecPads += Npads;
392 livePads += liveSecPads;
393 totalPads += totalSecPads;
394 if (maxHitsPerSector > 0) {
395 liveFrac = TMath::Max(0.1f, ((Float_t) liveSecPads) / (1e-15f + (Float_t) totalSecPads));
396 maxHits[sector-1] = (Int_t) (liveFrac * maxHitsPerSector);
397 if (Debug()) {LOG_INFO <<
"maxHits in sector " << sector <<
" = " << maxHits[sector-1] << endm;}
399 maxHits[sector-1] = 0;
400 if (Debug()) {LOG_INFO <<
"No maxHits in sector " << sector << endm;}
403 if (maxBinZeroHits > 0) {
404 liveFrac = TMath::Max(0.1f, ((Float_t) livePads) / (1e-15f + (Float_t) totalPads));
405 maxBin0Hits = (Int_t) (liveFrac * maxBinZeroHits);
406 if (Debug()) {LOG_INFO <<
"maxBinZeroHits " << maxBin0Hits << endm;}
409 if (Debug()) {LOG_INFO <<
"No maxBinZeroHits" << endm;}
417 void StTpcRTSHitMaker::PrintCld(
daq_cld *cld, Int_t IdTruth, Int_t quality) {
419 LOG_INFO << Form(
" pad %f[%d:%d], tb %f[%d:%d], cha %d, fla 0x%X, Id %d, Q %d ",
434 void StTpcRTSHitMaker::PrintAdc(
daq_dta *dta) {
437 Int_t sectorOld = -1;
440 while(dta && dta->iterate()) {
441 if (sectorOld != dta->sec || rowOld != dta->row) {
443 LOG_INFO << Form(
"*** sec %2d, row %2d, Sum adc = %d",sectorOld,rowOld,adcSum) << endm;
445 sectorOld = dta->sec;
449 if (Debug() > 1) {LOG_INFO << Form(
"*** sec %2d, row %2d, pad %3d: %3d pixels",dta->sec,dta->row,dta->pad,dta->ncontent) << endm;}
450 for(UInt_t i=0;i<dta->ncontent;i++) {
452 LOG_INFO << Form(
" %2d: adc %4d, tb %3d: track %4d",i,
455 dta->sim_adc[i].track_id
458 adcSum += dta->sim_adc[i].adc;
462 LOG_INFO << Form(
"*** sec %2d, row %2d, Sum adc = %d",sectorOld,rowOld,adcSum) << endm;
469 TBenchmark *myBenchmark =
new TBenchmark();
470 myBenchmark->Reset();
473 if (St_tpcStatusC::instance()->isDead()) {
474 LOG_WARN <<
"TPC status indicates it is unusable for this event. Ignoring hits." << endm;
477 if (IAttr(
"TPC23"))
return Make23();
478 static Short_t ADCs[__MaxNumberOfTimeBins__];
479 #ifdef __TFG__VERSION__
480 static Int_t IDTs[__MaxNumberOfTimeBins__];
482 static UShort_t IDTs[__MaxNumberOfTimeBins__];
488 LOG_WARN <<
"There is no StEvent" << endm;
492 if (! hitCollection ) {
494 rEvent->setTpcHitCollection(hitCollection);
496 TDataSet* tpcRawEvent = GetInputDS(
"Event");
498 LOG_WARN <<
"There is not Tpc Raw Event" << endm;
504 LOG_WARN <<
"There is not Tpc Raw Data" << endm;
509 static Int_t minSector = IAttr(
"minSector");
510 static Int_t maxSector = IAttr(
"maxSector");
511 static Int_t minRow = IAttr(
"minRow");
512 static Int_t maxRow = IAttr(
"maxRow");
513 StMaker* maskMk = GetMakerInheritsFrom(
"StMtdTrackingMaskMaker");
514 UInt_t mask = (maskMk ? maskMk->UAttr(
"TpcSectorsByMtd") : ~0U);
516 for (Int_t sector = minSector; sector <= maxSector; sector++) {
518 if (! digitalSector)
continue;
519 if (!((1U<<(sector-1)) & mask))
continue;
522 for (Int_t iTpcType = 1; iTpcType >= 0; iTpcType--) {
527 if (St_tpcPadConfigC::instance()->iTPC(sector)) {
533 row1 = TMath::Max(row1, 41);
534 if (fTpx) dta = fTpx->put(
"adc_sim");
536 row2 = TMath::Min(40, row2);
537 if (fiTpc) dta = fiTpc->put(
"adc_sim");
540 row2 = TMath::Min(45, row2);
541 if (fTpx) dta = fTpx->put(
"adc_sim");
545 for (Int_t row = row1; row <= row2; row++) {
546 if (! St_tpcPadGainT0BC::instance()->livePadrow(sector,row))
continue;
547 Int_t Npads = digitalSector->numberOfPadsInRow(row);
551 if (St_tpcPadConfigC::instance()->iTPC(sector) && row > 40) {
552 rowO = row - 40 + 13;
555 for(Int_t pad = 1; pad <= Npads; pad++) {
556 UInt_t ntimebins = digitalSector->numberOfTimeBins(row,pad);
557 if (! ntimebins)
continue;
561 digitalSector->getTimeAdc(row,pad,ADCs,IDTs);
563 for (UInt_t k = 0; k < __MaxNumberOfTimeBins__; k++) {
567 d[l].track_id = IDTs[k];
576 dta->finalize(l,sector,rowO,pad);
584 if (! NoAdcs)
continue;
587 if (fTpx) dtaX = fTpx->get(
"adc_sim");
589 if (fiTpc) dtaX = fiTpc->get(
"adc_sim");
597 if (! fTpx)
continue;
598 if (IAttr(
"TpxClu2D")) {
599 dtaX = fTpx->get(
"cld_2d_sim");
601 dtaX = fTpx->get(
"cld_sim");;
604 if (! fiTpc)
continue;
605 dtaX = fiTpc->get(
"cld_sim");
607 if (! dtaX)
continue;
609 #ifndef __TFG__VERSION__
610 Double_t ADC2GeV = 0;
613 static Int_t iBreak = 0;
614 while(dd && dd->iterate()) {
616 LOG_INFO << Form(
"CLD sec %2d: row %2d: %d clusters",dd->sec, dd->row, dd->ncontent) << endm;
618 for(UInt_t i=0;i<dd->ncontent;i++) {
621 UShort_t quality = 0;
625 IdTruth = dc.track_id;
626 quality = dc.quality;
630 IdTruth = dc_x.track_id;
631 quality = dc_x.quality;
634 PrintCld(&cld, IdTruth, quality);
637 if (cld.p1 > cld.p2)
continue;
638 if (cld.t1 > cld.t2)
continue;
639 if (cld.tb >= __MaxNumberOfTimeBins__)
continue;
640 if (cld.charge < fminCharge)
continue;
641 if ( ! (cld.pad > 0 && cld.pad <= 182 &&
642 cld.tb >= 0 && cld.tb < 512))
continue;
652 if ( cld.flags && (cld.flags & ~(FCF_ONEPAD | FCF_MERGED | FCF_BIG_CHARGE)))
continue;
653 Int_t rowO = dd->row;
655 if (! iTpcType && St_tpcPadConfigC::instance()->iTPC(sector) && rowO > 13) padrow = rowO + 40 - 13;
657 Float_t pad = cld.pad;
658 Int_t iRdo = StDetectorDbTpcRDOMasks::instance()->rdoForPadrow(sector,row,pad);
659 if ( ! StDetectorDbTpcRDOMasks::instance()->isOn(sector,iRdo))
continue;
664 transform(Pad,LS,kFALSE,kTRUE); PrPP(
Make,LS);
665 transform(LS,L); PrPP(
Make,L);
670 #ifndef __TFG__VERSION__
671 if (padrow != rowOld) {
673 Double_t gain = St_tpcPadConfigC::instance()->IsRowInner(dd->sec,padrow) ?
674 St_tss_tssparC::instance()->gain_in() :
675 St_tss_tssparC::instance()->gain_out();
676 Double_t wire_coupling = St_tpcPadConfigC::instance()->IsRowInner(dd->sec,padrow) ?
677 St_tss_tssparC::instance()->wire_coupling_in() :
678 St_tss_tssparC::instance()->wire_coupling_out();
679 ADC2GeV = ((Double_t) St_tss_tssparC::instance()->ave_ion_pot() *
680 (Double_t) St_tss_tssparC::instance()->scale())/(gain*wire_coupling) ;
682 Double_t q = ADC2GeV*cld.charge;
687 StTpcHit *
hit = StTpcHitMaker::StTpcHitFlag(L.position(),hard_coded_errors,hw,q
702 if (hit->minTmbk() == 0) bin0Hits++;
703 if (Debug() > 1) hit->Print();
704 hitCollection->addHit(hit);
705 if (Debug() > 1) {cout <<
"Add hit #" << hitCollection->numberOfHits() << endl;}
709 if (maxHits[sector-1] && hitsAdded > maxHits[sector-1]) {
710 LOG_ERROR <<
"Too many hits (" << hitsAdded <<
") in one sector ("
711 << sector <<
"). Skipping event." << endm;
715 if (maxBin0Hits && bin0Hits > maxBin0Hits) {
716 LOG_ERROR <<
"Too many hits (" << bin0Hits
717 <<
") starting at time bin 0. Skipping event." << endm;
720 if (! IAttr(
"NoTpxAfterBurner")) StTpcHitMaker::AfterBurner(hitCollection);
722 myBenchmark->Stop(
"StTpcRTSHitMaker::Make");
723 myBenchmark->Show(
"StTpcRTSHitMaker::Make");
724 myBenchmark->Show(
"StTpcRTSHitMaker::Make::finalize");
730 Int_t StTpcRTSHitMaker::Make23() {
731 if (! fTpx23 && ! fiTpc23)
return kStErr;
733 TBenchmark *myBenchmark =
new TBenchmark();
734 myBenchmark->Reset();
737 if (St_tpcStatusC::instance()->isDead()) {
738 LOG_WARN <<
"TPC status indicates it is unusable for this event. Ignoring hits." << endm;
741 static Short_t ADCs[__MaxNumberOfTimeBins__];
742 #ifdef __TFG__VERSION__
743 static Int_t IDTs[__MaxNumberOfTimeBins__];
745 static UShort_t IDTs[__MaxNumberOfTimeBins__];
751 LOG_WARN <<
"There is no StEvent" << endm;
755 if (! hitCollection ) {
757 rEvent->setTpcHitCollection(hitCollection);
759 TDataSet* tpcRawEvent = GetInputDS(
"Event");
761 LOG_WARN <<
"There is not Tpc Raw Event" << endm;
767 LOG_WARN <<
"There is not Tpc Raw Data" << endm;
772 static Int_t minSector = IAttr(
"minSector");
773 static Int_t maxSector = IAttr(
"maxSector");
774 static Int_t minRow = IAttr(
"minRow");
775 static Int_t maxRow = IAttr(
"maxRow");
777 for (Int_t sector = minSector; sector <= maxSector; sector++) {
779 if (! digitalSector)
continue;
783 for (Int_t iTpcType = 1; iTpcType >= 0; iTpcType--) {
788 if (St_tpcPadConfigC::instance()->iTPC(sector)) {
794 row1 = TMath::Max(row1, 41);
797 row2 = TMath::Min(40, row2);
801 row2 = TMath::Min(45, row2);
804 if (! tpc23)
continue;
805 #ifndef __TFG__VERSION__
806 Double_t ADC2GeV = 0;
809 for (Int_t row = row1; row <= row2; row++) {
810 if (! St_tpcPadGainT0BC::instance()->livePadrow(sector,row))
continue;
811 tpc23->sim_evt_start(sector) ;
813 Int_t Npads = digitalSector->numberOfPadsInRow(row);
817 if (St_tpcPadConfigC::instance()->iTPC(sector) && row > 40) {
818 rowO = row - 40 + 13;
821 for(Int_t pad = 1; pad <= Npads; pad++) {
822 UInt_t ntimebins = digitalSector->numberOfTimeBins(row,pad);
823 if (! ntimebins)
continue;
827 digitalSector->getTimeAdc(row,pad,ADCs,IDTs);
829 static UShort_t adcs[__MaxNumberOfTimeBins__];
830 memset(adcs, 0,
sizeof(adcs));
831 static Int_t idts[__MaxNumberOfTimeBins__];
832 memset(idts, 0,
sizeof(idts));
833 for (UInt_t k = 0; k < __MaxNumberOfTimeBins__; k++) {
843 tpc23->do_ch_sim(padrow,pad,adcs,idts) ;
853 const Int_t words_per_cluster = 5 ;
855 tpc23->s2_max_words = tpc23->sequence_cou*words_per_cluster + 2000 ;
857 tpc23->s2_start = (UInt_t *) malloc(tpc23->s2_max_words*4) ;
863 if(tpc23->s2_words) {
864 UInt_t *p_buff = tpc23->s2_start ;
865 UInt_t *end_buff = p_buff + tpc23->s2_words ;
867 cout << Form(
"*** sequences found %d",tpc23->sequence_cou) << endl ;
870 if(tpc23->s2_words >= tpc23->s2_max_words) {
871 LOG_ERROR <<
"Whoa -- lots of words " << tpc23->s2_words <<
"/" << tpc23->s2_max_words <<
"\t"
872 <<
"\tsector " << sector <<
"\trow " << row << endm;
875 while(p_buff < end_buff) {
879 Int_t ints_per_cluster ;
881 if(tpc23 == fTpx23) {
883 int_cou = *p_buff++ ;
885 version = (padrow>>16) ;
887 ints_per_cluster = fTpx23 -> online? 2 : 5;
891 version = *p_buff++ ;
892 int_cou = *p_buff++ ;
894 ints_per_cluster = (padrow>>16) ;
900 Int_t clusters = int_cou / ints_per_cluster ;
902 for(Int_t i=0;i<clusters;i++) {
904 tpc23->fcf_decode(p_buff,&dc,version) ;
910 if(dc.cld.flags & FCF_ONEPAD) strcat(c_flags,
"one+") ;
911 if(dc.cld.flags & FCF_MERGED) strcat(c_flags,
"merge+") ;
912 if(dc.cld.flags & FCF_DEAD_EDGE) strcat(c_flags,
"dead+") ;
913 if(dc.cld.flags & FCF_ROW_EDGE) strcat(c_flags,
"edge+") ;
if(dc.cld.flags & FCF_ONEPAD) strcat(c_flags,
" one") ;
914 if(dc.cld.flags & FCF_BROKEN_EDGE) strcat(c_flags,
"small+") ;
915 if(dc.cld.flags & FCF_BIG_CHARGE) strcat(c_flags,
"charge+") ;
917 if(strlen(c_flags)) {
918 c_flags[strlen(c_flags)-1] = 0 ;
921 cout << Form(
"row %d/%d: %f %d %d %f %d %d %d 0x%02X[%s]",row,rowO,
922 dc.cld.pad,dc.cld.p1,dc.cld.p2,
923 dc.cld.tb,dc.cld.t1,dc.cld.t2,
925 dc.cld.flags,c_flags) << endl;
926 cout << Form(
" track_id %u, quality %d, pixels %d, max_adc %d",
930 dc.max_adc) << endl;;
933 p_buff += ints_per_cluster ;
935 Int_t IdTruth = dc.reserved[0];
936 UShort_t quality = dc.quality;
938 if (dc.cld.p1 > dc.cld.p2)
continue;
939 if (dc.cld.t1 > dc.cld.t2)
continue;
940 if (dc.cld.tb >= __MaxNumberOfTimeBins__)
continue;
941 if (dc.cld.charge < fminCharge)
continue;
942 if ( ! (dc.cld.pad > 0 && dc.cld.pad <= 182 &&
943 dc.cld.tb >= 0 && dc.cld.tb < 512))
continue;
953 if ( dc.cld.flags && (dc.cld.flags & ~(FCF_ONEPAD | FCF_MERGED | FCF_BIG_CHARGE)))
continue;
954 Float_t pad = dc.cld.pad;
955 Int_t iRdo = StDetectorDbTpcRDOMasks::instance()->rdoForPadrow(sector,row,pad);
956 if ( ! StDetectorDbTpcRDOMasks::instance()->isOn(sector,iRdo))
continue;
961 transform(
Pad,LS,kFALSE,kTRUE); PrPP(
Make,LS);
962 transform(LS,L); PrPP(
Make,L);
967 #ifndef __TFG__VERSION__
970 Double_t gain = St_tpcPadConfigC::instance()->IsRowInner(sector,row) ?
971 St_tss_tssparC::instance()->gain_in() :
972 St_tss_tssparC::instance()->gain_out();
973 Double_t wire_coupling = St_tpcPadConfigC::instance()->IsRowInner(sector,row) ?
974 St_tss_tssparC::instance()->wire_coupling_in() :
975 St_tss_tssparC::instance()->wire_coupling_out();
976 ADC2GeV = ((Double_t) St_tss_tssparC::instance()->ave_ion_pot() *
977 (Double_t) St_tss_tssparC::instance()->scale())/(gain*wire_coupling) ;
979 Double_t q = ADC2GeV*dc.cld.charge;
984 StTpcHit *
hit = StTpcHitMaker::StTpcHitFlag(L.position(),hard_coded_errors,hw,q
999 if (hit->minTmbk() == 0) bin0Hits++;
1000 if (Debug() > 1) hit->Print();
1001 hitCollection->addHit(hit);
1002 if (Debug() > 1) {cout <<
"Add hit #" << hitCollection->numberOfHits() << endl;}
1008 free(tpc23->s2_start) ;
1009 tpc23->s2_start = 0 ;
1021 if (! IAttr(
"NoTpxAfterBurner")) StTpcHitMaker::AfterBurner(hitCollection);
1022 #ifdef __BENCHMARK__
1023 myBenchmark->Stop(
"StTpcRTSHitMaker::Make");
1024 myBenchmark->Show(
"StTpcRTSHitMaker::Make");
1025 myBenchmark->Show(
"StTpcRTSHitMaker::Make::finalize");
1031 TH2F *StTpcRTSHitMaker::PlotSecRow(Int_t sec, Int_t row, Int_t flags) {
1038 StEvent* pEvent = (
StEvent*) StMaker::GetChain()->GetInputDS(
"StEvent");
1039 if (!pEvent) { cout <<
"Can't find StEvent" << endl;
return plot;}
1041 if (! TpcHitCollection) { cout <<
"No TPC Hit Collection" << endl;
return plot;}
1043 if (! sectorCollection) { cout <<
"No TPC Hit Collection for sector " << sec << endl;
return plot;}
1045 if (! rowCollection) { cout <<
"No TPC Hit Collection for sector " << sec <<
" and row " << row << endl;
return plot;}
1046 TFile *f = StMaker::GetChain()->GetTFile();
1047 if (! f) {cout <<
"No TFile is opened" << endl;
return plot;}
1049 TString PlotName(Form(
"s%02ir%03i",sec,row));
1050 plot = (TH2F *) f->Get(PlotName);
1053 plot->SetTitle(Form(
"ADC versus pad and time buckets for sec = %i and row = %i in event %i",sec,row, pEvent->id()));
1055 Int_t npad = St_tpcPadConfigC::instance()->padsPerRow(sec,row);
1056 plot =
new TH2F(PlotName,Form(
"ADC versus pad and time buckets for sec = %i and row = %i in event %i",sec,row, pEvent->id()), 360,-0.5,359.5,npad,0.5,npad+0.5);
1059 TDataSet* tpcRawEvent = StMaker::GetChain()->GetInputDS(
"Event");
1060 if (! tpcRawEvent) {
1061 LOG_WARN <<
"There is not Tpc Raw Event" << endm;
1065 LOG_WARN <<
"There is not Tpc Raw Data" << endm;
1068 if (! digitalSector) {
1069 LOG_WARN <<
"There is not digital sector" << sec << endm;
1071 Int_t Npads = digitalSector->numberOfPadsInRow(row);
1072 for(Int_t pad = 1; pad <= Npads; pad++) {
1073 static Short_t ADCs[__MaxNumberOfTimeBins__];
1074 #ifdef __TFG__VERSION__
1075 static Int_t IDTs[__MaxNumberOfTimeBins__];
1077 static UShort_t IDTs[__MaxNumberOfTimeBins__];
1079 digitalSector->getTimeAdc(row,pad,ADCs,IDTs);
1080 for (UInt_t k = 0; k < __MaxNumberOfTimeBins__; k++) {
1081 if (ADCs[k]) plot->Fill(k,pad,ADCs[k]);
1087 StSPtrVecTpcHit &hits = rowCollection->hits();
1088 Long_t NoHits = hits.size();
1089 for (Long64_t k = 0; k < NoHits; k++) {
1093 Double_t offset = 0.0;
1094 Int_t flag = tpcHit->flag();
1095 if (flag & 256) {color = 2; style = 29; offset = 0.1; flag &= ~0x100;}
1096 if (flags > -1 && flag < flags)
continue;
1097 Double_t tb = tpcHit->timeBucket();
1098 Double_t pad = tpcHit->pad();
1099 TPolyMarker *pm =
new TPolyMarker(1,&tb, &pad);
1100 pm->SetMarkerStyle(style);
1101 pm->SetMarkerColor(color);
1102 pm->SetMarkerSize(2);
1103 plot->GetListOfFunctions()->Add(pm);
1104 TBox *box =
new TBox(tpcHit->minTmbk()-0.5 + offset,tpcHit->minPad()-0.5 + offset, tpcHit->maxTmbk()+0.5 + offset,tpcHit->maxPad()+0.5 + offset);
1105 box->SetLineWidth(4);
1106 box->SetLineColor(color);
1107 box->SetFillStyle(0);
1108 box->SetFillColor(0);
1109 plot->GetListOfFunctions()->Add(box);
void version(std::ostream &os=std::cout)
print HepMC version
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)