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 "StETofCalibMaker/StETofCalibMaker.h"
78 #include "StETofUtil/StETofConstants.h"
79 #include "StETofUtil/StETofGeometry.h"
81 #include "tables/St_etofHitParam_Table.h"
82 #include "tables/St_etofSignalVelocity_Table.h"
83 #include "tables/St_etofModCounter_Table.h"
85 #include "StarClassLibrary/SystemOfUnits.h"
86 #include "StarClassLibrary/PhysicalConstants.h"
87 #include "StBTofUtil/tofPathLength.hh"
91 StETofHitMaker::StETofHitMaker(
const char* name )
96 mFileNameHitParam(
"" ),
97 mFileNameSignalVelocity(
"" ),
98 mFileNameModMatrix(
"" ),
99 mFileNameAlignParam(
"" ),
103 mMapHitDigiIndices(),
104 mMapHitIndexDigiIndices(),
106 mMergingRadius( 1. ),
108 mSoftwareDeadTime( 150. ),
109 mDoClockJumpShift( true ),
110 mDoDoubleClockJumpShift( false ),
111 mClockJumpDirection(),
113 mGet4doublejumpTmin(-1.0),
114 mGet4doublejumpFlag(),
115 mGet4doublejumpTimes(),
124 LOG_DEBUG <<
"StETofHitMaker::ctor" << endm;
128 StETofHitMaker::~StETofHitMaker()
135 StETofHitMaker::Init()
137 LOG_INFO <<
"StETofHitMaker::Init()" << endm;
145 std::vector<int> nll;
146 for(
int i=0;i<eTofConst::nGet4sInSystem;i++){
147 mGet4PartnerPairMap[i] = nll;
167 mGet4PartnerPairMap[i].push_back(partnerId);
169 if(count <= 8 && !reset){
172 mGet4PartnerPairMap[i].push_back(pairId);
175 }
else if(count < 16 || reset){
178 mGet4PartnerPairMap[i].push_back(pairId2);
188 StETofHitMaker::InitRun( Int_t runnumber )
190 LOG_INFO <<
"StETofHitMaker::InitRun()" << endm;
196 for(
int i = 0; i < 864; i++){
197 mGet4DefaultMap[i] = mETofCalibMaker->GetDefaultState(i);
200 for(
int i = 0; i < 864; i++){
201 mGet4DefaultMap[i] = 0;
206 std::ifstream paramFile;
216 if( mFileNameHitParam.empty() ) {
217 LOG_INFO <<
"etofHitParam: no filename provided --> load database table" << endm;
219 dbDataSet = GetDataBase(
"Calibrations/etof/etofHitParam" );
221 St_etofHitParam* etofHitParam =
static_cast< St_etofHitParam*
> ( dbDataSet->
Find(
"etofHitParam" ) );
222 if( !etofHitParam ) {
223 LOG_ERROR <<
"unable to get the hit params from the database" << endm;
227 etofHitParam_st* hitParamTable = etofHitParam->GetTable();
229 mMaxYPos = hitParamTable->maxLocalY;
230 mMergingRadius = hitParamTable->clusterMergeRadius;
233 LOG_INFO <<
"etofHitParam: filename provided --> use parameter file: " << mFileNameHitParam.c_str() << endm;
235 paramFile.open( mFileNameHitParam.c_str() );
237 if( !paramFile.is_open() ) {
238 LOG_ERROR <<
"unable to get the 'etofHitParam' parameters from file --> file does not exist" << endm;
244 if( paramFile.good() ) {
245 paramFile >> temp1 >> temp2;
254 mMergingRadius = temp2;
258 LOG_INFO <<
" maximum local Y: " << mMaxYPos <<
" , cluster merging radius: " << mMergingRadius << endm;
265 if( mFileNameSignalVelocity.empty() ) {
266 LOG_INFO <<
"etofSignalVelocity: no filename provided --> load database table" << endm;
268 dbDataSet = GetDataBase(
"Calibrations/etof/etofSignalVelocity" );
270 St_etofSignalVelocity* etofSignalVelocity =
static_cast< St_etofSignalVelocity*
> ( dbDataSet->
Find(
"etofSignalVelocity" ) );
273 if( !etofSignalVelocity ) {
274 LOG_ERROR <<
"unable to get the signal velocity from the database" << endm;
278 etofSignalVelocity_st* velocityTable = etofSignalVelocity->GetTable();
280 for(
size_t i=0; i<eTofConst::nCountersInSystem; i++ ) {
281 if( velocityTable->signalVelocity[ i ] > 0 ) {
282 mSigVel[ detectorToKey( i ) ] = velocityTable->signalVelocity[ i ];
287 LOG_INFO <<
"etofSignalVelocity: filename provided --> use parameter file: " << mFileNameSignalVelocity.c_str() << endm;
289 paramFile.open( mFileNameSignalVelocity.c_str() );
291 if( !paramFile.is_open() ) {
292 LOG_ERROR <<
"unable to get the 'etofSignalVelocity' parameters from file --> file does not exist" << endm;
296 std::vector< float > velocity;
298 while( paramFile >> temp ) {
299 velocity.push_back( temp );
304 if( velocity.size() != eTofConst::nCountersInSystem ) {
305 LOG_ERROR <<
"parameter file for 'etofSignalVelocity' has not the right amount of entries: ";
306 LOG_ERROR << velocity.size() <<
" instead of " << eTofConst::nCountersInSystem <<
" !!!!" << endm;
310 for(
size_t i=0; i<eTofConst::nCountersInSystem; i++ ) {
311 if( velocity.at( i ) > 0 ) {
312 mSigVel[ detectorToKey( i ) ] = velocity.at( i );
317 for(
const auto& kv : mSigVel ) {
318 LOG_INFO <<
"counter key: " << kv.first <<
" --> signal velocity = " << kv.second <<
" cm / ns" << endm;
325 if(!mFileNameModMatrix.empty()){
327 LOG_INFO <<
"etofModMatrix: filename provided --> use parameter file: " << mFileNameSignalVelocity.c_str() << endm;
329 paramFile.open( mFileNameModMatrix.c_str() );
331 if( !paramFile.is_open() ) {
332 LOG_ERROR <<
"unable to get the 'etofModMatrix' parameters from file --> file does not exist" << endm;
336 std::vector< int > modMatrix;
338 while( paramFile >> temp ) {
339 modMatrix.push_back( temp );
345 if( modMatrix.size() != eTofConst::nCountersInSystem ) {
346 LOG_ERROR <<
"parameter file for 'etofModMatrix' has not the right amount of entries: ";
347 LOG_ERROR << modMatrix.size() <<
" instead of " << eTofConst::nCountersInSystem <<
" !!!!" << endm;
351 for(
size_t i=0; i<eTofConst::nCountersInSystem; i++ ) {
352 if( modMatrix.at( i ) > 0 ) {
353 mModMatrix[ detectorToKey( i ) ] = modMatrix.at( i );
359 dbDataSet = GetDataBase(
"Geometry/etof/etofModCounter" );
363 LOG_ERROR <<
"unable to get the dataset from the database" << endm;
367 St_etofModCounter* etofModCounter =
static_cast< St_etofModCounter*
> ( dbDataSet->
Find(
"etofModCounter") );
369 if( !etofModCounter ) {
370 LOG_WARN <<
"unable to get the ModMap from the database" << endm;
375 etofModCounter_st* ModCounterTable = etofModCounter->GetTable();
377 for(
size_t i=0; i<eTofConst::nCountersInSystem; i++ ) {
378 mModMatrix[ detectorToKey( i ) ] = ModCounterTable->detectorModFlag[ i ];
384 for(
int i=0; i<eTofConst::nCountersInSystem * 8; i++ ) {
385 int key = detectorToKey( i / 8 ) * 10 + ( i % 8 ) + 1;
386 mClockJumpDirection[ key ] = -1;
388 LOG_DEBUG << key <<
" " << mClockJumpDirection.at( key ) << endm;
390 mGet4doublejumpFlag[ key ] = 0;
392 for(
int k=0; k<3; k++){
393 mGet4doublejumpTimes[key].push_back(-999);
398 for(
int i=0; i<eTofConst::nCountersInSystem; i++ ) {
399 mCounterActive.push_back(
false );
406 LOG_INFO <<
" creating a new eTOF geometry . . . " << endm;
407 mETofGeom =
new StETofGeometry(
"etofGeometry",
"etofGeometry in HitMaker" );
410 if( mETofGeom && !mETofGeom->isInitDone() ) {
411 LOG_INFO <<
" eTOF geometry initialization ... " << endm;
413 if( !gGeoManager ) GetDataBase(
"VmcGeometry" );
416 LOG_ERROR <<
"Cannot get GeoManager" << endm;
420 LOG_DEBUG <<
" gGeoManager: Should set alignment file now! " << mFileNameAlignParam <<
" ! "<< endm;
421 if (mFileNameAlignParam !=
""){
422 LOG_INFO <<
" gGeoManager: Setting alignment file: " << mFileNameAlignParam << endm;
423 mETofGeom->setFileNameAlignParam(mFileNameAlignParam);
425 mETofGeom->init(gGeoManager);
426 LOG_DEBUG <<
" init done " << endm;
434 StETofHitMaker::FinishRun( Int_t runnumber )
436 LOG_INFO <<
"StETofHitMaker::FinishRun()" << endm;
438 for(
int iCounter = 0; iCounter < eTofConst::nCountersInSystem; iCounter++ ) {
439 if( mCounterActive.at( iCounter ) ) {
440 int day = ( runnumber % 1000000 ) / 1000;
441 int run = runnumber % 1000;
443 mHistograms.at(
"counter_active" )->Fill( 100 * day + run, iCounter );
459 LOG_INFO <<
"StETofHitMaker::Finish()" << endm;
462 LOG_INFO <<
"Finish() - writing *.etofHit.root ..." << endm;
474 LOG_DEBUG <<
"StETofHitMaker::Make(): starting ..." << endm;
476 mEvent = (
StEvent* ) GetInputDS(
"StEvent" );
480 LOG_DEBUG <<
"Make() - running on StEvent" << endm;
483 if( !etofCollection ) {
484 LOG_WARN <<
"Make() - Found StEvent data structure, but no eTOF collection. Try MuDst processing instead" << endm;
485 mMuDst = (
StMuDst* ) GetInputDS(
"MuDst" );
488 LOG_DEBUG <<
"Make() - running on MuDsts" << endm;
501 LOG_DEBUG <<
"Make(): no StEvent found" << endm;
503 mMuDst = (
StMuDst* ) GetInputDS(
"MuDst" );
506 LOG_DEBUG <<
"Make() - running on MuDsts" << endm;
513 LOG_WARN <<
"Make() - no StMuDst or StEvent" << endm;
521 StETofHitMaker::processStEvent()
525 if( !etofCollection ) {
526 LOG_WARN <<
"processStEvent() - no etof collection" << endm;
530 if( !etofCollection->digisPresent() ) {
531 LOG_WARN <<
"processStEvent() - no digis present" << endm;
535 const StSPtrVecETofDigi& etofDigis = etofCollection->etofDigis();
539 size_t nDigis = etofDigis.size();
541 LOG_DEBUG <<
"processStEvent() - # fired eTOF digis : " << nDigis << endm;
544 bool isMuDst =
false;
547 clearHits( isMuDst );
554 size_t nDigisInStore = 0;
556 for(
size_t i = 0; i<nDigis; i++ ) {
559 if( fillStorage( aDigi, i ) ) {
567 double tstart = startTime();
570 fillUnclusteredHitQA( tstart, isMuDst );
573 mergeClusters( isMuDst );
575 assignAssociatedHits( isMuDst );
579 mHistograms.at(
"multiplicity_etofDigis_etofHits" )->Fill( nDigisInStore, etofCollection->etofHits().size() );
582 if( etofCollection->hitsPresent() ) {
583 fillHitQA( isMuDst, tstart );
589 StETofHitMaker::processMuDst()
592 LOG_WARN <<
"processMuDst() - no digi array" << endm;
596 if( !mMuDst->numberOfETofDigi() ) {
597 LOG_WARN <<
"processMuDst() - no digis present" << endm;
603 size_t nDigis = mMuDst->numberOfETofDigi();
605 LOG_DEBUG <<
"processMuDst() - # fired eTOF digis : " << nDigis << endm;
610 clearHits( isMuDst );
617 size_t nDigisInStore = 0;
619 for(
size_t i = 0; i<nDigis; i++ ) {
622 if( fillStorage( aDigi, i ) ) {
630 double tstart = startTime();
633 fillUnclusteredHitQA( tstart, isMuDst );
636 mergeClusters( isMuDst );
638 assignAssociatedHits( isMuDst );
642 mHistograms.at(
"multiplicity_etofDigis_etofHits" )->Fill( nDigisInStore, mMuDst->numberOfETofHit() );
646 if( mMuDst->numberOfETofHit() ) {
647 fillHitQA( isMuDst, tstart );
656 StETofHitMaker::startTime()
659 LOG_INFO <<
"startTime(): -- loading start time from bTOF header" << endm;
664 LOG_INFO <<
"mIsSim = true --> startTime set to 0" << endm;
674 if ( btofCollection ) {
675 btofHeader = btofCollection->tofHeader();
678 LOG_DEBUG <<
"no StBTofCollection found by getTstart" << endm;
687 LOG_DEBUG <<
"startTime(): -- no bTOF header --> no start time avaiable" << endm;
691 double tstart = btofHeader->tStart();
693 if( !isfinite( tstart ) ) {
694 LOG_DEBUG <<
"startTime(): -- from bTOF header is NaN" << endm;
698 if( tstart != -9999. ) {
699 tstart = fmod( tstart, eTofConst::bTofClockCycle );
700 if( tstart < 0. ) tstart += eTofConst::bTofClockCycle;
704 LOG_INFO <<
"startTime(): -- start time: " << tstart << endm;
713 StETofHitMaker::startTimeVpd(
double& tstart,
double& vertexVz )
719 LOG_INFO <<
"startTimeVpd(): -- calculating VPD start time from bTOF header" << endm;
727 if ( btofCollection ) {
728 btofHeader = btofCollection->tofHeader();
731 LOG_DEBUG <<
"no StBTofCollection found by getTstart" << endm;
740 LOG_DEBUG <<
"startTimeVpd(): -- no bTOF header --> no start time avaiable" << endm;
746 int nWest = btofHeader->numberOfVpdHits( west );
747 int nEast = btofHeader->numberOfVpdHits( east );
749 double vpdLeTime[ 2 * nVpd ];
753 if( fabs( btofHeader->vpdVz() ) > 200. ) {
755 LOG_INFO <<
"startTimeVpd(): no valid Vpd data in the bTOF header " << endm;
760 vertexVz = btofHeader->vpdVz();
761 LOG_DEBUG <<
"startTimeVpd(): Vpd vertex is at: " << vertexVz << endm;
770 for(
int i=0; i< nVpd; i++ ) {
771 vpdLeTime[ i ] = btofHeader->vpdTime( west, i+1 );
772 if( vpdLeTime[ i ] > 0. ) {
773 updateCyclicRunningMean( vpdLeTime[ i ], tMean, nTubes, eTofConst::bTofClockCycle );
775 LOG_DEBUG <<
"startTimeVpd(): loading VPD west tubeId = " << i+1 <<
" time " << vpdLeTime[ i ] << endm;
780 for(
int i=0; i< nVpd; i++ ) {
781 vpdLeTime[ i + nVpd ] = btofHeader->vpdTime( east, i+1 );
782 if( vpdLeTime[ i + nVpd ] > 0. ) {
783 updateCyclicRunningMean( vpdLeTime[ i + nVpd ], tMean, nTubes, eTofConst::bTofClockCycle );
785 LOG_DEBUG <<
"startTimeVpd(): loading VPD east tubeId = " << i+1 <<
" time " << vpdLeTime[ i + nVpd ] << endm;
789 if( nTubesEast >= 2 && nTubesWest >= 2 ) {
793 if( tstart != -9999 ) {
794 tstart = fmod( tstart, eTofConst::bTofClockCycle );
795 if( tstart < 0. ) tstart += eTofConst::bTofClockCycle;
799 LOG_INFO <<
"startTimeVpd(): -- sum: " << tMean <<
" nWest: " << nWest <<
" nEast: " << nEast;
800 LOG_INFO <<
" --> compare (if bTofHeader is filled): " << btofHeader->tStart() << endm;
801 LOG_INFO <<
"startTimeVpd(): -- start time: " << tstart << endm;
808 StETofHitMaker::fillStorage(
StETofDigi* aDigi,
unsigned int index )
811 LOG_WARN <<
"No digi found" << endm;
817 LOG_DEBUG <<
"fillStorage() - digi not calibrated, most likely since it is outside the trigger window or pulser. Ignore." << endm;
823 LOG_WARN <<
"fillStorage() - sector / zPlane / counter / strip was not assigned to the digi" << endm;
830 LOG_DEBUG <<
"fillStorage() -- sector plane counter strip: " << pDigi->
sector() <<
" ";
831 LOG_DEBUG << pDigi->
zPlane() <<
" " << pDigi->
counter() <<
" " << pDigi->
strip() << endm;
832 LOG_DEBUG <<
"fillStorage() -- calibTime: " << pDigi->
calibTime();
833 LOG_DEBUG <<
" calibToT: " << pDigi->
calibTot() << endm;
836 unsigned int key = pDigi->
sector() * 10000 +
841 mStoreDigi[ key ].push_back( pDigi );
843 mMapDigiIndex[ pDigi ] = index;
847 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() );
849 mHistograms[ histName_digi_tot ]->Fill( pDigi->
strip() - 1 + pDigi->
side() * 0.3, pDigi->
calibTot() );
857 StETofHitMaker::fillStorage(
StMuETofDigi* aDigi,
unsigned int index )
859 return fillStorage( (
StETofDigi* ) aDigi, index );
865 StETofHitMaker::clearHits(
const bool isMuDst )
868 if( !( mEvent->etofCollection()->hitsPresent() ) ) {
872 LOG_DEBUG <<
"clearHits() - number of hits present (before clear): " << mEvent->etofCollection()->etofHits().size() << endm;
875 StSPtrVecETofHit& etofHits = mEvent->etofCollection()->etofHits();
878 LOG_DEBUG <<
"clearHits() - number of hits present (after clear): " << mEvent->etofCollection()->etofHits().size() << endm;
881 StSPtrVecETofDigi& etofDigis = mEvent->etofCollection()->etofDigis();
882 size_t nDigis = etofDigis.size();
884 for(
size_t i=0; i<nDigis; i++ ) {
887 if( !aDigi )
continue;
889 aDigi->setAssociatedHit(
nullptr );
891 LOG_DEBUG <<
"clearHits() - associated hits of digis set to nullptr" << endm;
894 if( mMuDst->numberOfETofHit() == 0 ) {
898 LOG_DEBUG <<
"clearHits() - number of hits present (before clear): " << mMuDst->numberOfETofHit() << endm;
901 mMuDst->
etofArray( muETofHit )->Clear(
"C" );
903 LOG_DEBUG <<
"clearHits() - number of hits present (after clear): " << mMuDst->numberOfETofHit() << endm;
906 size_t nDigis = mMuDst->numberOfETofDigi();
908 for(
size_t i=0; i<nDigis; i++ ) {
911 if( !aDigi )
continue;
913 aDigi->setAssociatedHitId( -1 );
915 LOG_DEBUG <<
"clearHits() - associated hit id of digis set to -1" << endm;
922 StETofHitMaker::clearStorage()
925 for(
auto kv = mStoreDigi.begin(); kv != mStoreDigi.end(); kv++ ) {
926 size_t remainingDigis = kv->second.size();
929 LOG_DEBUG <<
"strip key " << kv->first <<
" has " << remainingDigis <<
" left" << endm;
932 for(
unsigned int i=0; i<remainingDigis; i++ ) {
933 delete kv->second.at( i );
941 for(
auto kv = mStoreHit.begin(); kv != mStoreHit.end(); kv++ ) {
942 size_t remainingHits = kv->second.size();
945 LOG_DEBUG <<
"detector key " << kv->first <<
" has " << remainingHits <<
" left" << endm;
948 for(
size_t i=0; i<remainingHits; i++ ) {
949 delete kv->second.at( i );
957 mMapDigiIndex.clear();
960 mMapHitDigiIndices.clear();
963 mMapHitIndexDigiIndices.clear();
968 StETofHitMaker::matchSides()
970 std::vector< StETofDigi* >::iterator iterDigi;
972 std::string histNameDigisErased;
974 for(
auto kv = mStoreDigi.begin(); kv != mStoreDigi.end(); kv++ ) {
975 unsigned int stripIndex = kv->first;
976 std::vector< StETofDigi* > *digiVec = &( kv->second );
980 return lhs->
calibTime() < rhs->calibTime();
984 int nDigisOnStrip = digiVec->size();
988 LOG_INFO << stripIndex <<
" size: " << nDigisOnStrip << endm;
990 for(
size_t i=0; i<digiVec->size(); i++ ) {
991 LOG_INFO <<
"matchSides() - DIGI: " << digiVec->at( i ) <<
" ";
992 LOG_INFO <<
"calibTime=" << setprecision( 16 ) << digiVec->at( i )->calibTime() <<
" " << endm;
993 LOG_INFO <<
"calibTot=" << setprecision( 4 ) << digiVec->at( i )->calibTot() <<
" ";
994 LOG_INFO <<
"side=" << setprecision( 4 ) << digiVec->at( i )->side() << endm;
999 int detIndex = stripIndex / 100;
1000 int sector = detIndex / 100;
1001 int plane = ( detIndex % 100 ) / 10;
1002 int counter = detIndex % 10;
1003 int strip = stripIndex % 100;
1006 std::string histNameDigisPerStrip =
"digisPerStrip_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1007 mHistograms.at( histNameDigisPerStrip )->Fill( strip, nDigisOnStrip );
1009 histNameDigisErased =
"digisErased_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1015 std::vector< double > deadTime( 2, -60. );
1017 for(
auto it = digiVec->begin(); it != digiVec->end(); it++ ) {
1018 if( (*it)->rawTime() - deadTime.at( (*it)->side() - 1 ) < mSoftwareDeadTime ) {
1021 LOG_INFO <<
"digi within dead time --> ignore ... ( geomId : " << stripIndex * 10 + (*it)->side();
1022 LOG_INFO <<
" dead time: " << setprecision( 16 ) << deadTime.at( (*it)->side() - 1 );
1023 LOG_INFO <<
" calib time: " << setprecision( 16 ) << (*it)->calibTime();
1024 LOG_INFO <<
" difference: " << (*it)->calibTime() - deadTime.at( (*it)->side() - 1 ) << endm;
1028 digiVec->erase( it );
1030 mHistograms[ histNameDigisErased ]->Fill(1);
1035 deadTime.at( (*it)->side() - 1 ) = (*it)->rawTime();
1040 std::vector< unsigned int > containedDigiIndices;
1044 double timeDiff = 0.0;
1045 double totSum = 0.0;
1046 double t_corr_afterpulse = 0.0;
1049 if( mDoQA && digiVec->size() == 1 ) {
1050 mHistograms.at( histNameDigisErased )->Fill( 2 );
1055 if( digiVec->size() == 1 ) {
1070 if(!mIsSim && mApCorr){
1071 time += t_corr_afterpulse;
1076 if(xDigiA->
side() == 1){
1084 posX = ( -1 * eTofConst::nStrips / 2. + strip - 0.5 ) * eTofConst::stripPitch;
1086 unsigned int clusterSize = 1000;
1088 StETofHit* constructedHit =
new StETofHit( sector, plane, counter, time, totSum, clusterSize, posX, posY );
1090 mStoreHit[ detIndex ].push_back( constructedHit );
1092 containedDigiIndices.push_back( mMapDigiIndex.at( xDigiA ) );
1093 containedDigiIndices.push_back( mMapDigiIndex.at( xDigiB ) );
1095 mMapHitDigiIndices[ constructedHit ] = containedDigiIndices;
1101 while( digiVec->size() > 1 ) {
1103 LOG_DEBUG << stripIndex <<
" -- digiVec->size() -- " << digiVec->size() << endm;
1108 while( digiVec->at( 0 )->side() == digiVec->at( 1 )->side() ) {
1110 if( digiVec->size() > 2 ) {
1113 if( digiVec->at( 2 )->side() == digiVec->at( 0 )->side() ) {
1116 iterDigi = digiVec->begin();
1118 digiVec->erase( iterDigi );
1120 mHistograms.at( histNameDigisErased )->Fill( 3 );
1124 if( digiVec->at( 2 )->calibTime() - digiVec->at( 0 )->calibTime() >
1125 digiVec->at( 2 )->calibTime() - digiVec->at( 1 )->calibTime() ) {
1129 iterDigi = digiVec->begin();
1131 digiVec->erase( iterDigi );
1133 if(mApCorr) t_corr_afterpulse = digiVec->at( 0 )->calibTime() - digiVec->at( 1 )->calibTime();
1135 mHistograms.at( histNameDigisErased )->Fill( 4 );
1141 iterDigi = digiVec->begin() + 1;
1143 digiVec->erase( iterDigi );
1145 mHistograms.at( histNameDigisErased )->Fill( 7 );
1152 iterDigi = digiVec->begin();
1154 digiVec->erase( iterDigi );
1155 if( mDoQA && digiVec->size() == 1 ){
1156 mHistograms.at( histNameDigisErased )->Fill( 5 );
1160 if( digiVec->size() < 2 ) {
1161 if(mDoQA && digiVec->size() == 1) {
1162 mHistograms.at( histNameDigisErased )->Fill( 5 );
1169 LOG_DEBUG <<
"matchSides() - digi processing for sector " << stripIndex / 10000;
1170 LOG_DEBUG <<
" plane " << ( stripIndex % 10000 ) / 1000 <<
" counter " << ( stripIndex % 1000 ) / 100;
1171 LOG_DEBUG <<
" strip " << stripIndex % 100;
1172 LOG_DEBUG <<
" size: " << digiVec->size() << endm;
1175 if( digiVec->size() < 2 ) {
1178 mHistograms.at( histNameDigisErased )->Fill( 5 );
1190 LOG_DEBUG <<
"matchSides() - time difference in ns: " << timeDiff << endm;
1194 if( xDigiA->
side() == 2 ) {
1195 posY = mSigVel.at( detIndex ) * timeDiff * 0.5;
1198 posY = -1 * mSigVel.at( detIndex ) * timeDiff * 0.5;
1203 if( fabs( posY ) > mMaxYPos && digiVec->size() > 2 ) {
1205 LOG_DEBUG <<
"matchSides() - hit candidate outside correlation window, check for better possible digis" << endm;
1206 LOG_DEBUG <<
"size of digi vector: " << digiVec->size() << endm;
1211 double posYNew = 0.;
1212 double timeDiffNew = 0.;
1214 if( xDigiC->
side() == xDigiA->
side() ) {
1221 if( xDigiA->
side() == 2 ) {
1222 posYNew = mSigVel.at( detIndex ) * timeDiffNew * 0.5;
1225 posYNew = -1 * mSigVel.at( detIndex ) * timeDiffNew * 0.5;
1228 if( fabs( posYNew ) < fabs( posY ) ) {
1230 LOG_DEBUG <<
"matchSides() - found better match for hit candidate -> changing out digis" << endm;
1233 timeDiff = timeDiffNew;
1236 if( xDigiC->
side() == xDigiA->
side() ) {
1240 iterDigi = digiVec->begin();
1242 digiVec->erase( iterDigi );
1244 mHistograms.at( histNameDigisErased )->Fill( 4 );
1251 iterDigi = digiVec->begin() + 1;
1253 digiVec->erase( iterDigi );
1255 mHistograms.at( histNameDigisErased )->Fill( 4 );
1261 LOG_DEBUG <<
"matchSides() - no better match -> keep this hit candidate" << endm;
1267 if( xDigiA->
side() == xDigiB->
side() ) {
1268 LOG_ERROR <<
"matchSides() - wrong combinations of digis:" << endm;
1269 LOG_ERROR << *xDigiA << endm;
1270 LOG_ERROR << *xDigiB << endm;
1279 if(!mIsSim && mApCorr){
1280 time += t_corr_afterpulse;
1286 posX = ( -1 * eTofConst::nStrips / 2. + strip - 0.5 ) * eTofConst::stripPitch;
1289 bool hasClockJump =
false;
1290 if( fabs( posY ) > 0.5 * ( eTofConst::coarseClockCycle * mSigVel.at( detIndex ) - eTofConst::stripLength ) * 0.9 ) {
1291 hasClockJump =
true;
1296 bool leftjump =
false;
1297 bool outsider =
false;
1300 if(xDigiA->
side() == 2 ){
1308 if(dt < 8.5 && dt > 0){
1318 if( mDoClockJumpShift && hasClockJump ) {
1320 LOG_INFO <<
"shifted hit time in direction: " << mClockJumpDirection.at( detIndex * 10 + ( strip - 1 ) / 4 + 1 ) << endm;
1325 int keyGet4_comp = -1;
1326 int side = xDigiA->
side();
1328 keyGet4 = 144 * ( sector - 13 ) + 48 * ( plane -1 ) + 16 * ( counter - 1 ) + 8 * ( 1 - 1 ) + ( ( strip - 1 ) / 4 );
1329 keyGet4_comp = 144 * ( sector - 13 ) + 48 * ( plane -1 ) + 16 * ( counter - 1 ) + 8 * ( 2 - 1 ) + ( ( strip - 1 ) / 4 );
1331 keyGet4 = 144 * ( sector - 13 ) + 48 * ( plane -1 ) + 16 * ( counter - 1 ) + 8 * ( 2 - 1 ) + ( ( strip - 1 ) / 4 );
1332 keyGet4_comp = 144 * ( sector - 13 ) + 48 * ( plane -1 ) + 16 * ( counter - 1 ) + 8 * ( 1 - 1 ) + ( ( strip - 1 ) / 4 );
1334 int def = mGet4DefaultMap.at(mGet4PartnerPairMap.at(keyGet4).at(1));
1338 time -= eTofConst::coarseClockCycle * 0.5 * mClockJumpDirection.at( detIndex * 10 + ( strip - 1 ) / 4 + 1 );
1339 timeDiff -= eTofConst::coarseClockCycle * ( ( timeDiff < 0 ) ? -1 : ( timeDiff > 0 ) );
1347 if(!mETofCalibMaker->calState()){
1348 if(mETofCalibMaker->GetState(keyGet4) != 0 || mETofCalibMaker->GetState(keyGet4_comp) != 0){
1350 case 1 : def = 3;
break;
1351 case 2 : def = 4;
break;
1352 case 3 : def = 1;
break;
1353 case 4 : def = 2;
break;
1354 default : LOG_ERROR <<
"Unknown default state" << endm;
1360 time -= eTofConst::coarseClockCycle * 0.5;
1363 time += eTofConst::coarseClockCycle * 0.5;
1367 time -= eTofConst::coarseClockCycle * 0.5;
1369 time += eTofConst::coarseClockCycle * 0.5;
1374 time += eTofConst::coarseClockCycle * 0.5;
1376 time -= eTofConst::coarseClockCycle * 0.5;
1379 timeDiff -= eTofConst::coarseClockCycle * ( ( timeDiff < 0 ) ? -1 : ( timeDiff > 0 ) );
1382 if(leftjump && mDoDoubleClockJumpShift){
1383 time += 2*(eTofConst::coarseClockCycle * 0.5 * mClockJumpDirection.at( detIndex * 10 + ( strip - 1 ) / 4 + 1 ));
1387 if(outsider && mDoDoubleClockJumpShift){
1388 time += 100*(eTofConst::coarseClockCycle * 0.5 * mClockJumpDirection.at( detIndex * 10 + ( strip - 1 ) / 4 + 1 ));
1389 timeDiff -= 100*(eTofConst::coarseClockCycle * ( ( timeDiff < 0 ) ? -1 : ( timeDiff > 0 ) )) + 2.0;
1393 LOG_INFO <<
"shifted hit on: " << sector <<
"-" << plane <<
"-" << counter <<
" -- " << strip <<
" Direction " << mClockJumpDirection.at( detIndex * 10 + ( strip - 1 ) / 4 + 1 ) << endm;
1396 if( xDigiA->
side() == 2 ) {
1397 posY = mSigVel.at( detIndex ) * timeDiff * 0.5;
1400 posY = -1 * mSigVel.at( detIndex ) * timeDiff * 0.5;
1406 LOG_DEBUG <<
"detIndex=" << detIndex <<
"posX=" << posX <<
" posY=" << posY <<
" time= " << time <<
" totSum=" << totSum << endm;
1410 unsigned int clusterSize = 1;
1411 if( hasClockJump ) {
1418 if(mModMatrix.at(detIndex) > 0){
1419 int mode = mModMatrix.at(detIndex);
1420 modifyHit(mode, posX , posY , time);
1423 StETofHit* constructedHit =
new StETofHit( sector, plane, counter, time, totSum, clusterSize, posX, posY );
1426 if(mDoDoubleClockJumpShift){
1427 double starttime = startTime();
1431 double tof = fmod( constructedHit->
time() , eTofConst::bTofClockCycle ) - starttime;
1437 StThreeVectorD posGlo = mETofGeom->hitLocal2Master( constructedHit );
1441 exptof = tofPathLength(&vtxPos , &posGlo , 0) / ( nanosecond * c_light );
1445 int get4Nr = detIndex * 10 + ( strip - 1 ) / 4 + 1;
1447 double tMin = mGet4doublejumpTmin;
1448 double t1 = mGet4doublejumpTimes.at(get4Nr).at(0);
1449 double t2 = mGet4doublejumpTimes.at(get4Nr).at(1);
1451 mGet4doublejumpTimes.at(get4Nr).erase(mGet4doublejumpTimes.at(get4Nr).begin());
1452 mGet4doublejumpTimes.at(get4Nr).push_back(tof - exptof);
1453 if(mGet4doublejumpTimes.at(get4Nr).size() > 2 ){
1454 mGet4doublejumpTimes.at(get4Nr).erase(mGet4doublejumpTimes.at(get4Nr).begin());
1457 t1 = mGet4doublejumpTimes.at(get4Nr).at(0);
1458 t2 = mGet4doublejumpTimes.at(get4Nr).at(1);
1460 if(t2 < tMin && t1 < tMin && t2 > -999 && t1 > -999){
1461 mGet4doublejumpFlag.at(get4Nr) = 1;
1464 if(t2 > tMin && t1 > tMin ){
1465 mGet4doublejumpFlag.at(get4Nr) = 0;
1468 if(mGet4doublejumpFlag.at(get4Nr) == 1){
1469 constructedHit->setTime(constructedHit->
time() + eTofConst::coarseClockCycle);
1470 constructedHit->setClusterSize(constructedHit->
clusterSize() + 200);
1471 tof += eTofConst::coarseClockCycle;
1477 mStoreHit[ detIndex ].push_back( constructedHit );
1480 std::vector< unsigned int > containedDigiIndices;
1482 containedDigiIndices.push_back( mMapDigiIndex.at( xDigiA ) );
1483 containedDigiIndices.push_back( mMapDigiIndex.at( xDigiB ) );
1485 mMapHitDigiIndices[ constructedHit ] = containedDigiIndices;
1488 t_corr_afterpulse = 0.0;
1492 int DigiIdA = xDigiA->
rawTot();
1493 int DigiIdB = xDigiB->
rawTot();
1495 if(DigiIdB==DigiIdA){constructedHit->setIdTruth(DigiIdA);}
1496 else{constructedHit->setIdTruth(9999);}
1499 LOG_DEBUG << *( mStoreHit.at( detIndex ).back() ) << endm;
1502 iterDigi = digiVec->begin();
1504 delete *(iterDigi+1);
1505 digiVec->erase( iterDigi + 1 );
1506 digiVec->erase( iterDigi );
1508 mHistograms.at( histNameDigisErased )->Fill( 6 );
1509 mHistograms.at( histNameDigisErased )->Fill( 6 );
1516 LOG_DEBUG <<
"matchSides() - matching of sides done" << endm;
1523 StETofHitMaker::fillUnclusteredHitQA(
const double& tstart,
const bool isMuDst )
1530 if( fabs( tstart + 9999. ) < 1.e-5 ) {
1531 LOG_WARN <<
"fillUnclusteredHitQA(): -- no valid start time available ... skip filling histograms with time of flight information" << endm;
1535 int nHitsPrinted = 0;
1537 for(
const auto& kv : mStoreHit ) {
1538 unsigned int detIndex = kv.first;
1540 unsigned int sector = detIndex / 100;
1541 unsigned int plane = ( detIndex % 100 ) / 10;
1542 unsigned int counter = detIndex % 10;
1545 LOG_DEBUG << sector <<
" " << plane <<
" " << counter <<
" size hitVec: " << kv.second.size() << endm;
1548 for(
const auto&
hit : kv.second ) {
1550 LOG_DEBUG <<
"matchSides() - HIT: ";
1551 LOG_DEBUG <<
"time=" << setprecision( 16 ) <<
hit->time() <<
" ";
1552 LOG_DEBUG <<
"totalTot=" << setprecision( 4 ) <<
hit->totalTot() <<
" ";
1553 LOG_DEBUG <<
"localX=" << setprecision( 4 ) <<
hit->localX() <<
" ";
1554 LOG_DEBUG <<
"localY=" << setprecision( 4 ) <<
hit->localY() << endm;
1557 mCounterActive.at( ( sector - 13 ) * 9 + ( plane - 1 ) * 3 + ( counter - 1 ) ) =
true;
1559 mHistograms.at(
"unclusteredHit_tot" )->Fill(
hit->totalTot() );
1561 std::string histNameTot =
"unclusteredHit_tot_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1562 mHistograms.at( histNameTot )->Fill(
hit->totalTot(),
hit->localX() );
1568 if( mMapHitDigiIndices.at(
hit ).size() >= 2 ) {
1569 int digiIndexA = mMapHitDigiIndices.at(
hit ).at( 0 );
1570 int digiIndexB = mMapHitDigiIndices.at(
hit ).at( 1 );
1575 bool sideSwitch =
false;
1578 StSPtrVecETofDigi& etofDigis = mEvent->etofCollection()->etofDigis();
1579 totA = etofDigis[ digiIndexA ]->calibTot();
1580 totB = etofDigis[ digiIndexB ]->calibTot();
1582 if( etofDigis[ digiIndexA ]->side() == 2 ) {
1596 LOG_DEBUG <<
"tot of digis in the hit: " << totA <<
" and " << totB <<
" sideSwitch: " << sideSwitch << endm;
1599 float totDiff = totA - totB;
1600 if( sideSwitch ) totDiff *= -1;
1602 mHistograms.at(
"unclusteredHit_tot_difference" )->Fill( totDiff );
1604 if( fabs(
hit->localY() ) > mMaxYPos ) {
1605 mHistograms.at(
"unclusteredHit_tail_totAsym" )->Fill( totDiff / ( totA + totB) );
1613 std::string histNamePos =
"unclusteredHit_pos_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1614 mHistograms.at( histNamePos )->Fill(
hit->localX(),
hit->localY() );
1616 std::string histNamePosJump =
"unclusteredHit_jump_pos_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1617 if(
hit->clusterSize() > 100 ) mHistograms.at( histNamePosJump )->Fill(
hit->localX(),
hit->localY() );
1620 if( fabs( tstart + 9999. ) < 1.e-5 )
continue;
1622 double tof = fmod(
hit->time(), eTofConst::bTofClockCycle ) - tstart;
1625 LOG_DEBUG <<
"hit time, hit time mod bTOF clock cycle, start time, time difference: ";
1626 LOG_DEBUG <<
hit->time() <<
" , " << tof + tstart <<
" , " << tstart <<
" , " << tof << endm;
1627 LOG_DEBUG <<
"sector, plane, counter: " <<
hit->sector() <<
" , " <<
hit->zPlane() <<
" , " <<
hit->counter() << endm;
1629 mHistograms.at(
"unclusteredHit_tof_fullrange_all" )->Fill( tof );
1633 tof += eTofConst::bTofClockCycle;
1635 tof = fmod( tof, eTofConst::bTofClockCycle );
1638 mHistograms.at(
"unclusteredHit_tof_fullrange" )->Fill( tof );
1640 mHistograms.at(
"unclusteredHit_tof" )->Fill( tof );
1643 std::string histNameTof =
"unclusteredHit_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1644 mHistograms.at( histNameTof )->Fill(
hit->localX(), tof );
1646 std::string histNameTofJump =
"unclusteredHit_jump_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1647 if(
hit->clusterSize() > 100 ) mHistograms.at( histNameTofJump )->Fill(
hit->localX(), tof );
1655 if( fabs( vtxPos.z() ) <= 10. && fabs( vtxPos.perp() < 2.5 ) ) {
1656 histNameTof =
"unclusteredHit_pVtx_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1657 mHistograms.at( histNameTof )->Fill(
hit->localX(), tof );
1675 if( fabs( tof ) > 1000. && nHitsPrinted < 5 ) {
1676 LOG_INFO <<
"TOF UNNORMALLY LARGE: " << tof <<
" !!! " << endm;
1688 StETofHitMaker::mergeClusters(
const bool isMuDst )
1690 std::vector< StETofHit* >::iterator iterHit;
1691 std::vector< std::vector< StETofDigi* > >::iterator iterDigi;
1693 for(
auto kv = mStoreHit.begin(); kv != mStoreHit.end(); kv++ ) {
1694 unsigned int detIndex = kv->first;
1696 unsigned int sector = detIndex / 100;
1697 unsigned int plane = ( detIndex % 100 ) / 10;
1698 unsigned int counter = detIndex % 10;
1700 std::vector< StETofHit* > *hitVec = &( kv->second );
1702 size_t nHitsOnDet = 0;
1704 while( hitVec->size() > 0 ) {
1706 LOG_DEBUG <<
"mergeClusters() - hit vector size: " << hitVec->size();
1707 LOG_DEBUG <<
" for sector " << sector <<
" plane " << plane <<
" counter " << counter << endm;
1708 LOG_DEBUG <<
"mergeClusters() - checking hit vector for possible hits to merge with..." << endm;
1711 bool isMissmatch =
false;
1723 double weightedTime = pHit->
time() * weight;
1724 double weightedPosX = pHit->
localX() * weight;
1725 double weightedPosY = pHit->
localY() * weight;
1726 double weightsTotSum = 1. * weight;
1729 unsigned int clusterSize = 1;
1730 int lowestStrip = ceil( pHit->
localX() / eTofConst::stripPitch );
1731 int highestStrip = lowestStrip;
1733 bool hasClockJump =
false;
1735 hasClockJump =
true;
1738 bool isSingleSided =
false;
1740 isSingleSided =
true;
1743 unsigned int index = 1;
1744 while( hitVec->size() > 1 ) {
1746 LOG_DEBUG <<
"mergeClusters() - index in hit vector = " << index << endm;
1748 if( index >= hitVec->size() ) {
1750 LOG_DEBUG <<
"mergeClusters() - loop index is exceeds size of hit vector -> stop looping" << endm;
1755 StETofHit* pMergeHit = hitVec->at( index );
1758 double timeDiff = pHit->
time() - pMergeHit->
time();
1759 double posYDiff = ( pHit->
localY() - pMergeHit->
localY() ) / mSigVel.at( detIndex );
1761 bool isHigherAdjacentStip =
false;
1762 bool isLowerAdjacentStip =
false;
1764 if( ceil( pMergeHit->
localX() / eTofConst::stripPitch ) - highestStrip == 1 ) {
1765 isHigherAdjacentStip =
true;
1767 else if( ceil( pMergeHit->
localX() / eTofConst::stripPitch ) - lowestStrip == -1 ) {
1768 isLowerAdjacentStip =
true;
1771 double MergingRadius = 0;
1777 MergingRadius = mMergingRadius;
1782 if( ( isHigherAdjacentStip || isLowerAdjacentStip ) &&
1783 ( sqrt( timeDiff * timeDiff + posYDiff * posYDiff ) ) < MergingRadius )
1786 LOG_DEBUG <<
"mergeClusters() - merging is going on" << endm;
1789 if( mDoQA && clusterSize == 1 ) {
1790 std::string histName_unclusteredHit_delT_pos =
"unclusteredHit_delT_pos_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1791 std::string histName_unclusteredHit_delT_tot =
"unclusteredHit_delT_tot_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1792 std::string histName_unclusteredHit_delT =
"unclusteredHit_delT_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
1793 mHistograms.at( histName_unclusteredHit_delT )->Fill( pHit->
localX(), timeDiff );
1794 ((TH3F&) *mHistograms[ histName_unclusteredHit_delT_tot ]).TH3F::Fill( pHit->
localX(), timeDiff, pHit->
totalTot() );
1795 ((TH3F&) *mHistograms[ histName_unclusteredHit_delT_pos ]).TH3F::Fill( pHit->
localX(), timeDiff, posYDiff );
1798 double hitWeight = pMergeHit->
totalTot();
1800 if( hitWeight==0 ) {
1804 weightedTime += ( pMergeHit->
time() * hitWeight );
1805 weightedPosX += ( pMergeHit->
localX() * hitWeight );
1806 weightedPosY += ( pMergeHit->
localY() * hitWeight );
1807 weightsTotSum += hitWeight;
1811 hasClockJump =
true;
1814 if( isHigherAdjacentStip ) {
1817 else if( isLowerAdjacentStip ) {
1822 LOG_DEBUG <<
"mergeClusters() - detector: " << detIndex <<
" seed hit localX: " << pHit->
localX();
1823 LOG_DEBUG <<
" <> hit to merge localX: " << pMergeHit->
localX();
1824 LOG_DEBUG <<
" <> weighted localX: " << weightedPosX / weightsTotSum << endm;
1828 for(
unsigned int i : mMapHitDigiIndices.at( pMergeHit ) ) {
1829 mMapHitDigiIndices.at( pHit ).push_back( i );
1840 else if(!isMissmatch){
1847 iterHit = hitVec->begin() + index;
1849 hitVec->erase( iterHit );
1852 LOG_DEBUG <<
"mergeClusters() - deleting merged hit from Map" << endm;
1855 mMapHitDigiIndices.erase( pMergeHit );
1860 LOG_DEBUG <<
"mergeClusters() - merging condition not fulfilled -- check the next hit" << endm;
1875 weightedTime /= weightsTotSum;
1876 weightedPosX /= weightsTotSum;
1877 weightedPosY /= weightsTotSum;
1880 weightedTime = fmod( weightedTime, eTofConst::bTofClockCycle );
1881 if( weightedTime < 0 ) weightedTime += eTofConst::bTofClockCycle;
1883 if( hasClockJump ) {
1888 clusterSize += 1000;
1892 LOG_DEBUG <<
"mergeClusters() - MERGED HIT: ";
1893 LOG_DEBUG <<
"sector: " << sector <<
" plane: " << plane <<
" counter: " << counter <<
"\n";
1894 LOG_DEBUG <<
"time = " << setprecision( 16 ) << weightedTime <<
" ";
1895 LOG_DEBUG <<
"totalTot = " << setprecision( 4 ) << weightsTotSum <<
" ";
1896 LOG_DEBUG <<
"clusterSize = " << setprecision( 1 ) << clusterSize % 100 <<
" ";
1897 LOG_DEBUG <<
"localX = " << setprecision( 4 ) << weightedPosX <<
" ";
1898 LOG_DEBUG <<
"localY = " << setprecision( 4 ) << weightedPosY << endm;
1902 StETofHit* combinedHit =
new StETofHit( sector, plane, counter, weightedTime, weightsTotSum, clusterSize, weightedPosX, weightedPosY );
1905 combinedHit->setIdTruth(idTruth);
1911 mEvent->etofCollection()->addHit( combinedHit );
1914 mMapHitDigiIndices[ combinedHit ] = mMapHitDigiIndices.at( pHit );
1917 LOG_DEBUG <<
"mergeClusters(): size of digi vector for combined hit " << nHitsOnDet <<
" on the counter: ";
1918 LOG_DEBUG << mMapHitDigiIndices.at( combinedHit ).size() <<
" copied over from merged hit vector of size "<< mMapHitDigiIndices.at( pHit ).size() << endm;
1924 int lastHitIndex = mMuDst->numberOfETofHit() - 1;
1927 mMapHitIndexDigiIndices[ lastHitIndex ] = mMapHitDigiIndices.at( pHit );
1929 LOG_DEBUG <<
"mergeClusters(): size of digi vector for combined hit " << nHitsOnDet <<
" on the counter: ";
1930 LOG_DEBUG << mMapHitIndexDigiIndices.at( lastHitIndex ).size() <<
" copied over from merged hit vector of size "<< mMapHitDigiIndices.at( pHit ).size() << endm;
1936 iterHit = hitVec->begin();
1938 hitVec->erase( iterHit );
1940 mMapHitDigiIndices.erase( pHit );
1943 if( !isMuDst && mMapHitDigiIndices.count( combinedHit ) ) {
1944 LOG_DEBUG <<
"mergeClusters(): size of digi vector for combined hit " << nHitsOnDet <<
" on the counter: " << mMapHitDigiIndices.at( combinedHit ).size() <<
" after deletion of merged hit" << endm;
1946 if( isMuDst && mMapHitIndexDigiIndices.count( nHitsOnDet ) ) {
1947 LOG_DEBUG <<
"mergeClusters(): size of digi vector for combined hit " << nHitsOnDet <<
" on the counter: " << mMapHitIndexDigiIndices.at( mMuDst->numberOfETofHit() - 1 ).size() << endm;
1961 LOG_DEBUG <<
"mergeClusters() - merging into clusters done" << endm;
1967 StETofHitMaker::assignAssociatedHits(
const bool isMuDst )
1970 StSPtrVecETofHit& etofHits = mEvent->etofCollection()->etofHits();
1971 StSPtrVecETofDigi& etofDigis = mEvent->etofCollection()->etofDigis();
1973 for(
size_t ihit = 0; ihit < etofHits.size(); ihit++ ) {
1977 LOG_DEBUG <<
"assignAssociatedHits(): size of digi vector for hit " << ihit <<
": "<< mMapHitDigiIndices.at( aHit ).size() << endm;
1980 for (
size_t idigi = 0; idigi < mMapHitDigiIndices.at( aHit ).size(); idigi++ ) {
1982 LOG_DEBUG <<
"assignAssociatedHits(): link points to digi " << etofDigis[ mMapHitDigiIndices.at( aHit ).at( idigi ) ] << endm;
1984 etofDigis[ mMapHitDigiIndices.at( aHit ).at( idigi ) ]->setAssociatedHit( aHit );
1990 for(
const auto& kv : mMapHitIndexDigiIndices ) {
1992 LOG_DEBUG <<
"assignAssociatedHits(): size of digi vector for hit index " << kv.first <<
": "<< kv.second.size() << endm;
1995 for(
const auto& v: kv.second ) {
1997 LOG_DEBUG <<
"assignAssociatedHits(): link to digi index " << v << endm;
1999 mMuDst->
etofDigi( v )->setAssociatedHitId( kv.first );
2004 LOG_DEBUG <<
"assignAssociatedHits() - association between digis and hits done" << endm;
2011 StETofHitMaker::fillHitQA(
const bool isMuDst,
const double& tstart )
2013 int bTofCentral = 700;
2015 double vpdStart = -9999.;
2016 double vertexVz = -999.;
2019 startTimeVpd( vpdStart, vertexVz );
2026 const StSPtrVecETofHit& etofHits = mEvent->etofCollection()->etofHits();
2029 double averageETofHitTime = 0.;
2031 for(
size_t i=0; i<etofHits.size(); i++ ) {
2039 LOG_DEBUG << *aHit << endm;
2042 updateCyclicRunningMean( aHit->
time(), averageETofHitTime, nHitsETof, eTofConst::bTofClockCycle );
2046 string histNamePos =
"etofHit_pos_s" + std::to_string( aHit->
sector() ) +
"m" + std::to_string( aHit->
zPlane() ) +
"c" + std::to_string( aHit->
counter() );
2047 mHistograms.at( histNamePos )->Fill( aHit->
localX(), aHit->
localY() );
2050 std::string histNameClustersize =
"clustersize_s" + std::to_string( aHit->
sector() ) +
"m" + std::to_string( aHit->
zPlane() );
2051 mHistograms.at( histNameClustersize )->Fill( aHit->
clusterSize() % 100 );
2055 if( (fabs( tstart ) > 0.001 && fabs( tstart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001) || mIsSim ) {
2056 double tof = aHit->
time() - tstart;
2058 tof += eTofConst::bTofClockCycle;
2061 mHistograms.at(
"etofHit_tof" )->Fill( tof );
2062 mHistograms.at(
"etofHit_tof_fullrange" )->Fill( tof );
2066 if( fabs( vpdStart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001 ) {
2067 double tofVpd = aHit->
time() - vpdStart;
2068 if( tofVpd < -800 ) {
2069 tofVpd += eTofConst::bTofClockCycle;
2071 mHistograms.at(
"etofHit_vpdVz_tof" )->Fill( vertexVz, tofVpd );
2081 if( !btofCollection || !btofCollection->hitsPresent() ) {
2082 LOG_WARN <<
"fillHitQA - no btof collection or no bTof hits present" << endm;
2086 const StSPtrVecBTofHit& btofHits = btofCollection->tofHits();
2089 double averageBTofHitTime = 0.;
2091 for(
size_t i=0; i<btofHits.size(); i++ ) {
2098 updateCyclicRunningMean( aHit->leadingEdgeTime(), averageBTofHitTime, nHitsBTof, eTofConst::bTofClockCycle );
2101 if( mDoQA && ((fabs( tstart ) > 0.001 && fabs( tstart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001) || mIsSim) ) {
2102 double tof = aHit->leadingEdgeTime() - tstart;
2104 tof += eTofConst::bTofClockCycle;
2106 mHistograms.at(
"btofHit_tof_fullrange" )->Fill( tof );
2110 float diff = averageETofHitTime - averageBTofHitTime;
2111 if( diff < -800 ) diff += eTofConst::bTofClockCycle;
2112 mHistograms.at(
"averageTimeDiff_etofHits_btofHits" )->Fill( diff );
2113 mHistograms.at(
"multiplicity_etofHits_btofHits" )->Fill( nHitsETof, nHitsBTof );
2115 if( mDoQA && nHitsBTof > bTofCentral ) {
2116 std::vector< int > etofHitsPerModule( eTofConst::nModules );
2117 for(
size_t i=0; i<etofHits.size(); i++ ) {
2123 etofHitsPerModule.at( ( aHit->
sector() - 13 ) * 3 + aHit->
zPlane() - 1 ) += 1;
2126 for(
size_t i=0; i<eTofConst::nModules; i++ ) {
2127 mHistograms.at(
"hitMultiplicityPerModuleCentral" )->Fill( i, etofHitsPerModule.at( i ) );
2135 if( !epdCollection || !epdCollection->hitsPresent() ) {
2136 LOG_WARN <<
"fillHitQA - no epd collection or no epd hits present" << endm;
2140 const StSPtrVecEpdHit& epdHits = epdCollection->epdHits();
2142 float nHitsEpdEast = 0.;
2144 for(
size_t i=0; i<epdHits.size(); i++ ) {
2150 if( epdHit->
nMIP() < 0.3 )
continue;
2151 if( epdHit->
id() > 0 )
continue;
2153 if( epdHit->
nMIP() < 5 ) {
2154 nHitsEpdEast += epdHit->
nMIP();
2160 mHistograms.at(
"multiplicity_etofHits_epdEast" )->Fill( nHitsETof, nHitsEpdEast );
2162 mHistograms.at(
"multiplicity_btofHits_epdEast" )->Fill( nHitsBTof, nHitsEpdEast );
2171 double averageETofHitTime = 0.;
2173 for(
size_t i=0; i<mMuDst->numberOfETofHit(); i++ ) {
2181 LOG_DEBUG <<
"hit (" << i <<
"): sector,plane,counter=" << aHit->
sector() <<
",";
2182 LOG_DEBUG << aHit->
zPlane() <<
"," << aHit->
counter() <<
" time=" << aHit->
time();
2183 LOG_DEBUG <<
" localX=" << aHit->
localX() <<
" localY=" << aHit->
localY();
2184 LOG_DEBUG <<
" clustersize=" << aHit->
clusterSize() % 100 << endm;
2187 updateCyclicRunningMean( aHit->
time(), averageETofHitTime, nHitsETof, eTofConst::bTofClockCycle );
2190 string histNamePos =
"etofHit_pos_s" + std::to_string( aHit->
sector() ) +
"m" + std::to_string( aHit->
zPlane() ) +
"c" + std::to_string( aHit->
counter() );
2191 mHistograms.at( histNamePos )->Fill( aHit->
localX(), aHit->
localY() );
2194 std::string histNameClustersize =
"clustersize_s" + std::to_string( aHit->
sector() ) +
"m" + std::to_string( aHit->
zPlane() );
2195 mHistograms.at( histNameClustersize )->Fill( aHit->
clusterSize() % 100 );
2199 if( (fabs( tstart ) > 0.001 && fabs( tstart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001) || mIsSim ) {
2200 double tof = aHit->
time() - tstart;
2202 tof += eTofConst::bTofClockCycle;
2205 mHistograms.at(
"etofHit_tof" )->Fill( tof );
2206 mHistograms.at(
"etofHit_tof_fullrange" )->Fill( tof );
2210 if( fabs( vpdStart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001 ) {
2211 double tofVpd = aHit->
time() - vpdStart;
2212 if( tofVpd < -800 ) {
2213 tofVpd += eTofConst::bTofClockCycle;
2215 mHistograms.at(
"etofHit_vpdVz_tof" )->Fill( vertexVz, tofVpd );
2223 if( !mMuDst->
btofArray( muBTofHit ) || !mMuDst->numberOfBTofHit() ) {
2224 LOG_WARN <<
"fillHitQA - no btof hit array or no btof hits present" << endm;
2229 double averageBTofHitTime = 0.;
2231 for(
size_t i=0; i<mMuDst->numberOfBTofHit(); i++ ) {
2238 updateCyclicRunningMean( aHit->leadingEdgeTime(), averageBTofHitTime, nHitsBTof, eTofConst::bTofClockCycle );
2241 if( mDoQA && ((fabs( tstart ) > 0.001 && fabs( tstart - ( eTofConst::bTofClockCycle - 9999. ) ) > 0.001) || mIsSim) ) {
2242 double tof = aHit->leadingEdgeTime() - tstart;
2244 tof += eTofConst::bTofClockCycle;
2247 mHistograms.at(
"btofHit_tof_fullrange" )->Fill( tof );
2251 double diff = averageETofHitTime - averageBTofHitTime;
2252 if( diff < -800 ) diff += eTofConst::bTofClockCycle;
2254 mHistograms.at(
"averageTimeDiff_etofHits_btofHits" )->Fill( diff );
2255 mHistograms.at(
"multiplicity_etofHits_btofHits" )->Fill( nHitsETof, nHitsBTof );
2257 if( mDoQA && nHitsBTof > bTofCentral ) {
2258 std::vector< int > etofHitsPerModule( eTofConst::nModules );
2259 for(
size_t i=0; i<mMuDst->numberOfETofHit(); i++ ) {
2265 etofHitsPerModule.at( ( aHit->
sector() - 13 ) * 3 + aHit->
zPlane() - 1 ) += 1;
2268 for(
size_t i=0; i<eTofConst::nModules; i++ ) {
2269 mHistograms.at(
"hitMultiplicityPerModuleCentral" )->Fill( i, etofHitsPerModule.at( i ) );
2276 if( !mMuDst->
epdHits() || !mMuDst->numberOfEpdHit() ) {
2277 LOG_WARN <<
"fillHitQA - no epd hit array or no epd hits present" << endm;
2281 size_t nHitsEpd = mMuDst->numberOfEpdHit();
2282 float nHitsEpdEast = 0.;
2284 for(
size_t i=0; i<nHitsEpd; i++ ) {
2290 if( epdHit->
nMIP() < 0.3 )
continue;
2291 if( epdHit->
id() > 0 )
continue;
2293 if( epdHit->
nMIP() < 5 ) {
2294 nHitsEpdEast += epdHit->
nMIP();
2301 mHistograms.at(
"multiplicity_etofHits_epdEast" )->Fill( nHitsETof, nHitsEpdEast );
2303 mHistograms.at(
"multiplicity_btofHits_epdEast" )->Fill( nHitsBTof, nHitsEpdEast );
2308 LOG_DEBUG <<
"fillHitQA() - histograms filled" << endm;
2316 StETofHitMaker::setHistFileName()
2318 string extension =
".etofHit.root";
2320 if( GetChainOpt()->GetFileOut() !=
nullptr ) {
2321 TString outFile = GetChainOpt()->GetFileOut();
2323 mHistFileName = ( string ) outFile;
2326 size_t lastindex = mHistFileName.find_last_of(
"." );
2327 mHistFileName = mHistFileName.substr( 0, lastindex );
2330 lastindex = mHistFileName.find_last_of(
"." );
2331 mHistFileName = mHistFileName.substr( 0, lastindex );
2334 lastindex = mHistFileName.find_last_of(
"/" );
2335 mHistFileName = mHistFileName.substr( lastindex + 1, mHistFileName.length() );
2337 mHistFileName = mHistFileName + extension;
2339 LOG_ERROR <<
"Cannot set the output filename for histograms" << endm;
2345 StETofHitMaker::bookHistograms()
2347 LOG_INFO <<
"bookHistograms() ... " << endm;
2349 mHistograms[
"etofHit_tof" ] =
new TH1F(
"etofHit_tof",
"eTOF hit time of flight;time of flight (ns);# hits", 4000, -100., 150 );
2350 mHistograms[
"etofHit_tof_fullrange" ] =
new TH1F(
"etofHit_tof_fullrange",
"eTOF hit time of flight;time of flight (ns);# hits", 5000, -800., eTofConst::bTofClockCycle );
2351 mHistograms[
"averageTimeDiff_etofHits_btofHits" ] =
new TH1F(
"averageTimeDiff_etofHits_btofHits",
"difference between average times in bTOF and eTOF hits;#DeltaT (ns);# events", 4000, -500, 500 );
2352 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 );
2353 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 );
2355 AddHist( mHistograms.at(
"etofHit_tof" ) );
2356 AddHist( mHistograms.at(
"etofHit_tof_fullrange" ) );
2357 AddHist( mHistograms.at(
"averageTimeDiff_etofHits_btofHits" ) );
2358 AddHist( mHistograms.at(
"multiplicity_etofHits_btofHits" ) );
2359 AddHist( mHistograms.at(
"multiplicity_etofHits_epdEast" ) );
2362 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 );
2363 mHistograms[
"btofHit_tof_fullrange" ] =
new TH1F(
"btofHit_tof_fullrange",
"bTOF hit time of flight;time of flight (ns);# hits", 5000, -800., eTofConst::bTofClockCycle );
2364 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 );
2365 mHistograms[
"hitMultiplicityPerModuleCentral" ] =
new TH2F(
"hitMultiplicityPerModuleCentral",
"hit multiplicity per module in central bTOF events", 36, 0, 36, 50, 0, 50 );
2366 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 );
2369 for(
int sector = eTofConst::sectorStart; sector <= eTofConst::sectorStop; sector++ ) {
2370 for(
int plane = eTofConst::zPlaneStart; plane <= eTofConst::zPlaneStop; plane++ ) {
2371 for(
int counter = eTofConst::counterStart; counter <= eTofConst::counterStop; counter++ ) {
2372 std::string histName_etofHit_pos =
"etofHit_pos_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2374 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. );
2375 AddHist( mHistograms.at( histName_etofHit_pos ) );
2378 std::string histNameDigisPerStrip =
"digisPerStrip_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2379 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. );
2381 std::string histNameDigisErased =
"digisErased_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2382 mHistograms[ histNameDigisErased ] =
new TH1F( Form(
"digisErased_s%d_m%d_c%d", sector, plane, counter ),
"digis erased;;# digis", 6, 0.5, 6.5 );
2383 mHistograms[ histNameDigisErased ]->GetXaxis()->SetBinLabel( 1,
"digi inside dead time" );
2384 mHistograms[ histNameDigisErased ]->GetXaxis()->SetBinLabel( 2,
"single digi on strip" );
2385 mHistograms[ histNameDigisErased ]->GetXaxis()->SetBinLabel( 3,
"3 consecutive same side digis" );
2386 mHistograms[ histNameDigisErased ]->GetXaxis()->SetBinLabel( 4,
"better match for partner" );
2387 mHistograms[ histNameDigisErased ]->GetXaxis()->SetBinLabel( 5,
"single remaining digi" );
2388 mHistograms[ histNameDigisErased ]->GetXaxis()->SetBinLabel( 6,
"matched into pair" );
2393 std::string histName_clustersize =
"clustersize_s" + std::to_string( sector ) +
"m" + std::to_string( plane );
2394 mHistograms[ histName_clustersize ] =
new TH1F( Form(
"clustersize_s%d_m%d", sector, plane ),
"clustersize;clustersize;# events", 32, 0., 32. );
2400 mHistograms[
"unclusteredHit_tot" ] =
new TH1F(
"unclusteredHit_tot",
"unclustered hit tot; tot (ns);# unclustered hits", 1000, 0., 80. );
2401 mHistograms[
"unclusteredHit_tof" ] =
new TH1F(
"unclusteredHit_tof",
"unclustered hit time of flight; time of flight (ns);# unclustered hits", 5000, 0., 1000. );
2403 mHistograms[
"unclusteredHit_tot_difference" ] =
new TH1F(
"unclusteredHit_tot_difference",
"unclustered hit tot difference of digis; #Delta tot (ns);# unclustered hits", 1000, -100., 100. );
2404 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. );
2406 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 );
2407 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 );
2409 for(
int sector = eTofConst::sectorStart; sector <= eTofConst::sectorStop; sector++ ) {
2410 for(
int plane = eTofConst::zPlaneStart; plane <= eTofConst::zPlaneStop; plane++ ) {
2411 for(
int counter = eTofConst::counterStart; counter <= eTofConst::counterStop; counter++ ) {
2412 std::string histName_unclusteredHit_tot =
"unclusteredHit_tot_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2413 std::string histName_unclusteredHit_pos =
"unclusteredHit_pos_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2414 std::string histName_unclusteredHit_tof =
"unclusteredHit_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2415 std::string histName_unclusteredHit_delT =
"unclusteredHit_delT_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2416 std::string histName_unclusteredHit_delT_pos =
"unclusteredHit_delT_pos_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2417 std::string histName_unclusteredHit_delT_tot =
"unclusteredHit_delT_tot_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2419 std::string histName_unclusteredHit_tail_tof =
"unclusteredHit_tail_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2420 std::string histName_unclusteredHit_good_tof =
"unclusteredHit_good_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2421 std::string histName_unclusteredHit_pVtx_tof =
"unclusteredHit_pVtx_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2423 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. );
2424 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. );
2426 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. );
2427 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. );
2429 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. );
2431 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. );
2433 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. );
2434 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. );
2435 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. );
2437 std::string histName_digi_tot =
"digi_tot_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2439 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. );
2441 std::string histName_unclusteredHit_pos_time =
"unclusteredHit_pos_time_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2442 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. );
2445 std::string histName_unclusteredHit_jump_pos =
"unclusteredHit_jump_pos_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2446 std::string histName_unclusteredHit_jump_tof =
"unclusteredHit_jump_tof_s" + std::to_string( sector ) +
"m" + std::to_string( plane ) +
"c" + std::to_string( counter );
2448 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. );
2449 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. );
2454 mHistograms[
"counter_active" ] =
new TH2F(
"counter_active",
"active counters by run;100*day + run number;counter", 15000, 5000., 20000., 108 , 0.5, 108.5 );
2457 for (
auto& kv : mHistograms ) {
2458 kv.second->SetDirectory( 0 );
2464 StETofHitMaker::writeHistograms()
2466 if( mHistFileName !=
"" ) {
2467 LOG_INFO <<
"writing histograms to: " << mHistFileName.c_str() << endm;
2469 TFile histFile( mHistFileName.c_str(),
"RECREATE",
"etofHit" );
2472 for (
const auto& kv : mHistograms ) {
2473 if( kv.second->GetEntries() > 0 ) kv.second->Write();
2479 LOG_INFO <<
"histogram file name is empty string --> cannot write histograms" << endm;
2486 StETofHitMaker::detectorToKey(
const unsigned int detectorId )
2488 unsigned int sector = ( detectorId / eTofConst::nCountersPerSector ) + eTofConst::sectorStart;
2489 unsigned int zPlane = ( ( detectorId % eTofConst::nCountersPerSector ) / eTofConst::nCounters ) + eTofConst::zPlaneStart;
2490 unsigned int counter = ( detectorId % eTofConst::nCounters ) + eTofConst::counterStart;
2492 return sector * 100 + zPlane * 10 + counter;
2497 StETofHitMaker::updateCyclicRunningMean(
const double& value,
double& mean,
int& count,
const double& range )
2499 double valIn = value;
2500 if( mean - value < -0.9 * range ) {
2503 else if( mean - value > 0.9 * range ) {
2509 double scaling = 1. / count;
2512 LOG_INFO <<
"old mean: " << mean <<
" scaling: " << scaling <<
" value in: " << valIn << endm;
2515 mean = valIn * scaling + mean * ( 1. - scaling );
2518 LOG_INFO <<
"new mean: " << mean << endm;
2524 StETofHitMaker::updateClockJumpMap(
const std::map< int, int >& clockJumpDir )
2526 for(
const auto& kv: clockJumpDir ) {
2527 mClockJumpDirection.at( kv.first ) = kv.second;
2531 for(
const auto& kv : mClockJumpDirection ) {
2532 if( kv.second != 1 ) {
2533 LOG_INFO <<
"StETofHitMaker::updateClockJumpMap() -- entry in clock jump map: " << kv.first <<
" value: " << kv.second << endm;
2542 StETofHitMaker::modifyHit(
int modMode,
double& localX,
double& localY,
double& time )
2563 std::swap(localX, localY), localY = -localY;
2567 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