55 #include "StETofCollection.h"
56 #include "StETofDigi.h"
57 #include "StETofHit.h"
59 #include "StBTofCollection.h"
60 #include "StBTofHeader.h"
61 #include "StBTofHit.h"
63 #include "StEpdCollection.h"
66 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
67 #include "StMuDSTMaker/COMMON/StMuDst.h"
68 #include "StMuDSTMaker/COMMON/StMuETofDigi.h"
69 #include "StMuDSTMaker/COMMON/StMuETofHit.h"
70 #include "StMuDSTMaker/COMMON/StMuBTofHit.h"
71 #include "StMuDSTMaker/COMMON/StMuEpdHit.h"
72 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
74 #include "StChain/StChainOpt.h"
76 #include "StETofHitMaker.h"
77 #include "StETofUtil/StETofConstants.h"
78 #include "StETofUtil/StETofGeometry.h"
80 #include "tables/St_etofHitParam_Table.h"
81 #include "tables/St_etofSignalVelocity_Table.h"
82 #include "tables/St_etofModCounter_Table.h"
84 #include "StarClassLibrary/SystemOfUnits.h"
85 #include "StarClassLibrary/PhysicalConstants.h"
86 #include "StBTofUtil/tofPathLength.hh"
90 StETofHitMaker::StETofHitMaker(
const char* name )
95 mFileNameHitParam(
"" ),
96 mFileNameSignalVelocity(
"" ),
97 mFileNameModMatrix(
"" ),
98 mFileNameAlignParam(
"" ),
102 mMapHitDigiIndices(),
103 mMapHitIndexDigiIndices(),
105 mMergingRadius( 1. ),
107 mSoftwareDeadTime( 150. ),
108 mDoClockJumpShift( true ),
109 mDoDoubleClockJumpShift( true ),
110 mClockJumpDirection(),
112 mGet4doublejumpTmin(-1.0),
113 mGet4doublejumpFlag(),
114 mGet4doublejumpTimes(),
123 LOG_DEBUG <<
"StETofHitMaker::ctor" << endm;
127 StETofHitMaker::~StETofHitMaker()
134 StETofHitMaker::Init()
136 LOG_INFO <<
"StETofHitMaker::Init()" << endm;
145 StETofHitMaker::InitRun( Int_t runnumber )
147 LOG_INFO <<
"StETofHitMaker::InitRun()" << endm;
150 std::ifstream paramFile;
159 if( mFileNameHitParam.empty() ) {
160 LOG_INFO <<
"etofHitParam: no filename provided --> load database table" << endm;
162 dbDataSet = GetDataBase(
"Calibrations/etof/etofHitParam" );
164 St_etofHitParam* etofHitParam =
static_cast< St_etofHitParam*
> ( dbDataSet->
Find(
"etofHitParam" ) );
165 if( !etofHitParam ) {
166 LOG_ERROR <<
"unable to get the hit params from the database" << endm;
170 etofHitParam_st* hitParamTable = etofHitParam->GetTable();
172 mMaxYPos = hitParamTable->maxLocalY;
173 mMergingRadius = hitParamTable->clusterMergeRadius;
176 LOG_INFO <<
"etofHitParam: filename provided --> use parameter file: " << mFileNameHitParam.c_str() << endm;
178 paramFile.open( mFileNameHitParam.c_str() );
180 if( !paramFile.is_open() ) {
181 LOG_ERROR <<
"unable to get the 'etofHitParam' parameters from file --> file does not exist" << endm;
187 if( paramFile.good() ) {
188 paramFile >> temp1 >> temp2;
197 mMergingRadius = temp2;
201 LOG_INFO <<
" maximum local Y: " << mMaxYPos <<
" , cluster merging radius: " << mMergingRadius << endm;
208 if( mFileNameSignalVelocity.empty() ) {
209 LOG_INFO <<
"etofSignalVelocity: no filename provided --> load database table" << endm;
211 dbDataSet = GetDataBase(
"Calibrations/etof/etofSignalVelocity" );
213 St_etofSignalVelocity* etofSignalVelocity =
static_cast< St_etofSignalVelocity*
> ( dbDataSet->
Find(
"etofSignalVelocity" ) );
216 if( !etofSignalVelocity ) {
217 LOG_ERROR <<
"unable to get the signal velocity from the database" << endm;
221 etofSignalVelocity_st* velocityTable = etofSignalVelocity->GetTable();
223 for(
size_t i=0; i<eTofConst::nCountersInSystem; i++ ) {
224 if( velocityTable->signalVelocity[ i ] > 0 ) {
225 mSigVel[ detectorToKey( i ) ] = velocityTable->signalVelocity[ i ];
230 LOG_INFO <<
"etofSignalVelocity: filename provided --> use parameter file: " << mFileNameSignalVelocity.c_str() << endm;
232 paramFile.open( mFileNameSignalVelocity.c_str() );
234 if( !paramFile.is_open() ) {
235 LOG_ERROR <<
"unable to get the 'etofSignalVelocity' parameters from file --> file does not exist" << endm;
239 std::vector< float > velocity;
241 while( paramFile >> temp ) {
242 velocity.push_back( temp );
247 if( velocity.size() != eTofConst::nCountersInSystem ) {
248 LOG_ERROR <<
"parameter file for 'etofSignalVelocity' has not the right amount of entries: ";
249 LOG_ERROR << velocity.size() <<
" instead of " << eTofConst::nCountersInSystem <<
" !!!!" << endm;
253 for(
size_t i=0; i<eTofConst::nCountersInSystem; i++ ) {
254 if( velocity.at( i ) > 0 ) {
255 mSigVel[ detectorToKey( i ) ] = velocity.at( i );
260 for(
const auto& kv : mSigVel ) {
261 LOG_INFO <<
"counter key: " << kv.first <<
" --> signal velocity = " << kv.second <<
" cm / ns" << endm;
268 if(!mFileNameModMatrix.empty()){
270 LOG_INFO <<
"etofModMatrix: filename provided --> use parameter file: " << mFileNameSignalVelocity.c_str() << endm;
272 paramFile.open( mFileNameModMatrix.c_str() );
274 if( !paramFile.is_open() ) {
275 LOG_ERROR <<
"unable to get the 'etofModMatrix' parameters from file --> file does not exist" << endm;
279 std::vector< int > modMatrix;
281 while( paramFile >> temp ) {
282 modMatrix.push_back( temp );
288 if( modMatrix.size() != eTofConst::nCountersInSystem ) {
289 LOG_ERROR <<
"parameter file for 'etofModMatrix' has not the right amount of entries: ";
290 LOG_ERROR << modMatrix.size() <<
" instead of " << eTofConst::nCountersInSystem <<
" !!!!" << endm;
294 for(
size_t i=0; i<eTofConst::nCountersInSystem; i++ ) {
295 if( modMatrix.at( i ) > 0 ) {
296 mModMatrix[ detectorToKey( i ) ] = modMatrix.at( i );
302 dbDataSet = GetDataBase(
"Geometry/etof/etofModCounter" );
306 LOG_ERROR <<
"unable to get the dataset from the database" << endm;
310 St_etofModCounter* etofModCounter =
static_cast< St_etofModCounter*
> ( dbDataSet->
Find(
"etofModCounter") );
312 if( !etofModCounter ) {
313 LOG_WARN <<
"unable to get the ModMap from the database" << endm;
318 etofModCounter_st* ModCounterTable = etofModCounter->GetTable();
320 for(
size_t i=0; i<eTofConst::nCountersInSystem; i++ ) {
321 mModMatrix[ detectorToKey( i ) ] = ModCounterTable->detectorModFlag[ i ];
327 for(
int i=0; i<eTofConst::nCountersInSystem * 8; i++ ) {
328 int key = detectorToKey( i / 8 ) * 10 + ( i % 8 ) + 1;
329 mClockJumpDirection[ key ] = -1;
331 LOG_DEBUG << key <<
" " << mClockJumpDirection.at( key ) << endm;
333 mGet4doublejumpFlag[ key ] = 0;
335 for(
int k=0; k<3; k++){
336 mGet4doublejumpTimes[key].push_back(-999);
341 for(
int i=0; i<eTofConst::nCountersInSystem; i++ ) {
342 mCounterActive.push_back(
false );
349 LOG_INFO <<
" creating a new eTOF geometry . . . " << endm;
350 mETofGeom =
new StETofGeometry(
"etofGeometry",
"etofGeometry in HitMaker" );
353 if( mETofGeom && !mETofGeom->isInitDone() ) {
354 LOG_INFO <<
" eTOF geometry initialization ... " << endm;
356 if( !gGeoManager ) GetDataBase(
"VmcGeometry" );
359 LOG_ERROR <<
"Cannot get GeoManager" << endm;
363 LOG_DEBUG <<
" gGeoManager: Should set alignment file now! " << mFileNameAlignParam <<
" ! "<< endm;
364 if (mFileNameAlignParam !=
""){
365 LOG_INFO <<
" gGeoManager: Setting alignment file: " << mFileNameAlignParam << endm;
366 mETofGeom->setFileNameAlignParam(mFileNameAlignParam);
368 mETofGeom->init(gGeoManager);
369 LOG_DEBUG <<
" init done " << endm;
377 StETofHitMaker::FinishRun( Int_t runnumber )
379 LOG_INFO <<
"StETofHitMaker::FinishRun()" << endm;
381 for(
int iCounter = 0; iCounter < eTofConst::nCountersInSystem; iCounter++ ) {
382 if( mCounterActive.at( iCounter ) ) {
383 int day = ( runnumber % 1000000 ) / 1000;
384 int run = runnumber % 1000;
386 mHistograms.at(
"counter_active" )->Fill( 100 * day + run, iCounter );
402 LOG_INFO <<
"StETofHitMaker::Finish()" << endm;
405 LOG_INFO <<
"Finish() - writing *.etofHit.root ..." << endm;
417 LOG_DEBUG <<
"StETofHitMaker::Make(): starting ..." << endm;
419 mEvent = (
StEvent* ) GetInputDS(
"StEvent" );
423 LOG_DEBUG <<
"Make() - running on StEvent" << endm;
426 if( !etofCollection ) {
427 LOG_WARN <<
"Make() - Found StEvent data structure, but no eTOF collection. Try MuDst processing instead" << endm;
428 mMuDst = (
StMuDst* ) GetInputDS(
"MuDst" );
431 LOG_DEBUG <<
"Make() - running on MuDsts" << endm;
444 LOG_DEBUG <<
"Make(): no StEvent found" << endm;
446 mMuDst = (
StMuDst* ) GetInputDS(
"MuDst" );
449 LOG_DEBUG <<
"Make() - running on MuDsts" << endm;
456 LOG_WARN <<
"Make() - no StMuDst or StEvent" << endm;
464 StETofHitMaker::processStEvent()
468 if( !etofCollection ) {
469 LOG_WARN <<
"processStEvent() - no etof collection" << endm;
473 if( !etofCollection->digisPresent() ) {
474 LOG_WARN <<
"processStEvent() - no digis present" << endm;
478 const StSPtrVecETofDigi& etofDigis = etofCollection->etofDigis();
482 size_t nDigis = etofDigis.size();
484 LOG_DEBUG <<
"processStEvent() - # fired eTOF digis : " << nDigis << endm;
487 bool isMuDst =
false;
490 clearHits( isMuDst );
497 size_t nDigisInStore = 0;
499 for(
size_t i = 0; i<nDigis; i++ ) {
502 if( fillStorage( aDigi, i ) ) {
510 double tstart = startTime();
513 fillUnclusteredHitQA( tstart, isMuDst );
516 mergeClusters( isMuDst );
518 assignAssociatedHits( isMuDst );
522 mHistograms.at(
"multiplicity_etofDigis_etofHits" )->Fill( nDigisInStore, etofCollection->etofHits().size() );
525 if( etofCollection->hitsPresent() ) {
526 fillHitQA( isMuDst, tstart );
532 StETofHitMaker::processMuDst()
535 LOG_WARN <<
"processMuDst() - no digi array" << endm;
539 if( !mMuDst->numberOfETofDigi() ) {
540 LOG_WARN <<
"processMuDst() - no digis present" << endm;
546 size_t nDigis = mMuDst->numberOfETofDigi();
548 LOG_DEBUG <<
"processMuDst() - # fired eTOF digis : " << nDigis << endm;
553 clearHits( isMuDst );
560 size_t nDigisInStore = 0;
562 for(
size_t i = 0; i<nDigis; i++ ) {
565 if( fillStorage( aDigi, i ) ) {
573 double tstart = startTime();
576 fillUnclusteredHitQA( tstart, isMuDst );
579 mergeClusters( isMuDst );
581 assignAssociatedHits( isMuDst );
585 mHistograms.at(
"multiplicity_etofDigis_etofHits" )->Fill( nDigisInStore, mMuDst->numberOfETofHit() );
589 if( mMuDst->numberOfETofHit() ) {
590 fillHitQA( isMuDst, tstart );
599 StETofHitMaker::startTime()
602 LOG_INFO <<
"startTime(): -- loading start time from bTOF header" << endm;
607 LOG_INFO <<
"mIsSim = true --> startTime set to 0" << endm;
617 if ( btofCollection ) {
618 btofHeader = btofCollection->tofHeader();
621 LOG_DEBUG <<
"no StBTofCollection found by getTstart" << endm;
630 LOG_DEBUG <<
"startTime(): -- no bTOF header --> no start time avaiable" << endm;
634 double tstart = btofHeader->tStart();
636 if( !isfinite( tstart ) ) {
637 LOG_DEBUG <<
"startTime(): -- from bTOF header is NaN" << endm;
641 if( tstart != -9999. ) {
642 tstart = fmod( tstart, eTofConst::bTofClockCycle );
643 if( tstart < 0. ) tstart += eTofConst::bTofClockCycle;
647 LOG_INFO <<
"startTime(): -- start time: " << tstart << endm;
656 StETofHitMaker::startTimeVpd(
double& tstart,
double& vertexVz )
662 LOG_INFO <<
"startTimeVpd(): -- calculating VPD start time from bTOF header" << endm;
670 if ( btofCollection ) {
671 btofHeader = btofCollection->tofHeader();
674 LOG_DEBUG <<
"no StBTofCollection found by getTstart" << endm;
683 LOG_DEBUG <<
"startTimeVpd(): -- no bTOF header --> no start time avaiable" << endm;
689 int nWest = btofHeader->numberOfVpdHits( west );
690 int nEast = btofHeader->numberOfVpdHits( east );
692 double vpdLeTime[ 2 * nVpd ];
696 if( fabs( btofHeader->vpdVz() ) > 200. ) {
698 LOG_INFO <<
"startTimeVpd(): no valid Vpd data in the bTOF header " << endm;
703 vertexVz = btofHeader->vpdVz();
704 LOG_DEBUG <<
"startTimeVpd(): Vpd vertex is at: " << vertexVz << endm;
713 for(
int i=0; i< nVpd; i++ ) {
714 vpdLeTime[ i ] = btofHeader->vpdTime( west, i+1 );
715 if( vpdLeTime[ i ] > 0. ) {
716 updateCyclicRunningMean( vpdLeTime[ i ], tMean, nTubes, eTofConst::bTofClockCycle );
718 LOG_DEBUG <<
"startTimeVpd(): loading VPD west tubeId = " << i+1 <<
" time " << vpdLeTime[ i ] << endm;
723 for(
int i=0; i< nVpd; i++ ) {
724 vpdLeTime[ i + nVpd ] = btofHeader->vpdTime( east, i+1 );
725 if( vpdLeTime[ i + nVpd ] > 0. ) {
726 updateCyclicRunningMean( vpdLeTime[ i + nVpd ], tMean, nTubes, eTofConst::bTofClockCycle );
728 LOG_DEBUG <<
"startTimeVpd(): loading VPD east tubeId = " << i+1 <<
" time " << vpdLeTime[ i + nVpd ] << endm;
732 if( nTubesEast >= 2 && nTubesWest >= 2 ) {
736 if( tstart != -9999 ) {
737 tstart = fmod( tstart, eTofConst::bTofClockCycle );
738 if( tstart < 0. ) tstart += eTofConst::bTofClockCycle;
742 LOG_INFO <<
"startTimeVpd(): -- sum: " << tMean <<
" nWest: " << nWest <<
" nEast: " << nEast;
743 LOG_INFO <<
" --> compare (if bTofHeader is filled): " << btofHeader->tStart() << endm;
744 LOG_INFO <<
"startTimeVpd(): -- start time: " << tstart << endm;
751 StETofHitMaker::fillStorage(
StETofDigi* aDigi,
unsigned int index )
754 LOG_WARN <<
"No digi found" << endm;
760 LOG_DEBUG <<
"fillStorage() - digi not calibrated, most likely since it is outside the trigger window or pulser. Ignore." << endm;
766 LOG_WARN <<
"fillStorage() - sector / zPlane / counter / strip was not assigned to the digi" << endm;
773 LOG_DEBUG <<
"fillStorage() -- sector plane counter strip: " << pDigi->
sector() <<
" ";
774 LOG_DEBUG << pDigi->
zPlane() <<
" " << pDigi->
counter() <<
" " << pDigi->
strip() << endm;
775 LOG_DEBUG <<
"fillStorage() -- calibTime: " << pDigi->
calibTime();
776 LOG_DEBUG <<
" calibToT: " << pDigi->
calibTot() << endm;
779 unsigned int key = pDigi->
sector() * 10000 +
784 mStoreDigi[ key ].push_back( pDigi );
786 mMapDigiIndex[ pDigi ] = index;
790 std::string histName_digi_tot =
"digi_tot_s" + std::to_string( pDigi->
sector() ) +
"m" + std::to_string( pDigi->
zPlane() ) +
"c" + std::to_string( pDigi->
counter() );
792 mHistograms[ histName_digi_tot ]->Fill( pDigi->
strip() - 1 + pDigi->
side() * 0.3, pDigi->
calibTot() );
800 StETofHitMaker::fillStorage(
StMuETofDigi* aDigi,
unsigned int index )
802 return fillStorage( (
StETofDigi* ) aDigi, index );
808 StETofHitMaker::clearHits(
const bool isMuDst )
811 if( !( mEvent->etofCollection()->hitsPresent() ) ) {
815 LOG_DEBUG <<
"clearHits() - number of hits present (before clear): " << mEvent->etofCollection()->etofHits().size() << endm;
818 StSPtrVecETofHit& etofHits = mEvent->etofCollection()->etofHits();
821 LOG_DEBUG <<
"clearHits() - number of hits present (after clear): " << mEvent->etofCollection()->etofHits().size() << endm;
824 StSPtrVecETofDigi& etofDigis = mEvent->etofCollection()->etofDigis();
825 size_t nDigis = etofDigis.size();
827 for(
size_t i=0; i<nDigis; i++ ) {
830 if( !aDigi )
continue;
832 aDigi->setAssociatedHit(
nullptr );
834 LOG_DEBUG <<
"clearHits() - associated hits of digis set to nullptr" << endm;
837 if( mMuDst->numberOfETofHit() == 0 ) {
841 LOG_DEBUG <<
"clearHits() - number of hits present (before clear): " << mMuDst->numberOfETofHit() << endm;
844 mMuDst->
etofArray( muETofHit )->Clear(
"C" );
846 LOG_DEBUG <<
"clearHits() - number of hits present (after clear): " << mMuDst->numberOfETofHit() << endm;
849 size_t nDigis = mMuDst->numberOfETofDigi();
851 for(
size_t i=0; i<nDigis; i++ ) {
854 if( !aDigi )
continue;
856 aDigi->setAssociatedHitId( -1 );
858 LOG_DEBUG <<
"clearHits() - associated hit id of digis set to -1" << endm;
865 StETofHitMaker::clearStorage()
868 for(
auto kv = mStoreDigi.begin(); kv != mStoreDigi.end(); kv++ ) {
869 size_t remainingDigis = kv->second.size();
872 LOG_DEBUG <<
"strip key " << kv->first <<
" has " << remainingDigis <<
" left" << endm;
875 for(
unsigned int i=0; i<remainingDigis; i++ ) {
876 delete kv->second.at( i );
884 for(
auto kv = mStoreHit.begin(); kv != mStoreHit.end(); kv++ ) {
885 size_t remainingHits = kv->second.size();
888 LOG_DEBUG <<
"detector key " << kv->first <<
" has " << remainingHits <<
" left" << endm;
891 for(
size_t i=0; i<remainingHits; i++ ) {
892 delete kv->second.at( i );
900 mMapDigiIndex.clear();
903 mMapHitDigiIndices.clear();
906 mMapHitIndexDigiIndices.clear();
911 StETofHitMaker::matchSides()
913 std::vector< StETofDigi* >::iterator iterDigi;
915 std::string histNameDigisErased;
917 for(
auto kv = mStoreDigi.begin(); kv != mStoreDigi.end(); kv++ ) {
918 unsigned int stripIndex = kv->first;
919 std::vector< StETofDigi* > *digiVec = &( kv->second );
923 return lhs->
calibTime() < rhs->calibTime();
927 int nDigisOnStrip = digiVec->size();
931 LOG_INFO << stripIndex <<
" size: " << nDigisOnStrip << endm;
933 for(
size_t i=0; i<digiVec->size(); i++ ) {
934 LOG_INFO <<
"matchSides() - DIGI: " << digiVec->at( i ) <<
" ";
935 LOG_INFO <<
"calibTime=" << setprecision( 16 ) << digiVec->at( i )->calibTime() <<
" " << endm;
936 LOG_INFO <<
"calibTot=" << setprecision( 4 ) << digiVec->at( i )->calibTot() <<
" ";
937 LOG_INFO <<
"side=" << setprecision( 4 ) << digiVec->at( i )->side() << endm;
942 int detIndex = stripIndex / 100;
943 int sector = detIndex / 100;
944 int plane = ( detIndex % 100 ) / 10;
945 int counter = detIndex % 10;
946 int strip = stripIndex % 100;
949 std::string histNameDigisPerStrip =
"digisPerStrip_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
950 mHistograms.at( histNameDigisPerStrip )->Fill( strip, nDigisOnStrip );
952 histNameDigisErased =
"digisErased_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
958 std::vector< double > deadTime( 2, -60. );
960 for(
auto it = digiVec->begin(); it != digiVec->end(); it++ ) {
961 if( (*it)->rawTime() - deadTime.at( (*it)->side() - 1 ) < mSoftwareDeadTime ) {
964 LOG_INFO <<
"digi within dead time --> ignore ... ( geomId : " << stripIndex * 10 + (*it)->side();
965 LOG_INFO <<
" dead time: " << setprecision( 16 ) << deadTime.at( (*it)->side() - 1 );
966 LOG_INFO <<
" calib time: " << setprecision( 16 ) << (*it)->calibTime();
967 LOG_INFO <<
" difference: " << (*it)->calibTime() - deadTime.at( (*it)->side() - 1 ) << endm;
971 digiVec->erase( it );
973 mHistograms[ histNameDigisErased ]->Fill(1);
978 deadTime.at( (*it)->side() - 1 ) = (*it)->rawTime();
983 std::vector< unsigned int > containedDigiIndices;
987 double timeDiff = 0.0;
989 double t_corr_afterpulse = 0.0;
992 if( mDoQA && digiVec->size() == 1 ) {
993 mHistograms.at( histNameDigisErased )->Fill( 2 );
998 if( digiVec->size() == 1 ) {
1013 if(!mIsSim && mApCorr){
1014 time += t_corr_afterpulse;
1019 if(xDigiA->
side() == 1){
1027 posX = ( -1 * eTofConst::nStrips / 2. + strip - 0.5 ) * eTofConst::stripPitch;
1029 unsigned int clusterSize = 1000;
1031 StETofHit* constructedHit =
new StETofHit( sector, plane, counter, time, totSum, clusterSize, posX, posY );
1033 mStoreHit[ detIndex ].push_back( constructedHit );
1035 containedDigiIndices.push_back( mMapDigiIndex.at( xDigiA ) );
1036 containedDigiIndices.push_back( mMapDigiIndex.at( xDigiB ) );
1038 mMapHitDigiIndices[ constructedHit ] = containedDigiIndices;
1044 while( digiVec->size() > 1 ) {
1046 LOG_DEBUG << stripIndex <<
" -- digiVec->size() -- " << digiVec->size() << endm;
1051 while( digiVec->at( 0 )->side() == digiVec->at( 1 )->side() ) {
1053 if( digiVec->size() > 2 ) {
1056 if( digiVec->at( 2 )->side() == digiVec->at( 0 )->side() ) {
1059 iterDigi = digiVec->begin();
1061 digiVec->erase( iterDigi );
1063 mHistograms.at( histNameDigisErased )->Fill( 3 );
1067 if( digiVec->at( 2 )->calibTime() - digiVec->at( 0 )->calibTime() >
1068 digiVec->at( 2 )->calibTime() - digiVec->at( 1 )->calibTime() ) {
1072 iterDigi = digiVec->begin();
1074 digiVec->erase( iterDigi );
1076 if(mApCorr) t_corr_afterpulse = digiVec->at( 0 )->calibTime() - digiVec->at( 1 )->calibTime();
1078 mHistograms.at( histNameDigisErased )->Fill( 4 );
1084 iterDigi = digiVec->begin() + 1;
1086 digiVec->erase( iterDigi );
1088 mHistograms.at( histNameDigisErased )->Fill( 7 );
1095 iterDigi = digiVec->begin();
1097 digiVec->erase( iterDigi );
1098 if( mDoQA && digiVec->size() == 1 ){
1099 mHistograms.at( histNameDigisErased )->Fill( 5 );
1103 if( digiVec->size() < 2 ) {
1104 if(mDoQA && digiVec->size() == 1) {
1105 mHistograms.at( histNameDigisErased )->Fill( 5 );
1112 LOG_DEBUG <<
"matchSides() - digi processing for sector " << stripIndex / 10000;
1113 LOG_DEBUG <<
" plane " << ( stripIndex % 10000 ) / 1000 <<
" counter " << ( stripIndex % 1000 ) / 100;
1114 LOG_DEBUG <<
" strip " << stripIndex % 100;
1115 LOG_DEBUG <<
" size: " << digiVec->size() << endm;
1118 if( digiVec->size() < 2 ) {
1121 mHistograms.at( histNameDigisErased )->Fill( 5 );
1133 LOG_DEBUG <<
"matchSides() - time difference in ns: " << timeDiff << endm;
1137 if( xDigiA->
side() == 2 ) {
1138 posY = mSigVel.at( detIndex ) * timeDiff * 0.5;
1141 posY = -1 * mSigVel.at( detIndex ) * timeDiff * 0.5;
1146 if( fabs( posY ) > mMaxYPos && digiVec->size() > 2 ) {
1148 LOG_DEBUG <<
"matchSides() - hit candidate outside correlation window, check for better possible digis" << endm;
1149 LOG_DEBUG <<
"size of digi vector: " << digiVec->size() << endm;
1154 double posYNew = 0.;
1155 double timeDiffNew = 0.;
1157 if( xDigiC->
side() == xDigiA->
side() ) {
1164 if( xDigiA->
side() == 2 ) {
1165 posYNew = mSigVel.at( detIndex ) * timeDiffNew * 0.5;
1168 posYNew = -1 * mSigVel.at( detIndex ) * timeDiffNew * 0.5;
1171 if( fabs( posYNew ) < fabs( posY ) ) {
1173 LOG_DEBUG <<
"matchSides() - found better match for hit candidate -> changing out digis" << endm;
1176 timeDiff = timeDiffNew;
1179 if( xDigiC->
side() == xDigiA->
side() ) {
1183 iterDigi = digiVec->begin();
1185 digiVec->erase( iterDigi );
1187 mHistograms.at( histNameDigisErased )->Fill( 4 );
1194 iterDigi = digiVec->begin() + 1;
1196 digiVec->erase( iterDigi );
1198 mHistograms.at( histNameDigisErased )->Fill( 4 );
1204 LOG_DEBUG <<
"matchSides() - no better match -> keep this hit candidate" << endm;
1210 if( xDigiA->
side() == xDigiB->
side() ) {
1211 LOG_ERROR <<
"matchSides() - wrong combinations of digis:" << endm;
1212 LOG_ERROR << *xDigiA << endm;
1213 LOG_ERROR << *xDigiB << endm;
1222 if(!mIsSim && mApCorr){
1223 time += t_corr_afterpulse;
1229 posX = ( -1 * eTofConst::nStrips / 2. + strip - 0.5 ) * eTofConst::stripPitch;
1232 bool hasClockJump =
false;
1233 if( fabs( posY ) > 0.5 * ( eTofConst::coarseClockCycle * mSigVel.at( detIndex ) - eTofConst::stripLength ) * 0.9 ) {
1234 hasClockJump =
true;
1239 bool leftjump =
false;
1240 bool outsider =
false;
1243 if(xDigiA->
side() == 2 ){
1251 if(dt < 8.5 && dt > 0){
1261 if( mDoClockJumpShift && hasClockJump ) {
1263 LOG_INFO <<
"shifted hit time in direction: " << mClockJumpDirection.at( detIndex * 10 + ( strip - 1 ) / 4 + 1 ) << endm;
1266 time -= eTofConst::coarseClockCycle * 0.5 * mClockJumpDirection.at( detIndex * 10 + ( strip - 1 ) / 4 + 1 );
1267 timeDiff -= eTofConst::coarseClockCycle * ( ( timeDiff < 0 ) ? -1 : ( timeDiff > 0 ) );
1269 if(leftjump && mDoDoubleClockJumpShift){
1270 time += 2*(eTofConst::coarseClockCycle * 0.5 * mClockJumpDirection.at( detIndex * 10 + ( strip - 1 ) / 4 + 1 ));
1274 if(outsider && mDoDoubleClockJumpShift){
1275 time += 100*(eTofConst::coarseClockCycle * 0.5 * mClockJumpDirection.at( detIndex * 10 + ( strip - 1 ) / 4 + 1 ));
1276 timeDiff -= 100*(eTofConst::coarseClockCycle * ( ( timeDiff < 0 ) ? -1 : ( timeDiff > 0 ) )) + 2.0;
1280 LOG_INFO <<
"shifted hit on: " << sector <<
"-" << plane <<
"-" << counter <<
" -- " << strip <<
" Direction " << mClockJumpDirection.at( detIndex * 10 + ( strip - 1 ) / 4 + 1 ) << endm;
1283 if( xDigiA->
side() == 2 ) {
1284 posY = mSigVel.at( detIndex ) * timeDiff * 0.5;
1287 posY = -1 * mSigVel.at( detIndex ) * timeDiff * 0.5;
1293 LOG_DEBUG <<
"detIndex=" << detIndex <<
"posX=" << posX <<
" posY=" << posY <<
" time= " << time <<
" totSum=" << totSum << endm;
1297 unsigned int clusterSize = 1;
1298 if( hasClockJump ) {
1305 if(mModMatrix.at(detIndex) > 0){
1306 int mode = mModMatrix.at(detIndex);
1307 modifyHit(mode, posX , posY , time);
1310 StETofHit* constructedHit =
new StETofHit( sector, plane, counter, time, totSum, clusterSize, posX, posY );
1313 if(mDoDoubleClockJumpShift){
1314 double starttime = startTime();
1318 double tof = fmod( constructedHit->
time() , eTofConst::bTofClockCycle ) - starttime;
1324 StThreeVectorD posGlo = mETofGeom->hitLocal2Master( constructedHit );
1328 exptof = tofPathLength(&vtxPos , &posGlo , 0) / ( nanosecond * c_light );
1332 int get4Nr = detIndex * 10 + ( strip - 1 ) / 4 + 1;
1334 double tMin = mGet4doublejumpTmin;
1335 double t1 = mGet4doublejumpTimes.at(get4Nr).at(0);
1336 double t2 = mGet4doublejumpTimes.at(get4Nr).at(1);
1338 mGet4doublejumpTimes.at(get4Nr).erase(mGet4doublejumpTimes.at(get4Nr).begin());
1339 mGet4doublejumpTimes.at(get4Nr).push_back(tof - exptof);
1340 if(mGet4doublejumpTimes.at(get4Nr).size() > 2 ){
1341 mGet4doublejumpTimes.at(get4Nr).erase(mGet4doublejumpTimes.at(get4Nr).begin());
1344 t1 = mGet4doublejumpTimes.at(get4Nr).at(0);
1345 t2 = mGet4doublejumpTimes.at(get4Nr).at(1);
1347 if(t2 < tMin && t1 < tMin && t2 > -999 && t1 > -999){
1348 mGet4doublejumpFlag.at(get4Nr) = 1;
1351 if(t2 > tMin && t1 > tMin ){
1352 mGet4doublejumpFlag.at(get4Nr) = 0;
1355 if(mGet4doublejumpFlag.at(get4Nr) == 1){
1356 constructedHit->setTime(constructedHit->
time() + eTofConst::coarseClockCycle);
1357 constructedHit->setClusterSize(constructedHit->
clusterSize() + 200);
1358 tof += eTofConst::coarseClockCycle;
1364 mStoreHit[ detIndex ].push_back( constructedHit );
1367 std::vector< unsigned int > containedDigiIndices;
1369 containedDigiIndices.push_back( mMapDigiIndex.at( xDigiA ) );
1370 containedDigiIndices.push_back( mMapDigiIndex.at( xDigiB ) );
1372 mMapHitDigiIndices[ constructedHit ] = containedDigiIndices;
1375 t_corr_afterpulse = 0.0;
1379 int DigiIdA = xDigiA->
rawTot();
1380 int DigiIdB = xDigiB->
rawTot();
1382 if(DigiIdB==DigiIdA){constructedHit->setIdTruth(DigiIdA);}
1383 else{constructedHit->setIdTruth(9999);}
1386 LOG_DEBUG << *( mStoreHit.at( detIndex ).back() ) << endm;
1389 iterDigi = digiVec->begin();
1391 delete *(iterDigi+1);
1392 digiVec->erase( iterDigi + 1 );
1393 digiVec->erase( iterDigi );
1395 mHistograms.at( histNameDigisErased )->Fill( 6 );
1396 mHistograms.at( histNameDigisErased )->Fill( 6 );
1403 LOG_DEBUG <<
"matchSides() - matching of sides done" << endm;
1410 StETofHitMaker::fillUnclusteredHitQA(
const double& tstart,
const bool isMuDst )
1417 if( fabs( tstart + 9999. ) < 1.e-5 ) {
1418 LOG_WARN <<
"fillUnclusteredHitQA(): -- no valid start time available ... skip filling histograms with time of flight information" << endm;
1422 int nHitsPrinted = 0;
1424 for(
const auto& kv : mStoreHit ) {
1425 unsigned int detIndex = kv.first;
1427 unsigned int sector = detIndex / 100;
1428 unsigned int plane = ( detIndex % 100 ) / 10;
1429 unsigned int counter = detIndex % 10;
1432 LOG_DEBUG << sector <<
" " << plane <<
" " << counter <<
" size hitVec: " << kv.second.size() << endm;
1435 for(
const auto&
hit : kv.second ) {
1437 LOG_DEBUG <<
"matchSides() - HIT: ";
1438 LOG_DEBUG <<
"time=" << setprecision( 16 ) <<
hit->time() <<
" ";
1439 LOG_DEBUG <<
"totalTot=" << setprecision( 4 ) <<
hit->totalTot() <<
" ";
1440 LOG_DEBUG <<
"localX=" << setprecision( 4 ) <<
hit->localX() <<
" ";
1441 LOG_DEBUG <<
"localY=" << setprecision( 4 ) <<
hit->localY() << endm;
1444 mCounterActive.at( ( sector - 13 ) * 9 + ( plane - 1 ) * 3 + ( counter - 1 ) ) =
true;
1446 mHistograms.at(
"unclusteredHit_tot" )->Fill(
hit->totalTot() );
1448 std::string histNameTot =
"unclusteredHit_tot_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1449 mHistograms.at( histNameTot )->Fill(
hit->totalTot(),
hit->localX() );
1455 if( mMapHitDigiIndices.at(
hit ).size() >= 2 ) {
1456 int digiIndexA = mMapHitDigiIndices.at(
hit ).at( 0 );
1457 int digiIndexB = mMapHitDigiIndices.at(
hit ).at( 1 );
1462 bool sideSwitch =
false;
1465 StSPtrVecETofDigi& etofDigis = mEvent->etofCollection()->etofDigis();
1466 totA = etofDigis[ digiIndexA ]->calibTot();
1467 totB = etofDigis[ digiIndexB ]->calibTot();
1469 if( etofDigis[ digiIndexA ]->side() == 2 ) {
1483 LOG_DEBUG <<
"tot of digis in the hit: " << totA <<
" and " << totB <<
" sideSwitch: " << sideSwitch << endm;
1486 float totDiff = totA - totB;
1487 if( sideSwitch ) totDiff *= -1;
1489 mHistograms.at(
"unclusteredHit_tot_difference" )->Fill( totDiff );
1491 if( fabs(
hit->localY() ) > mMaxYPos ) {
1492 mHistograms.at(
"unclusteredHit_tail_totAsym" )->Fill( totDiff / ( totA + totB) );
1500 std::string histNamePos =
"unclusteredHit_pos_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1501 mHistograms.at( histNamePos )->Fill(
hit->localX(),
hit->localY() );
1503 std::string histNamePosJump =
"unclusteredHit_jump_pos_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1504 if(
hit->clusterSize() > 100 ) mHistograms.at( histNamePosJump )->Fill(
hit->localX(),
hit->localY() );
1507 if( fabs( tstart + 9999. ) < 1.e-5 )
continue;
1509 double tof = fmod(
hit->time(), eTofConst::bTofClockCycle ) - tstart;
1512 LOG_DEBUG <<
"hit time, hit time mod bTOF clock cycle, start time, time difference: ";
1513 LOG_DEBUG <<
hit->time() <<
" , " << tof + tstart <<
" , " << tstart <<
" , " << tof << endm;
1514 LOG_DEBUG <<
"sector, plane, counter: " <<
hit->sector() <<
" , " <<
hit->zPlane() <<
" , " <<
hit->counter() << endm;
1516 mHistograms.at(
"unclusteredHit_tof_fullrange_all" )->Fill( tof );
1520 tof += eTofConst::bTofClockCycle;
1522 tof = fmod( tof, eTofConst::bTofClockCycle );
1525 mHistograms.at(
"unclusteredHit_tof_fullrange" )->Fill( tof );
1527 mHistograms.at(
"unclusteredHit_tof" )->Fill( tof );
1530 std::string histNameTof =
"unclusteredHit_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1531 mHistograms.at( histNameTof )->Fill(
hit->localX(), tof );
1533 std::string histNameTofJump =
"unclusteredHit_jump_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1534 if(
hit->clusterSize() > 100 ) mHistograms.at( histNameTofJump )->Fill(
hit->localX(), tof );
1542 if( fabs( vtxPos.z() ) <= 10. && fabs( vtxPos.perp() < 2.5 ) ) {
1543 histNameTof =
"unclusteredHit_pVtx_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1544 mHistograms.at( histNameTof )->Fill(
hit->localX(), tof );
1562 if( fabs( tof ) > 1000. && nHitsPrinted < 5 ) {
1563 LOG_INFO <<
"TOF UNNORMALLY LARGE: " << tof <<
" !!! " << endm;
1575 StETofHitMaker::mergeClusters(
const bool isMuDst )
1577 std::vector< StETofHit* >::iterator iterHit;
1578 std::vector< std::vector< StETofDigi* > >::iterator iterDigi;
1580 for(
auto kv = mStoreHit.begin(); kv != mStoreHit.end(); kv++ ) {
1581 unsigned int detIndex = kv->first;
1583 unsigned int sector = detIndex / 100;
1584 unsigned int plane = ( detIndex % 100 ) / 10;
1585 unsigned int counter = detIndex % 10;
1587 std::vector< StETofHit* > *hitVec = &( kv->second );
1589 size_t nHitsOnDet = 0;
1591 while( hitVec->size() > 0 ) {
1593 LOG_DEBUG <<
"mergeClusters() - hit vector size: " << hitVec->size();
1594 LOG_DEBUG <<
" for sector " << sector <<
" plane " << plane <<
" counter " << counter << endm;
1595 LOG_DEBUG <<
"mergeClusters() - checking hit vector for possible hits to merge with..." << endm;
1598 bool isMissmatch =
false;
1610 double weightedTime = pHit->
time() * weight;
1611 double weightedPosX = pHit->
localX() * weight;
1612 double weightedPosY = pHit->
localY() * weight;
1613 double weightsTotSum = 1. * weight;
1616 unsigned int clusterSize = 1;
1617 int lowestStrip = ceil( pHit->
localX() / eTofConst::stripPitch );
1618 int highestStrip = lowestStrip;
1620 bool hasClockJump =
false;
1622 hasClockJump =
true;
1625 bool isSingleSided =
false;
1627 isSingleSided =
true;
1630 unsigned int index = 1;
1631 while( hitVec->size() > 1 ) {
1633 LOG_DEBUG <<
"mergeClusters() - index in hit vector = " << index << endm;
1635 if( index >= hitVec->size() ) {
1637 LOG_DEBUG <<
"mergeClusters() - loop index is exceeds size of hit vector -> stop looping" << endm;
1642 StETofHit* pMergeHit = hitVec->at( index );
1645 double timeDiff = pHit->
time() - pMergeHit->
time();
1646 double posYDiff = ( pHit->
localY() - pMergeHit->
localY() ) / mSigVel.at( detIndex );
1648 bool isHigherAdjacentStip =
false;
1649 bool isLowerAdjacentStip =
false;
1651 if( ceil( pMergeHit->
localX() / eTofConst::stripPitch ) - highestStrip == 1 ) {
1652 isHigherAdjacentStip =
true;
1654 else if( ceil( pMergeHit->
localX() / eTofConst::stripPitch ) - lowestStrip == -1 ) {
1655 isLowerAdjacentStip =
true;
1658 double MergingRadius = 0;
1664 MergingRadius = mMergingRadius;
1669 if( ( isHigherAdjacentStip || isLowerAdjacentStip ) &&
1670 ( sqrt( timeDiff * timeDiff + posYDiff * posYDiff ) ) < MergingRadius )
1673 LOG_DEBUG <<
"mergeClusters() - merging is going on" << endm;
1676 if( mDoQA && clusterSize == 1 ) {
1677 std::string histName_unclusteredHit_delT_pos =
"unclusteredHit_delT_pos_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1678 std::string histName_unclusteredHit_delT_tot =
"unclusteredHit_delT_tot_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1679 std::string histName_unclusteredHit_delT =
"unclusteredHit_delT_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1680 mHistograms.at( histName_unclusteredHit_delT )->Fill( pHit->
localX(), timeDiff );
1681 ((TH3F&) *mHistograms[ histName_unclusteredHit_delT_tot ]).TH3F::Fill( pHit->
localX(), timeDiff, pHit->
totalTot() );
1682 ((TH3F&) *mHistograms[ histName_unclusteredHit_delT_pos ]).TH3F::Fill( pHit->
localX(), timeDiff, posYDiff );
1685 double hitWeight = pMergeHit->
totalTot();
1687 if( hitWeight==0 ) {
1691 weightedTime += ( pMergeHit->
time() * hitWeight );
1692 weightedPosX += ( pMergeHit->
localX() * hitWeight );
1693 weightedPosY += ( pMergeHit->
localY() * hitWeight );
1694 weightsTotSum += hitWeight;
1698 hasClockJump =
true;
1701 if( isHigherAdjacentStip ) {
1704 else if( isLowerAdjacentStip ) {
1709 LOG_DEBUG <<
"mergeClusters() - detector: " << detIndex <<
" seed hit localX: " << pHit->
localX();
1710 LOG_DEBUG <<
" <> hit to merge localX: " << pMergeHit->
localX();
1711 LOG_DEBUG <<
" <> weighted localX: " << weightedPosX / weightsTotSum << endm;
1715 for(
unsigned int i : mMapHitDigiIndices.at( pMergeHit ) ) {
1716 mMapHitDigiIndices.at( pHit ).push_back( i );
1727 else if(!isMissmatch){
1734 iterHit = hitVec->begin() + index;
1736 hitVec->erase( iterHit );
1739 LOG_DEBUG <<
"mergeClusters() - deleting merged hit from Map" << endm;
1742 mMapHitDigiIndices.erase( pMergeHit );
1747 LOG_DEBUG <<
"mergeClusters() - merging condition not fulfilled -- check the next hit" << endm;
1762 weightedTime /= weightsTotSum;
1763 weightedPosX /= weightsTotSum;
1764 weightedPosY /= weightsTotSum;
1767 weightedTime = fmod( weightedTime, eTofConst::bTofClockCycle );
1768 if( weightedTime < 0 ) weightedTime += eTofConst::bTofClockCycle;
1770 if( hasClockJump ) {
1775 clusterSize += 1000;
1779 LOG_DEBUG <<
"mergeClusters() - MERGED HIT: ";
1780 LOG_DEBUG <<
"sector: " << sector <<
" plane: " << plane <<
" counter: " << counter <<
"\n";
1781 LOG_DEBUG <<
"time = " << setprecision( 16 ) << weightedTime <<
" ";
1782 LOG_DEBUG <<
"totalTot = " << setprecision( 4 ) << weightsTotSum <<
" ";
1783 LOG_DEBUG <<
"clusterSize = " << setprecision( 1 ) << clusterSize % 100 <<
" ";
1784 LOG_DEBUG <<
"localX = " << setprecision( 4 ) << weightedPosX <<
" ";
1785 LOG_DEBUG <<
"localY = " << setprecision( 4 ) << weightedPosY << endm;
1789 StETofHit* combinedHit =
new StETofHit( sector, plane, counter, weightedTime, weightsTotSum, clusterSize, weightedPosX, weightedPosY );
1792 combinedHit->setIdTruth(idTruth);
1798 mEvent->etofCollection()->addHit( combinedHit );
1801 mMapHitDigiIndices[ combinedHit ] = mMapHitDigiIndices.at( pHit );
1804 LOG_DEBUG <<
"mergeClusters(): size of digi vector for combined hit " << nHitsOnDet <<
" on the counter: ";
1805 LOG_DEBUG << mMapHitDigiIndices.at( combinedHit ).size() <<
" copied over from merged hit vector of size "<< mMapHitDigiIndices.at( pHit ).size() << endm;
1811 int lastHitIndex = mMuDst->numberOfETofHit() - 1;
1814 mMapHitIndexDigiIndices[ lastHitIndex ] = mMapHitDigiIndices.at( pHit );
1816 LOG_DEBUG <<
"mergeClusters(): size of digi vector for combined hit " << nHitsOnDet <<
" on the counter: ";
1817 LOG_DEBUG << mMapHitIndexDigiIndices.at( lastHitIndex ).size() <<
" copied over from merged hit vector of size "<< mMapHitDigiIndices.at( pHit ).size() << endm;
1823 iterHit = hitVec->begin();
1825 hitVec->erase( iterHit );
1827 mMapHitDigiIndices.erase( pHit );
1830 if( !isMuDst && mMapHitDigiIndices.count( combinedHit ) ) {
1831 LOG_DEBUG <<
"mergeClusters(): size of digi vector for combined hit " << nHitsOnDet <<
" on the counter: " << mMapHitDigiIndices.at( combinedHit ).size() <<
" after deletion of merged hit" << endm;
1833 if( isMuDst && mMapHitIndexDigiIndices.count( nHitsOnDet ) ) {
1834 LOG_DEBUG <<
"mergeClusters(): size of digi vector for combined hit " << nHitsOnDet <<
" on the counter: " << mMapHitIndexDigiIndices.at( mMuDst->numberOfETofHit() - 1 ).size() << endm;
1848 LOG_DEBUG <<
"mergeClusters() - merging into clusters done" << endm;
1854 StETofHitMaker::assignAssociatedHits(
const bool isMuDst )
1857 StSPtrVecETofHit& etofHits = mEvent->etofCollection()->etofHits();
1858 StSPtrVecETofDigi& etofDigis = mEvent->etofCollection()->etofDigis();
1860 for(
size_t ihit = 0; ihit < etofHits.size(); ihit++ ) {
1864 LOG_DEBUG <<
"assignAssociatedHits(): size of digi vector for hit " << ihit <<
": "<< mMapHitDigiIndices.at( aHit ).size() << endm;
1867 for (
size_t idigi = 0; idigi < mMapHitDigiIndices.at( aHit ).size(); idigi++ ) {
1869 LOG_DEBUG <<
"assignAssociatedHits(): link points to digi " << etofDigis[ mMapHitDigiIndices.at( aHit ).at( idigi ) ] << endm;
1871 etofDigis[ mMapHitDigiIndices.at( aHit ).at( idigi ) ]->setAssociatedHit( aHit );
1877 for(
const auto& kv : mMapHitIndexDigiIndices ) {
1879 LOG_DEBUG <<
"assignAssociatedHits(): size of digi vector for hit index " << kv.first <<
": "<< kv.second.size() << endm;
1882 for(
const auto& v: kv.second ) {
1884 LOG_DEBUG <<
"assignAssociatedHits(): link to digi index " << v << endm;
1886 mMuDst->
etofDigi( v )->setAssociatedHitId( kv.first );
1891 LOG_DEBUG <<
"assignAssociatedHits() - association between digis and hits done" << endm;
1898 StETofHitMaker::fillHitQA(
const bool isMuDst,
const double& tstart )
1900 int bTofCentral = 700;
1902 double vpdStart = -9999.;
1903 double vertexVz = -999.;
1906 startTimeVpd( vpdStart, vertexVz );
1913 const StSPtrVecETofHit& etofHits = mEvent->etofCollection()->etofHits();
1916 double averageETofHitTime = 0.;
1918 for(
size_t i=0; i<etofHits.size(); i++ ) {
1926 LOG_DEBUG << *aHit << endm;
1929 updateCyclicRunningMean( aHit->
time(), averageETofHitTime, nHitsETof, eTofConst::bTofClockCycle );
1933 string histNamePos =
"etofHit_pos_s" + std::to_string( aHit->
sector() ) +
"m" + std::to_string( aHit->
zPlane() ) +
"c" + std::to_string( aHit->
counter() );
1934 mHistograms.at( histNamePos )->Fill( aHit->
localX(), aHit->
localY() );
1937 std::string histNameClustersize =
"clustersize_s" + std::to_string( aHit->
sector() ) +
"m" + std::to_string( aHit->
zPlane() );
1938 mHistograms.at( histNameClustersize )->Fill( aHit->
clusterSize() % 100 );
1942 if( (fabs( tstart ) > 0.001 && fabs( tstart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001) || mIsSim ) {
1943 double tof = aHit->
time() - tstart;
1945 tof += eTofConst::bTofClockCycle;
1948 mHistograms.at(
"etofHit_tof" )->Fill( tof );
1949 mHistograms.at(
"etofHit_tof_fullrange" )->Fill( tof );
1953 if( fabs( vpdStart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001 ) {
1954 double tofVpd = aHit->
time() - vpdStart;
1955 if( tofVpd < -800 ) {
1956 tofVpd += eTofConst::bTofClockCycle;
1958 mHistograms.at(
"etofHit_vpdVz_tof" )->Fill( vertexVz, tofVpd );
1968 if( !btofCollection || !btofCollection->hitsPresent() ) {
1969 LOG_WARN <<
"fillHitQA - no btof collection or no bTof hits present" << endm;
1973 const StSPtrVecBTofHit& btofHits = btofCollection->tofHits();
1976 double averageBTofHitTime = 0.;
1978 for(
size_t i=0; i<btofHits.size(); i++ ) {
1985 updateCyclicRunningMean( aHit->leadingEdgeTime(), averageBTofHitTime, nHitsBTof, eTofConst::bTofClockCycle );
1988 if( mDoQA && ((fabs( tstart ) > 0.001 && fabs( tstart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001) || mIsSim) ) {
1989 double tof = aHit->leadingEdgeTime() - tstart;
1991 tof += eTofConst::bTofClockCycle;
1993 mHistograms.at(
"btofHit_tof_fullrange" )->Fill( tof );
1997 float diff = averageETofHitTime - averageBTofHitTime;
1998 if( diff < -800 ) diff += eTofConst::bTofClockCycle;
1999 mHistograms.at(
"averageTimeDiff_etofHits_btofHits" )->Fill( diff );
2000 mHistograms.at(
"multiplicity_etofHits_btofHits" )->Fill( nHitsETof, nHitsBTof );
2002 if( mDoQA && nHitsBTof > bTofCentral ) {
2003 std::vector< int > etofHitsPerModule( eTofConst::nModules );
2004 for(
size_t i=0; i<etofHits.size(); i++ ) {
2010 etofHitsPerModule.at( ( aHit->
sector() - 13 ) * 3 + aHit->
zPlane() - 1 ) += 1;
2013 for(
size_t i=0; i<eTofConst::nModules; i++ ) {
2014 mHistograms.at(
"hitMultiplicityPerModuleCentral" )->Fill( i, etofHitsPerModule.at( i ) );
2022 if( !epdCollection || !epdCollection->hitsPresent() ) {
2023 LOG_WARN <<
"fillHitQA - no epd collection or no epd hits present" << endm;
2027 const StSPtrVecEpdHit& epdHits = epdCollection->epdHits();
2029 float nHitsEpdEast = 0.;
2031 for(
size_t i=0; i<epdHits.size(); i++ ) {
2037 if( epdHit->
nMIP() < 0.3 )
continue;
2038 if( epdHit->
id() > 0 )
continue;
2040 if( epdHit->
nMIP() < 5 ) {
2041 nHitsEpdEast += epdHit->
nMIP();
2047 mHistograms.at(
"multiplicity_etofHits_epdEast" )->Fill( nHitsETof, nHitsEpdEast );
2049 mHistograms.at(
"multiplicity_btofHits_epdEast" )->Fill( nHitsBTof, nHitsEpdEast );
2058 double averageETofHitTime = 0.;
2060 for(
size_t i=0; i<mMuDst->numberOfETofHit(); i++ ) {
2068 LOG_DEBUG <<
"hit (" << i <<
"): sector,plane,counter=" << aHit->
sector() <<
",";
2069 LOG_DEBUG << aHit->
zPlane() <<
"," << aHit->
counter() <<
" time=" << aHit->
time();
2070 LOG_DEBUG <<
" localX=" << aHit->
localX() <<
" localY=" << aHit->
localY();
2071 LOG_DEBUG <<
" clustersize=" << aHit->
clusterSize() % 100 << endm;
2074 updateCyclicRunningMean( aHit->
time(), averageETofHitTime, nHitsETof, eTofConst::bTofClockCycle );
2077 string histNamePos =
"etofHit_pos_s" + std::to_string( aHit->
sector() ) +
"m" + std::to_string( aHit->
zPlane() ) +
"c" + std::to_string( aHit->
counter() );
2078 mHistograms.at( histNamePos )->Fill( aHit->
localX(), aHit->
localY() );
2081 std::string histNameClustersize =
"clustersize_s" + std::to_string( aHit->
sector() ) +
"m" + std::to_string( aHit->
zPlane() );
2082 mHistograms.at( histNameClustersize )->Fill( aHit->
clusterSize() % 100 );
2086 if( (fabs( tstart ) > 0.001 && fabs( tstart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001) || mIsSim ) {
2087 double tof = aHit->
time() - tstart;
2089 tof += eTofConst::bTofClockCycle;
2092 mHistograms.at(
"etofHit_tof" )->Fill( tof );
2093 mHistograms.at(
"etofHit_tof_fullrange" )->Fill( tof );
2097 if( fabs( vpdStart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001 ) {
2098 double tofVpd = aHit->
time() - vpdStart;
2099 if( tofVpd < -800 ) {
2100 tofVpd += eTofConst::bTofClockCycle;
2102 mHistograms.at(
"etofHit_vpdVz_tof" )->Fill( vertexVz, tofVpd );
2110 if( !mMuDst->
btofArray( muBTofHit ) || !mMuDst->numberOfBTofHit() ) {
2111 LOG_WARN <<
"fillHitQA - no btof hit array or no btof hits present" << endm;
2116 double averageBTofHitTime = 0.;
2118 for(
size_t i=0; i<mMuDst->numberOfBTofHit(); i++ ) {
2125 updateCyclicRunningMean( aHit->leadingEdgeTime(), averageBTofHitTime, nHitsBTof, eTofConst::bTofClockCycle );
2128 if( mDoQA && ((fabs( tstart ) > 0.001 && fabs( tstart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001) || mIsSim) ) {
2129 double tof = aHit->leadingEdgeTime() - tstart;
2131 tof += eTofConst::bTofClockCycle;
2134 mHistograms.at(
"btofHit_tof_fullrange" )->Fill( tof );
2138 double diff = averageETofHitTime - averageBTofHitTime;
2139 if( diff < -800 ) diff += eTofConst::bTofClockCycle;
2141 mHistograms.at(
"averageTimeDiff_etofHits_btofHits" )->Fill( diff );
2142 mHistograms.at(
"multiplicity_etofHits_btofHits" )->Fill( nHitsETof, nHitsBTof );
2144 if( mDoQA && nHitsBTof > bTofCentral ) {
2145 std::vector< int > etofHitsPerModule( eTofConst::nModules );
2146 for(
size_t i=0; i<mMuDst->numberOfETofHit(); i++ ) {
2152 etofHitsPerModule.at( ( aHit->
sector() - 13 ) * 3 + aHit->
zPlane() - 1 ) += 1;
2155 for(
size_t i=0; i<eTofConst::nModules; i++ ) {
2156 mHistograms.at(
"hitMultiplicityPerModuleCentral" )->Fill( i, etofHitsPerModule.at( i ) );
2163 if( !mMuDst->
epdHits() || !mMuDst->numberOfEpdHit() ) {
2164 LOG_WARN <<
"fillHitQA - no epd hit array or no epd hits present" << endm;
2168 size_t nHitsEpd = mMuDst->numberOfEpdHit();
2169 float nHitsEpdEast = 0.;
2171 for(
size_t i=0; i<nHitsEpd; i++ ) {
2177 if( epdHit->
nMIP() < 0.3 )
continue;
2178 if( epdHit->
id() > 0 )
continue;
2180 if( epdHit->
nMIP() < 5 ) {
2181 nHitsEpdEast += epdHit->
nMIP();
2188 mHistograms.at(
"multiplicity_etofHits_epdEast" )->Fill( nHitsETof, nHitsEpdEast );
2190 mHistograms.at(
"multiplicity_btofHits_epdEast" )->Fill( nHitsBTof, nHitsEpdEast );
2195 LOG_DEBUG <<
"fillHitQA() - histograms filled" << endm;
2203 StETofHitMaker::setHistFileName()
2205 string extension =
".etofHit.root";
2207 if( GetChainOpt()->GetFileOut() !=
nullptr ) {
2208 TString outFile = GetChainOpt()->GetFileOut();
2210 mHistFileName = ( string ) outFile;
2213 size_t lastindex = mHistFileName.find_last_of(
"." );
2214 mHistFileName = mHistFileName.substr( 0, lastindex );
2217 lastindex = mHistFileName.find_last_of(
"." );
2218 mHistFileName = mHistFileName.substr( 0, lastindex );
2221 lastindex = mHistFileName.find_last_of(
"/" );
2222 mHistFileName = mHistFileName.substr( lastindex + 1, mHistFileName.length() );
2224 mHistFileName = mHistFileName + extension;
2226 LOG_ERROR <<
"Cannot set the output filename for histograms" << endm;
2232 StETofHitMaker::bookHistograms()
2234 LOG_INFO <<
"bookHistograms() ... " << endm;
2236 mHistograms[
"etofHit_tof" ] =
new TH1F(
"etofHit_tof",
"eTOF hit time of flight;time of flight (ns);# hits", 4000, -100., 150 );
2237 mHistograms[
"etofHit_tof_fullrange" ] =
new TH1F(
"etofHit_tof_fullrange",
"eTOF hit time of flight;time of flight (ns);# hits", 5000, -800., eTofConst::bTofClockCycle );
2238 mHistograms[
"averageTimeDiff_etofHits_btofHits" ] =
new TH1F(
"averageTimeDiff_etofHits_btofHits",
"difference between average times in bTOF and eTOF hits;#DeltaT (ns);# events", 4000, -500, 500 );
2239 mHistograms[
"multiplicity_etofHits_btofHits" ] =
new TH2F(
"multiplicity_etofHits_btofHits",
"multiplicity correlation between bTOF and eTOF;# eTOF hits;# bTOF hits", 300, 0, 300, 500, 0, 1000 );
2240 mHistograms[
"multiplicity_etofHits_epdEast" ] =
new TH2F(
"multiplicity_etofHits_epdEast",
"multiplicity correlation between eTOF and east EPD;# eTOF hits;# hits east EPD", 300, 0, 300, 200, 0, 1000 );
2242 AddHist( mHistograms.at(
"etofHit_tof" ) );
2243 AddHist( mHistograms.at(
"etofHit_tof_fullrange" ) );
2244 AddHist( mHistograms.at(
"averageTimeDiff_etofHits_btofHits" ) );
2245 AddHist( mHistograms.at(
"multiplicity_etofHits_btofHits" ) );
2246 AddHist( mHistograms.at(
"multiplicity_etofHits_epdEast" ) );
2249 mHistograms[
"etofHit_vpdVz_tof" ] =
new TH2F(
"etofHit_vpdVz_tof",
"eTOF hit time of flight;VPD Vz (cm);time of flight (ns)", 100, -200, 200, 1000, -50., 50 );
2250 mHistograms[
"btofHit_tof_fullrange" ] =
new TH1F(
"btofHit_tof_fullrange",
"bTOF hit time of flight;time of flight (ns);# hits", 5000, -800., eTofConst::bTofClockCycle );
2251 mHistograms[
"multiplicity_btofHits_epdEast" ] =
new TH2F(
"multiplicity_btofHits_epdEast",
"multiplicity correlation between bTOF and east EPD;# bTOF hits;# hits east EPD", 200, 0, 1000, 200, 0, 1000 );
2252 mHistograms[
"hitMultiplicityPerModuleCentral" ] =
new TH2F(
"hitMultiplicityPerModuleCentral",
"hit multiplicity per module in central bTOF events", 36, 0, 36, 50, 0, 50 );
2253 mHistograms[
"multiplicity_etofDigis_etofHits" ] =
new TH2F(
"multiplicity_etofDigis_etofHits",
"multiplicity correlation between eTOF digis and hits;# eTOF digis;# eTOF hits", 500, 0, 1000, 500, 0, 1000 );
2256 for(
int sector = eTofConst::sectorStart; sector <= eTofConst::sectorStop; sector++ ) {
2257 for(
int plane = eTofConst::zPlaneStart; plane <= eTofConst::zPlaneStop; plane++ ) {
2258 for(
int counter = eTofConst::counterStart; counter <= eTofConst::counterStop; counter++ ) {
2259 std::string histName_etofHit_pos =
"etofHit_pos_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2261 mHistograms[ histName_etofHit_pos ] =
new TH2F( Form(
"etofHit_pos_s%d_m%d_c%d", sector, plane, counter ),
"eTOF hit localXY;local X (cm);local Y (cm)", 64, -16., 16., 400, -500., 500. );
2262 AddHist( mHistograms.at( histName_etofHit_pos ) );
2265 std::string histNameDigisPerStrip =
"digisPerStrip_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2266 mHistograms[ histNameDigisPerStrip ] =
new TH2F( Form(
"digisPerStrip_s%d_m%d_c%d", sector, plane, counter ),
"digis per strip;strip;# digis per event", 32, 0.5, 32.5, 20, 0., 20. );
2268 std::string histNameDigisErased =
"digisErased_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2269 mHistograms[ histNameDigisErased ] =
new TH1F( Form(
"digisErased_s%d_m%d_c%d", sector, plane, counter ),
"digis erased;;# digis", 6, 0.5, 6.5 );
2270 mHistograms[ histNameDigisErased ]->GetXaxis()->SetBinLabel( 1,
"digi inside dead time" );
2271 mHistograms[ histNameDigisErased ]->GetXaxis()->SetBinLabel( 2,
"single digi on strip" );
2272 mHistograms[ histNameDigisErased ]->GetXaxis()->SetBinLabel( 3,
"3 consecutive same side digis" );
2273 mHistograms[ histNameDigisErased ]->GetXaxis()->SetBinLabel( 4,
"better match for partner" );
2274 mHistograms[ histNameDigisErased ]->GetXaxis()->SetBinLabel( 5,
"single remaining digi" );
2275 mHistograms[ histNameDigisErased ]->GetXaxis()->SetBinLabel( 6,
"matched into pair" );
2280 std::string histName_clustersize =
"clustersize_s" + std::to_string( sector ) +
"m" + std::to_string( plane );
2281 mHistograms[ histName_clustersize ] =
new TH1F( Form(
"clustersize_s%d_m%d", sector, plane ),
"clustersize;clustersize;# events", 32, 0., 32. );
2287 mHistograms[
"unclusteredHit_tot" ] =
new TH1F(
"unclusteredHit_tot",
"unclustered hit tot; tot (ns);# unclustered hits", 1000, 0., 80. );
2288 mHistograms[
"unclusteredHit_tof" ] =
new TH1F(
"unclusteredHit_tof",
"unclustered hit time of flight; time of flight (ns);# unclustered hits", 5000, 0., 1000. );
2290 mHistograms[
"unclusteredHit_tot_difference" ] =
new TH1F(
"unclusteredHit_tot_difference",
"unclustered hit tot difference of digis; #Delta tot (ns);# unclustered hits", 1000, -100., 100. );
2291 mHistograms[
"unclusteredHit_tail_totAsym" ] =
new TH1F(
"unclusteredHit_tail_totAsym",
"unclustered hit tail tot asymmetry of digis; #Delta tot/ tot sum;# unclustered hits", 200, -1., 1. );
2293 mHistograms[
"unclusteredHit_tof_fullrange" ] =
new TH1F(
"unclusteredHit_tof_fullrange",
"unclustered hit time of flight; time of flight (ns);# unclustered hits", 5000, -1. * eTofConst::bTofClockCycle, eTofConst::bTofClockCycle );
2294 mHistograms[
"unclusteredHit_tof_fullrange_all" ] =
new TH1F(
"unclusteredHit_tof_fullrange_all",
"unclustered hit time of flight; time of flight (ns);# unclustered hits", 5000, -1. * eTofConst::bTofClockCycle, eTofConst::bTofClockCycle );
2296 for(
int sector = eTofConst::sectorStart; sector <= eTofConst::sectorStop; sector++ ) {
2297 for(
int plane = eTofConst::zPlaneStart; plane <= eTofConst::zPlaneStop; plane++ ) {
2298 for(
int counter = eTofConst::counterStart; counter <= eTofConst::counterStop; counter++ ) {
2299 std::string histName_unclusteredHit_tot =
"unclusteredHit_tot_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2300 std::string histName_unclusteredHit_pos =
"unclusteredHit_pos_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2301 std::string histName_unclusteredHit_tof =
"unclusteredHit_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2302 std::string histName_unclusteredHit_delT =
"unclusteredHit_delT_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2303 std::string histName_unclusteredHit_delT_pos =
"unclusteredHit_delT_pos_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2304 std::string histName_unclusteredHit_delT_tot =
"unclusteredHit_delT_tot_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2306 std::string histName_unclusteredHit_tail_tof =
"unclusteredHit_tail_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2307 std::string histName_unclusteredHit_good_tof =
"unclusteredHit_good_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2308 std::string histName_unclusteredHit_pVtx_tof =
"unclusteredHit_pVtx_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2310 mHistograms[ histName_unclusteredHit_tot ] =
new TH2F( Form(
"unclusteredHit_tot_s%d_m%d_c%d", sector, plane, counter ),
"unclustered hit tot; tot (ns);local X (cm)", 1000, 0., 80., 32, -16., 16. );
2311 mHistograms[ histName_unclusteredHit_pos ] =
new TH2F( Form(
"unclusteredHit_pos_s%d_m%d_c%d", sector, plane, counter ),
"unclustered hit localXY; local X (cm);local Y (cm)", 32, -16., 16., 400, -50., 50. );
2313 mHistograms[ histName_unclusteredHit_tof ] =
new TH2F( Form(
"unclusteredHit_tof_s%d_m%d_c%d", sector, plane, counter ),
"unclustered hit time of flight;local X (cm);time of flight (ns)", 32, -16., 16., 5000, 0., 1000. );
2314 mHistograms[ histName_unclusteredHit_delT ] =
new TH2F( Form(
"unclusteredHit_delT_s%d_m%d_c%d", sector, plane, counter ),
"unclustered hit time to cluster neighbor;local X (cm); delT_cluster (ns)", 32, -16., 16., 200, -1., 1. );
2316 mHistograms[ histName_unclusteredHit_delT_pos ] =
new TH3F( Form(
"unclusteredHit_delT_DelPos_s%d_m%d_c%d", sector, plane, counter ),
"unclustered hit time to cluster neighbor;local X (cm); delT_cluster (ns); y-pos (cm)", 32, -16., 16., 60, -0.3, 0.3, 20, -15., 15. );
2318 mHistograms[ histName_unclusteredHit_delT_tot ] =
new TH3F( Form(
"unclusteredHit_delT_tot_s%d_m%d_c%d", sector, plane, counter ),
"unclustered hit time to cluster neighbor;local X (cm); delT_cluster (ns); tot (ns)", 32, -16., 16., 60, -0.3, 0.3, 25, 0., 10. );
2320 mHistograms[ histName_unclusteredHit_tail_tof ] =
new TH2F( Form(
"unclusteredHit_tof_tail_s%d_m%d_c%d", sector, plane, counter ),
"unclustered hit (tail) time of flight;local X (cm);time of flight (ns)", 32, -16., 16., 5000, 0., 1000. );
2321 mHistograms[ histName_unclusteredHit_good_tof ] =
new TH2F( Form(
"unclusteredHit_tof_good_s%d_m%d_c%d", sector, plane, counter ),
"unclustered hit (good) time of flight;local X (cm);time of flight (ns)", 32, -16., 16., 2500, 0., 50. );
2322 mHistograms[ histName_unclusteredHit_pVtx_tof ] =
new TH2F( Form(
"unclusteredHit_pVtx_tof_s%d_m%d_c%d", sector, plane, counter ),
"unclustered hit time of flight;local X (cm);time of flight (ns)", 32, -16., 16., 2500, 0., 50. );
2324 std::string histName_digi_tot =
"digi_tot_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2326 mHistograms[ histName_digi_tot ] =
new TH2F( Form(
"digi_tot_s%d_m%d_c%d", sector, plane, counter ),
"digi tot;(strip-1)+0.5*(side-1);tot (arb. units)", 64, 0., 32., 200, 0., 40. );
2328 std::string histName_unclusteredHit_pos_time =
"unclusteredHit_pos_time_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2329 mHistograms[ histName_unclusteredHit_pos_time ] =
new TH2F( Form(
"unclusteredHit_pos_time_s%d_m%d_c%d", sector, plane, counter ),
"hit position over time;time (s);hit position (cm)", 3000, 56000., 59000., 200, -100., 100. );
2332 std::string histName_unclusteredHit_jump_pos =
"unclusteredHit_jump_pos_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2333 std::string histName_unclusteredHit_jump_tof =
"unclusteredHit_jump_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2335 mHistograms[ histName_unclusteredHit_jump_pos ] =
new TH2F( Form(
"unclusteredHit_jump_pos_s%d_m%d_c%d", sector, plane, counter ),
"unclustered jump hit localXY; local X (cm);local Y (cm)", 8, -16., 16., 200, -70., 70. );
2336 mHistograms[ histName_unclusteredHit_jump_tof ] =
new TH2F( Form(
"unclusteredHit_jump_tof_s%d_m%d_c%d", sector, plane, counter ),
"unclustered jump hit time of flight;local X (cm);time of flight (ns)", 8, -16., 16., 400, 0., 50. );
2341 mHistograms[
"counter_active" ] =
new TH2F(
"counter_active",
"active counters by run;100*day + run number;counter", 15000, 5000., 20000., 108 , 0.5, 108.5 );
2344 for (
auto& kv : mHistograms ) {
2345 kv.second->SetDirectory( 0 );
2351 StETofHitMaker::writeHistograms()
2353 if( mHistFileName !=
"" ) {
2354 LOG_INFO <<
"writing histograms to: " << mHistFileName.c_str() << endm;
2356 TFile histFile( mHistFileName.c_str(),
"RECREATE",
"etofHit" );
2359 for (
const auto& kv : mHistograms ) {
2360 if( kv.second->GetEntries() > 0 ) kv.second->Write();
2366 LOG_INFO <<
"histogram file name is empty string --> cannot write histograms" << endm;
2373 StETofHitMaker::detectorToKey(
const unsigned int detectorId )
2375 unsigned int sector = ( detectorId / eTofConst::nCountersPerSector ) + eTofConst::sectorStart;
2376 unsigned int zPlane = ( ( detectorId % eTofConst::nCountersPerSector ) / eTofConst::nCounters ) + eTofConst::zPlaneStart;
2377 unsigned int counter = ( detectorId % eTofConst::nCounters ) + eTofConst::counterStart;
2379 return sector * 100 + zPlane * 10 + counter;
2384 StETofHitMaker::updateCyclicRunningMean(
const double& value,
double& mean,
int& count,
const double& range )
2386 double valIn = value;
2387 if( mean - value < -0.9 * range ) {
2390 else if( mean - value > 0.9 * range ) {
2396 double scaling = 1. / count;
2399 LOG_INFO <<
"old mean: " << mean <<
" scaling: " << scaling <<
" value in: " << valIn << endm;
2402 mean = valIn * scaling + mean * ( 1. - scaling );
2405 LOG_INFO <<
"new mean: " << mean << endm;
2411 StETofHitMaker::updateClockJumpMap(
const std::map< int, int >& clockJumpDir )
2413 for(
const auto& kv: clockJumpDir ) {
2414 mClockJumpDirection.at( kv.first ) = kv.second;
2418 for(
const auto& kv : mClockJumpDirection ) {
2419 if( kv.second != 1 ) {
2420 LOG_INFO <<
"StETofHitMaker::updateClockJumpMap() -- entry in clock jump map: " << kv.first <<
" value: " << kv.second << endm;
2429 StETofHitMaker::modifyHit(
int modMode,
double& localX,
double& localY,
double& time )
2450 std::swap(localX, localY), localY = -localY;
2454 std::swap(localX, localY), localX = -localX;
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
double localY() const
Y-position.
unsigned int zPlane() const
ZPlane.
static StMuBTofHit * btofHit(int i)
returns pointer to the i-th muBTofHit
unsigned int clusterSize() const
Cluster size.
double time() const
Time.
double calibTime() const
calibrated time
unsigned int zPlane() const
ZPlane.
static TClonesArray * epdHits()
returns pointer to the EpdHitCollection
unsigned int side() const
Side.
unsigned int counter() const
Counter.
unsigned int sector() const
Sector.
double time() const
Time.
static StMuETofHit * etofHit(int i)
returns pointer to the i-th StMuETofHit
static TClonesArray * btofArray(int type)
returns pointer to the n-th TClonesArray from the btof arrays // dongx
unsigned int clusterSize() const
Cluster size.
unsigned int sector() const
Sector.
float nMIP() const
gain calibrated energy loss in tile, in units of Landau MPV for one MIP
unsigned int strip() const
Strip.
double rawTot() const
Getter for uncalibrated Tot.
unsigned int counter() const
Counter.
static TClonesArray * etofArray(int type)
returns pointer to the n-th TClonesArray from the etof arrays // FS
double localX() const
X-position.
Stores information for tiles in STAR Event Plane Detector.
unsigned int zPlane() const
ZPlane.
static StMuETofDigi * etofDigi(int i)
returns pointer to the i-th StMuEtofDigi
double localX() const
X-position.
unsigned int idTruth() const
mc-true associated track id in simulation
void addETofHit(const StMuETofHit *hit)
double totalTot() const
Total Tot.
double localY() const
Y-position.
Float_t nMIP()
gain calibrated energy loss in tile, in units of Landau MPV for one MIP
static StBTofHeader * btofHeader()
returns pointer to the btofHeader - dongx
unsigned int sector() const
Sector.
unsigned int counter() const
Counter.
double calibTot() const
Getter for calibrated Tot.
unsigned int side() const
Side.
double calibTot() const
Getter for calibrated Tot.
virtual TDataSet * Find(const char *path) const