From 30538a02a54c17f09e64a87096bedfef03917dbb Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Thu, 3 Jun 2021 11:01:38 -0400 Subject: [PATCH 01/62] fixed 64b integer conversion in getField() method and added additional setters from etofIn001 version of this file. Needed to unpack Get4Status bit into event files --- StRoot/StETofUtil/StETofMessageFormat.cxx | 14 +++++++++++++- StRoot/StETofUtil/StETofMessageFormat.h | 22 +++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/StRoot/StETofUtil/StETofMessageFormat.cxx b/StRoot/StETofUtil/StETofMessageFormat.cxx index 7a8c0d7d8db..88a1d680178 100644 --- a/StRoot/StETofUtil/StETofMessageFormat.cxx +++ b/StRoot/StETofUtil/StETofMessageFormat.cxx @@ -80,6 +80,18 @@ bool gdpbv100::Message::operator<(const gdpbv100::Message& other) const return uThisTs < uOtherTs; } //---------------------------------------------------------------------------- +//! equality operator, assumes same epoch for both messages +bool gdpbv100::Message::operator==(const gdpbv100::Message& other) const +{ + return this->data == other.data; +} +//---------------------------------------------------------------------------- +//! inequality operator, assumes same epoch for both messages +bool gdpbv100::Message::operator!=(const gdpbv100::Message& other) const +{ + return this->data != other.data; +} +//---------------------------------------------------------------------------- //! Returns expanded and adjusted time of message (in ns) uint64_t gdpbv100::Message::getMsgFullTime(uint64_t epoch) const { @@ -958,4 +970,4 @@ void gdpb::FullMessage::PrintMessage( unsigned outType, unsigned kind) const { std::cout << "Full epoch = " << std::setw(9) << fulExtendedEpoch << " "; printDataCout( outType, kind ); -} \ No newline at end of file +} diff --git a/StRoot/StETofUtil/StETofMessageFormat.h b/StRoot/StETofUtil/StETofMessageFormat.h index 396b01e8ddc..e17c22e0447 100644 --- a/StRoot/StETofUtil/StETofMessageFormat.h +++ b/StRoot/StETofUtil/StETofMessageFormat.h @@ -72,9 +72,9 @@ namespace gdpbv100 { // Epoch counter size in epoch const uint32_t kuEpochCounterSz = 0x7FFFFFFF; // Epoch counter size in bin - const uint64_t kulEpochCycleBins = static_cast(kuEpochCounterSz)* kuEpochInBins; + const uint64_t kulEpochCycleBins = static_cast(kuEpochCounterSz + 1)* kuEpochInBins; // Epoch counter size in s - const double kdEpochCycleInS = static_cast(kuEpochCounterSz) * (kdEpochInNs/1e9); + const double kdEpochCycleInS = static_cast(kuEpochCounterSz + 1) * (kdEpochInNs/1e9); // Epoch Cycle MS start message size in bits const uint64_t kulEpochCycleFieldSz = 0x1FFFFF; // 21 bits @@ -107,7 +107,8 @@ namespace gdpbv100 { enum PattMessageTypes { PATT_MISSMATCH = 0, // Missmatch pattern, 1 bit per ASIC PATT_ENABLE = 1, // Enable pattern, 1 bit per ASIC - PATT_RESYNC = 2 // Resync request pattern, 1 bit per ASIC + PATT_RESYNC = 2, // Resync request pattern, 1 bit per ASIC + PATT_STATUS = 3 // Status pattern, 1 bit per ASIC (SW only) }; enum MessagePrintMask { @@ -181,7 +182,7 @@ namespace gdpbv100 { { return (data >> shift) & (((static_cast(1)) << len) - 1); } inline uint32_t getField(uint32_t shift, uint32_t len) const - { return (data >> shift) & (((static_cast(1)) << len) - 1); } + { return (data >> shift) & (((static_cast(1)) << len) - 1); } //used to be 32 bit. might need to replace getfield by getfieldlong in getter of pattern message inline void setField(uint32_t shift, uint32_t len, uint32_t value) { uint64_t mask = (((static_cast(1)) << len) - 1); @@ -266,6 +267,8 @@ namespace gdpbv100 { inline uint16_t getGdpbSysErrData() const { return getField( 4, 7); } // ---------- Get4 gDPB unknown msg type access methods ------------------- inline uint32_t getGdpbSysUnkwData() const { return getField( 4, 32); } + // ---------- FW error msg type access methods ---------------------------- + inline uint32_t getGdpbSysFwErrResync() const { return getBit( 36 ); } // ---------- ASIC Pattern messages access methods ------------------------ inline uint16_t getGdpbSysPattType() const { return getField( 46, 2 ); } inline uint16_t getGdpbSysPattIndex() const { return getField( 40, 4 ); } @@ -290,6 +293,13 @@ namespace gdpbv100 { // ---------- Get4 gDPB 24b/32b Epoch setter methods ---------------------- inline void setGdpbEpEpochNb( uint32_t v ) { setField( 8, 31, v ); } + + // ---------- Get4 gDPB System Msg access methods ------------------------- + inline void setGdpbSysSubType( uint16_t v ) { setField( 38, 2, v); } + // ---------- ASIC Pattern messages access methods ------------------------ + inline void setGdpbSysPattType( uint16_t v ) { setField( 46, 2, v ); } + inline void setGdpbSysPattIndex( uint16_t v ) { setField( 40, 4, v ); } + inline void setGdpbSysPattPattern( uint32_t v ) { setField( 4, 32, v ); } // ---------- STAR Trigger messages setter methods ------------------------ inline void setStarTrigMsgIndex( uint8_t v ) { setField( 0, 2, v ); } @@ -340,6 +350,8 @@ namespace gdpbv100 { static double CalcDistanceD(double start, double stop); bool operator<(const gdpbv100::Message& other) const; + bool operator==(const gdpbv100::Message& other) const; + bool operator!=(const gdpbv100::Message& other) const; }; class FullMessage : public Message { @@ -895,4 +907,4 @@ namespace gdpb { } // gdpb -#endif // STETOFMESSAGEFORMAT_H \ No newline at end of file +#endif // STETOFMESSAGEFORMAT_H From fa8418b22f11eaf805e87e607263e87bb35da50b Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Mon, 4 Oct 2021 12:56:47 +0200 Subject: [PATCH 02/62] merged with group development to have support for local run-by-run calibrations in the repository version. Nessecary only for creating calibrations, but should be available in the offical code. Added calculation of goodEventFlag for every counter from Get4 missmatch bits and pulser digis. --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 716 ++++++++++++++++--- 1 file changed, 601 insertions(+), 115 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index a19b162c291..7d5da1f6209 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -43,21 +43,27 @@ #include #include #include +#include #include "TString.h" #include "TFile.h" #include "TH1F.h" #include "TH2F.h" +#include "TClass.h" +#include "TObject.h" #include "TProfile.h" #include "StChain/StChainOpt.h" // for renaming the histogram file #include "StEvent.h" + #include "StETofCollection.h" +#include "StETofHeader.h" //collection includes header. Make sure to include header first to get correct version! #include "StETofDigi.h" #include "StMuDSTMaker/COMMON/StMuDst.h" #include "StMuDSTMaker/COMMON/StMuETofDigi.h" +#include "StMuDSTMaker/COMMON/StMuETofHeader.h" #include "StETofCalibMaker.h" #include "StETofUtil/StETofHardwareMap.h" @@ -104,8 +110,10 @@ StETofCalibMaker::StETofCalibMaker( const char* name ) mResetTimeCorr( 0. ), mTriggerTime( 0. ), mResetTime( 0. ), + mResetTs( 0 ), mPulserPeakTime( 0. ), mReferencePulserIndex( 0 ), + mStrictPulserHandling( 0 ), mUsePulserGbtxDiff( true ), mDoQA( false ), mDebug( false ), @@ -124,9 +132,16 @@ StETofCalibMaker::StETofCalibMaker( const char* name ) mPulserPeakTot.clear(); mPulserTimeDiff.clear(); mPulserTimeDiffGbtx.clear(); + mNPulsersCounter.clear(); + mNStatusBitsCounter.clear(); + mPulserPresent.clear(); mJumpingPulsers.clear(); + mUnlockPulserState.clear(); + + mStuckFwDigi.clear(); + mHistograms.clear(); } @@ -333,7 +348,7 @@ StETofCalibMaker::InitRun( Int_t runnumber ) for( const auto& kv : mPulserWindow ) { LOG_DEBUG << "AFCK address: 0x" << std::hex << kv.first << std::dec << " --> pulser window from " << kv.second.first << " to " << kv.second.second << " ns" << endm; } - LOG_INFO << "pulser time peak at " << mPulserPeakTime << " ns" << endm; + LOG_DEBUG << "pulser time peak at " << mPulserPeakTime << " ns" << endm; // -------------------------------------------------------------------------------------------- // calib param @@ -354,8 +369,9 @@ StETofCalibMaker::InitRun( Int_t runnumber ) mMinDigisPerSlewBin = calibParamTable->minDigisInSlewBin; // only set the reference pulser index if it is not alredy set from outside by a steering macro - if( mReferencePulserIndex == 0 ) { - mReferencePulserIndex = calibParamTable->referencePulserIndex; + if( mReferencePulserIndex == 0 ) { //REMOVED TO COMPILE AGAINST NEW. PW + //mReferencePulserIndex = calibParamTable->referencePulserIndex; + mReferencePulserIndex = 1; } else { LOG_INFO << "--- reference pulser index is set manually ---" << endm; @@ -405,6 +421,7 @@ StETofCalibMaker::InitRun( Int_t runnumber ) LOG_INFO << " minimal number of digis required in slewing bin: " << mMinDigisPerSlewBin << endm; LOG_INFO << " reference pulser index: " << mReferencePulserIndex << endm; + // -------------------------------------------------------------------------------------------- // signal velocities @@ -603,7 +620,7 @@ StETofCalibMaker::InitRun( Int_t runnumber ) kv.second->SetDirectory( 0 ); } } - else { + else {//input from file LOG_INFO << "etof calibration histograms: filename provided --> use parameter file: " << mFileNameCalibHistograms.c_str() << endm; if( !isFileExisting( mFileNameCalibHistograms ) ) { @@ -617,6 +634,28 @@ StETofCalibMaker::InitRun( Int_t runnumber ) LOG_INFO << "setting all parameters to default" << endm; } + TFile* histOffsetFile = new TFile( mFileNameOffsetHistograms.c_str(), "READ" ); //create setter! + + if( !histOffsetFile || histOffsetFile->IsZombie() ) { + LOG_ERROR << "unable to open file: " << mFileNameOffsetHistograms.c_str() << endm; + LOG_INFO << "setting all parameters to default" << endm; + }else{ + LOG_INFO << "Successfully opened RunOffset file "<< mFileNameOffsetHistograms.c_str() << endm; + } + + + + TString hPosOffsetName = Form( "calib_Run%d_PosOffsets_pfx", runnumber ); + TString hT0OffsetName = Form( "calib_Run%d_T0Offsets_pfx", runnumber ); + TProfile* hPosOffsetProfile = nullptr; + TProfile* hT0OffsetProfile = nullptr; + + if( histOffsetFile && !(histOffsetFile->IsZombie()) ){ + LOG_INFO << "Getting run offset histograms Pos: "<< hPosOffsetName << " T0: "<< hT0OffsetName << endm; + hPosOffsetProfile = ( TProfile* ) histOffsetFile->Get( hPosOffsetName ); + hT0OffsetProfile = ( TProfile* ) histOffsetFile->Get( hT0OffsetName ); + } + for( unsigned int sector = eTofConst::sectorStart; sector <= eTofConst::sectorStop; sector++ ) { if( mRunYear == 2018 && sector != 18 ) continue; @@ -630,6 +669,8 @@ StETofCalibMaker::InitRun( Int_t runnumber ) TString hname; TProfile* hProfile; + + //------------------- // digi tot corr //------------------- @@ -644,14 +685,14 @@ StETofCalibMaker::InitRun( Int_t runnumber ) if( hProfile ) { for( size_t i=1; i<=2 * eTofConst::nStrips; i++ ) { if( hProfile->GetBinContent( i ) != 0 ) { - mDigiTotCorr.at( key )->SetBinContent( i , 2. / hProfile->GetBinContent( i ) ); + mDigiTotCorr.at( key )->SetBinContent( i , hProfile->GetBinContent( i ) ); } else { mDigiTotCorr.at( key )->SetBinContent( i , 1. ); } - if( mDigiTotCorr.at( key )->GetBinContent( i ) > 10. ) { + if( mDigiTotCorr.at( key )->GetBinContent( i ) < 0.05 || mDigiTotCorr.at( key )->GetBinContent( i ) > 10 ) { mDigiTotCorr.at( key )->SetBinContent( i , 1. ); } } @@ -681,10 +722,19 @@ StETofCalibMaker::InitRun( Int_t runnumber ) hname = Form( "calib_Sector%02d_ZPlane%d_Det%d_Pos_pfx", sector, zPlane, counter ); hProfile = ( TProfile* ) histFile->Get( hname ); + double dRunOffset = 0; + if (hPosOffsetProfile) { + int mCounterBin = hPosOffsetProfile->FindBin( 9*(sector -13) + 3 * (zPlane - 1) + counter ); + dRunOffset = hPosOffsetProfile->GetBinContent( mCounterBin ); + LOG_DEBUG << "setting run position offset to "<< dRunOffset<< " for counter "<< ( 9*(sector -13) + 3 * (zPlane - 1) + counter ) << endm; + }else{ + LOG_INFO << "position offset histogram "<AddBinContent( i , -1. * hProfile->GetBinContent( i ) / mSignalVelocity.at( key ) ); - mDigiTimeCorr.at( key )->AddBinContent( eTofConst::nStrips + i , hProfile->GetBinContent( i ) / mSignalVelocity.at( key ) ); + mDigiTimeCorr.at( key )->AddBinContent( i , -1. * ( hProfile->GetBinContent( i ) + dRunOffset ) / mSignalVelocity.at( key ) ); + mDigiTimeCorr.at( key )->AddBinContent( eTofConst::nStrips + i , ( hProfile->GetBinContent( i ) + dRunOffset ) / mSignalVelocity.at( key ) ); } } else{ @@ -697,17 +747,24 @@ StETofCalibMaker::InitRun( Int_t runnumber ) hname = Form( "calib_Sector%02d_ZPlane%d_Det%d_T0corr", sector, zPlane, counter ); hProfile = ( TProfile* ) histFile->Get( hname ); + dRunOffset = 0; + if (hT0OffsetProfile) { + int mCounterBin = hT0OffsetProfile->FindBin( 9*(sector -13) + 3 * (zPlane - 1) + counter ); + dRunOffset = hT0OffsetProfile->GetBinContent( mCounterBin ); + } + LOG_DEBUG << "setting run time offset to "<< dRunOffset<< " for counter "<< ( 9*(sector -13) + 3 * (zPlane - 1) + counter ) << endm; + if( hProfile && hProfile->GetNbinsX() == 1 ) { LOG_DEBUG << "T0 histogram with 1 bin: " << key << endm; for( size_t i=1; i<=2 * eTofConst::nStrips; i++ ) { - mDigiTimeCorr.at( key )->AddBinContent( i , hProfile->GetBinContent( 1 ) ); + mDigiTimeCorr.at( key )->AddBinContent( i , hProfile->GetBinContent( 1 ) + dRunOffset ); } } else if( hProfile && hProfile->GetNbinsX() == eTofConst::nStrips ) { LOG_DEBUG << "T0 histogram with 32 bins: " << key << endm; for( size_t i=1; i<= eTofConst::nStrips; i++ ) { - mDigiTimeCorr.at( key )->AddBinContent( i , hProfile->GetBinContent( i ) ); - mDigiTimeCorr.at( key )->AddBinContent( i + eTofConst::nStrips , hProfile->GetBinContent( i ) ); + mDigiTimeCorr.at( key )->AddBinContent( i , hProfile->GetBinContent( i ) + dRunOffset ); + mDigiTimeCorr.at( key )->AddBinContent( i + eTofConst::nStrips , hProfile->GetBinContent( i ) + dRunOffset ); } } else{ @@ -1092,6 +1149,21 @@ StETofCalibMaker::processStEvent() StETofHeader* etofHeader = etofCollection->etofHeader(); StSPtrVecETofDigi& etofDigis = etofCollection->etofDigis(); + /*if( mDoQA ){ + LOG_INFO << "filling missmatch histograms now" << endm; + TClass* headerClass = etofHeader->IsA(); + if( headerClass->GetClassVersion() > 1 ){ + LOG_INFO << "getting missmatch vector" << endm; + std::vector< Bool_t > vMissmatchVec = etofHeader->missMatchFlagVec(); //lookup error? + int iGet4Id = 0; + for( auto iMissMatchFlag : vMissmatchVec ){ + int iCounter = iGet4Id % 16; //probalby wrong! + mHistograms[ "ETOF_QA_daqMissmatches_get4" ]->Fill(iGet4Id, iMissMatchFlag); + mHistograms[ "ETOF_QA_daqMissmatches_counter" ]->Fill(iCounter, iMissMatchFlag); + } + } + }*/ + size_t nDigis = etofDigis.size(); if( mDebug ) { LOG_INFO << "processStEvent() - # fired eTOF digis : " << nDigis << endm; @@ -1104,15 +1176,18 @@ StETofCalibMaker::processStEvent() /// first loop over digis to apply hardware mappping and find the pulsers for( size_t i=0; iIsA(); + if( headerClass->GetClassVersion() > 2 ){ + mNStatusBitsCounter.clear(); + std::vector< Bool_t > vMissmatchVec = etofHeader->missMatchFlagVec(); + int iGet4Id = 0; + for( auto iMissMatchFlag : vMissmatchVec ){ + // From DigiMaker: + // mMissMatchFlagVec.at( 144 * ( sector - 13 ) + 48 * ( zplane -1 ) + 16 * ( counter - 1 ) + 8 * ( side - 1 ) + ( ( strip - 1 ) / 4 ) ) = true; + if (iMissMatchFlag == false) continue; + int iCounter = iGet4Id / 16; + if( mNStatusBitsCounter.count(iCounter) ){ + mNStatusBitsCounter[iCounter]++; + }else{ + mNStatusBitsCounter[iCounter] = 1; + } + } + + std::vector goodEventFlagVec; + for( int iCounter = 0; iCounter < 108; iCounter++){ + if ( !(mNPulsersCounter.count(iCounter) ) ){ + goodEventFlagVec.push_back(false); + }else{ + if ( !(mNStatusBitsCounter.count(iCounter)) && mNPulsersCounter[iCounter] == 2){ + goodEventFlagVec.push_back(true); //true when 2 pulser digis and zero status bits are available on this counter + }else{ + goodEventFlagVec.push_back(false); + } + } + } + if (goodEventFlagVec.size() == 108){ + etofHeader->setGoodEventFlagVec(goodEventFlagVec); + } + } /// second loop to apply calibrations to (non-pulser) digis inside the timing window - int previousGeomId = -1; - double previousTot = -1.; - double previousTime = -1.; - + StructStuckFwDigi current = { -1, -1., -1. }; + StructStuckFwDigi prev = { -1, -1., -1. }; int nDuplicates = 0; for( size_t i=0; isector() * 100000 + aDigi->zPlane() * 10000 + aDigi->counter() * 1000 + aDigi->strip() * 10 + aDigi->side(); + current.tot = aDigi->rawTot(); + current.time = aDigi->rawTime(); + // ignore digis that were sent in bulk from the same channel with exactly the same tot and time due to stuck firmware - int currentGeomId = aDigi->sector() * 100000 + aDigi->zPlane() * 10000 + aDigi->counter() * 1000 + aDigi->strip() * 10 + aDigi->side(); - double currentTot = aDigi->rawTot(); - double currentTime = aDigi->rawTime(); - - if( currentGeomId == previousGeomId && - fabs( currentTime - previousTime ) < 1.e-5 && - fabs( currentTot - previousTot ) < 1.e-5 ) - { + auto it = std::find( mStuckFwDigi.begin(), mStuckFwDigi.end(), current ); + if( it != mStuckFwDigi.end() ) { if( mDebug ) { - LOG_INFO << "digi from stuck firmware --> ignore" << endm; + LOG_INFO << "digi from stuck firmware (s" << aDigi->sector() << " m" << aDigi->zPlane() << " c" << aDigi->counter() << ") --> ignore" << endm; } + + nDuplicates++; + continue; + } + else if( current == prev ) { + mStuckFwDigi.push_back( current ); + resetToRaw( mMuDst->etofDigi( i-1 ) ); + nDuplicates++; continue; } else { - previousGeomId = currentGeomId; - previousTot = currentTot; - previousTime = currentTime; + prev = current; } @@ -1171,9 +1283,13 @@ StETofCalibMaker::processStEvent() applyCalibration( aDigi, etofHeader ); } - if( mDebug && nDuplicates > 0 ) { + if( mDoQA && nDuplicates > 0 ) { LOG_INFO << "*** # duplicate digis from stuck firmware: " << nDuplicates << endm; + for( const auto& v : mStuckFwDigi ) { + LOG_INFO << "stuck channel with geomId: " << v.geomId << " " << v.tot << " " << v.time << endm; + } } + mStuckFwDigi.clear(); } @@ -1200,19 +1316,36 @@ StETofCalibMaker::processMuDst() } StMuETofHeader* etofHeader = mMuDst->etofHeader(); + mNPulsersCounter.clear(); //--------------------------------- +/* if( mDoQA ){ + LOG_INFO << "filling missmatch histograms now" << endm; + TClass* headerClass = etofHeader->IsA(); + if( headerClass->GetClassVersion() > 1 ){ + LOG_INFO << "getting missmatch vector" << endm; + std::vector< Bool_t > vMissmatchVec = etofHeader->missMatchFlagVec(); //lookup error? + int iGet4Id = 0; + for( auto iMissMatchFlag : vMissmatchVec ){ + int iCounter = iGet4Id % 16; //probalby wrong! + mHistograms[ "ETOF_QA_daqMissmatches_get4" ]->Fill(iGet4Id, iMissMatchFlag); + mHistograms[ "ETOF_QA_daqMissmatches_counter" ]->Fill(iCounter, iMissMatchFlag); + } + } + }*/ + size_t nDigis = mMuDst->numberOfETofDigi(); - LOG_INFO << "processMuDst() - # fired eTOF digis : " << nDigis << endm; + //LOG_INFO << "processMuDst() - # fired eTOF digis : " << nDigis << endm; mTriggerTime = triggerTime( ( StETofHeader* ) etofHeader ); mResetTime = fmod( resetTime( ( StETofHeader* ) etofHeader ), eTofConst::bTofClockCycle ); - + //LOG_INFO << "created pulser digi map" << endm; std::map< unsigned int, std::vector< unsigned int >> pulserCandMap; /// first loop over digis to apply hardware mappping and find the pulsers for( size_t i=0; ietofDigi( i ); if( !aDigi ) { @@ -1220,29 +1353,65 @@ StETofCalibMaker::processMuDst() continue; } /// reset digi to carry only raw information (needed for afterburner mode) + //LOG_INFO << "resetting digi "<< i <<"/"<< nDigis << endm; resetToRaw( aDigi ); /// apply hardware mapping from rocId, chipId, channelId to - /// sector, zplane, counter, strip, side + /// sector, zplane, counter, strip, side + //LOG_INFO << "mapping digi: "<< i <<"/"<< nDigis << endm; applyMapping( aDigi ); /// flag pulser digis + //LOG_INFO << "pulser digi flagging: "<< i <<"/"<< nDigis << endm; if( mRunYear != 2018 ) { flagPulserDigis( aDigi, i, pulserCandMap ); } } - LOG_INFO << "size of pulserCandMap: " << pulserCandMap.size() << endm; + //LOG_INFO << "size of pulserCandMap: " << pulserCandMap.size() << endm; calculatePulserOffsets( pulserCandMap ); - + + // collect status bit information and fill good event flag for 2020+ data + TClass* headerClass = etofHeader->IsA(); + if( headerClass->GetClassVersion() > 2 ){ + mNStatusBitsCounter.clear(); + std::vector< Bool_t > vMissmatchVec = etofHeader->missMatchFlagVec(); + int iGet4Id = 0; + for( auto iMissMatchFlag : vMissmatchVec ){ + // From DigiMaker: + // mMissMatchFlagVec.at( 144 * ( sector - 13 ) + 48 * ( zplane -1 ) + 16 * ( counter - 1 ) + 8 * ( side - 1 ) + ( ( strip - 1 ) / 4 ) ) = true; + if (iMissMatchFlag == false) continue; + int iCounter = iGet4Id / 16; + if( mNStatusBitsCounter.count(iCounter) ){ + mNStatusBitsCounter[iCounter]++; + }else{ + mNStatusBitsCounter[iCounter] = 1; + } + } + + std::vector goodEventFlagVec; + for( int iCounter = 0; iCounter < 108; iCounter++){ + if ( !(mNPulsersCounter.count(iCounter) ) ){ + goodEventFlagVec.push_back(false); + }else{ + if ( !(mNStatusBitsCounter.count(iCounter)) && mNPulsersCounter[iCounter] == 2){ + goodEventFlagVec.push_back(true); //true when 2 pulser digis and zero status bits are available on this counter + }else{ + goodEventFlagVec.push_back(false); + } + } + } + if (goodEventFlagVec.size() == 108){ + etofHeader->setGoodEventFlagVec(goodEventFlagVec); + } + } /// second loop to apply calibrations to (non-pulser) digis inside the timing window - int previousGeomId = -1; - double previousTot = -1.; - double previousTime = -1.; - + StructStuckFwDigi current = { -1, -1., -1. }; + StructStuckFwDigi prev = { -1, -1., -1. }; int nDuplicates = 0; + for( size_t i=0; ietofDigi( i ); @@ -1251,25 +1420,29 @@ StETofCalibMaker::processMuDst() continue; } + current.geomId = aDigi->sector() * 100000 + aDigi->zPlane() * 10000 + aDigi->counter() * 1000 + aDigi->strip() * 10 + aDigi->side(); + current.tot = aDigi->rawTot(); + current.time = aDigi->rawTime(); + // ignore digis that were sent in bulk from the same channel with exactly the same tot and time due to stuck firmware - int currentGeomId = aDigi->sector() * 100000 + aDigi->zPlane() * 10000 + aDigi->counter() * 1000 + aDigi->strip() * 10 + aDigi->side(); - double currentTot = aDigi->rawTot(); - double currentTime = aDigi->rawTime(); - - if( currentGeomId == previousGeomId && - fabs( currentTime - previousTime ) < 1.e-5 && - fabs( currentTot - previousTot ) < 1.e-5 ) - { + auto it = std::find( mStuckFwDigi.begin(), mStuckFwDigi.end(), current ); + if( it != mStuckFwDigi.end() ) { if( mDebug ) { - LOG_INFO << "digi from stuck firmware --> ignore" << endm; + LOG_INFO << "digi from stuck firmware (s" << aDigi->sector() << " m" << aDigi->zPlane() << " c" << aDigi->counter() << ") --> ignore" << endm; } + + nDuplicates++; + continue; + } + else if( current == prev ) { + mStuckFwDigi.push_back( current ); + resetToRaw( mMuDst->etofDigi( i-1 ) ); + nDuplicates++; continue; } else { - previousGeomId = currentGeomId; - previousTot = currentTot; - previousTime = currentTime; + prev = current; } @@ -1278,9 +1451,13 @@ StETofCalibMaker::processMuDst() applyCalibration( aDigi, etofHeader ); } - if( mDebug && nDuplicates > 0 ) { + if( mDoQA && nDuplicates > 0 ) { LOG_INFO << "*** # duplicate digis from stuck firmware: " << nDuplicates << endm; + for( const auto& v : mStuckFwDigi ) { + LOG_INFO << "stuck channel with geomId: " << v.geomId << " " << v.tot << " " << v.time << endm; + } } + mStuckFwDigi.clear(); } //_____________________________________________________________ @@ -1301,6 +1478,8 @@ StETofCalibMaker::isFileExisting( const std::string fileName ) void StETofCalibMaker::resetToRaw( StETofDigi* aDigi ) { + if( !aDigi ) return; + aDigi->setGeoAddress( 0, 0, 0, 0, 0 ); aDigi->setCalibTime( 0. ); aDigi->setCalibTot( -1. ); @@ -1369,9 +1548,10 @@ StETofCalibMaker::flagPulserDigis( StETofDigi* aDigi, unsigned int index, std::m if( ( aDigi->strip() == 1 && aDigi->side() == 1 ) || ( aDigi->strip() == 32 && aDigi->side() == 2 ) ) { float timeToTrigger = aDigi->rawTime() - mTriggerTime; float totToPeak = aDigi->rawTot() - mPulserPeakTot.at( key ); + float totToHalfPeak = aDigi->rawTot() - mPulserPeakTot.at( key ) * 0.5; if( timeToTrigger > mPulserWindow.at( aDigi->rocId() ).first && timeToTrigger < mPulserWindow.at( aDigi->rocId() ).second ) { - if( fabs( totToPeak ) < 25 ) { + if( fabs( totToPeak ) < 25 || fabs( totToHalfPeak ) < 10 ) { isPulserCand = true; } } @@ -1411,6 +1591,8 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u std::map< int, double > pulserTimes; + mNPulsersCounter.clear(); + mPulserPresent.clear(); //clear map of present pulsers in each event // loop over all candidates to find real pulser, save time in pulserTimes map for( auto it=pulserDigiMap.begin(); it!=pulserDigiMap.end(); it++ ) { @@ -1442,7 +1624,7 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u } // find "best fitting digi", remove other digis (likely misidentified noise) - double currentDiff = fabs( timeToTrigger - mPulserPeakTime ) * 0.1 + fabs( totToPeak ); + double currentDiff = fabs( timeToTrigger - mPulserPeakTime ) * 0.1 + fabs( totToPeak ); // might need better criterion? Normalisation to widths? PW if( currentDiff < bestDiff ) { bestDiff = currentDiff; candIndex = j; @@ -1468,18 +1650,28 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u } pulserTimes[ sideIndex ] = pulserTime; - } - + + int sector = sideIndex / 1000; + int plane = ( sideIndex % 1000) / 100; + int counter = ( sideIndex % 100) / 10; + int key = 9 * ( sector - 13 ) + 3 * ( plane - 1 ) + ( counter - 1 ); + if( mNPulsersCounter.count( key ) ){ + mNPulsersCounter[key]++; + }else{ + mNPulsersCounter[key] = 1; + } + mPulserPresent[ sideIndex ] = true; + } double referenceTime = 0.; // update reference time (for QA) if( mDoQA ) { if( pulserTimes.count( mReferencePulserIndex ) ) { - referenceTime = pulserTimes.at( mReferencePulserIndex ); + referenceTime = pulserTimes.at( mReferencePulserIndex ); //only updated for QA?? needed to remove smeared pulsers if( mDebug ) { - LOG_INFO << "time of reference pulser updated" << endm; + LOG_INFO << "preliminary reference time:" << referenceTime << endm; } } } @@ -1503,7 +1695,7 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u int key = partialKey + 10 * counter; if( pulserTimes.count( key ) ) { - if( mDoQA ) { + if( mDoQA ) {// fill if all relevant pulsers are available. if( pulserTimes.count( partialKey + 10 ) ) { mHistograms.at( "pulserDigiTimeToCounter1" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, pulserTimes.at( partialKey + 10 ) - pulserTimes.at( key ) ); } @@ -1515,26 +1707,54 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u } } - times.at( counter - 1 ) = pulserTimes.at( key ) + mPulserTimeDiffGbtx.at( key ); + times.at( counter - 1 ) = pulserTimes.at( key ) + mPulserTimeDiffGbtx.at( key ); //substract pulser time difference from database table + + bool isNonSmearedPulser = false; + if( referenceTime != 0 ) { + double dist = times.at( counter - 1 ) - referenceTime; //distance to reference pulser + double redDist = mHistograms.at( "pulserDigiTimeDiff_GbtxCorrProfMod" )->GetBinContent( gbtxId * eTofConst::nCounters + counter ); // average distance to next clock edge for this pulser + + double modDist = fmod( dist - redDist, eTofConst::coarseClockCycle ); //Distance to "normal" offset. full clock cycle distances are thrown out? Why? + modDist = modDist - eTofConst::coarseClockCycle * round( modDist / eTofConst::coarseClockCycle ); //substract a clock cycle if modDist > 0.5 coarseClockCycle + //=> -0.5*coarseClockCycle < modDist < 0.5*coarseClockCycle => Distance to closest clock cycle + + if( redDist == 0 || fabs( modDist ) > 0.5 ) { //> 0.5ns + n*ClockCycle away from reference pulser. Hard cut? If the first pulser is off, all following will be neglected! + if( redDist != 0 ) LOG_INFO << "too far away --> smeared pulser: " << key << "(" << gbtxId << "-" << counter << ")" << endm; + redDist = dist; //empty in the beginning, Example distance to reference pulser + } + else { + redDist += modDist; //adds always up? + isNonSmearedPulser = true; + } + + mHistograms.at( "pulserDigiTimeDiff_GbtxCorrProf" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, dist ); + mHistograms.at( "pulserDigiTimeDiff_GbtxCorrProfMod" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, redDist ); // TProfile! => Average! - average += times.at( counter - 1 ); - nAv++; + if( mDoQA ) { + mHistograms.at( "pulserDigiTimeDiff_GbtxCorr" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, dist ); //Pulser offset on GBTX from database substracted + mHistograms.at( "pulserDigiTimeDiff" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, pulserTimes.at( key ) - referenceTime ); //Pulser offset on GBTX not substracted + } + } - if( mDoQA && referenceTime != 0 ) { - mHistograms.at( "pulserDigiTimeDiff" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, pulserTimes.at( key ) - referenceTime ); - mHistograms.at( "pulserDigiTimeDiff_GbtxCorr" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, times.at( counter - 1 ) - referenceTime ); + // only use non-smeared pulsers for the + if( isNonSmearedPulser ) { + average += times.at( counter - 1 ); + nAv++; + } + else { + times.at( counter - 1 ) = 0.; } + } } - - if( nAv == eTofConst::nCounters ) { + if( nAv == eTofConst::nCounters ) { //all pulser present, check for single pulser jumps by comparing to average of the other two. double diff12 = fabs( times.at( 0 ) - times.at( 1 ) ); double diff13 = fabs( times.at( 0 ) - times.at( 2 ) ); double diff23 = fabs( times.at( 1 ) - times.at( 2 ) ); - if( diff12 > 1 && diff13 > 1 && diff23 < 1 ) { + if( diff12 > 0.2 && diff13 > 0.2 && diff23 < 0.2 ) { average -= times.at( 0 ); nAv--; @@ -1557,7 +1777,7 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u mHistograms.at( "1_off" )->Fill( gbtxId * eTofConst::nCounters + 1.5, times.at( 0 ) - ( average / nAv ) ); } } - else if( diff12 > 1 && diff13 < 1 && diff23 > 1 ) { + else if( diff12 > 0.2 && diff13 < 0.2 && diff23 > 0.2 ) { average -= times.at( 1 ); nAv--; @@ -1580,7 +1800,7 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u mHistograms.at( "2_off" )->Fill( gbtxId * eTofConst::nCounters + 1.5, times.at( 1 ) - ( average / nAv ) ); } } - else if( diff12 < 1 && diff13 > 1 && diff23 > 1 ) { + else if( diff12 < 0.2 && diff13 > 0.2 && diff23 > 0.2 ) { average -= times.at( 2 ); nAv--; @@ -1604,55 +1824,173 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u } } } - else if( nAv == eTofConst::nCounters - 1 ) { - if( times.at( 0 ) > 0 && fabs( fabs( times.at( 0 ) - ( average / nAv ) ) - eTofConst::coarseClockCycle * 0.5 ) < 0.2 ) { + + if( nAv == eTofConst::nCounters - 1 ) { + // if there are two pulsers, restore missing pulser from average of the other two + if( times.at( 0 ) > 0 && times.at( 1 ) > 0 && fabs( fabs( times.at( 0 ) - times.at( 1 ) ) - eTofConst::coarseClockCycle ) < 0.2 ) { if( mJumpingPulsers.count( partialKey + 10 ) ) { + //LOG_INFO << gbtxId << " ### case 1 (1) ### " << endm; times.at( 0 ) += mJumpingPulsers.at( partialKey + 10 ) * eTofConst::coarseClockCycle; average += mJumpingPulsers.at( partialKey + 10 ) * eTofConst::coarseClockCycle; + } + else if( mJumpingPulsers.count( partialKey + 20 ) ) { + //LOG_INFO << gbtxId << " ### case 1 (2) ### " << endm; + times.at( 1 ) += mJumpingPulsers.at( partialKey + 20 ) * eTofConst::coarseClockCycle; + average += mJumpingPulsers.at( partialKey + 20 ) * eTofConst::coarseClockCycle; + } + else { + //LOG_INFO << gbtxId << " ### case 1 (3) ### " << endm; + if( times.at( 0 ) < times.at( 1 ) ) { + times.at( 0 ) += eTofConst::coarseClockCycle; + average += eTofConst::coarseClockCycle; + } + else { + times.at( 1 ) += eTofConst::coarseClockCycle; + average += eTofConst::coarseClockCycle; + } } } - if( times.at( 1 ) > 0 && fabs( fabs( times.at( 1 ) - ( average / nAv ) ) - eTofConst::coarseClockCycle * 0.5 ) < 0.2 ) { + else if( times.at( 0 ) && times.at( 2 ) > 0 && fabs( fabs( times.at( 0 ) - times.at( 2 ) ) - eTofConst::coarseClockCycle ) < 0.2 ) { + if( mJumpingPulsers.count( partialKey + 10 ) ) { + //LOG_INFO << gbtxId << " ### case 2 (1) ### " << endm; + times.at( 0 ) += mJumpingPulsers.at( partialKey + 10 ) * eTofConst::coarseClockCycle; + average += mJumpingPulsers.at( partialKey + 10 ) * eTofConst::coarseClockCycle; + } + else if( mJumpingPulsers.count( partialKey + 30 ) ) { + //LOG_INFO << gbtxId << " ### case 2 (2) ### " << endm; + times.at( 2 ) += mJumpingPulsers.at( partialKey + 30 ) * eTofConst::coarseClockCycle; + average += mJumpingPulsers.at( partialKey + 30 ) * eTofConst::coarseClockCycle; + } + else { + //LOG_INFO << gbtxId << " ### case 2 (3) ### " << endm; + if( times.at( 0 ) < times.at( 2 ) ) { + times.at( 0 ) += eTofConst::coarseClockCycle; + average += eTofConst::coarseClockCycle; + } + else { + times.at( 2 ) += eTofConst::coarseClockCycle; + average += eTofConst::coarseClockCycle; + } + } + } + else if( times.at( 1 ) > 0 && times.at( 2 ) > 0 && fabs( fabs( times.at( 1 ) - times.at( 2 ) ) - eTofConst::coarseClockCycle ) < 0.2 ) { if( mJumpingPulsers.count( partialKey + 20 ) ) { + //LOG_INFO << gbtxId << " ### case 3 (1) ### " << endm; times.at( 1 ) += mJumpingPulsers.at( partialKey + 20 ) * eTofConst::coarseClockCycle; average += mJumpingPulsers.at( partialKey + 20 ) * eTofConst::coarseClockCycle; - } - } - if( times.at( 2 ) > 0 && fabs( fabs( times.at( 2 ) - ( average / nAv ) ) - eTofConst::coarseClockCycle * 0.5 ) < 0.2 ) { - if( mJumpingPulsers.count( partialKey + 30 ) ) { + } + else if( mJumpingPulsers.count( partialKey + 30 ) ) { + //LOG_INFO << gbtxId << " ### case 3 (2) ### " << endm; times.at( 2 ) += mJumpingPulsers.at( partialKey + 30 ) * eTofConst::coarseClockCycle; average += mJumpingPulsers.at( partialKey + 30 ) * eTofConst::coarseClockCycle; } + else { + //LOG_INFO << gbtxId << " ### case 3 (3) ### " << endm; + if( times.at( 1 ) < times.at( 2 ) ) { + times.at( 1 ) += eTofConst::coarseClockCycle; + average += eTofConst::coarseClockCycle; + } + else { + times.at( 2 ) += eTofConst::coarseClockCycle; + average += eTofConst::coarseClockCycle; + } + } } } - if( nAv > 0 ) average /= nAv; + + if( nAv >= 2 ) { + average /= nAv; + } if( mDoQA && referenceTime != 0 ) { mHistograms.at( "pulserDigiTimeDiff_perGbtx" )->Fill( gbtxId * eTofConst::nCounters + 1.5, average - referenceTime ); } - for( int counter=1; counter<=3; counter++ ) { - if( mDoQA && times.at( counter - 1 ) != 0. ) { - mHistograms.at( "pulserDigiTimeDiff_toAverage" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, times.at( counter - 1 ) - average ); + for( int counter = eTofConst::counterStart; counter <= eTofConst::counterStop; counter++ ) { + double diffToAv = 0.; + + if( times.at( counter - eTofConst::counterStart ) != 0. ) { + diffToAv = times.at( counter - eTofConst::counterStart ) - average; + + if( fabs( diffToAv ) > 0.2 ) diffToAv = 0.; //removing didn't work + + if( mDoQA ) { + mHistograms.at( "pulserDigiTimeDiff_toAverage" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, diffToAv ); + } } - pulserTimes[ partialKey + 10 * counter ] = average - mPulserTimeDiffGbtx.at( partialKey + 10 * counter ); + if( average != 0. ) {//only allow counter pulsers that are now close to average + //times.at( counter - 1 ) = pulserTimes.at( key ) + mPulserTimeDiffGbtx.at( key ) + pulserTimes[ partialKey + 10 * counter ] = average + diffToAv - mPulserTimeDiffGbtx.at( partialKey + 10 * counter ); //restores original pulser times INCLUDING GBTX offset ?!?! + //pulserTimes[ partialKey + 10 * counter ] = average; + } + else { + if( pulserTimes.count( partialKey + 10 * counter ) ) { + pulserTimes.erase( partialKey + 10 * counter ); + } + } } } } // calculate difference to the reference + referenceTime = 0.; if( pulserTimes.count( mReferencePulserIndex ) ) { - referenceTime = pulserTimes.at( mReferencePulserIndex ); - if( mDebug ) { - LOG_INFO << "time of reference pulser updated" << endm; - } + if( mPulserTimeDiff.count( mReferencePulserIndex ) ){ + referenceTime = pulserTimes.at( mReferencePulserIndex ) - mPulserTimeDiff[ mReferencePulserIndex ]; + //LOG_INFO << "time of reference pulser updated: " << referenceTime << " with reference correction "<< mPulserTimeDiff[ mReferencePulserIndex ] << endm; + }else{ + referenceTime = pulserTimes.at( mReferencePulserIndex ); + //LOG_INFO << "time of reference pulser updated: " << referenceTime << endm; + } } + + if( referenceTime != 0 ) { + int iLockThreshold = 0; + mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->Reset("ICESM"); + for( auto& kv : pulserTimes ) { - mPulserTimeDiff[ kv.first ] = kv.second - referenceTime; + // check if new pulser time difference seems reasonable ( only allow jumps in multiple of the coarse clock tick ) to avoid smeared pulsers + if( mPulserTimeDiff.count( kv.first ) ) {//pulser time difference default available previous events + //double modDist = fmod( mPulserTimeDiff.at( kv.first ) - ( kv.second - referenceTime ), eTofConst::coarseClockCycle ); + //modDist = modDist - eTofConst::coarseClockCycle * round( modDist / eTofConst::coarseClockCycle ); + + double modDist = mPulserTimeDiff.at( kv.first ) - ( kv.second - referenceTime ); //test PW + //modDist = modDist - eTofConst::coarseClockCycle * round( modDist / eTofConst::coarseClockCycle ); + + + if( fabs( modDist ) > 0.2 ) { + mUnlockPulserState[ kv.first ]++; + + // LOG_INFO << " pulser time " << kv.first << " seems unreasonable (" << kv.second - referenceTime << ")"; + // LOG_INFO << " compared to previous stored value (" << mPulserTimeDiff.at( kv.first ) << ")" << endm; + + // only unlock pulser state if 10 consecutive events have a modDist larger then the threshold + if( mUnlockPulserState.at( kv.first ) < iLockThreshold ) { + // LOG_INFO << " --> ignore for now and move on" << endm; + continue; //move on, don't update pulser times! + } + else{ + // LOG_INFO << " --> pulser state has been unlocked" << endm; + } + + //fill 2d Hist here with GBTX and counter number + mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->Fill( kv.second - referenceTime ); + + } + else{ + if( mUnlockPulserState.count( kv.first ) ) { + LOG_INFO << " --> new event doesn't have offset for pulser " << kv.first << " --> remove the entry" << endm; + mUnlockPulserState.erase( kv.first ); + } + } + } + //pulser time differece was set here! + if( mDoQA ) { int sector = kv.first / 1000; @@ -1664,9 +2002,52 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u + ( zPlane - eTofConst::zPlaneStart ) * eTofConst::nSides + ( side - eTofConst::sideStart ); - mHistograms.at( "pulserDigiTimeDiff_fullCorr" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, mPulserTimeDiff.at( kv.first ) ); + if( mPulserTimeDiff.count( kv.first ) ) { + mHistograms.at( "pulserDigiTimeDiff_fullCorr" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, mPulserTimeDiff.at( kv.first ) ); + } + + mHistograms[ "pulserDigiPresence" ]->Fill(gbtxId * eTofConst::nCounters + counter - 0.5); } } + + //LOG_INFO << "Check " << referenceTime << endm; + if( mDoQA ) { + mHistograms[ "pulserDigiPresence" ]->Fill( -1 ); //use as event counter + mHistograms[ "pulserDigiTimeDiff_CorrAgreement" ]->Fill( mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->GetMaximum() ); + mHistograms[ "pulserDigiTimeDiff_CorrCommonJump" ]->Fill( mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->GetEntries() ); + } + if( ( mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->GetEntries() > 150 ) && ( mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->GetMaximum() > 15 ) ){ + + //LOG_INFO << "Check: found " << mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->GetMaximum() <<" agreeing time shifts. Shifting reference times " << endm; + int iMaximumBin = mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->GetMaximumBin(); + double dRefCorrAverage = 0; + int iNRefCorrAgree = 0; + + for( auto& kv : pulserTimes ) { //build average of all agreeing pulsers + if ( mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->FindBin(kv.second - referenceTime) == iMaximumBin ){ + dRefCorrAverage += kv.second - referenceTime; + iNRefCorrAgree++; + } + } + dRefCorrAverage /= iNRefCorrAgree; + referenceTime -= dRefCorrAverage; + //pulserTimes.at( mReferencePulserIndex ) -= dRefCorrAverage; + mPulserTimeDiff[ mReferencePulserIndex ] -= dRefCorrAverage; + + }else{ + //LOG_INFO << "Check: found only " << mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->GetMaximum() <<" agreeing time shifts. Shifting pulser times " << endm; + for( auto& kv : pulserTimes ) { + if ( ! mPulserTimeDiff[ kv.first ] ) { + mPulserTimeDiff[ kv.first ] = kv.second - referenceTime; + continue; + } + if( mUnlockPulserState.count( kv.first ) ){ + if( mUnlockPulserState.at( kv.first ) > iLockThreshold ){// check if pulser is locked + mPulserTimeDiff[ kv.first ] = kv.second - referenceTime; + } + } + } + } } } @@ -1700,6 +2081,17 @@ StETofCalibMaker::applyCalibration( StETofDigi* aDigi, StETofHeader* etofHeader if( timeToTrigger > mTimingWindow.at( aDigi->rocId() ).first && timeToTrigger < mTimingWindow.at( aDigi->rocId() ).second ) { + + if( mStrictPulserHandling ){ + int PulserKey = aDigi->sector() * 1000 + aDigi->zPlane() * 100 + aDigi->side() + 10 * aDigi->counter(); + if( !mPulserPresent.count( PulserKey ) ) { + if( mDebug ) { + LOG_DEBUG << "no pulser in the same event for this counter --> digi skipped due to strict pulser handling" << endm; + } + return; + } + } + double calibTot = aDigi->rawTot() * mGet4TotBinWidthNs * calibTotFactor( aDigi ); aDigi->setCalibTot( calibTot ); @@ -1732,6 +2124,8 @@ StETofCalibMaker::applyCalibration( StETofDigi* aDigi, StETofHeader* etofHeader void StETofCalibMaker::resetToRaw( StMuETofDigi* aDigi ) { + if( !aDigi ) return; + aDigi->setGeoAddress( 0, 0, 0, 0, 0 ); aDigi->setCalibTime( 0. ); aDigi->setCalibTot( -1. ); @@ -1782,7 +2176,7 @@ StETofCalibMaker::calibTotFactor( StETofDigi* aDigi ) if( mDebug ) { LOG_DEBUG << "calibTotFactor: histogram with key " << key << " at bin " << bin << " -> return bin content: " << binContent << endm; } - return binContent; + return (1.0/binContent); //invert here to get to fixed mean value! } else { if( mDebug ) { @@ -1837,7 +2231,8 @@ StETofCalibMaker::slewingTimeOffset( StETofDigi* aDigi ) if( mDigiSlewCorr.count( key ) ) { - unsigned int totBin = mDigiSlewCorr.at( key )->FindBin( aDigi->calibTot() ); + unsigned int totBin = mDigiSlewCorr.at( key )->FindBin( aDigi->rawTot() ); //adjusted. PW +mDebug = true; if( mDigiSlewCorr.at( key )->GetBinEntries( totBin ) <= mMinDigisPerSlewBin && totBin < etofSlewing::nTotBins ) { if( mDebug ) { LOG_DEBUG << "slewingTimeOffset: insufficient statistics for slewing calibration in channel " << key << " at tot bin " << totBin << " --> return 0" << endm; @@ -1845,7 +2240,7 @@ StETofCalibMaker::slewingTimeOffset( StETofDigi* aDigi ) return 0.; } - float val = mDigiSlewCorr.at( key )->Interpolate( aDigi->calibTot() ); + float val = mDigiSlewCorr.at( key )->Interpolate( aDigi->rawTot() ); //adjusted. PW if( mDebug ) { LOG_DEBUG << "slewingTimeOffset: histogram with key " << key << " with calib TOT of " << aDigi->calibTot() << " --> interpolated correction: " << val << endm; } @@ -1891,7 +2286,7 @@ StETofCalibMaker::triggerTime( StETofHeader* header ) std::map< uint64_t, short > countsGdpbTs; for( const auto& kv : header->rocGdpbTs() ) { if( mDebug ) { - LOG_DEBUG << "triggerTime (" << std::hex << "Ox" << kv.first << std::dec << ") " << kv.second * eTofConst::coarseClockCycle * 1.e-9 << endm; + LOG_DEBUG << "triggerTime (" << std::hex << "Ox" << kv.first << std::dec << ") " << kv.second * eTofConst::coarseClockCycle * 1.e-9 << endm; } ++countsGdpbTs[ kv.second ]; } @@ -1925,7 +2320,7 @@ StETofCalibMaker::triggerTime( StETofHeader* header ) } } - if( mostProbableTriggerTs > 0) { + if( mostProbableTriggerTs > 0 ) { triggerTime = mostProbableTriggerTs * eTofConst::coarseClockCycle; } @@ -1945,16 +2340,62 @@ double StETofCalibMaker::resetTime( StETofHeader* header ) { // count the occurance of a given reset time stamp in the StarTs map of the eTOF header - std::map< uint64_t, short > countsStarTs; + std::map< uint64_t, short > countsStarTsRaw; for( const auto& kv : header->rocStarTs() ) { if( mDebug ) { - LOG_DEBUG << "resetTime (" << std::hex << "Ox" << kv.first << std::dec << ") " << kv.second * eTofConst::coarseClockCycle * 1.e-9 << endm; + LOG_DEBUG << "resetTime (" << std::hex << "Ox" << kv.first << std::dec << ") " << kv.second * eTofConst::coarseClockCycle * 1.e-9 << endm; } - + // in Run18 only one of the AFCKs was giving the correct reset time: 0x18e6 if( mRunYear == 2018 && kv.first != 0x18e6 ) continue; - ++countsStarTs[ kv.second ]; + if( kv.second != 0 ) { + ++countsStarTsRaw[ kv.second ]; + } + } + + + // combine adjacent reset time values with the earlier one + std::map< uint64_t, short > countsStarTs; + for( auto it = countsStarTsRaw.begin(); it != countsStarTsRaw.end(); it++ ) { + auto next = std::next( it, 1 ); + + short countTs = it->second; + + if( next != countsStarTsRaw.end() && ( next->first - it->first ) == 1 ) { + countTs += next->second; + } + + countsStarTs[ it->first ] = countTs; + } + + + + + if( mDoQA ) { + if( countsStarTs.size() == 0 ) { + LOG_INFO << "all AFCKs report a reset time value 0" << endm; + } + + for( const auto& kv : countsStarTs ) { + LOG_DEBUG << "resetTime cand:" << kv.first << " (" << kv.second << " times)" << endm; + mHistograms.at( "resetTimeCand_times" )->Fill( kv.second ); + } + + for( const auto& kv : header->rocStarTs() ) { + unsigned int sector; + mHwMap->mapToSector( kv.first, sector ); + + LOG_DEBUG << "resetTime(" << sector << "): " << kv.second << endm; + + std::string histName = "resetTimeDifferenceToSector" + to_string( sector ); + for( const auto& jv : header->rocStarTs() ) { + unsigned int sec; + mHwMap->mapToSector( jv.first, sec ); + + mHistograms.at( histName )->Fill( sec, ( int64_t ) jv.second - ( int64_t ) kv.second ); + } + } } @@ -1966,11 +2407,33 @@ StETofCalibMaker::resetTime( StETofHeader* header ) double resetTime = it->first * eTofConst::coarseClockCycle; + // only update reset time if it is at least two clock ticks away from the old reset time to avoid jitter + if( abs( mResetTs - ( int64_t ) it->first ) < 2 ) { + resetTime = mResetTs * eTofConst::coarseClockCycle; + } + else { + LOG_INFO << "change in reset TS: " << mResetTs << " --> " << it->first << endm; + mResetTs = it->first; + } + + // Run19: trigger - reset time should be on the order of a few second up to 120 minutes (7.2*10^12 ns), i.e. max. run length // Run20: difference can be negative due to eTOF DAQ restarts at the beginning of runs while eTOF is put to "BUSY" in run control if( mTriggerTime - resetTime < 7.2e12 ) { if( mDebug ) { - LOG_INFO << "reset time (ns): " << resetTime << " --> difference to trigger time in seconds: " << ( mTriggerTime - resetTime ) * 1.e-9 << endm; + LOG_DEBUG << "reset time (ns): " << resetTime << " --> difference to trigger time in seconds: " << ( mTriggerTime - resetTime ) * 1.e-9 << endm; + } + LOG_DEBUG << "--> picked reset TS:" << mResetTs << endm; + + if( mDoQA ) { + mHistograms.at( "resetTimeCand_picked" )->Fill( it->second ); + + auto rawIt = std::max_element( countsStarTsRaw.begin(), countsStarTsRaw.end(), + []( const pair< uint64_t, short >& p1, const pair< uint64_t, short >& p2 ) { + return p1.second < p2.second; } ); + + mHistograms.at( "resetTimeCand_compare" )->Fill( ( int64_t ) mResetTs - ( int64_t ) rawIt->first ); + mHistograms.at( "resetTimeCand_value" )->Fill( mResetTs % ( int ) eTofConst::bTofClockCycle ); } return resetTime; @@ -2056,27 +2519,45 @@ StETofCalibMaker::setHistFileName() void StETofCalibMaker::bookHistograms() { - if( !mDoQA ) { - return; - } - LOG_INFO << "bookHistograms() ... " << endm; - mHistograms[ "pulserDigiTimeDiff" ] = new TH2F( "pulserDigiTimeDiff", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - mHistograms[ "pulserDigiTimeToCounter1" ] = new TH2F( "pulserDigiTimeToCounter1", "time difference of pulsers to counter 1;pulser channel;#Delta T (ns)", 216, 0, 216, 2*360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - mHistograms[ "pulserDigiTimeToCounter2" ] = new TH2F( "pulserDigiTimeToCounter2", "time difference of pulsers to counter 2;pulser channel;#Delta T (ns)", 216, 0, 216, 2*360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - mHistograms[ "pulserDigiTimeToCounter3" ] = new TH2F( "pulserDigiTimeToCounter3", "time difference of pulsers to counter 3;pulser channel;#Delta T (ns)", 216, 0, 216, 2*360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - - mHistograms[ "pulserDigiTimeDiff_GbtxCorr" ] = new TH2F( "pulserDigiTimeDiff_GbtxCorr", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - mHistograms[ "pulserDigiTimeDiff_perGbtx" ] = new TH2F( "pulserDigiTimeDiff_perGbtx", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - mHistograms[ "pulserDigiTimeDiff_toAverage" ] = new TH2F( "pulserDigiTimeDiff_toAverage", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 4*360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - - mHistograms[ "1_off" ] = new TH2F( "1_off", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - mHistograms[ "2_off" ] = new TH2F( "2_off", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - mHistograms[ "3_off" ] = new TH2F( "3_off", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - + mHistograms[ "pulserDigiTimeDiff_GbtxCorrProf" ] = new TProfile( "pulserDigiTimeDiff_GbtxCorrProf", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, "s" ); + mHistograms[ "pulserDigiTimeDiff_GbtxCorrProfMod" ] = new TProfile( "pulserDigiTimeDiff_GbtxCorrProfMod", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, "s" ); mHistograms[ "pulserDigiTimeDiff_fullCorr" ] = new TH2F( "pulserDigiTimeDiff_fullCorr", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + if( mDoQA ) { + mHistograms[ "pulserDigiTimeDiff" ] = new TH2F( "pulserDigiTimeDiff", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "pulserDigiTimeToCounter1" ] = new TH2F( "pulserDigiTimeToCounter1", "time difference of pulsers to counter 1;pulser channel;#Delta T (ns)", 216, 0, 216, 2*360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "pulserDigiTimeToCounter2" ] = new TH2F( "pulserDigiTimeToCounter2", "time difference of pulsers to counter 2;pulser channel;#Delta T (ns)", 216, 0, 216, 2*360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "pulserDigiTimeToCounter3" ] = new TH2F( "pulserDigiTimeToCounter3", "time difference of pulsers to counter 3;pulser channel;#Delta T (ns)", 216, 0, 216, 2*360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + + mHistograms[ "pulserDigiTimeDiff_GbtxCorr" ] = new TH2F( "pulserDigiTimeDiff_GbtxCorr", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "pulserDigiTimeDiff_perGbtx" ] = new TH2F( "pulserDigiTimeDiff_perGbtx", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "pulserDigiTimeDiff_toAverage" ] = new TH2F( "pulserDigiTimeDiff_toAverage", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 4*360, -359.5 * ( 6.25 / 112 ), 360.5 * ( 6.25 / 112 ) ); + + mHistograms[ "1_off" ] = new TH2F( "1_off", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "2_off" ] = new TH2F( "2_off", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "3_off" ] = new TH2F( "3_off", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + + mHistograms[ "pulserDigiTimeDiff_CorrAgreement" ] = new TH1F("pulserDigiTimeDiff_CorrAgreement", "Number of pulsers agreeing on a common shift between events; #pulsers", 218, -0.5, 217.5); + mHistograms[ "pulserDigiTimeDiff_CorrCommonJump" ] = new TH1F("pulserDigiTimeDiff_CorrCommonJump", "Number of pulsers jumping at the same time between events; #pulsers", 218, -0.5, 217.5); + + mHistograms[ "pulserDigiPresence" ] = new TH1F( "pulserDigiPresence", "pulser presence (number of events at ( -1 );pulser channel", 218, -1.5, 216.5); + + mHistograms[ "pulserDigiTimeDiff_RefCorr" ] = new TH1F("pulserDigiTimeDiff_RefCorr", "time difference of pulsers to reference; #Delta T (ns)", 45, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 )); + + for( int i=0; i<12; i++ ) { + std::string histName = "resetTimeDifferenceToSector" + to_string( i + 13 ); + mHistograms[ histName ] = new TH2F( Form( "resetTimeDifferenceToSector%d", i + 13 ), Form("reset time difference to sector %d;sector;#DeltaT (clock ticks)", i + 13 ), 12, 12.5, 24.4, 5, -2.5, 2.5 ); + } + mHistograms[ "ETOF_QA_daqMissmatches_get4" ] = new TProfile( "ETOF_QA_daqMissmatches_get4", "missmatch percentage for each get4; get4 []; missmatch percentage", 1728, 0.5, 1728.5 ); + mHistograms[ "ETOF_QA_daqMissmatches_counter" ] = new TProfile( "ETOF_QA_daqMissmatches_counter", "missmatch percentage for each counter; counter []; missmatch percentage", 108, 0.5, 108.5 ); + mHistograms[ "resetTimeCand_times" ] = new TH1F( "resetTimeCand_times", "sectors agreeing on reset time candidates;# sectors with common candidate;# events", 12, 0.5, 12.5 ); + mHistograms[ "resetTimeCand_picked" ] = new TH1F( "resetTimeCand_picked", "sectors agreeing on picked reset time;# sectors with picked reset time;# events", 12, 0.5, 12.5 ); + mHistograms[ "resetTimeCand_compare" ] = new TH1F( "resetTimeCand_compare", "difference between old and new way;#DeltaT (clock ticks);# events", 5, -2.5, 2.5 ); + mHistograms[ "resetTimeCand_value" ] = new TH1F( "resetTimeCand_value", "picked reset time value;clock ticks;# events", ( int ) eTofConst::bTofClockCycle, 0.5, 0.5 + eTofConst::bTofClockCycle ); + } + for ( auto& kv : mHistograms ) { kv.second->SetDirectory( 0 ); } @@ -2091,6 +2572,11 @@ StETofCalibMaker::writeHistograms() TFile histFile( mHistFileName.c_str(), "RECREATE", "etofCalib" ); histFile.cd(); + + for( int i=0; i<12; i++ ) { + std::string histName = "resetTimeDifferenceToSector" + to_string( i + 13 ); + mHistograms.at( histName )->Scale( 12. / mHistograms.at( histName )->GetEntries() ); + } for ( const auto& kv : mHistograms ) { if( kv.second->GetEntries() > 0 ) kv.second->Write(); @@ -2101,4 +2587,4 @@ StETofCalibMaker::writeHistograms() else { LOG_INFO << "histogram file name is empty string --> cannot write histograms" << endm; } -} \ No newline at end of file +} From 5395cb8e2f66d655e2d7e15b5b21190bc2704fa9 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Mon, 4 Oct 2021 13:16:34 +0200 Subject: [PATCH 03/62] merged with group development to have support for local run-by-run calibrations in the repository version. Nessecary only for creating calibrations, but should be available in the offical code. Added calculation of goodEventFlag for every counter from Get4 missmatch bits and pulser digis. --- StRoot/StETofCalibMaker/StETofCalibMaker.h | 38 +++++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.h b/StRoot/StETofCalibMaker/StETofCalibMaker.h index 6c40d2cdf97..fecd3ac4d3d 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.h +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.h @@ -80,12 +80,14 @@ class StETofCalibMaker: public StMaker { void setFileNameTimingWindow( const char* fileName ); void setFileNameSignalVelocity( const char* fileName ); void setFileNameCalibHistograms( const char* fileName ); + void setFileNameOffsetHistograms( const char* fileName ); void setFileNameResetTimeCorr( const char* fileName ); void setFileNamePulserTotPeak( const char* fileName ); void setFileNamePulserTimeDiffGbtx( const char* fileName ); void setDoQA( const bool doQA ); void setDebug( const bool debug ); + void setStrictPulserHandling( const bool debug ); void setReferencePulserIndex( const int index ); @@ -136,6 +138,7 @@ class StETofCalibMaker: public StMaker { std::string mFileNameTimingWindow; // name of parameter file for timing window std::string mFileNameSignalVelocity; // name of parameter file for signal velocity std::string mFileNameCalibHistograms; // name of parameter file for calibration histograms (output of QA maker) + std::string mFileNameOffsetHistograms; // name of parameter file for run by run offsets histograms (output of QA maker) std::string mFileNameResetTimeCorr; // name of parameter file for reset time correction std::string mFileNamePulserTotPeak; // name of parameter file for pulser peak tot std::string mFileNamePulserTimeDiffGbtx; // name of parameter file for pulser time diff @@ -146,7 +149,8 @@ class StETofCalibMaker: public StMaker { Float_t mResetTimeCorr; // additional offset for the whole system in case reset time was not saved correctly Double_t mTriggerTime; // trigger time in ns - Double_t mResetTime; // reset time in ns + Double_t mResetTime; // reset time in ns + Long64_t mResetTs; // reset time stamp in clock ticks Float_t mPulserPeakTime; // pulser peak time relative to the trigger time in ns Int_t mReferencePulserIndex; // index of reference pulser used in the pulser correction to correct time offset between different Gbtx @@ -162,10 +166,29 @@ class StETofCalibMaker: public StMaker { std::map< UInt_t, Float_t > mPulserPeakTot; // TOT of pulsers on each side of the RPC counters (as key) std::map< UInt_t, Double_t > mPulserTimeDiff; // pulser time difference with respect to the reference pulser for each detector side as key - std::map< UInt_t, Double_t > mPulserTimeDiffGbtx; // pulser time difference with inside a Gbtx with respect to counter 1 + std::map< UInt_t, Double_t > mPulserTimeDiffGbtx; // pulser time difference with inside a Gbtx with respect to counter 1 + std::map< UInt_t, UInt_t > mNPulsersCounter; // number of found pulsers on each counter. Has to be 2 for good the counter to be considered good in this event. + std::map< UInt_t, UInt_t > mNStatusBitsCounter; // number of Get4 status bits on each counter. Has to be 0 for good the counter to be considered good in this event. + std::map< UInt_t, Bool_t > mPulserPresent; // map of present pulsers for each event (by counter side) - std::map< UInt_t, UInt_t > mJumpingPulsers; // flag jumping pulsers + std::map< UInt_t, Int_t > mJumpingPulsers; // flag jumping pulsers + std::map< UInt_t, Int_t > mUnlockPulserState; // map that counts pulser offsets to avoid locking into the wrong pulser offset state + + + struct StructStuckFwDigi{ + Int_t geomId; + Double_t time; + Double_t tot; + + bool operator==( const StructStuckFwDigi& r ) const { + return geomId == r.geomId && fabs( time - r.time ) < 1.e-5 && fabs( tot - r.tot ) < 1.e-5; + } + }; + + std::vector< StructStuckFwDigi > mStuckFwDigi; // list of digis to ignore for the rest of the run due to stuck firmware + + Bool_t mStrictPulserHandling; Bool_t mUsePulserGbtxDiff; Bool_t mDoQA; Bool_t mDebug; @@ -173,9 +196,12 @@ class StETofCalibMaker: public StMaker { std::map< std::string, TH1* > mHistograms; + + + virtual const Char_t *GetCVS() const { static const char cvs[]="Tag $Name: $Id: built " __DATE__ " " __TIME__ ; return cvs; } - ClassDef( StETofCalibMaker, 0 ) + ClassDef( StETofCalibMaker, 1 ) }; inline void StETofCalibMaker::setFileNameCalibParam( const char* fileName ) { mFileNameCalibParam = fileName; } @@ -184,6 +210,7 @@ inline void StETofCalibMaker::setFileNameStatusMap( const char* fileNam inline void StETofCalibMaker::setFileNameTimingWindow( const char* fileName ) { mFileNameTimingWindow = fileName; } inline void StETofCalibMaker::setFileNameSignalVelocity( const char* fileName ) { mFileNameSignalVelocity = fileName; } inline void StETofCalibMaker::setFileNameCalibHistograms( const char* fileName ) { mFileNameCalibHistograms = fileName; } +inline void StETofCalibMaker::setFileNameOffsetHistograms( const char* fileName ) { mFileNameOffsetHistograms = fileName; } inline void StETofCalibMaker::setFileNameResetTimeCorr( const char* fileName ) { mFileNameResetTimeCorr = fileName; } inline void StETofCalibMaker::setFileNamePulserTotPeak( const char* fileName ) { mFileNamePulserTotPeak = fileName; } inline void StETofCalibMaker::setFileNamePulserTimeDiffGbtx( const char* fileName ) { mFileNamePulserTimeDiffGbtx = fileName; } @@ -191,8 +218,9 @@ inline void StETofCalibMaker::setFileNamePulserTimeDiffGbtx( const char* fileNam inline double StETofCalibMaker::resetTimeCorr() const { return mResetTimeCorr; } +inline void StETofCalibMaker::setStrictPulserHandling( const bool StrictPulserHandling ) { mStrictPulserHandling = StrictPulserHandling; } inline void StETofCalibMaker::setDoQA( const bool doQA ) { mDoQA = doQA; } inline void StETofCalibMaker::setDebug( const bool debug ) { mDebug = debug; } inline void StETofCalibMaker::setReferencePulserIndex( const int index ) { mReferencePulserIndex = index; } -#endif // STETOFCALIBMAKER_H \ No newline at end of file +#endif // STETOFCALIBMAKER_H From 55bf9ff76b508faa26c839bfbd90025f56d73c4a Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Mon, 4 Oct 2021 13:31:29 +0200 Subject: [PATCH 04/62] header include needed to be added for local compilation (?) --- StRoot/StMuDSTMaker/COMMON/StMuDstMaker.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/StRoot/StMuDSTMaker/COMMON/StMuDstMaker.cxx b/StRoot/StMuDSTMaker/COMMON/StMuDstMaker.cxx index d9f31b1d79a..9eed9c32985 100644 --- a/StRoot/StMuDSTMaker/COMMON/StMuDstMaker.cxx +++ b/StRoot/StMuDSTMaker/COMMON/StMuDstMaker.cxx @@ -114,6 +114,8 @@ #include "StMuMcTrack.h" #include "StG2TrackVertexMap.h" +#include //added/needed to compile successfully after 01.Oct.21. Remove in merger if problem is solved in a different way. No further changes in file. Weidenkaff + class StEpdHit; // MALisa ClassImp(StMuDstMaker) From 1572c6b1b2df5d122ce61947b31105497dff657a Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Mon, 4 Oct 2021 13:38:43 +0200 Subject: [PATCH 05/62] added eTofGoodEventFlag to mark counters which are good foer analysis in each event --- StRoot/StEvent/StETofCollection.h | 2 +- StRoot/StEvent/StETofHeader.cxx | 47 +++++++++++++++---- StRoot/StEvent/StETofHeader.h | 33 ++++++++++--- StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx | 43 +++++++++++++++-- StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h | 30 ++++++++++-- StRoot/StPicoDstMaker/StPicoDstMaker.cxx | 5 ++ StRoot/StPicoDstMaker/StPicoDstMaker.h | 2 +- StRoot/StPicoEvent/StPicoEvent.cxx | 34 +++++++++++++- StRoot/StPicoEvent/StPicoEvent.h | 15 +++++- 9 files changed, 186 insertions(+), 25 deletions(-) diff --git a/StRoot/StEvent/StETofCollection.h b/StRoot/StEvent/StETofCollection.h index 9a5c360785b..7f6e3b9af30 100644 --- a/StRoot/StEvent/StETofCollection.h +++ b/StRoot/StEvent/StETofCollection.h @@ -59,7 +59,7 @@ class StETofCollection : public StObject { StSPtrVecETofHit mETofHits; - ClassDef( StETofCollection, 1 ) + ClassDef( StETofCollection, 2 ) }; #endif // STETOFCOLLECTION_H diff --git a/StRoot/StEvent/StETofHeader.cxx b/StRoot/StEvent/StETofHeader.cxx index b3ac6a080be..0a51fc77794 100644 --- a/StRoot/StEvent/StETofHeader.cxx +++ b/StRoot/StEvent/StETofHeader.cxx @@ -38,6 +38,10 @@ StETofHeader::StETofHeader() { mRocGdpbTs.clear(); mRocStarTs.clear(); + const size_t kNbGet4sInSystem = 1728; + mMissMatchFlagVec = std::vector( kNbGet4sInSystem, false ); + const size_t kNbCountersInSystem = 108; + mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); } @@ -55,13 +59,15 @@ StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); const size_t kNbGet4sInSystem = 1728; - mMissMatchFlagVec = vector( kNbGet4sInSystem, false ); + mMissMatchFlagVec = std::vector( kNbGet4sInSystem, false ); + const size_t kNbCountersInSystem = 108; + mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); } StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime, const map< unsigned int, uint64_t >& gdpbTs, const map< unsigned int, uint64_t >& starTs, const unsigned int& starToken, const unsigned int& starDaqCmdIn, const unsigned int& starTrgCmdIn, - const uint64_t& eventStatusFlag, const vector& MissMatchFlagVec ) + const uint64_t& eventStatusFlag, const std::vector& MissMatchFlagVec ) : mTrgGdpbFullTime( trgGdpbTime ), mTrgStarFullTime( trgStarTime ), mStarToken( starToken ), @@ -72,12 +78,25 @@ StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime { setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); - //const size_t kNbGet4sInSystem = 1728; - //mMissMatchFlagVec.resize( kNbGet4sInSystem ); - //for( auto mapcheck : mMissMatchFlagVec ){ - // cout << mapcheck << endl; - // } + const size_t kNbCountersInSystem = 108; + mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); +} +StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime, + const map< unsigned int, uint64_t >& gdpbTs, const map< unsigned int, uint64_t >& starTs, + const unsigned int& starToken, const unsigned int& starDaqCmdIn, const unsigned int& starTrgCmdIn, + const uint64_t& eventStatusFlag, const std::vector& MissMatchFlagVec, const std::vector& GoodEventFlagVec ) +: mTrgGdpbFullTime( trgGdpbTime ), + mTrgStarFullTime( trgStarTime ), + mStarToken( starToken ), + mStarDaqCmdIn( starDaqCmdIn ), + mStarTrgCmdIn( starTrgCmdIn ), + mEventStatusFlag( eventStatusFlag ), + mMissMatchFlagVec( MissMatchFlagVec ), + mGoodEventFlagVec( GoodEventFlagVec ) +{ + setRocGdpbTs( gdpbTs ); + setRocStarTs( starTs ); } @@ -142,12 +161,18 @@ StETofHeader::eventStatusFlag() const return mEventStatusFlag; } -vector +std::vector StETofHeader::missMatchFlagVec() const { return mMissMatchFlagVec; } +std::vector +StETofHeader::goodEventFlagVec() const +{ + return mGoodEventFlagVec; +} + void StETofHeader::setTrgGdpbFullTime( const double& gdpbFullTime ) { @@ -202,3 +227,9 @@ StETofHeader::setEventStatusFlag( const uint64_t& statusFlag ) { mEventStatusFlag = statusFlag; } + +void +StETofHeader::setGoodEventFlagVec( const std::vector& FlagVec ) +{ + mGoodEventFlagVec = FlagVec; +} diff --git a/StRoot/StEvent/StETofHeader.h b/StRoot/StEvent/StETofHeader.h index 01d4b9b3c54..8daaa42f7a9 100644 --- a/StRoot/StEvent/StETofHeader.h +++ b/StRoot/StEvent/StETofHeader.h @@ -41,10 +41,21 @@ class StETofHeader : public StObject { public: StETofHeader(); + /** + ** @brief default constructor for pre-2020 data. No missmatch information available. Used in StEtofDigiMaker to initialise the header. + **/ StETofHeader( const double&, const double&, const map< unsigned int, uint64_t >&, const map< unsigned int, uint64_t >& , const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t& ); + /** + ** @brief default constructor for post-2020 data. Include missmatch information from FEE. Used in StEtofDigiMaker to initialise the header. + **/ StETofHeader( const double&, const double&, const map< unsigned int, uint64_t >&, const map< unsigned int, uint64_t >& , - const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t&, const vector& ); + const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t&, const std::vector& ); + /** + ** @brief Full constructor including goodEventFlag, which is normally set in calibrations only. + **/ + StETofHeader( const double&, const double&, const map< unsigned int, uint64_t >&, const map< unsigned int, uint64_t >& , + const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t&, const std::vector&, const std::vector& ); ~StETofHeader(); @@ -57,9 +68,15 @@ class StETofHeader : public StObject { unsigned int starToken() const; unsigned int starDaqCmdIn() const; unsigned int starTrgCmdIn() const; - uint64_t eventStatusFlag() const; - - vector missMatchFlagVec() const; + uint64_t eventStatusFlag() const; + /** + ** @brief Flag for each Get4 TDC to mark if it is available in this event. + **/ + std::vector missMatchFlagVec() const; + /** + ** @brief Flag to mark if the event is good for physics analysis for each counter. A counter is considered good in each event when there are zero missmatch flags set and pulser digis on both sides are found. In this case, the counter should perform at its best. Counter efficiency should be constant between good events. + **/ + std::vector goodEventFlagVec() const; void setTrgGdpbFullTime( const double& gdpbFullTime ); @@ -73,6 +90,9 @@ class StETofHeader : public StObject { void setStarTrgCmdIn( const unsigned int& trgCmdIn ); void setEventStatusFlag( const uint64_t& statusFlag ); + void setGoodEventFlagVec( const std::vector& FlagVec ); + void setGoodEventFlagVec( int blubb ) {return;} + // void setGoodEventFlagVec( const std::vector& FlagVec ); private: Double_t mTrgGdpbFullTime; @@ -87,9 +107,10 @@ class StETofHeader : public StObject { ULong64_t mEventStatusFlag; - vector< Bool_t > mMissMatchFlagVec; + std::vector< Bool_t > mMissMatchFlagVec; + std::vector< Bool_t > mGoodEventFlagVec; - ClassDef( StETofHeader, 2 ) + ClassDef( StETofHeader, 3 ) }; #endif // STETOFHEADER_H diff --git a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx index 90e078a6de3..6e2d7b62ac5 100644 --- a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx +++ b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx @@ -34,6 +34,11 @@ StMuETofHeader::StMuETofHeader() { mRocGdpbTs.clear(); mRocStarTs.clear(); + mRocStarTs.clear(); + const size_t kNbGet4sInSystem = 1728; + mMissMatchFlagVec = std::vector( kNbGet4sInSystem, false ); + const size_t kNbCountersInSystem = 108; + mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); } @@ -51,13 +56,15 @@ StMuETofHeader::StMuETofHeader( const double& trgGdpbTime, const double& trgStar setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); const size_t kNbGet4sInSystem = 1728; - mMissMatchFlagVec = std::vector< Bool_t >( kNbGet4sInSystem, false ); + mMissMatchFlagVec = std::vector< Bool_t >( kNbGet4sInSystem, false ); + const size_t kNbCountersInSystem = 108; + mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); } StMuETofHeader::StMuETofHeader( const double& trgGdpbTime, const double& trgStarTime, const map< unsigned int, uint64_t >& gdpbTs, const map< unsigned int, uint64_t >& starTs, const unsigned int& starToken, const unsigned int& starDaqCmdIn, const unsigned int& starTrgCmdIn, - const uint64_t& eventStatusFlag, const vector< Bool_t >& MissMatchFlagVec ) + const uint64_t& eventStatusFlag, const std::vector< Bool_t >& MissMatchFlagVec ) : mTrgGdpbFullTime( trgGdpbTime ), mTrgStarFullTime( trgStarTime ), mStarToken( starToken ), @@ -70,6 +77,23 @@ StMuETofHeader::StMuETofHeader( const double& trgGdpbTime, const double& trgStar setRocStarTs( starTs ); } +StMuETofHeader::StMuETofHeader( const double& trgGdpbTime, const double& trgStarTime, + const map< unsigned int, uint64_t >& gdpbTs, const map< unsigned int, uint64_t >& starTs, + const unsigned int& starToken, const unsigned int& starDaqCmdIn, const unsigned int& starTrgCmdIn, + const uint64_t& eventStatusFlag, const std::vector& MissMatchFlagVec, const std::vector& GoodEventFlagVec ) +: mTrgGdpbFullTime( trgGdpbTime ), + mTrgStarFullTime( trgStarTime ), + mStarToken( starToken ), + mStarDaqCmdIn( starDaqCmdIn ), + mStarTrgCmdIn( starTrgCmdIn ), + mEventStatusFlag( eventStatusFlag ), + mMissMatchFlagVec( MissMatchFlagVec ), + mGoodEventFlagVec( GoodEventFlagVec ) +{ + setRocGdpbTs( gdpbTs ); + setRocStarTs( starTs ); +} + StMuETofHeader::StMuETofHeader( const StETofHeader* header ) : mTrgGdpbFullTime( header->trgGdpbFullTime() ), mTrgStarFullTime( header->trgStarFullTime() ), @@ -77,7 +101,8 @@ StMuETofHeader::StMuETofHeader( const StETofHeader* header ) mStarDaqCmdIn( header->starDaqCmdIn() ), mStarTrgCmdIn( header->starTrgCmdIn() ), mEventStatusFlag( header->eventStatusFlag() ), - mMissMatchFlagVec(header->missMatchFlagVec()) + mMissMatchFlagVec(header->missMatchFlagVec()), + mGoodEventFlagVec(header->goodEventFlagVec()) { setRocGdpbTs( header->rocGdpbTs() ); setRocStarTs( header->rocStarTs() ); @@ -151,6 +176,12 @@ StMuETofHeader::missMatchFlagVec() const return mMissMatchFlagVec; } +std::vector +StMuETofHeader::goodEventFlagVec() const +{ + return mGoodEventFlagVec; +} + void StMuETofHeader::setTrgGdpbFullTime( const double& gdpbFullTime ) @@ -206,3 +237,9 @@ StMuETofHeader::setEventStatusFlag( const uint64_t& statusFlag ) { mEventStatusFlag = statusFlag; } + +void +StMuETofHeader::setGoodEventFlagVec( const std::vector& FlagVec ) +{ + mGoodEventFlagVec = FlagVec; +} diff --git a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h index 87c98d8e135..c5750f04e81 100644 --- a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h +++ b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h @@ -35,11 +35,26 @@ class StMuETofHeader : public TObject { public: StMuETofHeader(); + /** + ** @brief Constructor for conversion from StEvent header. + **/ StMuETofHeader( const StETofHeader* header ); + /** + ** @brief default constructor for pre-2020 data. No missmatch information available. Used in StEtofDigiMaker to initialise the header. + **/ StMuETofHeader( const double&, const double&, const std::map< unsigned int, uint64_t >&, const std::map< unsigned int, uint64_t >& , const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t& ); + /** + ** @brief default constructor for post-2020 data. Include missmatch information from FEE. Used in StEtofDigiMaker to initialise the header. + **/ StMuETofHeader( const double&, const double&, const std::map< unsigned int, uint64_t >&, const std::map< unsigned int, uint64_t >& , const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t&, const std::vector< Bool_t >& ); + /** + ** @brief Full constructor including goodEventFlag, which is normally set in calibrations only. + **/ + StMuETofHeader( const double&, const double&, const std::map< unsigned int, uint64_t >&, const std::map< unsigned int, uint64_t >& , + const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t&, const std::vector&, + const std::vector& ); ~StMuETofHeader(); @@ -53,7 +68,14 @@ class StMuETofHeader : public TObject { unsigned int starDaqCmdIn() const; unsigned int starTrgCmdIn() const; uint64_t eventStatusFlag() const; - std::vector< Bool_t > missMatchFlagVec() const; + /** + ** @brief Flag for each Get4 TDC to mark if it is available in this event. + **/ + std::vector missMatchFlagVec() const; + /** + ** @brief Flag to mark if the event is good for physics analysis for each counter. A counter is considered good in each event when there are zero missmatch flags set and pulser digis on both sides are found. In this case, the counter should perform at its best. Counter efficiency should be constant between good events. + **/ + std::vector goodEventFlagVec() const; void setTrgGdpbFullTime( const double& gdpbFullTime ); @@ -67,6 +89,7 @@ class StMuETofHeader : public TObject { void setStarTrgCmdIn( const unsigned int& trgCmdIn ); void setEventStatusFlag( const uint64_t& statusFlag ); + void setGoodEventFlagVec( const std::vector& FlagVec ); private: Double_t mTrgGdpbFullTime; @@ -81,9 +104,10 @@ class StMuETofHeader : public TObject { ULong64_t mEventStatusFlag; - std::vector< Bool_t > mMissMatchFlagVec; + std::vector< Bool_t > mMissMatchFlagVec; + std::vector< Bool_t > mGoodEventFlagVec; - ClassDef( StMuETofHeader, 2 ) + ClassDef( StMuETofHeader, 3 ) }; #endif // STMUETOFHEADER_H diff --git a/StRoot/StPicoDstMaker/StPicoDstMaker.cxx b/StRoot/StPicoDstMaker/StPicoDstMaker.cxx index 0401b3ec9d6..848e00d941e 100644 --- a/StRoot/StPicoDstMaker/StPicoDstMaker.cxx +++ b/StRoot/StPicoDstMaker/StPicoDstMaker.cxx @@ -55,6 +55,7 @@ #include "StMuDSTMaker/COMMON/StMuEpdHit.h" #include "StMuDSTMaker/COMMON/StMuETofHit.h" #include "StMuDSTMaker/COMMON/StMuETofDigi.h" +#include "StMuDSTMaker/COMMON/StMuETofHeader.h" #include "StMuDSTMaker/COMMON/StMuMcTrack.h" #include "StMuDSTMaker/COMMON/StMuMcVertex.h" @@ -1825,6 +1826,10 @@ void StPicoDstMaker::fillEvent() { picoEvent->setNumberOfPrimaryTracks( mMuDst->numberOfPrimaryTracks() ); picoEvent->setbTofTrayMultiplicity( ev->btofTrayMultiplicity() ); picoEvent->setETofHitMultiplicity( ev->etofHitMultiplicity() ); + StMuETofHeader *header = mMuDst->etofHeader(); + if( header ) { + picoEvent->setETofGoodEventFlag( header->goodEventFlagVec() ); + } // Save the number of etof digis that were useable in the hit building process unsigned short nUseableETofDigis = 0; diff --git a/StRoot/StPicoDstMaker/StPicoDstMaker.h b/StRoot/StPicoDstMaker/StPicoDstMaker.h index e5f91085fb2..42eca81418f 100644 --- a/StRoot/StPicoDstMaker/StPicoDstMaker.h +++ b/StRoot/StPicoDstMaker/StPicoDstMaker.h @@ -349,7 +349,7 @@ class StPicoDstMaker : public StMaker { return cvs; } - ClassDef(StPicoDstMaker, 0) + ClassDef(StPicoDstMaker, 1) }; inline void StPicoDstMaker::setSplit(int split) { mSplit = split; } diff --git a/StRoot/StPicoEvent/StPicoEvent.cxx b/StRoot/StPicoEvent/StPicoEvent.cxx index 37159dba21e..f39454a0013 100644 --- a/StRoot/StPicoEvent/StPicoEvent.cxx +++ b/StRoot/StPicoEvent/StPicoEvent.cxx @@ -36,7 +36,7 @@ StPicoEvent::StPicoEvent(): TObject(), mZdcSumAdcEast(0), mZdcSumAdcWest(0), mZdcSmdEastHorizontal{}, mZdcSmdEastVertical{}, mZdcSmdWestHorizontal{}, mZdcSmdWestVertical{}, mBbcAdcEast{}, mBbcAdcWest{}, mHighTowerThreshold{}, mJetPatchThreshold{}, - mETofHitMultiplicity(0), mETofDigiMultiplicity(0), mNumberOfPrimaryTracks(0), mZdcUnAttenuated{} { + mETofHitMultiplicity(0), mETofDigiMultiplicity(0), mETofGoodEventFlag{}, mNumberOfPrimaryTracks(0), mZdcUnAttenuated{} { // Default constructor if( !mTriggerIds.empty() ) { @@ -146,6 +146,10 @@ StPicoEvent::StPicoEvent(const StPicoEvent &event) : TObject() { mHighTowerThreshold[iIter] = event.mHighTowerThreshold[iIter]; mJetPatchThreshold[iIter] = event.mJetPatchThreshold[iIter]; } + + for(int iIter=0; iIter<108; iIter++) { + mETofGoodEventFlag[iIter] = event.mETofGoodEventFlag[iIter]; + } } //_________________ @@ -333,3 +337,31 @@ void StPicoEvent::setBunchId(Int_t id) { (UChar_t)id ); } } + +//_________________ +bool StPicoEvent::eTofGoodEventFlag( UShort_t iSector, UShort_t iModule, UShort_t iCounter ) const { + if( iSector < 13 || iSector > 24 ){ + LOG_INFO << "StPicoEvent::eTofGoodEventFlag() - non-existing sector id " << iSector <<" -> return false"<< endm; + return false; + } + if( iModule < 1 || iModule > 3 ){ + LOG_INFO << "StPicoEvent::eTofGoodEventFlag() - non-existing module id " << iModule <<" -> return false"<< endm; + return false; + } + if( iCounter < 1 || iCounter > 3 ){ + LOG_INFO << "StPicoEvent::eTofGoodEventFlag() - non-existing counter id " << iCounter <<" -> return false"<< endm; + return false; + } + + return (bool) mETofGoodEventFlag[ 9*(iSector-13) + 3*(iModule-1) + (iCounter-1) ]; +} +//_________________ +void StPicoEvent::setETofGoodEventFlag( std::vector flagVec ) { + if( flagVec.size() != 108 ){ + LOG_INFO << "StPicoEvent::setETofGoodEventFlag() - eTof flag vector wrong size " << flagVec.size() <<" / 108"<< endm; + }else{ + for( auto iterCounter : flagVec ){ + mETofGoodEventFlag[iterCounter] = flagVec[iterCounter]; + } + } +} diff --git a/StRoot/StPicoEvent/StPicoEvent.h b/StRoot/StPicoEvent/StPicoEvent.h index ce84c67020d..3ff0b07a231 100644 --- a/StRoot/StPicoEvent/StPicoEvent.h +++ b/StRoot/StPicoEvent/StPicoEvent.h @@ -141,6 +141,10 @@ class StPicoEvent : public TObject { UShort_t etofHitMultiplicity() const { return mETofHitMultiplicity; } /// Return number of digis in ETOF modules UShort_t etofDigiMultiplicity() const { return mETofDigiMultiplicity; } + /// Return goodEventFlag for a specific eTOF counter + bool eTofGoodEventFlag( UShort_t iSector, UShort_t iModule, UShort_t iCounter ) const; + /// Return goodEventFlag by array entry + bool eTofGoodEventFlag( UShort_t iDet ) const { return (bool) mETofGoodEventFlag[ iDet ]; } /// Return number of primary tracks UShort_t numberOfPrimaryTracks() const { return mNumberOfPrimaryTracks; } /// Return FXT multiplicity (corresponds to the number of primary tracks) @@ -274,9 +278,14 @@ class StPicoEvent : public TObject { void setETofHitMultiplicity(UShort_t mult) { mETofHitMultiplicity = (UShort_t)mult; } /// Set total number of digis in ETOF modules void setETofDigiMultiplicity(UShort_t mult) { mETofDigiMultiplicity = (UShort_t)mult; } + /// Set goodEventFlag for a specific eTOF counter + void setETofGoodEventFlag( bool flag, UShort_t iSector, UShort_t iModule, UShort_t iCounter ) { mETofGoodEventFlag[ 9*(iSector-1) + 3*(iModule-1) + (iCounter-1) ] = flag; } + /// Full setter goodEventFlag all specific eTOF counter. Used to copy over MuDst data + void setETofGoodEventFlag( std::vector flagVec ); /// Set number of primary tracks void setNumberOfPrimaryTracks(UShort_t mult) { mNumberOfPrimaryTracks = (UShort_t)mult; } + /// Set trigger id void setTriggerId(UInt_t id); /// Set trigger id (pass STL vector with trigger IDs) @@ -600,6 +609,8 @@ class StPicoEvent : public TObject { UShort_t mETofHitMultiplicity ; /// Total digi multiplicity in ETOF modules UShort_t mETofDigiMultiplicity ; + /// Flag to mark if the event is good for physics analysis for each counter. A counter is considered good in each event when there are zero missmatch flags set and pulser digis on both sides are found. In this case, the counter should perform at its best. Counter efficiency should be constant between good events. Here: CounterNr = 9*sector + 3*module + counter. + bool mETofGoodEventFlag[108]; /// Number of primary tracks UShort_t mNumberOfPrimaryTracks; @@ -608,9 +619,9 @@ class StPicoEvent : public TObject { UShort_t mZdcUnAttenuated[2]; #if defined (__TFG__VERSION__) - ClassDef(StPicoEvent, 8) + ClassDef(StPicoEvent, 9) #else /* ! __TFG__VERSION__ */ - ClassDef(StPicoEvent, 6) + ClassDef(StPicoEvent, 7) #endif }; From 0e25fc47a4d3feb47a871ecdece46950c008e967 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Wed, 6 Oct 2021 20:26:04 +0200 Subject: [PATCH 06/62] moved struct to public to avoid root6 issue. Changed class dev version back to 0 --- StRoot/StETofCalibMaker/StETofCalibMaker.h | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.h b/StRoot/StETofCalibMaker/StETofCalibMaker.h index fecd3ac4d3d..1b7b0d0eaca 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.h +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.h @@ -89,6 +89,17 @@ class StETofCalibMaker: public StMaker { void setDebug( const bool debug ); void setStrictPulserHandling( const bool debug ); void setReferencePulserIndex( const int index ); + + //moved to public to avoid problem with root6 + struct StructStuckFwDigi{ + Int_t geomId; + Double_t time; + Double_t tot; + + bool operator==( const StructStuckFwDigi& r ) const { + return geomId == r.geomId && fabs( time - r.time ) < 1.e-5 && fabs( tot - r.tot ) < 1.e-5; + } + }; private: @@ -138,7 +149,7 @@ class StETofCalibMaker: public StMaker { std::string mFileNameTimingWindow; // name of parameter file for timing window std::string mFileNameSignalVelocity; // name of parameter file for signal velocity std::string mFileNameCalibHistograms; // name of parameter file for calibration histograms (output of QA maker) - std::string mFileNameOffsetHistograms; // name of parameter file for run by run offsets histograms (output of QA maker) + std::string mFileNameOffsetHistograms; // name of parameter file for run by run offsets histograms (output of QA maker) std::string mFileNameResetTimeCorr; // name of parameter file for reset time correction std::string mFileNamePulserTotPeak; // name of parameter file for pulser peak tot std::string mFileNamePulserTimeDiffGbtx; // name of parameter file for pulser time diff @@ -175,17 +186,6 @@ class StETofCalibMaker: public StMaker { std::map< UInt_t, Int_t > mUnlockPulserState; // map that counts pulser offsets to avoid locking into the wrong pulser offset state - - struct StructStuckFwDigi{ - Int_t geomId; - Double_t time; - Double_t tot; - - bool operator==( const StructStuckFwDigi& r ) const { - return geomId == r.geomId && fabs( time - r.time ) < 1.e-5 && fabs( tot - r.tot ) < 1.e-5; - } - }; - std::vector< StructStuckFwDigi > mStuckFwDigi; // list of digis to ignore for the rest of the run due to stuck firmware Bool_t mStrictPulserHandling; @@ -201,7 +201,7 @@ class StETofCalibMaker: public StMaker { virtual const Char_t *GetCVS() const { static const char cvs[]="Tag $Name: $Id: built " __DATE__ " " __TIME__ ; return cvs; } - ClassDef( StETofCalibMaker, 1 ) + ClassDef( StETofCalibMaker, 0 ) }; inline void StETofCalibMaker::setFileNameCalibParam( const char* fileName ) { mFileNameCalibParam = fileName; } From d28aaf38cdb1e93b655fd881860e8d47f3c4cd5a Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Wed, 6 Oct 2021 20:35:14 +0200 Subject: [PATCH 07/62] added kStFatal return in ::init if calib histo files are corrupt --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index 7d5da1f6209..8b39d854911 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -629,16 +629,24 @@ StETofCalibMaker::InitRun( Int_t runnumber ) TFile* histFile = new TFile( mFileNameCalibHistograms.c_str(), "READ" ); - if( !histFile || histFile->IsZombie() ) { - LOG_ERROR << "unable to open file: " << mFileNameCalibHistograms.c_str() << endm; + if( !histFile ) { + LOG_ERROR << "No calibration file found: " << mFileNameCalibHistograms.c_str() << endm; LOG_INFO << "setting all parameters to default" << endm; + }else if( histFile->IsZombie() ){ + LOG_ERROR << "Zombie calibration file: " << mFileNameCalibHistograms.c_str() << endm; + LOG_INFO << "stopping execution" << endm; + return kStFatal; } TFile* histOffsetFile = new TFile( mFileNameOffsetHistograms.c_str(), "READ" ); //create setter! - if( !histOffsetFile || histOffsetFile->IsZombie() ) { - LOG_ERROR << "unable to open file: " << mFileNameOffsetHistograms.c_str() << endm; + if( !histOffsetFile ) { + LOG_INFO << "No offset file found: " << mFileNameOffsetHistograms.c_str() << endm; LOG_INFO << "setting all parameters to default" << endm; + }else if( histOffsetFile->IsZombie() ) { + LOG_ERROR << "Zombie offset file: " << mFileNameOffsetHistograms.c_str() << endm; + LOG_INFO << "stopping execution" << endm; + return kStFatal; }else{ LOG_INFO << "Successfully opened RunOffset file "<< mFileNameOffsetHistograms.c_str() << endm; } From 5dbebdee06d271ce138a1406c3153d3034c749a2 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Wed, 6 Oct 2021 20:40:04 +0200 Subject: [PATCH 08/62] Changed class dev version back to 0 --- StRoot/StPicoDstMaker/StPicoDstMaker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StRoot/StPicoDstMaker/StPicoDstMaker.h b/StRoot/StPicoDstMaker/StPicoDstMaker.h index 42eca81418f..e5f91085fb2 100644 --- a/StRoot/StPicoDstMaker/StPicoDstMaker.h +++ b/StRoot/StPicoDstMaker/StPicoDstMaker.h @@ -349,7 +349,7 @@ class StPicoDstMaker : public StMaker { return cvs; } - ClassDef(StPicoDstMaker, 1) + ClassDef(StPicoDstMaker, 0) }; inline void StPicoDstMaker::setSplit(int split) { mSplit = split; } From 6681b26d708e37d4ee51e1d18cc48006365d0a5a Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Mon, 18 Oct 2021 13:39:26 +0200 Subject: [PATCH 09/62] Trying to fix merger --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 716 ++++++++++++++++--- 1 file changed, 601 insertions(+), 115 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index a19b162c291..7d5da1f6209 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -43,21 +43,27 @@ #include #include #include +#include #include "TString.h" #include "TFile.h" #include "TH1F.h" #include "TH2F.h" +#include "TClass.h" +#include "TObject.h" #include "TProfile.h" #include "StChain/StChainOpt.h" // for renaming the histogram file #include "StEvent.h" + #include "StETofCollection.h" +#include "StETofHeader.h" //collection includes header. Make sure to include header first to get correct version! #include "StETofDigi.h" #include "StMuDSTMaker/COMMON/StMuDst.h" #include "StMuDSTMaker/COMMON/StMuETofDigi.h" +#include "StMuDSTMaker/COMMON/StMuETofHeader.h" #include "StETofCalibMaker.h" #include "StETofUtil/StETofHardwareMap.h" @@ -104,8 +110,10 @@ StETofCalibMaker::StETofCalibMaker( const char* name ) mResetTimeCorr( 0. ), mTriggerTime( 0. ), mResetTime( 0. ), + mResetTs( 0 ), mPulserPeakTime( 0. ), mReferencePulserIndex( 0 ), + mStrictPulserHandling( 0 ), mUsePulserGbtxDiff( true ), mDoQA( false ), mDebug( false ), @@ -124,9 +132,16 @@ StETofCalibMaker::StETofCalibMaker( const char* name ) mPulserPeakTot.clear(); mPulserTimeDiff.clear(); mPulserTimeDiffGbtx.clear(); + mNPulsersCounter.clear(); + mNStatusBitsCounter.clear(); + mPulserPresent.clear(); mJumpingPulsers.clear(); + mUnlockPulserState.clear(); + + mStuckFwDigi.clear(); + mHistograms.clear(); } @@ -333,7 +348,7 @@ StETofCalibMaker::InitRun( Int_t runnumber ) for( const auto& kv : mPulserWindow ) { LOG_DEBUG << "AFCK address: 0x" << std::hex << kv.first << std::dec << " --> pulser window from " << kv.second.first << " to " << kv.second.second << " ns" << endm; } - LOG_INFO << "pulser time peak at " << mPulserPeakTime << " ns" << endm; + LOG_DEBUG << "pulser time peak at " << mPulserPeakTime << " ns" << endm; // -------------------------------------------------------------------------------------------- // calib param @@ -354,8 +369,9 @@ StETofCalibMaker::InitRun( Int_t runnumber ) mMinDigisPerSlewBin = calibParamTable->minDigisInSlewBin; // only set the reference pulser index if it is not alredy set from outside by a steering macro - if( mReferencePulserIndex == 0 ) { - mReferencePulserIndex = calibParamTable->referencePulserIndex; + if( mReferencePulserIndex == 0 ) { //REMOVED TO COMPILE AGAINST NEW. PW + //mReferencePulserIndex = calibParamTable->referencePulserIndex; + mReferencePulserIndex = 1; } else { LOG_INFO << "--- reference pulser index is set manually ---" << endm; @@ -405,6 +421,7 @@ StETofCalibMaker::InitRun( Int_t runnumber ) LOG_INFO << " minimal number of digis required in slewing bin: " << mMinDigisPerSlewBin << endm; LOG_INFO << " reference pulser index: " << mReferencePulserIndex << endm; + // -------------------------------------------------------------------------------------------- // signal velocities @@ -603,7 +620,7 @@ StETofCalibMaker::InitRun( Int_t runnumber ) kv.second->SetDirectory( 0 ); } } - else { + else {//input from file LOG_INFO << "etof calibration histograms: filename provided --> use parameter file: " << mFileNameCalibHistograms.c_str() << endm; if( !isFileExisting( mFileNameCalibHistograms ) ) { @@ -617,6 +634,28 @@ StETofCalibMaker::InitRun( Int_t runnumber ) LOG_INFO << "setting all parameters to default" << endm; } + TFile* histOffsetFile = new TFile( mFileNameOffsetHistograms.c_str(), "READ" ); //create setter! + + if( !histOffsetFile || histOffsetFile->IsZombie() ) { + LOG_ERROR << "unable to open file: " << mFileNameOffsetHistograms.c_str() << endm; + LOG_INFO << "setting all parameters to default" << endm; + }else{ + LOG_INFO << "Successfully opened RunOffset file "<< mFileNameOffsetHistograms.c_str() << endm; + } + + + + TString hPosOffsetName = Form( "calib_Run%d_PosOffsets_pfx", runnumber ); + TString hT0OffsetName = Form( "calib_Run%d_T0Offsets_pfx", runnumber ); + TProfile* hPosOffsetProfile = nullptr; + TProfile* hT0OffsetProfile = nullptr; + + if( histOffsetFile && !(histOffsetFile->IsZombie()) ){ + LOG_INFO << "Getting run offset histograms Pos: "<< hPosOffsetName << " T0: "<< hT0OffsetName << endm; + hPosOffsetProfile = ( TProfile* ) histOffsetFile->Get( hPosOffsetName ); + hT0OffsetProfile = ( TProfile* ) histOffsetFile->Get( hT0OffsetName ); + } + for( unsigned int sector = eTofConst::sectorStart; sector <= eTofConst::sectorStop; sector++ ) { if( mRunYear == 2018 && sector != 18 ) continue; @@ -630,6 +669,8 @@ StETofCalibMaker::InitRun( Int_t runnumber ) TString hname; TProfile* hProfile; + + //------------------- // digi tot corr //------------------- @@ -644,14 +685,14 @@ StETofCalibMaker::InitRun( Int_t runnumber ) if( hProfile ) { for( size_t i=1; i<=2 * eTofConst::nStrips; i++ ) { if( hProfile->GetBinContent( i ) != 0 ) { - mDigiTotCorr.at( key )->SetBinContent( i , 2. / hProfile->GetBinContent( i ) ); + mDigiTotCorr.at( key )->SetBinContent( i , hProfile->GetBinContent( i ) ); } else { mDigiTotCorr.at( key )->SetBinContent( i , 1. ); } - if( mDigiTotCorr.at( key )->GetBinContent( i ) > 10. ) { + if( mDigiTotCorr.at( key )->GetBinContent( i ) < 0.05 || mDigiTotCorr.at( key )->GetBinContent( i ) > 10 ) { mDigiTotCorr.at( key )->SetBinContent( i , 1. ); } } @@ -681,10 +722,19 @@ StETofCalibMaker::InitRun( Int_t runnumber ) hname = Form( "calib_Sector%02d_ZPlane%d_Det%d_Pos_pfx", sector, zPlane, counter ); hProfile = ( TProfile* ) histFile->Get( hname ); + double dRunOffset = 0; + if (hPosOffsetProfile) { + int mCounterBin = hPosOffsetProfile->FindBin( 9*(sector -13) + 3 * (zPlane - 1) + counter ); + dRunOffset = hPosOffsetProfile->GetBinContent( mCounterBin ); + LOG_DEBUG << "setting run position offset to "<< dRunOffset<< " for counter "<< ( 9*(sector -13) + 3 * (zPlane - 1) + counter ) << endm; + }else{ + LOG_INFO << "position offset histogram "<AddBinContent( i , -1. * hProfile->GetBinContent( i ) / mSignalVelocity.at( key ) ); - mDigiTimeCorr.at( key )->AddBinContent( eTofConst::nStrips + i , hProfile->GetBinContent( i ) / mSignalVelocity.at( key ) ); + mDigiTimeCorr.at( key )->AddBinContent( i , -1. * ( hProfile->GetBinContent( i ) + dRunOffset ) / mSignalVelocity.at( key ) ); + mDigiTimeCorr.at( key )->AddBinContent( eTofConst::nStrips + i , ( hProfile->GetBinContent( i ) + dRunOffset ) / mSignalVelocity.at( key ) ); } } else{ @@ -697,17 +747,24 @@ StETofCalibMaker::InitRun( Int_t runnumber ) hname = Form( "calib_Sector%02d_ZPlane%d_Det%d_T0corr", sector, zPlane, counter ); hProfile = ( TProfile* ) histFile->Get( hname ); + dRunOffset = 0; + if (hT0OffsetProfile) { + int mCounterBin = hT0OffsetProfile->FindBin( 9*(sector -13) + 3 * (zPlane - 1) + counter ); + dRunOffset = hT0OffsetProfile->GetBinContent( mCounterBin ); + } + LOG_DEBUG << "setting run time offset to "<< dRunOffset<< " for counter "<< ( 9*(sector -13) + 3 * (zPlane - 1) + counter ) << endm; + if( hProfile && hProfile->GetNbinsX() == 1 ) { LOG_DEBUG << "T0 histogram with 1 bin: " << key << endm; for( size_t i=1; i<=2 * eTofConst::nStrips; i++ ) { - mDigiTimeCorr.at( key )->AddBinContent( i , hProfile->GetBinContent( 1 ) ); + mDigiTimeCorr.at( key )->AddBinContent( i , hProfile->GetBinContent( 1 ) + dRunOffset ); } } else if( hProfile && hProfile->GetNbinsX() == eTofConst::nStrips ) { LOG_DEBUG << "T0 histogram with 32 bins: " << key << endm; for( size_t i=1; i<= eTofConst::nStrips; i++ ) { - mDigiTimeCorr.at( key )->AddBinContent( i , hProfile->GetBinContent( i ) ); - mDigiTimeCorr.at( key )->AddBinContent( i + eTofConst::nStrips , hProfile->GetBinContent( i ) ); + mDigiTimeCorr.at( key )->AddBinContent( i , hProfile->GetBinContent( i ) + dRunOffset ); + mDigiTimeCorr.at( key )->AddBinContent( i + eTofConst::nStrips , hProfile->GetBinContent( i ) + dRunOffset ); } } else{ @@ -1092,6 +1149,21 @@ StETofCalibMaker::processStEvent() StETofHeader* etofHeader = etofCollection->etofHeader(); StSPtrVecETofDigi& etofDigis = etofCollection->etofDigis(); + /*if( mDoQA ){ + LOG_INFO << "filling missmatch histograms now" << endm; + TClass* headerClass = etofHeader->IsA(); + if( headerClass->GetClassVersion() > 1 ){ + LOG_INFO << "getting missmatch vector" << endm; + std::vector< Bool_t > vMissmatchVec = etofHeader->missMatchFlagVec(); //lookup error? + int iGet4Id = 0; + for( auto iMissMatchFlag : vMissmatchVec ){ + int iCounter = iGet4Id % 16; //probalby wrong! + mHistograms[ "ETOF_QA_daqMissmatches_get4" ]->Fill(iGet4Id, iMissMatchFlag); + mHistograms[ "ETOF_QA_daqMissmatches_counter" ]->Fill(iCounter, iMissMatchFlag); + } + } + }*/ + size_t nDigis = etofDigis.size(); if( mDebug ) { LOG_INFO << "processStEvent() - # fired eTOF digis : " << nDigis << endm; @@ -1104,15 +1176,18 @@ StETofCalibMaker::processStEvent() /// first loop over digis to apply hardware mappping and find the pulsers for( size_t i=0; iIsA(); + if( headerClass->GetClassVersion() > 2 ){ + mNStatusBitsCounter.clear(); + std::vector< Bool_t > vMissmatchVec = etofHeader->missMatchFlagVec(); + int iGet4Id = 0; + for( auto iMissMatchFlag : vMissmatchVec ){ + // From DigiMaker: + // mMissMatchFlagVec.at( 144 * ( sector - 13 ) + 48 * ( zplane -1 ) + 16 * ( counter - 1 ) + 8 * ( side - 1 ) + ( ( strip - 1 ) / 4 ) ) = true; + if (iMissMatchFlag == false) continue; + int iCounter = iGet4Id / 16; + if( mNStatusBitsCounter.count(iCounter) ){ + mNStatusBitsCounter[iCounter]++; + }else{ + mNStatusBitsCounter[iCounter] = 1; + } + } + + std::vector goodEventFlagVec; + for( int iCounter = 0; iCounter < 108; iCounter++){ + if ( !(mNPulsersCounter.count(iCounter) ) ){ + goodEventFlagVec.push_back(false); + }else{ + if ( !(mNStatusBitsCounter.count(iCounter)) && mNPulsersCounter[iCounter] == 2){ + goodEventFlagVec.push_back(true); //true when 2 pulser digis and zero status bits are available on this counter + }else{ + goodEventFlagVec.push_back(false); + } + } + } + if (goodEventFlagVec.size() == 108){ + etofHeader->setGoodEventFlagVec(goodEventFlagVec); + } + } /// second loop to apply calibrations to (non-pulser) digis inside the timing window - int previousGeomId = -1; - double previousTot = -1.; - double previousTime = -1.; - + StructStuckFwDigi current = { -1, -1., -1. }; + StructStuckFwDigi prev = { -1, -1., -1. }; int nDuplicates = 0; for( size_t i=0; isector() * 100000 + aDigi->zPlane() * 10000 + aDigi->counter() * 1000 + aDigi->strip() * 10 + aDigi->side(); + current.tot = aDigi->rawTot(); + current.time = aDigi->rawTime(); + // ignore digis that were sent in bulk from the same channel with exactly the same tot and time due to stuck firmware - int currentGeomId = aDigi->sector() * 100000 + aDigi->zPlane() * 10000 + aDigi->counter() * 1000 + aDigi->strip() * 10 + aDigi->side(); - double currentTot = aDigi->rawTot(); - double currentTime = aDigi->rawTime(); - - if( currentGeomId == previousGeomId && - fabs( currentTime - previousTime ) < 1.e-5 && - fabs( currentTot - previousTot ) < 1.e-5 ) - { + auto it = std::find( mStuckFwDigi.begin(), mStuckFwDigi.end(), current ); + if( it != mStuckFwDigi.end() ) { if( mDebug ) { - LOG_INFO << "digi from stuck firmware --> ignore" << endm; + LOG_INFO << "digi from stuck firmware (s" << aDigi->sector() << " m" << aDigi->zPlane() << " c" << aDigi->counter() << ") --> ignore" << endm; } + + nDuplicates++; + continue; + } + else if( current == prev ) { + mStuckFwDigi.push_back( current ); + resetToRaw( mMuDst->etofDigi( i-1 ) ); + nDuplicates++; continue; } else { - previousGeomId = currentGeomId; - previousTot = currentTot; - previousTime = currentTime; + prev = current; } @@ -1171,9 +1283,13 @@ StETofCalibMaker::processStEvent() applyCalibration( aDigi, etofHeader ); } - if( mDebug && nDuplicates > 0 ) { + if( mDoQA && nDuplicates > 0 ) { LOG_INFO << "*** # duplicate digis from stuck firmware: " << nDuplicates << endm; + for( const auto& v : mStuckFwDigi ) { + LOG_INFO << "stuck channel with geomId: " << v.geomId << " " << v.tot << " " << v.time << endm; + } } + mStuckFwDigi.clear(); } @@ -1200,19 +1316,36 @@ StETofCalibMaker::processMuDst() } StMuETofHeader* etofHeader = mMuDst->etofHeader(); + mNPulsersCounter.clear(); //--------------------------------- +/* if( mDoQA ){ + LOG_INFO << "filling missmatch histograms now" << endm; + TClass* headerClass = etofHeader->IsA(); + if( headerClass->GetClassVersion() > 1 ){ + LOG_INFO << "getting missmatch vector" << endm; + std::vector< Bool_t > vMissmatchVec = etofHeader->missMatchFlagVec(); //lookup error? + int iGet4Id = 0; + for( auto iMissMatchFlag : vMissmatchVec ){ + int iCounter = iGet4Id % 16; //probalby wrong! + mHistograms[ "ETOF_QA_daqMissmatches_get4" ]->Fill(iGet4Id, iMissMatchFlag); + mHistograms[ "ETOF_QA_daqMissmatches_counter" ]->Fill(iCounter, iMissMatchFlag); + } + } + }*/ + size_t nDigis = mMuDst->numberOfETofDigi(); - LOG_INFO << "processMuDst() - # fired eTOF digis : " << nDigis << endm; + //LOG_INFO << "processMuDst() - # fired eTOF digis : " << nDigis << endm; mTriggerTime = triggerTime( ( StETofHeader* ) etofHeader ); mResetTime = fmod( resetTime( ( StETofHeader* ) etofHeader ), eTofConst::bTofClockCycle ); - + //LOG_INFO << "created pulser digi map" << endm; std::map< unsigned int, std::vector< unsigned int >> pulserCandMap; /// first loop over digis to apply hardware mappping and find the pulsers for( size_t i=0; ietofDigi( i ); if( !aDigi ) { @@ -1220,29 +1353,65 @@ StETofCalibMaker::processMuDst() continue; } /// reset digi to carry only raw information (needed for afterburner mode) + //LOG_INFO << "resetting digi "<< i <<"/"<< nDigis << endm; resetToRaw( aDigi ); /// apply hardware mapping from rocId, chipId, channelId to - /// sector, zplane, counter, strip, side + /// sector, zplane, counter, strip, side + //LOG_INFO << "mapping digi: "<< i <<"/"<< nDigis << endm; applyMapping( aDigi ); /// flag pulser digis + //LOG_INFO << "pulser digi flagging: "<< i <<"/"<< nDigis << endm; if( mRunYear != 2018 ) { flagPulserDigis( aDigi, i, pulserCandMap ); } } - LOG_INFO << "size of pulserCandMap: " << pulserCandMap.size() << endm; + //LOG_INFO << "size of pulserCandMap: " << pulserCandMap.size() << endm; calculatePulserOffsets( pulserCandMap ); - + + // collect status bit information and fill good event flag for 2020+ data + TClass* headerClass = etofHeader->IsA(); + if( headerClass->GetClassVersion() > 2 ){ + mNStatusBitsCounter.clear(); + std::vector< Bool_t > vMissmatchVec = etofHeader->missMatchFlagVec(); + int iGet4Id = 0; + for( auto iMissMatchFlag : vMissmatchVec ){ + // From DigiMaker: + // mMissMatchFlagVec.at( 144 * ( sector - 13 ) + 48 * ( zplane -1 ) + 16 * ( counter - 1 ) + 8 * ( side - 1 ) + ( ( strip - 1 ) / 4 ) ) = true; + if (iMissMatchFlag == false) continue; + int iCounter = iGet4Id / 16; + if( mNStatusBitsCounter.count(iCounter) ){ + mNStatusBitsCounter[iCounter]++; + }else{ + mNStatusBitsCounter[iCounter] = 1; + } + } + + std::vector goodEventFlagVec; + for( int iCounter = 0; iCounter < 108; iCounter++){ + if ( !(mNPulsersCounter.count(iCounter) ) ){ + goodEventFlagVec.push_back(false); + }else{ + if ( !(mNStatusBitsCounter.count(iCounter)) && mNPulsersCounter[iCounter] == 2){ + goodEventFlagVec.push_back(true); //true when 2 pulser digis and zero status bits are available on this counter + }else{ + goodEventFlagVec.push_back(false); + } + } + } + if (goodEventFlagVec.size() == 108){ + etofHeader->setGoodEventFlagVec(goodEventFlagVec); + } + } /// second loop to apply calibrations to (non-pulser) digis inside the timing window - int previousGeomId = -1; - double previousTot = -1.; - double previousTime = -1.; - + StructStuckFwDigi current = { -1, -1., -1. }; + StructStuckFwDigi prev = { -1, -1., -1. }; int nDuplicates = 0; + for( size_t i=0; ietofDigi( i ); @@ -1251,25 +1420,29 @@ StETofCalibMaker::processMuDst() continue; } + current.geomId = aDigi->sector() * 100000 + aDigi->zPlane() * 10000 + aDigi->counter() * 1000 + aDigi->strip() * 10 + aDigi->side(); + current.tot = aDigi->rawTot(); + current.time = aDigi->rawTime(); + // ignore digis that were sent in bulk from the same channel with exactly the same tot and time due to stuck firmware - int currentGeomId = aDigi->sector() * 100000 + aDigi->zPlane() * 10000 + aDigi->counter() * 1000 + aDigi->strip() * 10 + aDigi->side(); - double currentTot = aDigi->rawTot(); - double currentTime = aDigi->rawTime(); - - if( currentGeomId == previousGeomId && - fabs( currentTime - previousTime ) < 1.e-5 && - fabs( currentTot - previousTot ) < 1.e-5 ) - { + auto it = std::find( mStuckFwDigi.begin(), mStuckFwDigi.end(), current ); + if( it != mStuckFwDigi.end() ) { if( mDebug ) { - LOG_INFO << "digi from stuck firmware --> ignore" << endm; + LOG_INFO << "digi from stuck firmware (s" << aDigi->sector() << " m" << aDigi->zPlane() << " c" << aDigi->counter() << ") --> ignore" << endm; } + + nDuplicates++; + continue; + } + else if( current == prev ) { + mStuckFwDigi.push_back( current ); + resetToRaw( mMuDst->etofDigi( i-1 ) ); + nDuplicates++; continue; } else { - previousGeomId = currentGeomId; - previousTot = currentTot; - previousTime = currentTime; + prev = current; } @@ -1278,9 +1451,13 @@ StETofCalibMaker::processMuDst() applyCalibration( aDigi, etofHeader ); } - if( mDebug && nDuplicates > 0 ) { + if( mDoQA && nDuplicates > 0 ) { LOG_INFO << "*** # duplicate digis from stuck firmware: " << nDuplicates << endm; + for( const auto& v : mStuckFwDigi ) { + LOG_INFO << "stuck channel with geomId: " << v.geomId << " " << v.tot << " " << v.time << endm; + } } + mStuckFwDigi.clear(); } //_____________________________________________________________ @@ -1301,6 +1478,8 @@ StETofCalibMaker::isFileExisting( const std::string fileName ) void StETofCalibMaker::resetToRaw( StETofDigi* aDigi ) { + if( !aDigi ) return; + aDigi->setGeoAddress( 0, 0, 0, 0, 0 ); aDigi->setCalibTime( 0. ); aDigi->setCalibTot( -1. ); @@ -1369,9 +1548,10 @@ StETofCalibMaker::flagPulserDigis( StETofDigi* aDigi, unsigned int index, std::m if( ( aDigi->strip() == 1 && aDigi->side() == 1 ) || ( aDigi->strip() == 32 && aDigi->side() == 2 ) ) { float timeToTrigger = aDigi->rawTime() - mTriggerTime; float totToPeak = aDigi->rawTot() - mPulserPeakTot.at( key ); + float totToHalfPeak = aDigi->rawTot() - mPulserPeakTot.at( key ) * 0.5; if( timeToTrigger > mPulserWindow.at( aDigi->rocId() ).first && timeToTrigger < mPulserWindow.at( aDigi->rocId() ).second ) { - if( fabs( totToPeak ) < 25 ) { + if( fabs( totToPeak ) < 25 || fabs( totToHalfPeak ) < 10 ) { isPulserCand = true; } } @@ -1411,6 +1591,8 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u std::map< int, double > pulserTimes; + mNPulsersCounter.clear(); + mPulserPresent.clear(); //clear map of present pulsers in each event // loop over all candidates to find real pulser, save time in pulserTimes map for( auto it=pulserDigiMap.begin(); it!=pulserDigiMap.end(); it++ ) { @@ -1442,7 +1624,7 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u } // find "best fitting digi", remove other digis (likely misidentified noise) - double currentDiff = fabs( timeToTrigger - mPulserPeakTime ) * 0.1 + fabs( totToPeak ); + double currentDiff = fabs( timeToTrigger - mPulserPeakTime ) * 0.1 + fabs( totToPeak ); // might need better criterion? Normalisation to widths? PW if( currentDiff < bestDiff ) { bestDiff = currentDiff; candIndex = j; @@ -1468,18 +1650,28 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u } pulserTimes[ sideIndex ] = pulserTime; - } - + + int sector = sideIndex / 1000; + int plane = ( sideIndex % 1000) / 100; + int counter = ( sideIndex % 100) / 10; + int key = 9 * ( sector - 13 ) + 3 * ( plane - 1 ) + ( counter - 1 ); + if( mNPulsersCounter.count( key ) ){ + mNPulsersCounter[key]++; + }else{ + mNPulsersCounter[key] = 1; + } + mPulserPresent[ sideIndex ] = true; + } double referenceTime = 0.; // update reference time (for QA) if( mDoQA ) { if( pulserTimes.count( mReferencePulserIndex ) ) { - referenceTime = pulserTimes.at( mReferencePulserIndex ); + referenceTime = pulserTimes.at( mReferencePulserIndex ); //only updated for QA?? needed to remove smeared pulsers if( mDebug ) { - LOG_INFO << "time of reference pulser updated" << endm; + LOG_INFO << "preliminary reference time:" << referenceTime << endm; } } } @@ -1503,7 +1695,7 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u int key = partialKey + 10 * counter; if( pulserTimes.count( key ) ) { - if( mDoQA ) { + if( mDoQA ) {// fill if all relevant pulsers are available. if( pulserTimes.count( partialKey + 10 ) ) { mHistograms.at( "pulserDigiTimeToCounter1" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, pulserTimes.at( partialKey + 10 ) - pulserTimes.at( key ) ); } @@ -1515,26 +1707,54 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u } } - times.at( counter - 1 ) = pulserTimes.at( key ) + mPulserTimeDiffGbtx.at( key ); + times.at( counter - 1 ) = pulserTimes.at( key ) + mPulserTimeDiffGbtx.at( key ); //substract pulser time difference from database table + + bool isNonSmearedPulser = false; + if( referenceTime != 0 ) { + double dist = times.at( counter - 1 ) - referenceTime; //distance to reference pulser + double redDist = mHistograms.at( "pulserDigiTimeDiff_GbtxCorrProfMod" )->GetBinContent( gbtxId * eTofConst::nCounters + counter ); // average distance to next clock edge for this pulser + + double modDist = fmod( dist - redDist, eTofConst::coarseClockCycle ); //Distance to "normal" offset. full clock cycle distances are thrown out? Why? + modDist = modDist - eTofConst::coarseClockCycle * round( modDist / eTofConst::coarseClockCycle ); //substract a clock cycle if modDist > 0.5 coarseClockCycle + //=> -0.5*coarseClockCycle < modDist < 0.5*coarseClockCycle => Distance to closest clock cycle + + if( redDist == 0 || fabs( modDist ) > 0.5 ) { //> 0.5ns + n*ClockCycle away from reference pulser. Hard cut? If the first pulser is off, all following will be neglected! + if( redDist != 0 ) LOG_INFO << "too far away --> smeared pulser: " << key << "(" << gbtxId << "-" << counter << ")" << endm; + redDist = dist; //empty in the beginning, Example distance to reference pulser + } + else { + redDist += modDist; //adds always up? + isNonSmearedPulser = true; + } + + mHistograms.at( "pulserDigiTimeDiff_GbtxCorrProf" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, dist ); + mHistograms.at( "pulserDigiTimeDiff_GbtxCorrProfMod" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, redDist ); // TProfile! => Average! - average += times.at( counter - 1 ); - nAv++; + if( mDoQA ) { + mHistograms.at( "pulserDigiTimeDiff_GbtxCorr" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, dist ); //Pulser offset on GBTX from database substracted + mHistograms.at( "pulserDigiTimeDiff" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, pulserTimes.at( key ) - referenceTime ); //Pulser offset on GBTX not substracted + } + } - if( mDoQA && referenceTime != 0 ) { - mHistograms.at( "pulserDigiTimeDiff" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, pulserTimes.at( key ) - referenceTime ); - mHistograms.at( "pulserDigiTimeDiff_GbtxCorr" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, times.at( counter - 1 ) - referenceTime ); + // only use non-smeared pulsers for the + if( isNonSmearedPulser ) { + average += times.at( counter - 1 ); + nAv++; + } + else { + times.at( counter - 1 ) = 0.; } + } } - - if( nAv == eTofConst::nCounters ) { + if( nAv == eTofConst::nCounters ) { //all pulser present, check for single pulser jumps by comparing to average of the other two. double diff12 = fabs( times.at( 0 ) - times.at( 1 ) ); double diff13 = fabs( times.at( 0 ) - times.at( 2 ) ); double diff23 = fabs( times.at( 1 ) - times.at( 2 ) ); - if( diff12 > 1 && diff13 > 1 && diff23 < 1 ) { + if( diff12 > 0.2 && diff13 > 0.2 && diff23 < 0.2 ) { average -= times.at( 0 ); nAv--; @@ -1557,7 +1777,7 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u mHistograms.at( "1_off" )->Fill( gbtxId * eTofConst::nCounters + 1.5, times.at( 0 ) - ( average / nAv ) ); } } - else if( diff12 > 1 && diff13 < 1 && diff23 > 1 ) { + else if( diff12 > 0.2 && diff13 < 0.2 && diff23 > 0.2 ) { average -= times.at( 1 ); nAv--; @@ -1580,7 +1800,7 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u mHistograms.at( "2_off" )->Fill( gbtxId * eTofConst::nCounters + 1.5, times.at( 1 ) - ( average / nAv ) ); } } - else if( diff12 < 1 && diff13 > 1 && diff23 > 1 ) { + else if( diff12 < 0.2 && diff13 > 0.2 && diff23 > 0.2 ) { average -= times.at( 2 ); nAv--; @@ -1604,55 +1824,173 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u } } } - else if( nAv == eTofConst::nCounters - 1 ) { - if( times.at( 0 ) > 0 && fabs( fabs( times.at( 0 ) - ( average / nAv ) ) - eTofConst::coarseClockCycle * 0.5 ) < 0.2 ) { + + if( nAv == eTofConst::nCounters - 1 ) { + // if there are two pulsers, restore missing pulser from average of the other two + if( times.at( 0 ) > 0 && times.at( 1 ) > 0 && fabs( fabs( times.at( 0 ) - times.at( 1 ) ) - eTofConst::coarseClockCycle ) < 0.2 ) { if( mJumpingPulsers.count( partialKey + 10 ) ) { + //LOG_INFO << gbtxId << " ### case 1 (1) ### " << endm; times.at( 0 ) += mJumpingPulsers.at( partialKey + 10 ) * eTofConst::coarseClockCycle; average += mJumpingPulsers.at( partialKey + 10 ) * eTofConst::coarseClockCycle; + } + else if( mJumpingPulsers.count( partialKey + 20 ) ) { + //LOG_INFO << gbtxId << " ### case 1 (2) ### " << endm; + times.at( 1 ) += mJumpingPulsers.at( partialKey + 20 ) * eTofConst::coarseClockCycle; + average += mJumpingPulsers.at( partialKey + 20 ) * eTofConst::coarseClockCycle; + } + else { + //LOG_INFO << gbtxId << " ### case 1 (3) ### " << endm; + if( times.at( 0 ) < times.at( 1 ) ) { + times.at( 0 ) += eTofConst::coarseClockCycle; + average += eTofConst::coarseClockCycle; + } + else { + times.at( 1 ) += eTofConst::coarseClockCycle; + average += eTofConst::coarseClockCycle; + } } } - if( times.at( 1 ) > 0 && fabs( fabs( times.at( 1 ) - ( average / nAv ) ) - eTofConst::coarseClockCycle * 0.5 ) < 0.2 ) { + else if( times.at( 0 ) && times.at( 2 ) > 0 && fabs( fabs( times.at( 0 ) - times.at( 2 ) ) - eTofConst::coarseClockCycle ) < 0.2 ) { + if( mJumpingPulsers.count( partialKey + 10 ) ) { + //LOG_INFO << gbtxId << " ### case 2 (1) ### " << endm; + times.at( 0 ) += mJumpingPulsers.at( partialKey + 10 ) * eTofConst::coarseClockCycle; + average += mJumpingPulsers.at( partialKey + 10 ) * eTofConst::coarseClockCycle; + } + else if( mJumpingPulsers.count( partialKey + 30 ) ) { + //LOG_INFO << gbtxId << " ### case 2 (2) ### " << endm; + times.at( 2 ) += mJumpingPulsers.at( partialKey + 30 ) * eTofConst::coarseClockCycle; + average += mJumpingPulsers.at( partialKey + 30 ) * eTofConst::coarseClockCycle; + } + else { + //LOG_INFO << gbtxId << " ### case 2 (3) ### " << endm; + if( times.at( 0 ) < times.at( 2 ) ) { + times.at( 0 ) += eTofConst::coarseClockCycle; + average += eTofConst::coarseClockCycle; + } + else { + times.at( 2 ) += eTofConst::coarseClockCycle; + average += eTofConst::coarseClockCycle; + } + } + } + else if( times.at( 1 ) > 0 && times.at( 2 ) > 0 && fabs( fabs( times.at( 1 ) - times.at( 2 ) ) - eTofConst::coarseClockCycle ) < 0.2 ) { if( mJumpingPulsers.count( partialKey + 20 ) ) { + //LOG_INFO << gbtxId << " ### case 3 (1) ### " << endm; times.at( 1 ) += mJumpingPulsers.at( partialKey + 20 ) * eTofConst::coarseClockCycle; average += mJumpingPulsers.at( partialKey + 20 ) * eTofConst::coarseClockCycle; - } - } - if( times.at( 2 ) > 0 && fabs( fabs( times.at( 2 ) - ( average / nAv ) ) - eTofConst::coarseClockCycle * 0.5 ) < 0.2 ) { - if( mJumpingPulsers.count( partialKey + 30 ) ) { + } + else if( mJumpingPulsers.count( partialKey + 30 ) ) { + //LOG_INFO << gbtxId << " ### case 3 (2) ### " << endm; times.at( 2 ) += mJumpingPulsers.at( partialKey + 30 ) * eTofConst::coarseClockCycle; average += mJumpingPulsers.at( partialKey + 30 ) * eTofConst::coarseClockCycle; } + else { + //LOG_INFO << gbtxId << " ### case 3 (3) ### " << endm; + if( times.at( 1 ) < times.at( 2 ) ) { + times.at( 1 ) += eTofConst::coarseClockCycle; + average += eTofConst::coarseClockCycle; + } + else { + times.at( 2 ) += eTofConst::coarseClockCycle; + average += eTofConst::coarseClockCycle; + } + } } } - if( nAv > 0 ) average /= nAv; + + if( nAv >= 2 ) { + average /= nAv; + } if( mDoQA && referenceTime != 0 ) { mHistograms.at( "pulserDigiTimeDiff_perGbtx" )->Fill( gbtxId * eTofConst::nCounters + 1.5, average - referenceTime ); } - for( int counter=1; counter<=3; counter++ ) { - if( mDoQA && times.at( counter - 1 ) != 0. ) { - mHistograms.at( "pulserDigiTimeDiff_toAverage" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, times.at( counter - 1 ) - average ); + for( int counter = eTofConst::counterStart; counter <= eTofConst::counterStop; counter++ ) { + double diffToAv = 0.; + + if( times.at( counter - eTofConst::counterStart ) != 0. ) { + diffToAv = times.at( counter - eTofConst::counterStart ) - average; + + if( fabs( diffToAv ) > 0.2 ) diffToAv = 0.; //removing didn't work + + if( mDoQA ) { + mHistograms.at( "pulserDigiTimeDiff_toAverage" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, diffToAv ); + } } - pulserTimes[ partialKey + 10 * counter ] = average - mPulserTimeDiffGbtx.at( partialKey + 10 * counter ); + if( average != 0. ) {//only allow counter pulsers that are now close to average + //times.at( counter - 1 ) = pulserTimes.at( key ) + mPulserTimeDiffGbtx.at( key ) + pulserTimes[ partialKey + 10 * counter ] = average + diffToAv - mPulserTimeDiffGbtx.at( partialKey + 10 * counter ); //restores original pulser times INCLUDING GBTX offset ?!?! + //pulserTimes[ partialKey + 10 * counter ] = average; + } + else { + if( pulserTimes.count( partialKey + 10 * counter ) ) { + pulserTimes.erase( partialKey + 10 * counter ); + } + } } } } // calculate difference to the reference + referenceTime = 0.; if( pulserTimes.count( mReferencePulserIndex ) ) { - referenceTime = pulserTimes.at( mReferencePulserIndex ); - if( mDebug ) { - LOG_INFO << "time of reference pulser updated" << endm; - } + if( mPulserTimeDiff.count( mReferencePulserIndex ) ){ + referenceTime = pulserTimes.at( mReferencePulserIndex ) - mPulserTimeDiff[ mReferencePulserIndex ]; + //LOG_INFO << "time of reference pulser updated: " << referenceTime << " with reference correction "<< mPulserTimeDiff[ mReferencePulserIndex ] << endm; + }else{ + referenceTime = pulserTimes.at( mReferencePulserIndex ); + //LOG_INFO << "time of reference pulser updated: " << referenceTime << endm; + } } + + if( referenceTime != 0 ) { + int iLockThreshold = 0; + mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->Reset("ICESM"); + for( auto& kv : pulserTimes ) { - mPulserTimeDiff[ kv.first ] = kv.second - referenceTime; + // check if new pulser time difference seems reasonable ( only allow jumps in multiple of the coarse clock tick ) to avoid smeared pulsers + if( mPulserTimeDiff.count( kv.first ) ) {//pulser time difference default available previous events + //double modDist = fmod( mPulserTimeDiff.at( kv.first ) - ( kv.second - referenceTime ), eTofConst::coarseClockCycle ); + //modDist = modDist - eTofConst::coarseClockCycle * round( modDist / eTofConst::coarseClockCycle ); + + double modDist = mPulserTimeDiff.at( kv.first ) - ( kv.second - referenceTime ); //test PW + //modDist = modDist - eTofConst::coarseClockCycle * round( modDist / eTofConst::coarseClockCycle ); + + + if( fabs( modDist ) > 0.2 ) { + mUnlockPulserState[ kv.first ]++; + + // LOG_INFO << " pulser time " << kv.first << " seems unreasonable (" << kv.second - referenceTime << ")"; + // LOG_INFO << " compared to previous stored value (" << mPulserTimeDiff.at( kv.first ) << ")" << endm; + + // only unlock pulser state if 10 consecutive events have a modDist larger then the threshold + if( mUnlockPulserState.at( kv.first ) < iLockThreshold ) { + // LOG_INFO << " --> ignore for now and move on" << endm; + continue; //move on, don't update pulser times! + } + else{ + // LOG_INFO << " --> pulser state has been unlocked" << endm; + } + + //fill 2d Hist here with GBTX and counter number + mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->Fill( kv.second - referenceTime ); + + } + else{ + if( mUnlockPulserState.count( kv.first ) ) { + LOG_INFO << " --> new event doesn't have offset for pulser " << kv.first << " --> remove the entry" << endm; + mUnlockPulserState.erase( kv.first ); + } + } + } + //pulser time differece was set here! + if( mDoQA ) { int sector = kv.first / 1000; @@ -1664,9 +2002,52 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u + ( zPlane - eTofConst::zPlaneStart ) * eTofConst::nSides + ( side - eTofConst::sideStart ); - mHistograms.at( "pulserDigiTimeDiff_fullCorr" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, mPulserTimeDiff.at( kv.first ) ); + if( mPulserTimeDiff.count( kv.first ) ) { + mHistograms.at( "pulserDigiTimeDiff_fullCorr" )->Fill( gbtxId * eTofConst::nCounters + counter - 0.5, mPulserTimeDiff.at( kv.first ) ); + } + + mHistograms[ "pulserDigiPresence" ]->Fill(gbtxId * eTofConst::nCounters + counter - 0.5); } } + + //LOG_INFO << "Check " << referenceTime << endm; + if( mDoQA ) { + mHistograms[ "pulserDigiPresence" ]->Fill( -1 ); //use as event counter + mHistograms[ "pulserDigiTimeDiff_CorrAgreement" ]->Fill( mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->GetMaximum() ); + mHistograms[ "pulserDigiTimeDiff_CorrCommonJump" ]->Fill( mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->GetEntries() ); + } + if( ( mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->GetEntries() > 150 ) && ( mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->GetMaximum() > 15 ) ){ + + //LOG_INFO << "Check: found " << mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->GetMaximum() <<" agreeing time shifts. Shifting reference times " << endm; + int iMaximumBin = mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->GetMaximumBin(); + double dRefCorrAverage = 0; + int iNRefCorrAgree = 0; + + for( auto& kv : pulserTimes ) { //build average of all agreeing pulsers + if ( mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->FindBin(kv.second - referenceTime) == iMaximumBin ){ + dRefCorrAverage += kv.second - referenceTime; + iNRefCorrAgree++; + } + } + dRefCorrAverage /= iNRefCorrAgree; + referenceTime -= dRefCorrAverage; + //pulserTimes.at( mReferencePulserIndex ) -= dRefCorrAverage; + mPulserTimeDiff[ mReferencePulserIndex ] -= dRefCorrAverage; + + }else{ + //LOG_INFO << "Check: found only " << mHistograms[ "pulserDigiTimeDiff_RefCorr" ]->GetMaximum() <<" agreeing time shifts. Shifting pulser times " << endm; + for( auto& kv : pulserTimes ) { + if ( ! mPulserTimeDiff[ kv.first ] ) { + mPulserTimeDiff[ kv.first ] = kv.second - referenceTime; + continue; + } + if( mUnlockPulserState.count( kv.first ) ){ + if( mUnlockPulserState.at( kv.first ) > iLockThreshold ){// check if pulser is locked + mPulserTimeDiff[ kv.first ] = kv.second - referenceTime; + } + } + } + } } } @@ -1700,6 +2081,17 @@ StETofCalibMaker::applyCalibration( StETofDigi* aDigi, StETofHeader* etofHeader if( timeToTrigger > mTimingWindow.at( aDigi->rocId() ).first && timeToTrigger < mTimingWindow.at( aDigi->rocId() ).second ) { + + if( mStrictPulserHandling ){ + int PulserKey = aDigi->sector() * 1000 + aDigi->zPlane() * 100 + aDigi->side() + 10 * aDigi->counter(); + if( !mPulserPresent.count( PulserKey ) ) { + if( mDebug ) { + LOG_DEBUG << "no pulser in the same event for this counter --> digi skipped due to strict pulser handling" << endm; + } + return; + } + } + double calibTot = aDigi->rawTot() * mGet4TotBinWidthNs * calibTotFactor( aDigi ); aDigi->setCalibTot( calibTot ); @@ -1732,6 +2124,8 @@ StETofCalibMaker::applyCalibration( StETofDigi* aDigi, StETofHeader* etofHeader void StETofCalibMaker::resetToRaw( StMuETofDigi* aDigi ) { + if( !aDigi ) return; + aDigi->setGeoAddress( 0, 0, 0, 0, 0 ); aDigi->setCalibTime( 0. ); aDigi->setCalibTot( -1. ); @@ -1782,7 +2176,7 @@ StETofCalibMaker::calibTotFactor( StETofDigi* aDigi ) if( mDebug ) { LOG_DEBUG << "calibTotFactor: histogram with key " << key << " at bin " << bin << " -> return bin content: " << binContent << endm; } - return binContent; + return (1.0/binContent); //invert here to get to fixed mean value! } else { if( mDebug ) { @@ -1837,7 +2231,8 @@ StETofCalibMaker::slewingTimeOffset( StETofDigi* aDigi ) if( mDigiSlewCorr.count( key ) ) { - unsigned int totBin = mDigiSlewCorr.at( key )->FindBin( aDigi->calibTot() ); + unsigned int totBin = mDigiSlewCorr.at( key )->FindBin( aDigi->rawTot() ); //adjusted. PW +mDebug = true; if( mDigiSlewCorr.at( key )->GetBinEntries( totBin ) <= mMinDigisPerSlewBin && totBin < etofSlewing::nTotBins ) { if( mDebug ) { LOG_DEBUG << "slewingTimeOffset: insufficient statistics for slewing calibration in channel " << key << " at tot bin " << totBin << " --> return 0" << endm; @@ -1845,7 +2240,7 @@ StETofCalibMaker::slewingTimeOffset( StETofDigi* aDigi ) return 0.; } - float val = mDigiSlewCorr.at( key )->Interpolate( aDigi->calibTot() ); + float val = mDigiSlewCorr.at( key )->Interpolate( aDigi->rawTot() ); //adjusted. PW if( mDebug ) { LOG_DEBUG << "slewingTimeOffset: histogram with key " << key << " with calib TOT of " << aDigi->calibTot() << " --> interpolated correction: " << val << endm; } @@ -1891,7 +2286,7 @@ StETofCalibMaker::triggerTime( StETofHeader* header ) std::map< uint64_t, short > countsGdpbTs; for( const auto& kv : header->rocGdpbTs() ) { if( mDebug ) { - LOG_DEBUG << "triggerTime (" << std::hex << "Ox" << kv.first << std::dec << ") " << kv.second * eTofConst::coarseClockCycle * 1.e-9 << endm; + LOG_DEBUG << "triggerTime (" << std::hex << "Ox" << kv.first << std::dec << ") " << kv.second * eTofConst::coarseClockCycle * 1.e-9 << endm; } ++countsGdpbTs[ kv.second ]; } @@ -1925,7 +2320,7 @@ StETofCalibMaker::triggerTime( StETofHeader* header ) } } - if( mostProbableTriggerTs > 0) { + if( mostProbableTriggerTs > 0 ) { triggerTime = mostProbableTriggerTs * eTofConst::coarseClockCycle; } @@ -1945,16 +2340,62 @@ double StETofCalibMaker::resetTime( StETofHeader* header ) { // count the occurance of a given reset time stamp in the StarTs map of the eTOF header - std::map< uint64_t, short > countsStarTs; + std::map< uint64_t, short > countsStarTsRaw; for( const auto& kv : header->rocStarTs() ) { if( mDebug ) { - LOG_DEBUG << "resetTime (" << std::hex << "Ox" << kv.first << std::dec << ") " << kv.second * eTofConst::coarseClockCycle * 1.e-9 << endm; + LOG_DEBUG << "resetTime (" << std::hex << "Ox" << kv.first << std::dec << ") " << kv.second * eTofConst::coarseClockCycle * 1.e-9 << endm; } - + // in Run18 only one of the AFCKs was giving the correct reset time: 0x18e6 if( mRunYear == 2018 && kv.first != 0x18e6 ) continue; - ++countsStarTs[ kv.second ]; + if( kv.second != 0 ) { + ++countsStarTsRaw[ kv.second ]; + } + } + + + // combine adjacent reset time values with the earlier one + std::map< uint64_t, short > countsStarTs; + for( auto it = countsStarTsRaw.begin(); it != countsStarTsRaw.end(); it++ ) { + auto next = std::next( it, 1 ); + + short countTs = it->second; + + if( next != countsStarTsRaw.end() && ( next->first - it->first ) == 1 ) { + countTs += next->second; + } + + countsStarTs[ it->first ] = countTs; + } + + + + + if( mDoQA ) { + if( countsStarTs.size() == 0 ) { + LOG_INFO << "all AFCKs report a reset time value 0" << endm; + } + + for( const auto& kv : countsStarTs ) { + LOG_DEBUG << "resetTime cand:" << kv.first << " (" << kv.second << " times)" << endm; + mHistograms.at( "resetTimeCand_times" )->Fill( kv.second ); + } + + for( const auto& kv : header->rocStarTs() ) { + unsigned int sector; + mHwMap->mapToSector( kv.first, sector ); + + LOG_DEBUG << "resetTime(" << sector << "): " << kv.second << endm; + + std::string histName = "resetTimeDifferenceToSector" + to_string( sector ); + for( const auto& jv : header->rocStarTs() ) { + unsigned int sec; + mHwMap->mapToSector( jv.first, sec ); + + mHistograms.at( histName )->Fill( sec, ( int64_t ) jv.second - ( int64_t ) kv.second ); + } + } } @@ -1966,11 +2407,33 @@ StETofCalibMaker::resetTime( StETofHeader* header ) double resetTime = it->first * eTofConst::coarseClockCycle; + // only update reset time if it is at least two clock ticks away from the old reset time to avoid jitter + if( abs( mResetTs - ( int64_t ) it->first ) < 2 ) { + resetTime = mResetTs * eTofConst::coarseClockCycle; + } + else { + LOG_INFO << "change in reset TS: " << mResetTs << " --> " << it->first << endm; + mResetTs = it->first; + } + + // Run19: trigger - reset time should be on the order of a few second up to 120 minutes (7.2*10^12 ns), i.e. max. run length // Run20: difference can be negative due to eTOF DAQ restarts at the beginning of runs while eTOF is put to "BUSY" in run control if( mTriggerTime - resetTime < 7.2e12 ) { if( mDebug ) { - LOG_INFO << "reset time (ns): " << resetTime << " --> difference to trigger time in seconds: " << ( mTriggerTime - resetTime ) * 1.e-9 << endm; + LOG_DEBUG << "reset time (ns): " << resetTime << " --> difference to trigger time in seconds: " << ( mTriggerTime - resetTime ) * 1.e-9 << endm; + } + LOG_DEBUG << "--> picked reset TS:" << mResetTs << endm; + + if( mDoQA ) { + mHistograms.at( "resetTimeCand_picked" )->Fill( it->second ); + + auto rawIt = std::max_element( countsStarTsRaw.begin(), countsStarTsRaw.end(), + []( const pair< uint64_t, short >& p1, const pair< uint64_t, short >& p2 ) { + return p1.second < p2.second; } ); + + mHistograms.at( "resetTimeCand_compare" )->Fill( ( int64_t ) mResetTs - ( int64_t ) rawIt->first ); + mHistograms.at( "resetTimeCand_value" )->Fill( mResetTs % ( int ) eTofConst::bTofClockCycle ); } return resetTime; @@ -2056,27 +2519,45 @@ StETofCalibMaker::setHistFileName() void StETofCalibMaker::bookHistograms() { - if( !mDoQA ) { - return; - } - LOG_INFO << "bookHistograms() ... " << endm; - mHistograms[ "pulserDigiTimeDiff" ] = new TH2F( "pulserDigiTimeDiff", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - mHistograms[ "pulserDigiTimeToCounter1" ] = new TH2F( "pulserDigiTimeToCounter1", "time difference of pulsers to counter 1;pulser channel;#Delta T (ns)", 216, 0, 216, 2*360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - mHistograms[ "pulserDigiTimeToCounter2" ] = new TH2F( "pulserDigiTimeToCounter2", "time difference of pulsers to counter 2;pulser channel;#Delta T (ns)", 216, 0, 216, 2*360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - mHistograms[ "pulserDigiTimeToCounter3" ] = new TH2F( "pulserDigiTimeToCounter3", "time difference of pulsers to counter 3;pulser channel;#Delta T (ns)", 216, 0, 216, 2*360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - - mHistograms[ "pulserDigiTimeDiff_GbtxCorr" ] = new TH2F( "pulserDigiTimeDiff_GbtxCorr", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - mHistograms[ "pulserDigiTimeDiff_perGbtx" ] = new TH2F( "pulserDigiTimeDiff_perGbtx", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - mHistograms[ "pulserDigiTimeDiff_toAverage" ] = new TH2F( "pulserDigiTimeDiff_toAverage", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 4*360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - - mHistograms[ "1_off" ] = new TH2F( "1_off", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - mHistograms[ "2_off" ] = new TH2F( "2_off", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - mHistograms[ "3_off" ] = new TH2F( "3_off", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); - + mHistograms[ "pulserDigiTimeDiff_GbtxCorrProf" ] = new TProfile( "pulserDigiTimeDiff_GbtxCorrProf", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, "s" ); + mHistograms[ "pulserDigiTimeDiff_GbtxCorrProfMod" ] = new TProfile( "pulserDigiTimeDiff_GbtxCorrProfMod", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, "s" ); mHistograms[ "pulserDigiTimeDiff_fullCorr" ] = new TH2F( "pulserDigiTimeDiff_fullCorr", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + if( mDoQA ) { + mHistograms[ "pulserDigiTimeDiff" ] = new TH2F( "pulserDigiTimeDiff", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "pulserDigiTimeToCounter1" ] = new TH2F( "pulserDigiTimeToCounter1", "time difference of pulsers to counter 1;pulser channel;#Delta T (ns)", 216, 0, 216, 2*360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "pulserDigiTimeToCounter2" ] = new TH2F( "pulserDigiTimeToCounter2", "time difference of pulsers to counter 2;pulser channel;#Delta T (ns)", 216, 0, 216, 2*360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "pulserDigiTimeToCounter3" ] = new TH2F( "pulserDigiTimeToCounter3", "time difference of pulsers to counter 3;pulser channel;#Delta T (ns)", 216, 0, 216, 2*360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + + mHistograms[ "pulserDigiTimeDiff_GbtxCorr" ] = new TH2F( "pulserDigiTimeDiff_GbtxCorr", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "pulserDigiTimeDiff_perGbtx" ] = new TH2F( "pulserDigiTimeDiff_perGbtx", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "pulserDigiTimeDiff_toAverage" ] = new TH2F( "pulserDigiTimeDiff_toAverage", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 4*360, -359.5 * ( 6.25 / 112 ), 360.5 * ( 6.25 / 112 ) ); + + mHistograms[ "1_off" ] = new TH2F( "1_off", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "2_off" ] = new TH2F( "2_off", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "3_off" ] = new TH2F( "3_off", "average time difference of pulsers in one Gbtx to reference;pulser channel;#Delta T (ns)", 216/3, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + + mHistograms[ "pulserDigiTimeDiff_CorrAgreement" ] = new TH1F("pulserDigiTimeDiff_CorrAgreement", "Number of pulsers agreeing on a common shift between events; #pulsers", 218, -0.5, 217.5); + mHistograms[ "pulserDigiTimeDiff_CorrCommonJump" ] = new TH1F("pulserDigiTimeDiff_CorrCommonJump", "Number of pulsers jumping at the same time between events; #pulsers", 218, -0.5, 217.5); + + mHistograms[ "pulserDigiPresence" ] = new TH1F( "pulserDigiPresence", "pulser presence (number of events at ( -1 );pulser channel", 218, -1.5, 216.5); + + mHistograms[ "pulserDigiTimeDiff_RefCorr" ] = new TH1F("pulserDigiTimeDiff_RefCorr", "time difference of pulsers to reference; #Delta T (ns)", 45, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 )); + + for( int i=0; i<12; i++ ) { + std::string histName = "resetTimeDifferenceToSector" + to_string( i + 13 ); + mHistograms[ histName ] = new TH2F( Form( "resetTimeDifferenceToSector%d", i + 13 ), Form("reset time difference to sector %d;sector;#DeltaT (clock ticks)", i + 13 ), 12, 12.5, 24.4, 5, -2.5, 2.5 ); + } + mHistograms[ "ETOF_QA_daqMissmatches_get4" ] = new TProfile( "ETOF_QA_daqMissmatches_get4", "missmatch percentage for each get4; get4 []; missmatch percentage", 1728, 0.5, 1728.5 ); + mHistograms[ "ETOF_QA_daqMissmatches_counter" ] = new TProfile( "ETOF_QA_daqMissmatches_counter", "missmatch percentage for each counter; counter []; missmatch percentage", 108, 0.5, 108.5 ); + mHistograms[ "resetTimeCand_times" ] = new TH1F( "resetTimeCand_times", "sectors agreeing on reset time candidates;# sectors with common candidate;# events", 12, 0.5, 12.5 ); + mHistograms[ "resetTimeCand_picked" ] = new TH1F( "resetTimeCand_picked", "sectors agreeing on picked reset time;# sectors with picked reset time;# events", 12, 0.5, 12.5 ); + mHistograms[ "resetTimeCand_compare" ] = new TH1F( "resetTimeCand_compare", "difference between old and new way;#DeltaT (clock ticks);# events", 5, -2.5, 2.5 ); + mHistograms[ "resetTimeCand_value" ] = new TH1F( "resetTimeCand_value", "picked reset time value;clock ticks;# events", ( int ) eTofConst::bTofClockCycle, 0.5, 0.5 + eTofConst::bTofClockCycle ); + } + for ( auto& kv : mHistograms ) { kv.second->SetDirectory( 0 ); } @@ -2091,6 +2572,11 @@ StETofCalibMaker::writeHistograms() TFile histFile( mHistFileName.c_str(), "RECREATE", "etofCalib" ); histFile.cd(); + + for( int i=0; i<12; i++ ) { + std::string histName = "resetTimeDifferenceToSector" + to_string( i + 13 ); + mHistograms.at( histName )->Scale( 12. / mHistograms.at( histName )->GetEntries() ); + } for ( const auto& kv : mHistograms ) { if( kv.second->GetEntries() > 0 ) kv.second->Write(); @@ -2101,4 +2587,4 @@ StETofCalibMaker::writeHistograms() else { LOG_INFO << "histogram file name is empty string --> cannot write histograms" << endm; } -} \ No newline at end of file +} From 7519f89ffe19172dd3e61851747604dbd4767446 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Mon, 18 Oct 2021 17:56:36 +0200 Subject: [PATCH 10/62] Trying to fix merger --- StRoot/StETofCalibMaker/StETofCalibMaker.h | 38 +++++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.h b/StRoot/StETofCalibMaker/StETofCalibMaker.h index 6c40d2cdf97..fecd3ac4d3d 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.h +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.h @@ -80,12 +80,14 @@ class StETofCalibMaker: public StMaker { void setFileNameTimingWindow( const char* fileName ); void setFileNameSignalVelocity( const char* fileName ); void setFileNameCalibHistograms( const char* fileName ); + void setFileNameOffsetHistograms( const char* fileName ); void setFileNameResetTimeCorr( const char* fileName ); void setFileNamePulserTotPeak( const char* fileName ); void setFileNamePulserTimeDiffGbtx( const char* fileName ); void setDoQA( const bool doQA ); void setDebug( const bool debug ); + void setStrictPulserHandling( const bool debug ); void setReferencePulserIndex( const int index ); @@ -136,6 +138,7 @@ class StETofCalibMaker: public StMaker { std::string mFileNameTimingWindow; // name of parameter file for timing window std::string mFileNameSignalVelocity; // name of parameter file for signal velocity std::string mFileNameCalibHistograms; // name of parameter file for calibration histograms (output of QA maker) + std::string mFileNameOffsetHistograms; // name of parameter file for run by run offsets histograms (output of QA maker) std::string mFileNameResetTimeCorr; // name of parameter file for reset time correction std::string mFileNamePulserTotPeak; // name of parameter file for pulser peak tot std::string mFileNamePulserTimeDiffGbtx; // name of parameter file for pulser time diff @@ -146,7 +149,8 @@ class StETofCalibMaker: public StMaker { Float_t mResetTimeCorr; // additional offset for the whole system in case reset time was not saved correctly Double_t mTriggerTime; // trigger time in ns - Double_t mResetTime; // reset time in ns + Double_t mResetTime; // reset time in ns + Long64_t mResetTs; // reset time stamp in clock ticks Float_t mPulserPeakTime; // pulser peak time relative to the trigger time in ns Int_t mReferencePulserIndex; // index of reference pulser used in the pulser correction to correct time offset between different Gbtx @@ -162,10 +166,29 @@ class StETofCalibMaker: public StMaker { std::map< UInt_t, Float_t > mPulserPeakTot; // TOT of pulsers on each side of the RPC counters (as key) std::map< UInt_t, Double_t > mPulserTimeDiff; // pulser time difference with respect to the reference pulser for each detector side as key - std::map< UInt_t, Double_t > mPulserTimeDiffGbtx; // pulser time difference with inside a Gbtx with respect to counter 1 + std::map< UInt_t, Double_t > mPulserTimeDiffGbtx; // pulser time difference with inside a Gbtx with respect to counter 1 + std::map< UInt_t, UInt_t > mNPulsersCounter; // number of found pulsers on each counter. Has to be 2 for good the counter to be considered good in this event. + std::map< UInt_t, UInt_t > mNStatusBitsCounter; // number of Get4 status bits on each counter. Has to be 0 for good the counter to be considered good in this event. + std::map< UInt_t, Bool_t > mPulserPresent; // map of present pulsers for each event (by counter side) - std::map< UInt_t, UInt_t > mJumpingPulsers; // flag jumping pulsers + std::map< UInt_t, Int_t > mJumpingPulsers; // flag jumping pulsers + std::map< UInt_t, Int_t > mUnlockPulserState; // map that counts pulser offsets to avoid locking into the wrong pulser offset state + + + struct StructStuckFwDigi{ + Int_t geomId; + Double_t time; + Double_t tot; + + bool operator==( const StructStuckFwDigi& r ) const { + return geomId == r.geomId && fabs( time - r.time ) < 1.e-5 && fabs( tot - r.tot ) < 1.e-5; + } + }; + + std::vector< StructStuckFwDigi > mStuckFwDigi; // list of digis to ignore for the rest of the run due to stuck firmware + + Bool_t mStrictPulserHandling; Bool_t mUsePulserGbtxDiff; Bool_t mDoQA; Bool_t mDebug; @@ -173,9 +196,12 @@ class StETofCalibMaker: public StMaker { std::map< std::string, TH1* > mHistograms; + + + virtual const Char_t *GetCVS() const { static const char cvs[]="Tag $Name: $Id: built " __DATE__ " " __TIME__ ; return cvs; } - ClassDef( StETofCalibMaker, 0 ) + ClassDef( StETofCalibMaker, 1 ) }; inline void StETofCalibMaker::setFileNameCalibParam( const char* fileName ) { mFileNameCalibParam = fileName; } @@ -184,6 +210,7 @@ inline void StETofCalibMaker::setFileNameStatusMap( const char* fileNam inline void StETofCalibMaker::setFileNameTimingWindow( const char* fileName ) { mFileNameTimingWindow = fileName; } inline void StETofCalibMaker::setFileNameSignalVelocity( const char* fileName ) { mFileNameSignalVelocity = fileName; } inline void StETofCalibMaker::setFileNameCalibHistograms( const char* fileName ) { mFileNameCalibHistograms = fileName; } +inline void StETofCalibMaker::setFileNameOffsetHistograms( const char* fileName ) { mFileNameOffsetHistograms = fileName; } inline void StETofCalibMaker::setFileNameResetTimeCorr( const char* fileName ) { mFileNameResetTimeCorr = fileName; } inline void StETofCalibMaker::setFileNamePulserTotPeak( const char* fileName ) { mFileNamePulserTotPeak = fileName; } inline void StETofCalibMaker::setFileNamePulserTimeDiffGbtx( const char* fileName ) { mFileNamePulserTimeDiffGbtx = fileName; } @@ -191,8 +218,9 @@ inline void StETofCalibMaker::setFileNamePulserTimeDiffGbtx( const char* fileNam inline double StETofCalibMaker::resetTimeCorr() const { return mResetTimeCorr; } +inline void StETofCalibMaker::setStrictPulserHandling( const bool StrictPulserHandling ) { mStrictPulserHandling = StrictPulserHandling; } inline void StETofCalibMaker::setDoQA( const bool doQA ) { mDoQA = doQA; } inline void StETofCalibMaker::setDebug( const bool debug ) { mDebug = debug; } inline void StETofCalibMaker::setReferencePulserIndex( const int index ) { mReferencePulserIndex = index; } -#endif // STETOFCALIBMAKER_H \ No newline at end of file +#endif // STETOFCALIBMAKER_H From 1e96e9b6565ce94b937db1721ff90775237785f9 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Mon, 4 Oct 2021 13:38:43 +0200 Subject: [PATCH 11/62] added eTofGoodEventFlag to mark counters which are good foer analysis in each event --- StRoot/StEvent/StETofCollection.h | 2 +- StRoot/StEvent/StETofHeader.cxx | 47 +++++++++++++++---- StRoot/StEvent/StETofHeader.h | 33 ++++++++++--- StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx | 43 +++++++++++++++-- StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h | 30 ++++++++++-- StRoot/StPicoDstMaker/StPicoDstMaker.cxx | 5 ++ StRoot/StPicoDstMaker/StPicoDstMaker.h | 2 +- StRoot/StPicoEvent/StPicoEvent.cxx | 34 +++++++++++++- StRoot/StPicoEvent/StPicoEvent.h | 15 +++++- 9 files changed, 186 insertions(+), 25 deletions(-) diff --git a/StRoot/StEvent/StETofCollection.h b/StRoot/StEvent/StETofCollection.h index 9a5c360785b..7f6e3b9af30 100644 --- a/StRoot/StEvent/StETofCollection.h +++ b/StRoot/StEvent/StETofCollection.h @@ -59,7 +59,7 @@ class StETofCollection : public StObject { StSPtrVecETofHit mETofHits; - ClassDef( StETofCollection, 1 ) + ClassDef( StETofCollection, 2 ) }; #endif // STETOFCOLLECTION_H diff --git a/StRoot/StEvent/StETofHeader.cxx b/StRoot/StEvent/StETofHeader.cxx index b3ac6a080be..0a51fc77794 100644 --- a/StRoot/StEvent/StETofHeader.cxx +++ b/StRoot/StEvent/StETofHeader.cxx @@ -38,6 +38,10 @@ StETofHeader::StETofHeader() { mRocGdpbTs.clear(); mRocStarTs.clear(); + const size_t kNbGet4sInSystem = 1728; + mMissMatchFlagVec = std::vector( kNbGet4sInSystem, false ); + const size_t kNbCountersInSystem = 108; + mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); } @@ -55,13 +59,15 @@ StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); const size_t kNbGet4sInSystem = 1728; - mMissMatchFlagVec = vector( kNbGet4sInSystem, false ); + mMissMatchFlagVec = std::vector( kNbGet4sInSystem, false ); + const size_t kNbCountersInSystem = 108; + mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); } StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime, const map< unsigned int, uint64_t >& gdpbTs, const map< unsigned int, uint64_t >& starTs, const unsigned int& starToken, const unsigned int& starDaqCmdIn, const unsigned int& starTrgCmdIn, - const uint64_t& eventStatusFlag, const vector& MissMatchFlagVec ) + const uint64_t& eventStatusFlag, const std::vector& MissMatchFlagVec ) : mTrgGdpbFullTime( trgGdpbTime ), mTrgStarFullTime( trgStarTime ), mStarToken( starToken ), @@ -72,12 +78,25 @@ StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime { setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); - //const size_t kNbGet4sInSystem = 1728; - //mMissMatchFlagVec.resize( kNbGet4sInSystem ); - //for( auto mapcheck : mMissMatchFlagVec ){ - // cout << mapcheck << endl; - // } + const size_t kNbCountersInSystem = 108; + mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); +} +StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime, + const map< unsigned int, uint64_t >& gdpbTs, const map< unsigned int, uint64_t >& starTs, + const unsigned int& starToken, const unsigned int& starDaqCmdIn, const unsigned int& starTrgCmdIn, + const uint64_t& eventStatusFlag, const std::vector& MissMatchFlagVec, const std::vector& GoodEventFlagVec ) +: mTrgGdpbFullTime( trgGdpbTime ), + mTrgStarFullTime( trgStarTime ), + mStarToken( starToken ), + mStarDaqCmdIn( starDaqCmdIn ), + mStarTrgCmdIn( starTrgCmdIn ), + mEventStatusFlag( eventStatusFlag ), + mMissMatchFlagVec( MissMatchFlagVec ), + mGoodEventFlagVec( GoodEventFlagVec ) +{ + setRocGdpbTs( gdpbTs ); + setRocStarTs( starTs ); } @@ -142,12 +161,18 @@ StETofHeader::eventStatusFlag() const return mEventStatusFlag; } -vector +std::vector StETofHeader::missMatchFlagVec() const { return mMissMatchFlagVec; } +std::vector +StETofHeader::goodEventFlagVec() const +{ + return mGoodEventFlagVec; +} + void StETofHeader::setTrgGdpbFullTime( const double& gdpbFullTime ) { @@ -202,3 +227,9 @@ StETofHeader::setEventStatusFlag( const uint64_t& statusFlag ) { mEventStatusFlag = statusFlag; } + +void +StETofHeader::setGoodEventFlagVec( const std::vector& FlagVec ) +{ + mGoodEventFlagVec = FlagVec; +} diff --git a/StRoot/StEvent/StETofHeader.h b/StRoot/StEvent/StETofHeader.h index 01d4b9b3c54..8daaa42f7a9 100644 --- a/StRoot/StEvent/StETofHeader.h +++ b/StRoot/StEvent/StETofHeader.h @@ -41,10 +41,21 @@ class StETofHeader : public StObject { public: StETofHeader(); + /** + ** @brief default constructor for pre-2020 data. No missmatch information available. Used in StEtofDigiMaker to initialise the header. + **/ StETofHeader( const double&, const double&, const map< unsigned int, uint64_t >&, const map< unsigned int, uint64_t >& , const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t& ); + /** + ** @brief default constructor for post-2020 data. Include missmatch information from FEE. Used in StEtofDigiMaker to initialise the header. + **/ StETofHeader( const double&, const double&, const map< unsigned int, uint64_t >&, const map< unsigned int, uint64_t >& , - const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t&, const vector& ); + const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t&, const std::vector& ); + /** + ** @brief Full constructor including goodEventFlag, which is normally set in calibrations only. + **/ + StETofHeader( const double&, const double&, const map< unsigned int, uint64_t >&, const map< unsigned int, uint64_t >& , + const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t&, const std::vector&, const std::vector& ); ~StETofHeader(); @@ -57,9 +68,15 @@ class StETofHeader : public StObject { unsigned int starToken() const; unsigned int starDaqCmdIn() const; unsigned int starTrgCmdIn() const; - uint64_t eventStatusFlag() const; - - vector missMatchFlagVec() const; + uint64_t eventStatusFlag() const; + /** + ** @brief Flag for each Get4 TDC to mark if it is available in this event. + **/ + std::vector missMatchFlagVec() const; + /** + ** @brief Flag to mark if the event is good for physics analysis for each counter. A counter is considered good in each event when there are zero missmatch flags set and pulser digis on both sides are found. In this case, the counter should perform at its best. Counter efficiency should be constant between good events. + **/ + std::vector goodEventFlagVec() const; void setTrgGdpbFullTime( const double& gdpbFullTime ); @@ -73,6 +90,9 @@ class StETofHeader : public StObject { void setStarTrgCmdIn( const unsigned int& trgCmdIn ); void setEventStatusFlag( const uint64_t& statusFlag ); + void setGoodEventFlagVec( const std::vector& FlagVec ); + void setGoodEventFlagVec( int blubb ) {return;} + // void setGoodEventFlagVec( const std::vector& FlagVec ); private: Double_t mTrgGdpbFullTime; @@ -87,9 +107,10 @@ class StETofHeader : public StObject { ULong64_t mEventStatusFlag; - vector< Bool_t > mMissMatchFlagVec; + std::vector< Bool_t > mMissMatchFlagVec; + std::vector< Bool_t > mGoodEventFlagVec; - ClassDef( StETofHeader, 2 ) + ClassDef( StETofHeader, 3 ) }; #endif // STETOFHEADER_H diff --git a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx index 90e078a6de3..6e2d7b62ac5 100644 --- a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx +++ b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx @@ -34,6 +34,11 @@ StMuETofHeader::StMuETofHeader() { mRocGdpbTs.clear(); mRocStarTs.clear(); + mRocStarTs.clear(); + const size_t kNbGet4sInSystem = 1728; + mMissMatchFlagVec = std::vector( kNbGet4sInSystem, false ); + const size_t kNbCountersInSystem = 108; + mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); } @@ -51,13 +56,15 @@ StMuETofHeader::StMuETofHeader( const double& trgGdpbTime, const double& trgStar setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); const size_t kNbGet4sInSystem = 1728; - mMissMatchFlagVec = std::vector< Bool_t >( kNbGet4sInSystem, false ); + mMissMatchFlagVec = std::vector< Bool_t >( kNbGet4sInSystem, false ); + const size_t kNbCountersInSystem = 108; + mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); } StMuETofHeader::StMuETofHeader( const double& trgGdpbTime, const double& trgStarTime, const map< unsigned int, uint64_t >& gdpbTs, const map< unsigned int, uint64_t >& starTs, const unsigned int& starToken, const unsigned int& starDaqCmdIn, const unsigned int& starTrgCmdIn, - const uint64_t& eventStatusFlag, const vector< Bool_t >& MissMatchFlagVec ) + const uint64_t& eventStatusFlag, const std::vector< Bool_t >& MissMatchFlagVec ) : mTrgGdpbFullTime( trgGdpbTime ), mTrgStarFullTime( trgStarTime ), mStarToken( starToken ), @@ -70,6 +77,23 @@ StMuETofHeader::StMuETofHeader( const double& trgGdpbTime, const double& trgStar setRocStarTs( starTs ); } +StMuETofHeader::StMuETofHeader( const double& trgGdpbTime, const double& trgStarTime, + const map< unsigned int, uint64_t >& gdpbTs, const map< unsigned int, uint64_t >& starTs, + const unsigned int& starToken, const unsigned int& starDaqCmdIn, const unsigned int& starTrgCmdIn, + const uint64_t& eventStatusFlag, const std::vector& MissMatchFlagVec, const std::vector& GoodEventFlagVec ) +: mTrgGdpbFullTime( trgGdpbTime ), + mTrgStarFullTime( trgStarTime ), + mStarToken( starToken ), + mStarDaqCmdIn( starDaqCmdIn ), + mStarTrgCmdIn( starTrgCmdIn ), + mEventStatusFlag( eventStatusFlag ), + mMissMatchFlagVec( MissMatchFlagVec ), + mGoodEventFlagVec( GoodEventFlagVec ) +{ + setRocGdpbTs( gdpbTs ); + setRocStarTs( starTs ); +} + StMuETofHeader::StMuETofHeader( const StETofHeader* header ) : mTrgGdpbFullTime( header->trgGdpbFullTime() ), mTrgStarFullTime( header->trgStarFullTime() ), @@ -77,7 +101,8 @@ StMuETofHeader::StMuETofHeader( const StETofHeader* header ) mStarDaqCmdIn( header->starDaqCmdIn() ), mStarTrgCmdIn( header->starTrgCmdIn() ), mEventStatusFlag( header->eventStatusFlag() ), - mMissMatchFlagVec(header->missMatchFlagVec()) + mMissMatchFlagVec(header->missMatchFlagVec()), + mGoodEventFlagVec(header->goodEventFlagVec()) { setRocGdpbTs( header->rocGdpbTs() ); setRocStarTs( header->rocStarTs() ); @@ -151,6 +176,12 @@ StMuETofHeader::missMatchFlagVec() const return mMissMatchFlagVec; } +std::vector +StMuETofHeader::goodEventFlagVec() const +{ + return mGoodEventFlagVec; +} + void StMuETofHeader::setTrgGdpbFullTime( const double& gdpbFullTime ) @@ -206,3 +237,9 @@ StMuETofHeader::setEventStatusFlag( const uint64_t& statusFlag ) { mEventStatusFlag = statusFlag; } + +void +StMuETofHeader::setGoodEventFlagVec( const std::vector& FlagVec ) +{ + mGoodEventFlagVec = FlagVec; +} diff --git a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h index 87c98d8e135..c5750f04e81 100644 --- a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h +++ b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h @@ -35,11 +35,26 @@ class StMuETofHeader : public TObject { public: StMuETofHeader(); + /** + ** @brief Constructor for conversion from StEvent header. + **/ StMuETofHeader( const StETofHeader* header ); + /** + ** @brief default constructor for pre-2020 data. No missmatch information available. Used in StEtofDigiMaker to initialise the header. + **/ StMuETofHeader( const double&, const double&, const std::map< unsigned int, uint64_t >&, const std::map< unsigned int, uint64_t >& , const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t& ); + /** + ** @brief default constructor for post-2020 data. Include missmatch information from FEE. Used in StEtofDigiMaker to initialise the header. + **/ StMuETofHeader( const double&, const double&, const std::map< unsigned int, uint64_t >&, const std::map< unsigned int, uint64_t >& , const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t&, const std::vector< Bool_t >& ); + /** + ** @brief Full constructor including goodEventFlag, which is normally set in calibrations only. + **/ + StMuETofHeader( const double&, const double&, const std::map< unsigned int, uint64_t >&, const std::map< unsigned int, uint64_t >& , + const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t&, const std::vector&, + const std::vector& ); ~StMuETofHeader(); @@ -53,7 +68,14 @@ class StMuETofHeader : public TObject { unsigned int starDaqCmdIn() const; unsigned int starTrgCmdIn() const; uint64_t eventStatusFlag() const; - std::vector< Bool_t > missMatchFlagVec() const; + /** + ** @brief Flag for each Get4 TDC to mark if it is available in this event. + **/ + std::vector missMatchFlagVec() const; + /** + ** @brief Flag to mark if the event is good for physics analysis for each counter. A counter is considered good in each event when there are zero missmatch flags set and pulser digis on both sides are found. In this case, the counter should perform at its best. Counter efficiency should be constant between good events. + **/ + std::vector goodEventFlagVec() const; void setTrgGdpbFullTime( const double& gdpbFullTime ); @@ -67,6 +89,7 @@ class StMuETofHeader : public TObject { void setStarTrgCmdIn( const unsigned int& trgCmdIn ); void setEventStatusFlag( const uint64_t& statusFlag ); + void setGoodEventFlagVec( const std::vector& FlagVec ); private: Double_t mTrgGdpbFullTime; @@ -81,9 +104,10 @@ class StMuETofHeader : public TObject { ULong64_t mEventStatusFlag; - std::vector< Bool_t > mMissMatchFlagVec; + std::vector< Bool_t > mMissMatchFlagVec; + std::vector< Bool_t > mGoodEventFlagVec; - ClassDef( StMuETofHeader, 2 ) + ClassDef( StMuETofHeader, 3 ) }; #endif // STMUETOFHEADER_H diff --git a/StRoot/StPicoDstMaker/StPicoDstMaker.cxx b/StRoot/StPicoDstMaker/StPicoDstMaker.cxx index 0401b3ec9d6..848e00d941e 100644 --- a/StRoot/StPicoDstMaker/StPicoDstMaker.cxx +++ b/StRoot/StPicoDstMaker/StPicoDstMaker.cxx @@ -55,6 +55,7 @@ #include "StMuDSTMaker/COMMON/StMuEpdHit.h" #include "StMuDSTMaker/COMMON/StMuETofHit.h" #include "StMuDSTMaker/COMMON/StMuETofDigi.h" +#include "StMuDSTMaker/COMMON/StMuETofHeader.h" #include "StMuDSTMaker/COMMON/StMuMcTrack.h" #include "StMuDSTMaker/COMMON/StMuMcVertex.h" @@ -1825,6 +1826,10 @@ void StPicoDstMaker::fillEvent() { picoEvent->setNumberOfPrimaryTracks( mMuDst->numberOfPrimaryTracks() ); picoEvent->setbTofTrayMultiplicity( ev->btofTrayMultiplicity() ); picoEvent->setETofHitMultiplicity( ev->etofHitMultiplicity() ); + StMuETofHeader *header = mMuDst->etofHeader(); + if( header ) { + picoEvent->setETofGoodEventFlag( header->goodEventFlagVec() ); + } // Save the number of etof digis that were useable in the hit building process unsigned short nUseableETofDigis = 0; diff --git a/StRoot/StPicoDstMaker/StPicoDstMaker.h b/StRoot/StPicoDstMaker/StPicoDstMaker.h index e5f91085fb2..42eca81418f 100644 --- a/StRoot/StPicoDstMaker/StPicoDstMaker.h +++ b/StRoot/StPicoDstMaker/StPicoDstMaker.h @@ -349,7 +349,7 @@ class StPicoDstMaker : public StMaker { return cvs; } - ClassDef(StPicoDstMaker, 0) + ClassDef(StPicoDstMaker, 1) }; inline void StPicoDstMaker::setSplit(int split) { mSplit = split; } diff --git a/StRoot/StPicoEvent/StPicoEvent.cxx b/StRoot/StPicoEvent/StPicoEvent.cxx index 37159dba21e..f39454a0013 100644 --- a/StRoot/StPicoEvent/StPicoEvent.cxx +++ b/StRoot/StPicoEvent/StPicoEvent.cxx @@ -36,7 +36,7 @@ StPicoEvent::StPicoEvent(): TObject(), mZdcSumAdcEast(0), mZdcSumAdcWest(0), mZdcSmdEastHorizontal{}, mZdcSmdEastVertical{}, mZdcSmdWestHorizontal{}, mZdcSmdWestVertical{}, mBbcAdcEast{}, mBbcAdcWest{}, mHighTowerThreshold{}, mJetPatchThreshold{}, - mETofHitMultiplicity(0), mETofDigiMultiplicity(0), mNumberOfPrimaryTracks(0), mZdcUnAttenuated{} { + mETofHitMultiplicity(0), mETofDigiMultiplicity(0), mETofGoodEventFlag{}, mNumberOfPrimaryTracks(0), mZdcUnAttenuated{} { // Default constructor if( !mTriggerIds.empty() ) { @@ -146,6 +146,10 @@ StPicoEvent::StPicoEvent(const StPicoEvent &event) : TObject() { mHighTowerThreshold[iIter] = event.mHighTowerThreshold[iIter]; mJetPatchThreshold[iIter] = event.mJetPatchThreshold[iIter]; } + + for(int iIter=0; iIter<108; iIter++) { + mETofGoodEventFlag[iIter] = event.mETofGoodEventFlag[iIter]; + } } //_________________ @@ -333,3 +337,31 @@ void StPicoEvent::setBunchId(Int_t id) { (UChar_t)id ); } } + +//_________________ +bool StPicoEvent::eTofGoodEventFlag( UShort_t iSector, UShort_t iModule, UShort_t iCounter ) const { + if( iSector < 13 || iSector > 24 ){ + LOG_INFO << "StPicoEvent::eTofGoodEventFlag() - non-existing sector id " << iSector <<" -> return false"<< endm; + return false; + } + if( iModule < 1 || iModule > 3 ){ + LOG_INFO << "StPicoEvent::eTofGoodEventFlag() - non-existing module id " << iModule <<" -> return false"<< endm; + return false; + } + if( iCounter < 1 || iCounter > 3 ){ + LOG_INFO << "StPicoEvent::eTofGoodEventFlag() - non-existing counter id " << iCounter <<" -> return false"<< endm; + return false; + } + + return (bool) mETofGoodEventFlag[ 9*(iSector-13) + 3*(iModule-1) + (iCounter-1) ]; +} +//_________________ +void StPicoEvent::setETofGoodEventFlag( std::vector flagVec ) { + if( flagVec.size() != 108 ){ + LOG_INFO << "StPicoEvent::setETofGoodEventFlag() - eTof flag vector wrong size " << flagVec.size() <<" / 108"<< endm; + }else{ + for( auto iterCounter : flagVec ){ + mETofGoodEventFlag[iterCounter] = flagVec[iterCounter]; + } + } +} diff --git a/StRoot/StPicoEvent/StPicoEvent.h b/StRoot/StPicoEvent/StPicoEvent.h index ce84c67020d..3ff0b07a231 100644 --- a/StRoot/StPicoEvent/StPicoEvent.h +++ b/StRoot/StPicoEvent/StPicoEvent.h @@ -141,6 +141,10 @@ class StPicoEvent : public TObject { UShort_t etofHitMultiplicity() const { return mETofHitMultiplicity; } /// Return number of digis in ETOF modules UShort_t etofDigiMultiplicity() const { return mETofDigiMultiplicity; } + /// Return goodEventFlag for a specific eTOF counter + bool eTofGoodEventFlag( UShort_t iSector, UShort_t iModule, UShort_t iCounter ) const; + /// Return goodEventFlag by array entry + bool eTofGoodEventFlag( UShort_t iDet ) const { return (bool) mETofGoodEventFlag[ iDet ]; } /// Return number of primary tracks UShort_t numberOfPrimaryTracks() const { return mNumberOfPrimaryTracks; } /// Return FXT multiplicity (corresponds to the number of primary tracks) @@ -274,9 +278,14 @@ class StPicoEvent : public TObject { void setETofHitMultiplicity(UShort_t mult) { mETofHitMultiplicity = (UShort_t)mult; } /// Set total number of digis in ETOF modules void setETofDigiMultiplicity(UShort_t mult) { mETofDigiMultiplicity = (UShort_t)mult; } + /// Set goodEventFlag for a specific eTOF counter + void setETofGoodEventFlag( bool flag, UShort_t iSector, UShort_t iModule, UShort_t iCounter ) { mETofGoodEventFlag[ 9*(iSector-1) + 3*(iModule-1) + (iCounter-1) ] = flag; } + /// Full setter goodEventFlag all specific eTOF counter. Used to copy over MuDst data + void setETofGoodEventFlag( std::vector flagVec ); /// Set number of primary tracks void setNumberOfPrimaryTracks(UShort_t mult) { mNumberOfPrimaryTracks = (UShort_t)mult; } + /// Set trigger id void setTriggerId(UInt_t id); /// Set trigger id (pass STL vector with trigger IDs) @@ -600,6 +609,8 @@ class StPicoEvent : public TObject { UShort_t mETofHitMultiplicity ; /// Total digi multiplicity in ETOF modules UShort_t mETofDigiMultiplicity ; + /// Flag to mark if the event is good for physics analysis for each counter. A counter is considered good in each event when there are zero missmatch flags set and pulser digis on both sides are found. In this case, the counter should perform at its best. Counter efficiency should be constant between good events. Here: CounterNr = 9*sector + 3*module + counter. + bool mETofGoodEventFlag[108]; /// Number of primary tracks UShort_t mNumberOfPrimaryTracks; @@ -608,9 +619,9 @@ class StPicoEvent : public TObject { UShort_t mZdcUnAttenuated[2]; #if defined (__TFG__VERSION__) - ClassDef(StPicoEvent, 8) + ClassDef(StPicoEvent, 9) #else /* ! __TFG__VERSION__ */ - ClassDef(StPicoEvent, 6) + ClassDef(StPicoEvent, 7) #endif }; From 0b1b984077de14efef06450e519b71c2c3046a07 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Wed, 6 Oct 2021 20:26:04 +0200 Subject: [PATCH 12/62] moved struct to public to avoid root6 issue. Changed class dev version back to 0 --- StRoot/StETofCalibMaker/StETofCalibMaker.h | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.h b/StRoot/StETofCalibMaker/StETofCalibMaker.h index fecd3ac4d3d..1b7b0d0eaca 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.h +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.h @@ -89,6 +89,17 @@ class StETofCalibMaker: public StMaker { void setDebug( const bool debug ); void setStrictPulserHandling( const bool debug ); void setReferencePulserIndex( const int index ); + + //moved to public to avoid problem with root6 + struct StructStuckFwDigi{ + Int_t geomId; + Double_t time; + Double_t tot; + + bool operator==( const StructStuckFwDigi& r ) const { + return geomId == r.geomId && fabs( time - r.time ) < 1.e-5 && fabs( tot - r.tot ) < 1.e-5; + } + }; private: @@ -138,7 +149,7 @@ class StETofCalibMaker: public StMaker { std::string mFileNameTimingWindow; // name of parameter file for timing window std::string mFileNameSignalVelocity; // name of parameter file for signal velocity std::string mFileNameCalibHistograms; // name of parameter file for calibration histograms (output of QA maker) - std::string mFileNameOffsetHistograms; // name of parameter file for run by run offsets histograms (output of QA maker) + std::string mFileNameOffsetHistograms; // name of parameter file for run by run offsets histograms (output of QA maker) std::string mFileNameResetTimeCorr; // name of parameter file for reset time correction std::string mFileNamePulserTotPeak; // name of parameter file for pulser peak tot std::string mFileNamePulserTimeDiffGbtx; // name of parameter file for pulser time diff @@ -175,17 +186,6 @@ class StETofCalibMaker: public StMaker { std::map< UInt_t, Int_t > mUnlockPulserState; // map that counts pulser offsets to avoid locking into the wrong pulser offset state - - struct StructStuckFwDigi{ - Int_t geomId; - Double_t time; - Double_t tot; - - bool operator==( const StructStuckFwDigi& r ) const { - return geomId == r.geomId && fabs( time - r.time ) < 1.e-5 && fabs( tot - r.tot ) < 1.e-5; - } - }; - std::vector< StructStuckFwDigi > mStuckFwDigi; // list of digis to ignore for the rest of the run due to stuck firmware Bool_t mStrictPulserHandling; @@ -201,7 +201,7 @@ class StETofCalibMaker: public StMaker { virtual const Char_t *GetCVS() const { static const char cvs[]="Tag $Name: $Id: built " __DATE__ " " __TIME__ ; return cvs; } - ClassDef( StETofCalibMaker, 1 ) + ClassDef( StETofCalibMaker, 0 ) }; inline void StETofCalibMaker::setFileNameCalibParam( const char* fileName ) { mFileNameCalibParam = fileName; } From e1dd9b73ca7f65d036be8a4a6fad5cb4c8a7f5e0 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Wed, 6 Oct 2021 20:35:14 +0200 Subject: [PATCH 13/62] added kStFatal return in ::init if calib histo files are corrupt --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index 7d5da1f6209..8b39d854911 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -629,16 +629,24 @@ StETofCalibMaker::InitRun( Int_t runnumber ) TFile* histFile = new TFile( mFileNameCalibHistograms.c_str(), "READ" ); - if( !histFile || histFile->IsZombie() ) { - LOG_ERROR << "unable to open file: " << mFileNameCalibHistograms.c_str() << endm; + if( !histFile ) { + LOG_ERROR << "No calibration file found: " << mFileNameCalibHistograms.c_str() << endm; LOG_INFO << "setting all parameters to default" << endm; + }else if( histFile->IsZombie() ){ + LOG_ERROR << "Zombie calibration file: " << mFileNameCalibHistograms.c_str() << endm; + LOG_INFO << "stopping execution" << endm; + return kStFatal; } TFile* histOffsetFile = new TFile( mFileNameOffsetHistograms.c_str(), "READ" ); //create setter! - if( !histOffsetFile || histOffsetFile->IsZombie() ) { - LOG_ERROR << "unable to open file: " << mFileNameOffsetHistograms.c_str() << endm; + if( !histOffsetFile ) { + LOG_INFO << "No offset file found: " << mFileNameOffsetHistograms.c_str() << endm; LOG_INFO << "setting all parameters to default" << endm; + }else if( histOffsetFile->IsZombie() ) { + LOG_ERROR << "Zombie offset file: " << mFileNameOffsetHistograms.c_str() << endm; + LOG_INFO << "stopping execution" << endm; + return kStFatal; }else{ LOG_INFO << "Successfully opened RunOffset file "<< mFileNameOffsetHistograms.c_str() << endm; } From 8466d725e6572a1dc74174a9c3a3c51a80c17ea3 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Wed, 6 Oct 2021 20:40:04 +0200 Subject: [PATCH 14/62] Changed class dev version back to 0 --- StRoot/StPicoDstMaker/StPicoDstMaker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StRoot/StPicoDstMaker/StPicoDstMaker.h b/StRoot/StPicoDstMaker/StPicoDstMaker.h index 42eca81418f..e5f91085fb2 100644 --- a/StRoot/StPicoDstMaker/StPicoDstMaker.h +++ b/StRoot/StPicoDstMaker/StPicoDstMaker.h @@ -349,7 +349,7 @@ class StPicoDstMaker : public StMaker { return cvs; } - ClassDef(StPicoDstMaker, 1) + ClassDef(StPicoDstMaker, 0) }; inline void StPicoDstMaker::setSplit(int split) { mSplit = split; } From b61cbfffbbe25b9ea0a0b701da42844b05ed1f64 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Sat, 23 Oct 2021 13:35:58 +0200 Subject: [PATCH 15/62] decremented classDef version of StEtofCollection. Makers compile correct header version after rebase without increment --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 2 +- StRoot/StEvent/StETofCollection.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index 8b39d854911..19ec51ca5a3 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -58,7 +58,7 @@ #include "StEvent.h" #include "StETofCollection.h" -#include "StETofHeader.h" //collection includes header. Make sure to include header first to get correct version! +//#include "StETofHeader.h" //collection includes header. Make sure to include header first to get correct version! #include "StETofDigi.h" #include "StMuDSTMaker/COMMON/StMuDst.h" diff --git a/StRoot/StEvent/StETofCollection.h b/StRoot/StEvent/StETofCollection.h index 7f6e3b9af30..9a5c360785b 100644 --- a/StRoot/StEvent/StETofCollection.h +++ b/StRoot/StEvent/StETofCollection.h @@ -59,7 +59,7 @@ class StETofCollection : public StObject { StSPtrVecETofHit mETofHits; - ClassDef( StETofCollection, 2 ) + ClassDef( StETofCollection, 1 ) }; #endif // STETOFCOLLECTION_H From 7c318e02bfa70b98487708fe013246fd67dec1e4 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Sun, 24 Oct 2021 13:55:24 +0200 Subject: [PATCH 16/62] removed double line in MuEtofHeader constructor --- StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx index 6e2d7b62ac5..ff6c2eab8e5 100644 --- a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx +++ b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx @@ -34,7 +34,6 @@ StMuETofHeader::StMuETofHeader() { mRocGdpbTs.clear(); mRocStarTs.clear(); - mRocStarTs.clear(); const size_t kNbGet4sInSystem = 1728; mMissMatchFlagVec = std::vector( kNbGet4sInSystem, false ); const size_t kNbCountersInSystem = 108; From 3c2234c5264c4c888d442d3dc0313b3c61ea18a4 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Sun, 24 Oct 2021 18:21:26 +0200 Subject: [PATCH 17/62] included eTOF constants header and moved constants here --- StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx index ff6c2eab8e5..730745efa3e 100644 --- a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx +++ b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx @@ -22,6 +22,7 @@ ***************************************************************************/ #include "StMuETofHeader.h" #include "StETofHeader.h" +#include "StETofUtil/StETofConstants.h" StMuETofHeader::StMuETofHeader() @@ -34,10 +35,8 @@ StMuETofHeader::StMuETofHeader() { mRocGdpbTs.clear(); mRocStarTs.clear(); - const size_t kNbGet4sInSystem = 1728; - mMissMatchFlagVec = std::vector( kNbGet4sInSystem, false ); - const size_t kNbCountersInSystem = 108; - mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); + mMissMatchFlagVec = std::vector( eTofConst::nGet4sInSystem, false ); + mGoodEventFlagVec = std::vector( eTofConst::nCountersInSystem, false ); } @@ -54,10 +53,8 @@ StMuETofHeader::StMuETofHeader( const double& trgGdpbTime, const double& trgStar { setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); - const size_t kNbGet4sInSystem = 1728; - mMissMatchFlagVec = std::vector< Bool_t >( kNbGet4sInSystem, false ); - const size_t kNbCountersInSystem = 108; - mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); + mMissMatchFlagVec = std::vector( eTofConst::nGet4sInSystem, false ); + mGoodEventFlagVec = std::vector( eTofConst::nCountersInSystem, false ); } StMuETofHeader::StMuETofHeader( const double& trgGdpbTime, const double& trgStarTime, From 29c68fb37f229e049ce54498bfbcc4566b4640b8 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Sun, 24 Oct 2021 19:26:41 +0200 Subject: [PATCH 18/62] included eTOF constants header and moved constants here --- StRoot/StEvent/StETofHeader.cxx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/StRoot/StEvent/StETofHeader.cxx b/StRoot/StEvent/StETofHeader.cxx index 0a51fc77794..6d63e7cd420 100644 --- a/StRoot/StEvent/StETofHeader.cxx +++ b/StRoot/StEvent/StETofHeader.cxx @@ -24,6 +24,8 @@ * ***************************************************************************/ #include "StETofHeader.h" +#include "StETofUtil/StETofConstants.h" + #include #include #include @@ -38,10 +40,8 @@ StETofHeader::StETofHeader() { mRocGdpbTs.clear(); mRocStarTs.clear(); - const size_t kNbGet4sInSystem = 1728; - mMissMatchFlagVec = std::vector( kNbGet4sInSystem, false ); - const size_t kNbCountersInSystem = 108; - mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); + mMissMatchFlagVec = std::vector( eTofConst::nGet4sInSystem, false ); + mGoodEventFlagVec = std::vector( eTofConst::nCountersInSystem, false ); } @@ -58,10 +58,8 @@ StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime { setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); - const size_t kNbGet4sInSystem = 1728; - mMissMatchFlagVec = std::vector( kNbGet4sInSystem, false ); - const size_t kNbCountersInSystem = 108; - mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); + mMissMatchFlagVec = std::vector( eTofConst::nGet4sInSystem, false ); + mGoodEventFlagVec = std::vector( eTofConst::nCountersInSystem, false ); } StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime, From 532c054e31a0e812611538c782bdd5d31d64c319 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Sun, 24 Oct 2021 20:29:21 +0200 Subject: [PATCH 19/62] added constant nbGet4s here for use in event headers --- StRoot/StETofUtil/StETofConstants.h | 1 + 1 file changed, 1 insertion(+) diff --git a/StRoot/StETofUtil/StETofConstants.h b/StRoot/StETofUtil/StETofConstants.h index 5d30c1b520e..3e13a234f83 100644 --- a/StRoot/StETofUtil/StETofConstants.h +++ b/StRoot/StETofUtil/StETofConstants.h @@ -57,6 +57,7 @@ namespace eTofConst{ const int nChannelsPerSector = nChannelsPerModule * nPlanes; const int nChannelsInSystem = nChannelsPerSector * nSectors; + const int nGet4sInSystem = nChannelsInSystem / 4; // clock related constants const double coarseClockCycle = 6.25; // [ns] -- needs to be double otherwise strange things happen ... From 7152b45b1738c278c767fcb00dd43a5f2537654e Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Wed, 27 Oct 2021 12:25:32 +0200 Subject: [PATCH 20/62] Removed strstr include in StMuDstMaker.cxx. Now indentical to repository version --- StRoot/StMuDSTMaker/COMMON/StMuDstMaker.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/StRoot/StMuDSTMaker/COMMON/StMuDstMaker.cxx b/StRoot/StMuDSTMaker/COMMON/StMuDstMaker.cxx index 1354db05431..b672161936e 100644 --- a/StRoot/StMuDSTMaker/COMMON/StMuDstMaker.cxx +++ b/StRoot/StMuDSTMaker/COMMON/StMuDstMaker.cxx @@ -114,8 +114,6 @@ #include "StMuMcTrack.h" #include "StG2TrackVertexMap.h" -#include //added/needed to compile successfully after 01.Oct.21. Remove in merger if problem is solved in a different way. No further changes in file. Weidenkaff - class StEpdHit; // MALisa ClassImp(StMuDstMaker) From 61250b3225ee25f20519d6d7aeeb372b0c480d40 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Wed, 27 Oct 2021 13:14:14 +0200 Subject: [PATCH 21/62] Moved vector init in eTOF headers to initializer list --- StRoot/StEvent/StETofHeader.cxx | 17 ++++++++--------- StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx | 15 ++++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/StRoot/StEvent/StETofHeader.cxx b/StRoot/StEvent/StETofHeader.cxx index 6d63e7cd420..2588562ef5d 100644 --- a/StRoot/StEvent/StETofHeader.cxx +++ b/StRoot/StEvent/StETofHeader.cxx @@ -36,12 +36,12 @@ StETofHeader::StETofHeader() mStarToken( 0 ), mStarDaqCmdIn( 0 ), mStarTrgCmdIn( 0 ), - mEventStatusFlag( 0 ) + mEventStatusFlag( 0 ), + mMissMatchFlagVec( eTofConst::nGet4sInSystem, false ), + mGoodEventFlagVec( eTofConst::nCountersInSystem, false ) { mRocGdpbTs.clear(); mRocStarTs.clear(); - mMissMatchFlagVec = std::vector( eTofConst::nGet4sInSystem, false ); - mGoodEventFlagVec = std::vector( eTofConst::nCountersInSystem, false ); } @@ -54,12 +54,12 @@ StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime mStarToken( starToken ), mStarDaqCmdIn( starDaqCmdIn ), mStarTrgCmdIn( starTrgCmdIn ), - mEventStatusFlag( eventStatusFlag ) + mEventStatusFlag( eventStatusFlag ), + mMissMatchFlagVec( eTofConst::nGet4sInSystem, false ), + mGoodEventFlagVec( eTofConst::nCountersInSystem, false ) { setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); - mMissMatchFlagVec = std::vector( eTofConst::nGet4sInSystem, false ); - mGoodEventFlagVec = std::vector( eTofConst::nCountersInSystem, false ); } StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime, @@ -72,12 +72,11 @@ StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime mStarDaqCmdIn( starDaqCmdIn ), mStarTrgCmdIn( starTrgCmdIn ), mEventStatusFlag( eventStatusFlag ), - mMissMatchFlagVec( MissMatchFlagVec ) + mMissMatchFlagVec( MissMatchFlagVec ), + mGoodEventFlagVec( eTofConst::nCountersInSystem, false ) { setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); - const size_t kNbCountersInSystem = 108; - mGoodEventFlagVec = std::vector( kNbCountersInSystem, false ); } StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime, diff --git a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx index 730745efa3e..5f655a2a041 100644 --- a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx +++ b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx @@ -31,12 +31,12 @@ StMuETofHeader::StMuETofHeader() mStarToken( 0 ), mStarDaqCmdIn( 0 ), mStarTrgCmdIn( 0 ), - mEventStatusFlag( 0 ) + mEventStatusFlag( 0 ), + mMissMatchFlagVec( eTofConst::nGet4sInSystem, false ), + mGoodEventFlagVec( eTofConst::nCountersInSystem, false ) { mRocGdpbTs.clear(); mRocStarTs.clear(); - mMissMatchFlagVec = std::vector( eTofConst::nGet4sInSystem, false ); - mGoodEventFlagVec = std::vector( eTofConst::nCountersInSystem, false ); } @@ -49,12 +49,12 @@ StMuETofHeader::StMuETofHeader( const double& trgGdpbTime, const double& trgStar mStarToken( starToken ), mStarDaqCmdIn( starDaqCmdIn ), mStarTrgCmdIn( starTrgCmdIn ), - mEventStatusFlag( eventStatusFlag ) + mEventStatusFlag( eventStatusFlag ), + mMissMatchFlagVec( eTofConst::nGet4sInSystem, false ), + mGoodEventFlagVec( eTofConst::nCountersInSystem, false ) { setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); - mMissMatchFlagVec = std::vector( eTofConst::nGet4sInSystem, false ); - mGoodEventFlagVec = std::vector( eTofConst::nCountersInSystem, false ); } StMuETofHeader::StMuETofHeader( const double& trgGdpbTime, const double& trgStarTime, @@ -67,7 +67,8 @@ StMuETofHeader::StMuETofHeader( const double& trgGdpbTime, const double& trgStar mStarDaqCmdIn( starDaqCmdIn ), mStarTrgCmdIn( starTrgCmdIn ), mEventStatusFlag( eventStatusFlag ), - mMissMatchFlagVec( MissMatchFlagVec ) + mMissMatchFlagVec( MissMatchFlagVec ), + mGoodEventFlagVec( eTofConst::nCountersInSystem, false ) { setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); From c0e8a8ea57a2a52e9a7db1c8b1e9ed7953525b6c Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Fri, 29 Oct 2021 12:50:21 +0200 Subject: [PATCH 22/62] Changed default reference pulser setting in calib maker back to data base. Decremented etof collection ClassDef for real this time --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 5 ++--- StRoot/StEvent/StETofCollection.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index 7a1a901bdd8..f8488f75bcd 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -369,9 +369,8 @@ StETofCalibMaker::InitRun( Int_t runnumber ) mMinDigisPerSlewBin = calibParamTable->minDigisInSlewBin; // only set the reference pulser index if it is not alredy set from outside by a steering macro - if( mReferencePulserIndex == 0 ) { //REMOVED TO COMPILE AGAINST NEW. PW - //mReferencePulserIndex = calibParamTable->referencePulserIndex; - mReferencePulserIndex = 1; + if( mReferencePulserIndex == 0 ) { + mReferencePulserIndex = calibParamTable->referencePulserIndex; } else { LOG_INFO << "--- reference pulser index is set manually ---" << endm; diff --git a/StRoot/StEvent/StETofCollection.h b/StRoot/StEvent/StETofCollection.h index 7f6e3b9af30..9a5c360785b 100644 --- a/StRoot/StEvent/StETofCollection.h +++ b/StRoot/StEvent/StETofCollection.h @@ -59,7 +59,7 @@ class StETofCollection : public StObject { StSPtrVecETofHit mETofHits; - ClassDef( StETofCollection, 2 ) + ClassDef( StETofCollection, 1 ) }; #endif // STETOFCOLLECTION_H From 2e76f1efdb115bec1283ea9f9c78bddebd4495fc Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Tue, 9 Nov 2021 18:00:30 +0100 Subject: [PATCH 23/62] Moved reference pulser histogram creation outside of doQA flag. Fixing Issue #181 --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index f8488f75bcd..a7839cb74f5 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -2531,6 +2531,7 @@ StETofCalibMaker::bookHistograms() mHistograms[ "pulserDigiTimeDiff_GbtxCorrProf" ] = new TProfile( "pulserDigiTimeDiff_GbtxCorrProf", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, "s" ); mHistograms[ "pulserDigiTimeDiff_GbtxCorrProfMod" ] = new TProfile( "pulserDigiTimeDiff_GbtxCorrProfMod", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, "s" ); mHistograms[ "pulserDigiTimeDiff_fullCorr" ] = new TH2F( "pulserDigiTimeDiff_fullCorr", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); + mHistograms[ "pulserDigiTimeDiff_RefCorr" ] = new TH1F("pulserDigiTimeDiff_RefCorr", "time difference of pulsers to reference; #Delta T (ns)", 45, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 )); if( mDoQA ) { mHistograms[ "pulserDigiTimeDiff" ] = new TH2F( "pulserDigiTimeDiff", "time difference of pulsers to reference;pulser channel;#Delta T (ns)", 216, 0, 216, 360, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 ) ); @@ -2548,11 +2549,8 @@ StETofCalibMaker::bookHistograms() mHistograms[ "pulserDigiTimeDiff_CorrAgreement" ] = new TH1F("pulserDigiTimeDiff_CorrAgreement", "Number of pulsers agreeing on a common shift between events; #pulsers", 218, -0.5, 217.5); mHistograms[ "pulserDigiTimeDiff_CorrCommonJump" ] = new TH1F("pulserDigiTimeDiff_CorrCommonJump", "Number of pulsers jumping at the same time between events; #pulsers", 218, -0.5, 217.5); - mHistograms[ "pulserDigiPresence" ] = new TH1F( "pulserDigiPresence", "pulser presence (number of events at ( -1 );pulser channel", 218, -1.5, 216.5); - mHistograms[ "pulserDigiTimeDiff_RefCorr" ] = new TH1F("pulserDigiTimeDiff_RefCorr", "time difference of pulsers to reference; #Delta T (ns)", 45, -179.5 * ( 6.25 / 112 ), 180.5 * ( 6.25 / 112 )); - for( int i=0; i<12; i++ ) { std::string histName = "resetTimeDifferenceToSector" + to_string( i + 13 ); mHistograms[ histName ] = new TH2F( Form( "resetTimeDifferenceToSector%d", i + 13 ), Form("reset time difference to sector %d;sector;#DeltaT (clock ticks)", i + 13 ), 12, 12.5, 24.4, 5, -2.5, 2.5 ); From 8074c658529ff18ebaf49db5ec002218b2e0dd71 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff Date: Thu, 11 Nov 2021 23:13:30 +0100 Subject: [PATCH 24/62] fixed pulser presence histogram filling in online etofbuilder --- OnlTools/Jevp/StJevpBuilders/etofBuilder.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OnlTools/Jevp/StJevpBuilders/etofBuilder.cxx b/OnlTools/Jevp/StJevpBuilders/etofBuilder.cxx index 0200cce1517..c5ed909acdc 100644 --- a/OnlTools/Jevp/StJevpBuilders/etofBuilder.cxx +++ b/OnlTools/Jevp/StJevpBuilders/etofBuilder.cxx @@ -1261,7 +1261,7 @@ void etofBuilder::processMessages( uint64_t* messageBuffer, size_t nFullMessages } if( pulser.at( i ).size() > 1 ) LOG( DBG, "-->selected index: %d", index ); - if(index > 0) { // JML 1/30/21 FIX SIGABORT! + if(index >= 0) { // JML 1/30/21 FIX SIGABORT! PW 11/11/21 Fixed pulser histogram filling. pulserTimestamp[ i ] = pulser.at( i ).at( index ).GetFullTimeNs(); contents.nPulsersPerSide[ i / 18 ]->Fill( ( i % 18 ) ); } From 0fbfa84a61a15496361b13952e52ac523a377ed2 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Thu, 24 Mar 2022 10:21:18 -0400 Subject: [PATCH 25/62] Fixed calibmaker pulser correction to work without QA flag online --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index a7839cb74f5..8851364813a 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -1674,9 +1674,9 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u double referenceTime = 0.; // update reference time (for QA) + if( pulserTimes.count( mReferencePulserIndex ) ) { + referenceTime = pulserTimes.at( mReferencePulserIndex ); //only updated for QA?? needed to remove smeared pulsers if( mDoQA ) { - if( pulserTimes.count( mReferencePulserIndex ) ) { - referenceTime = pulserTimes.at( mReferencePulserIndex ); //only updated for QA?? needed to remove smeared pulsers if( mDebug ) { LOG_INFO << "preliminary reference time:" << referenceTime << endm; } From 0f7aa47a3f265c997317733a72c05ed639ee2473 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Thu, 24 Mar 2022 10:23:56 -0400 Subject: [PATCH 26/62] adjustment of nominal eTOF module positions to fit better with data --- StarVMC/Geometry/EtofGeo/EtofGeo0.xml | 93 ++++++++++++++------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/StarVMC/Geometry/EtofGeo/EtofGeo0.xml b/StarVMC/Geometry/EtofGeo/EtofGeo0.xml index 730c5b4a101..1d26cc6a518 100644 --- a/StarVMC/Geometry/EtofGeo/EtofGeo0.xml +++ b/StarVMC/Geometry/EtofGeo/EtofGeo0.xml @@ -37,7 +37,7 @@ - + @@ -60,151 +60,151 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -215,7 +215,7 @@ - + @@ -223,22 +223,23 @@ + - + - - + + - - + + - - + + @@ -549,4 +550,4 @@ - \ No newline at end of file + From 37d145deda0d422513e0e7a73a3e048be91cf968 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Wed, 6 Apr 2022 12:47:58 -0400 Subject: [PATCH 27/62] Revert "adjustment of nominal eTOF module positions to fit better with data" This reverts commit 0f7aa47a3f265c997317733a72c05ed639ee2473. --- StarVMC/Geometry/EtofGeo/EtofGeo0.xml | 93 +++++++++++++-------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/StarVMC/Geometry/EtofGeo/EtofGeo0.xml b/StarVMC/Geometry/EtofGeo/EtofGeo0.xml index 1d26cc6a518..730c5b4a101 100644 --- a/StarVMC/Geometry/EtofGeo/EtofGeo0.xml +++ b/StarVMC/Geometry/EtofGeo/EtofGeo0.xml @@ -37,7 +37,7 @@ - + @@ -60,151 +60,151 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -215,7 +215,7 @@ - + @@ -223,23 +223,22 @@ - - + - - + + - - + + - - + + @@ -550,4 +549,4 @@ - + \ No newline at end of file From 75c8710b1fce66187fe0d4e12d8d2d9f8a847bfd Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Thu, 5 May 2022 06:52:58 -0400 Subject: [PATCH 28/62] adjustments to eTOF counter positioning based on exact technical drawings --- StarVMC/Geometry/EtofGeo/EtofGeo0.xml | 93 ++++++++++++++------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/StarVMC/Geometry/EtofGeo/EtofGeo0.xml b/StarVMC/Geometry/EtofGeo/EtofGeo0.xml index 730c5b4a101..1d26cc6a518 100644 --- a/StarVMC/Geometry/EtofGeo/EtofGeo0.xml +++ b/StarVMC/Geometry/EtofGeo/EtofGeo0.xml @@ -37,7 +37,7 @@ - + @@ -60,151 +60,151 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -215,7 +215,7 @@ - + @@ -223,22 +223,23 @@ + - + - - + + - - + + - - + + @@ -549,4 +550,4 @@ - \ No newline at end of file + From 9a3a14c50dffe5f2c659bc1cf569853de1388c14 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Tue, 17 May 2022 07:49:03 -0400 Subject: [PATCH 29/62] first attempt to adapt genMuDst to eTOF --- StRoot/macros/mudst/genDst.C | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/StRoot/macros/mudst/genDst.C b/StRoot/macros/mudst/genDst.C index baa29b19849..e237e1c48c5 100644 --- a/StRoot/macros/mudst/genDst.C +++ b/StRoot/macros/mudst/genDst.C @@ -107,6 +107,14 @@ void loadLibsBTof() gSystem->Load("StBTofMatchMaker"); } +void loadLibsETof() +{ + gSystem->Load("StETofUtil"); + gSystem->Load("StETofCalibMaker"); + gSystem->Load("StETofHitMaker"); + gSystem->Load("StETofMatchMaker"); +} + void procGeoTag(TObjArray* optionTokens) { if (TClass::GetClass("AgBlock")) return; // arbitrarily chosen AgML class @@ -267,6 +275,18 @@ void genDst(unsigned int First, } + if (findAndRemoveOption("etofmatch",optionTokens)) { + + procGeoTag(optionTokens); + loadLibsETof(); + + // instantiate eTOF CalibMakers, HitMaker and MatchMaker + StETofCalibMaker* etofCalib = new StETofCalibMaker(); + StETofHitMaker* etofHit = new StETofHitMaker(); + StETofMatchMaker* etofMatch = new StETofMatchMaker(); + + } + if (findAndRemoveOption("mtdmatch",optionTokens)) { procGeoTag(optionTokens); @@ -432,6 +452,10 @@ void genDst(unsigned int Last, ///////////////////////////////////////////////////////////////////////////// // // $Log: genDst.C,v $ +// Revision 1.10 2022/05/12 07:16:56 weidenkaff +// Added eTOF support +// +// $Log: genDst.C,v $ // Revision 1.9 2020/10/10 07:16:56 genevb // Specify makers to set attributes // From 4e21db7122a15dfb1566bb047b2f6c0da894dd17 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Thu, 19 May 2022 08:01:49 -0400 Subject: [PATCH 30/62] switched geometry class to version readign local alignment files --- StRoot/StETofUtil/StETofGeometry.cxx | 172 ++++++++++++++++++++++----- StRoot/StETofUtil/StETofGeometry.h | 15 ++- 2 files changed, 155 insertions(+), 32 deletions(-) diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index 58c879a384f..e257bad5d58 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -30,12 +30,19 @@ * ***************************************************************************/ #include +#include +#include +#include #include "TGeoManager.h" +#include "TGeoNavigator.h" #include "TGeoVolume.h" #include "TGeoPhysicalNode.h" #include "TGeoMatrix.h" #include "TGeoBBox.h" +#include "TRotation.h" +#include "TMath.h" +#include "TFile.h" #include "StETofUtil/StETofGeometry.h" #include "StMessMgr.h" @@ -60,16 +67,7 @@ StETofNode::StETofNode( const TGeoPhysicalNode& gpNode ) { mGeoMatrix = static_cast< TGeoHMatrix* > ( gpNode.GetMatrix() ); - /* - double* trans = mGeoMatrix->GetTranslation(); - double* rot = mGeoMatrix->GetRotationMatrix(); - LOG_INFO << trans[0] << " " << trans[1] << " " << trans[2] << endm; - - LOG_INFO << rot[0] << " " << rot[1] << " " << rot[2] << endm; - LOG_INFO << rot[3] << " " << rot[4] << " " << rot[5] << endm; - LOG_INFO << rot[6] << " " << rot[7] << " " << rot[8] << endm; - */ mBox = static_cast< TGeoBBox* > ( gpNode.GetShape() ); buildMembers(); @@ -95,11 +93,53 @@ StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const f // resize mBox with dx and dy float dz = mBox->GetDZ(); - mBox->SetBoxDimensions( dx, dy, dz ); + mBox->SetBoxDimensions( dx, dy, dz ); buildMembers(); } +StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const StThreeVectorD alignment ) +: mSafetyMarginX( 0. ), + mSafetyMarginY( 0. ), + mDebug( false ) +{ + + mGeoMatrix = static_cast< TGeoHMatrix* > ( gpNode.GetMatrix() ); + + mBox = static_cast< TGeoBBox* > ( gpNode.GetShape() ); + + + + // resize mBox with dx and dy + float dz = mBox->GetDZ(); + mBox->SetBoxDimensions( dx, dy, dz ); + + // modified buildMembers() method. PW; + // build member variables: mMinEta, mMaxEta, mMinPhi, mMaxPhi, mCenter, mNormal + double xl[3] = { -alignment.x(), -alignment.y(), -alignment.z() }; +//z alignment is positive to reflect the correct direction in which z has to be moved in global coordinates. x and y are negative to match the numbers from hit-intersection + double xm[3]; + local2Master( xl, xm ); + mCenter = StThreeVectorD( xm[ 0 ], xm[ 1 ], xm[ 2 ] ); + mGeoMatrix->SetDx(xm[ 0 ]); + mGeoMatrix->SetDy(xm[ 1 ]); + mGeoMatrix->SetDz(xm[ 2 ]); + //correct counter rotation is implemented in .XML + + LOG_DEBUG << "StETofNode::Created physical node at: "<< xm[ 0 ]<<","<< xm[ 1 ]<<"," << xm[ 2 ]<<" with alignments: "<< alignment.x()<<","<< alignment.y()<<"," << alignment.z()<< endm;//debug PW. + + mNormal = calcXYPlaneNormal(); + + mEtaMin = calcEta( -1. ); + mEtaMax = calcEta( 1. ); + + mPhiMin = calcPhi( -1, -1. ); + mPhiMax = calcPhi( -1, 1. ); + + if( mDebug ) print(); + +// buildMembers(); +} void StETofNode::convertPos( StETofNode* from, const double* pos_from, StETofNode* to, double* pos_to ) @@ -135,7 +175,7 @@ StThreeVectorD StETofNode::calcCenterPos() { // calculate center position of the node in global coordinates - double xl[3] = { 0, 0, 0 }; + double xl[3] = { 0, 0, 0 }; //can change centers here, but might not change actual box dimensions double xm[3]; local2Master( xl, xm ); @@ -150,7 +190,7 @@ StETofNode::calcXYPlaneNormal() // calculate the normal vector to the local XY-plane // i.e. the global representation of the local unit vector (0,0,1) - double xl[ 3 ] = { 0, 0, 1 }; + double xl[ 3 ] = { 0, 0, 1 }; //change to x = 0.0227. PW. double xm[ 3 ]; // transform to global coordinates @@ -317,7 +357,7 @@ StETofNode::helixCross( const StPicoHelix& helix, double& pathLength, TVector3& // find intersection between helix & the node's XY-plane TVector3 center( mCenter.x(), mCenter.y(), mCenter.z() ); TVector3 normal( mNormal.x(), mNormal.y(), mNormal.z() ); - pathLength = helix.pathLength( center, normal ); + pathLength = helix.pathLength( center, normal ); //pathlength at the crossing with counter plane defined by counter center and normal vector if( pathLength > 0 && pathLength < maxPathLength ) { cross = helix.at( pathLength ); @@ -395,6 +435,16 @@ StETofGeomModule::addCounter( const TGeoPhysicalNode& gpNode, const float& dx, c mETofCounter.push_back( counter ); } +void +StETofGeomModule::addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins, const StThreeVectorD alignment ) +{ + StETofGeomCounter* counter = new StETofGeomCounter( gpNode, dx, dy, moduleId, counterId, alignment ); + + counter->setSafetyMargins( safetyMargins ); + + mETofCounter.push_back( counter ); +} + StETofGeomCounter* StETofGeomModule::counter( const unsigned int i ) const @@ -468,7 +518,6 @@ StETofGeomCounter::StETofGeomCounter( const TGeoPhysicalNode& gpNode, const int if( mDebug ) print(); } - StETofGeomCounter::StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId ) : StETofNode( gpNode, dx, dy ), mModuleIndex( moduleId ), @@ -483,6 +532,19 @@ StETofGeomCounter::StETofGeomCounter( const TGeoPhysicalNode& gpNode, const floa if( mDebug ) print(); } +StETofGeomCounter::StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const StThreeVectorD alignment ) +: StETofNode( gpNode, dx, dy, alignment ), + mModuleIndex( moduleId ), + mCounterIndex( counterId ), + mDebug( false ) +{ + mSector = calcSector( moduleId ); + mPlane = calcPlane( moduleId ); + + createGeomStrips(); + + if( mDebug ) print(); +} int StETofGeomCounter::calcSector( const int moduleId ) @@ -562,7 +624,8 @@ StETofGeometry::StETofGeometry( const char* name, const char* title ) mNValidModules( 0 ), mInitFlag( false ), mDebug( false ), - mStarBField( nullptr ) + mStarBField( nullptr ), + mFileNameAlignParam ("") { } @@ -600,6 +663,14 @@ StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins, cons mNValidModules = 0; + + if( mFileNameAlignParam != ""){ + readAlignmentParameters(); + } + + geoManager->AddNavigator(); + + int iCounterAlignment = 0; // loop over sectors for( int sector = eTofConst::sectorStart; sector <= eTofConst::sectorStop; sector++ ) { // loop over planes @@ -607,16 +678,13 @@ StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins, cons std::string geoPath( formTGeoPath( geoManager, plane, sector ) ); if( geoPath.empty() ) { - LOG_DEBUG << "StETofGeometry::Init(...) - cannot find path to ETOF module " + LOG_INFO << "StETofGeometry::Init(...) - cannot find path to ETOF module " "(id " << plane << sector << "). Skipping..." << endm; continue; } mNValidModules++; - const TGeoPhysicalNode* gpNode = geoManager->MakePhysicalNode( geoPath.c_str() ); - int moduleId = calcModuleIndex( sector, plane ); - mETofModule[ mNValidModules-1 ] = new StETofGeomModule( *gpNode, moduleId ); @@ -653,9 +721,12 @@ StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins, cons LOG_DEBUG << activeVolume->GetDX() << " " << activeVolume->GetDY() << " " << activeVolume->GetDZ() << endm; int counterId = counter - eTofConst::counterStart; - - mETofModule[ mNValidModules-1 ]->addCounter( *gpNode, dx, dy, moduleId, counterId, safetyMargins ); - + if( mAlignmentParameters.size() == 108 ){ //alignment parameters for all counters available + mETofModule[ mNValidModules-1 ]->addCounter( *gpNode, dx, dy, moduleId, counterId, safetyMargins, mAlignmentParameters.at(iCounterAlignment) ); + iCounterAlignment++; + }else{ + mETofModule[ mNValidModules-1 ]->addCounter( *gpNode, dx, dy, moduleId, counterId, safetyMargins ); + } } // end of loop over counters @@ -715,23 +786,19 @@ StETofGeometry::formTGeoPath( const TGeoManager* geoManager, int plane, int sect std::ostringstream geoPath; geoPath << "/HALL_1/CAVE_1/MagRefSys_1/ETOF_" << plane << sector; - bool found = geoManager->CheckPath( geoPath.str().c_str() ); - if( !found ) { geoPath.str(""); geoPath.clear(); geoPath << "/HALL_1/CAVE_1/ETOF_" << plane << sector; } - // go deeper if counter is requested if( counter >= 1 ) { geoPath << "/EGAS_1/ECOU_" << counter; } found = geoManager->CheckPath( geoPath.str().c_str() ); - return found ? geoPath.str() : ""; } @@ -832,6 +899,21 @@ StETofGeometry::findETofNode( const int moduleId, const int counterId ) return mETofModule[ iModule ]->counter( iCounter ); } +void +StETofGeometry::pointMaster2local( const int moduleId, const int counterId, const double* master, double* local ) +{ + local[ 0 ] = 0; + local[ 1 ] = 0; + local[ 2 ] = 0; + + if( !findETofNode( moduleId, counterId ) ) { + LOG_ERROR << "ETOF volume of a hit is not loaded in the geometry" << endl; + return; + } + + findETofNode( moduleId, counterId )->master2Local( master, local ); +} + void StETofGeometry::hitLocal2Master( const int moduleId, const int counterId, const double* local, double* master ) @@ -1435,8 +1517,6 @@ StETofGeometry::logPoint( const char* text, const TVector3& point ) LOG_INFO << text << " at (" << point.x() << ", " << point.y() << ", " << point.z() << ")" << endm; } - - StThreeVectorD StETofGeometry::getField( const StThreeVectorD& pos ) { if( !mStarBField ) { @@ -1488,4 +1568,38 @@ StETofGeometry::getFieldZ( const double& x, const double& y, const double& z ) { mStarBField->BField( X, B ); return B[ 2 ]; -} \ No newline at end of file +} + +void +StETofGeometry::readAlignmentParameters(){ + LOG_INFO << "etofAlignParam: filename provided --> use parameter file: " << mFileNameAlignParam.c_str() << endm; + + //add check for no alignment set here. + + ifstream paramFile; + paramFile.open( mFileNameAlignParam.c_str() ); + + if( !paramFile.is_open() ) { + LOG_INFO << "unable to get the alignments parameters from file --> file does not exist" << endm; + return; + } + + StThreeVectorD counterAlignmentParameter; + float tempX; + float tempY; + float tempZ; + while( paramFile >> tempX >> tempY >> tempZ ) { + counterAlignmentParameter = StThreeVectorD( tempX, tempY, tempZ ); + mAlignmentParameters.push_back( counterAlignmentParameter ); + } + + paramFile.close(); + + if( mAlignmentParameters.size() != 108 ) { + LOG_INFO << "parameter file for alignments has not the right amount of entries: "; + LOG_INFO << mAlignmentParameters.size() << " instead of 108 !!!!" << endm; + return; + } + +} + diff --git a/StRoot/StETofUtil/StETofGeometry.h b/StRoot/StETofUtil/StETofGeometry.h index c86cc7f339e..f16952a1d21 100644 --- a/StRoot/StETofUtil/StETofGeometry.h +++ b/StRoot/StETofUtil/StETofGeometry.h @@ -71,6 +71,7 @@ class StETofNode : public TObject { StETofNode( const TGeoPhysicalNode& gpNode ); StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy ); + StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const StThreeVectorD alignment ); void convertPos( StETofNode* from, const double* pos_from, StETofNode* to, double* pos_to ); @@ -167,6 +168,7 @@ class StETofGeomModule : public StETofNode { void addCounter( const TGeoPhysicalNode& gpNode, const int moduleId, const int counterId ); void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId ); void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins ); + void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins, const StThreeVectorD alignment ); StETofGeomCounter* counter( const unsigned int i ) const; @@ -227,7 +229,7 @@ class StETofGeomCounter : public StETofNode { StETofGeomCounter( const TGeoPhysicalNode& gpNode, const int moduleId, const int counterId ); StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId ); - + StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const StThreeVectorD alignment ); void createGeomStrips(); int findStrip( const double* local ); @@ -305,6 +307,7 @@ class StETofGeometry : public TNamed { StETofNode* findETofNode( const int moduleId, const int counter ); + void pointMaster2local( const int moduleId, const int counterId, const double* master, double* local ); void hitLocal2Master( const int moduleId, const int counter, const double* local, double* master ); StThreeVectorD hitLocal2Master( StETofHit* hit ); StThreeVectorD hitLocal2Master( StMuETofHit* hit ); @@ -359,6 +362,9 @@ class StETofGeometry : public TNamed { StETofGeomModule* module( const unsigned int i ); unsigned int nValidModules() const; + void readAlignmentParameters(); + void setFileNameAlignParam(std::string FileNameAlignParam); + void debugOn(); void debugOff(); bool isDebugOn() const; @@ -373,6 +379,9 @@ class StETofGeometry : public TNamed { StarMagField* mStarBField; + std::string mFileNameAlignParam; + std::vector mAlignmentParameters; + ClassDef( StETofGeometry, 1 ) }; @@ -387,7 +396,7 @@ inline void StETofGeometry::debugOn() { mDebug = true; } inline void StETofGeometry::debugOff() { mDebug = false; } inline bool StETofGeometry::isDebugOn() const { return mDebug; } +inline void StETofGeometry::setFileNameAlignParam(std::string FileNameAlignParam) {mFileNameAlignParam = FileNameAlignParam;} - -#endif /// STETOFGEOMETRY_H \ No newline at end of file +#endif /// STETOFGEOMETRY_H From e377952bc4cc0fad5634ef178d9a01ebccc4c986 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Mon, 30 May 2022 10:37:34 -0400 Subject: [PATCH 31/62] added alignment readout from database --- StRoot/StETofUtil/StETofGeometry.cxx | 54 ++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index e257bad5d58..936d2bc09dc 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -51,6 +51,8 @@ #include "StMuDSTMaker/COMMON/StMuETofHit.h" #include "StPicoEvent/StPicoETofHit.h" +#include "tables/St_etofAlign_Table.h" + #include "StarMagField.h" /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -641,18 +643,18 @@ void StETofGeometry::init( TGeoManager* geoManager ) { double safetyMargins[ 2 ] = { 0., 0. }; - init( geoManager, safetyMargins, false ); + init( NULL, geoManager, safetyMargins, false ); } void StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins ) { - init( geoManager, safetyMargins, false ); + init( NULL, geoManager, safetyMargins, false ); } void -StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins, const bool& useHelixSwimmer ) +StETofGeometry::init(StMaker* maker, TGeoManager* geoManager, const double* safetyMargins, const bool& useHelixSwimmer ) { if( !geoManager ) { LOG_ERROR << " *** StETofGeometry::Init - cannot find TGeoManager *** " << endm; @@ -666,6 +668,8 @@ StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins, cons if( mFileNameAlignParam != ""){ readAlignmentParameters(); + }else{ + readAlignmentDatabase(maker); } geoManager->AddNavigator(); @@ -1603,3 +1607,47 @@ StETofGeometry::readAlignmentParameters(){ } +void +StETofGeometry::readAlignmentDatabase(StMaker* maker){ + LOG_INFO << "No etof alignment file provided --> use database: " << endm; + + //add check for no alignment set here. + + TDataSet* dbDataSet = nullptr; + + if(!maker){ + LOG_WARN << "No valid pointer to any StMaker given. Do not load alignment from database" << endm; + return; + } + + dbDataSet = maker->GetDataBase( "Geometry / etof / etofAlign" ); + + St_etofAlign* etofAlign = static_cast< St_etofAlign * > ( dbDataSet->Find( "etofAlign" ) ); + if( !etofAlign ) { + LOG_ERROR << "unable to get the align params from the database" << endm; + return; + } + + etofAlign_st* table = etofAlign->GetTable(); + StThreeVectorD counterAlignmentParameter; + float tempX; + float tempY; + float tempZ; + + for( int iCounter = 0; iCounter < eTofConst::nCounters; iCounter++){ + tempX = table[iCounter].detectorAlignX[0]; + tempY = table[iCounter].detectorAlignY[0]; + tempZ = table[iCounter].detectorAlignZ[0]; + StThreeVectorD counterAlignmentParameter = StThreeVectorD( tempX, tempY, tempZ ); + mAlignmentParameters.push_back( counterAlignmentParameter ); + } + + if( mAlignmentParameters.size() != 108 ) { + LOG_WARN << "parameter vector for alignments has not the right amount of entries: "; + LOG_WARN << mAlignmentParameters.size() << " instead of 108 !!!!" << endm; + return; + }else{ + return; + } +} + From 46e493549596998f1b699c19a1412203ae321b56 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Mon, 30 May 2022 10:37:42 -0400 Subject: [PATCH 32/62] added alignment readout from database --- StRoot/StETofUtil/StETofGeometry.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/StRoot/StETofUtil/StETofGeometry.h b/StRoot/StETofUtil/StETofGeometry.h index f16952a1d21..0857b189856 100644 --- a/StRoot/StETofUtil/StETofGeometry.h +++ b/StRoot/StETofUtil/StETofGeometry.h @@ -47,6 +47,8 @@ #include "StETofUtil/StETofConstants.h" +#include "StMaker.h" + class TNamed; class StETofHit; @@ -288,9 +290,9 @@ class StETofGeometry : public TNamed { StETofGeometry( const char* name = "etofGeo", const char* title = "simplified ETOF Geometry" ); ~StETofGeometry(); - void init( TGeoManager* geoManager ); - void init( TGeoManager* geoManager, const double* safetyMargins ); - void init( TGeoManager* geoManager, const double* safetyMargins, const bool& useHelixSwimmer ); + void init( TGeoManager* geoManager ); //does not load alignment from local file or database + void init( TGeoManager* geoManager, const double* safetyMargins ); //does not load alignment from local file or database + void init( StMaker* maker, TGeoManager* geoManager, const double* safetyMargins, const bool& useHelixSwimmer ); void reset(); @@ -363,6 +365,7 @@ class StETofGeometry : public TNamed { unsigned int nValidModules() const; void readAlignmentParameters(); + void readAlignmentDatabase(StMaker* maker); void setFileNameAlignParam(std::string FileNameAlignParam); void debugOn(); From 093dac27cc4ed71c9be1133daba88f33f9f838cb Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Mon, 30 May 2022 10:39:36 -0400 Subject: [PATCH 33/62] added geometry alignment readout from file and database. Now searches for MuDsts if StEvents without StEtofCollection is found (needed for genDst.C) --- StRoot/StETofMatchMaker/StETofMatchMaker.cxx | 26 +++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx index 86bfcbacb14..5d05ee9759e 100644 --- a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx +++ b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx @@ -311,7 +311,7 @@ StETofMatchMaker::InitRun( Int_t runnumber ) LOG_DEBUG << " gGeoManager: " << gGeoManager << endm; - mETofGeom->init( gGeoManager, etofProjection::safetyMargins, mUseHelixSwimmer ); + mETofGeom->init( (StMaker*)this, gGeoManager, etofProjection::safetyMargins, mUseHelixSwimmer ); //provide backline to initiating maker to load DB tables } if( mDoQA ) { @@ -394,13 +394,31 @@ StETofMatchMaker::Make() mIsMuDstIn = false; mEvent = ( StEvent* ) GetInputDS( "StEvent" ); + // mEvent = NULL; //don't check for StEvent for genDst.C testing. PW if ( mEvent ) { LOG_DEBUG << "Make() - running on StEvent" << endm; - mIsStEventIn = true; + StETofCollection* etofCollection = mEvent->etofCollection(); - cleanUpTraits(); + if( !etofCollection ) { //additional check for empty StEvents structures produced by other Makers. Needed for genDst.C + LOG_WARN << "Make() - Found StEvent data structure, but no eTOF collection. Try MuDst processing instead" << endm; + mMuDst = ( StMuDst* ) GetInputDS( "MuDst" ); + + if( mMuDst ) { + LOG_DEBUG << "Make() - running on MuDsts" << endm; + + mIsMuDstIn = true; + + fillIndexToPrimaryMap(); + + cleanUpTraits(); + } + }else{ + mIsStEventIn = true; + + cleanUpTraits(); + } } else { LOG_DEBUG << "Make(): no StEvent found" << endm; @@ -3016,4 +3034,4 @@ ETofTrack::ETofTrack( const StMuTrack* mutrack ) if ( phi < 0. ) phi += 2. * M_PI; } -} \ No newline at end of file +} From f778235e18b42ce1f547a253c2afd4ccd600cb84 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Mon, 30 May 2022 10:40:05 -0400 Subject: [PATCH 34/62] Now searches for MuDsts if StEvents without StEtofCollection is found (needed for genDst.C) --- StRoot/StETofHitMaker/StETofHitMaker.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/StRoot/StETofHitMaker/StETofHitMaker.cxx b/StRoot/StETofHitMaker/StETofHitMaker.cxx index 3b94e234c46..926da3890d5 100644 --- a/StRoot/StETofHitMaker/StETofHitMaker.cxx +++ b/StRoot/StETofHitMaker/StETofHitMaker.cxx @@ -306,9 +306,24 @@ StETofHitMaker::Make() LOG_DEBUG << "StETofHitMaker::Make(): starting ..." << endm; mEvent = ( StEvent* ) GetInputDS( "StEvent" ); + // mEvent = NULL; //don't check for StEvent for genDst.C testing. PW if ( mEvent ) { LOG_DEBUG << "Make() - running on StEvent" << endm; + StETofCollection* etofCollection = mEvent->etofCollection(); + + if( !etofCollection ) { //additional check for empty StEvents structures produced by other Makers. Needed for genDst.C + LOG_WARN << "Make() - Found StEvent data structure, but no eTOF collection. Try MuDst processing instead" << endm; + mMuDst = ( StMuDst* ) GetInputDS( "MuDst" ); + + if( mMuDst ) { + LOG_DEBUG << "Make() - running on MuDsts" << endm; + + processMuDst(); + + return kStOk; + } + } processStEvent(); From 3ce3837f6a09cbaa90148278726992760e608267 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Mon, 30 May 2022 10:40:24 -0400 Subject: [PATCH 35/62] Now searches for MuDsts if StEvents without StEtofCollection is found (needed for genDst.C) --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 21 ++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index 8851364813a..d2f1c79c9cf 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -1100,15 +1100,32 @@ StETofCalibMaker::Make() { LOG_DEBUG << "StETofCalibMaker::Make(): starting ..." << endm; - mEvent = ( StEvent* ) GetInputDS( "StEvent" ); + //mEvent = ( StEvent* ) GetInputDS( "StEvent" ); + mEvent = NULL; //don't check for StEvent for genDst.C testing. PW if ( mEvent ) { LOG_DEBUG << "Make(): running on StEvent" << endm; + StETofCollection* etofCollection = mEvent->etofCollection(); + + if( !etofCollection ) { //additional check for empty StEvents structures produced by other Makers. Needed for genDst.C + LOG_WARN << "Make() - Found StEvent data structure, but no eTOF collection. Try MuDst processing instead" << endm; + mMuDst = ( StMuDst* ) GetInputDS( "MuDst" ); + + if( mMuDst ) { + LOG_DEBUG << "Make() - running on MuDsts" << endm; + + processMuDst(); + + return kStOk; + } + } + processStEvent(); - + return kStOk; } + else { LOG_DEBUG << "Make(): no StEvent found" << endm; From 475b3a4b33a3bfd1a8d1882d3cb20bec92de6031 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Mon, 6 Jun 2022 16:10:20 -0400 Subject: [PATCH 36/62] code clean-up in StETofGeometry.cxx --- StRoot/StETofUtil/StETofGeometry.cxx | 34 +--------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index 936d2bc09dc..ba897f18f93 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -31,8 +31,6 @@ ***************************************************************************/ #include #include -#include -#include #include "TGeoManager.h" #include "TGeoNavigator.h" @@ -41,8 +39,6 @@ #include "TGeoMatrix.h" #include "TGeoBBox.h" #include "TRotation.h" -#include "TMath.h" -#include "TFile.h" #include "StETofUtil/StETofGeometry.h" #include "StMessMgr.h" @@ -81,16 +77,6 @@ StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const f mDebug( false ) { mGeoMatrix = static_cast< TGeoHMatrix* > ( gpNode.GetMatrix() ); - /* - double* trans = mGeoMatrix->GetTranslation(); - double* rot = mGeoMatrix->GetRotationMatrix(); - - LOG_INFO << trans[0] << " " << trans[1] << " " << trans[2] << endm; - - LOG_INFO << rot[0] << " " << rot[1] << " " << rot[2] << endm; - LOG_INFO << rot[3] << " " << rot[4] << " " << rot[5] << endm; - LOG_INFO << rot[6] << " " << rot[7] << " " << rot[8] << endm; - */ mBox = static_cast< TGeoBBox* > ( gpNode.GetShape() ); // resize mBox with dx and dy @@ -110,8 +96,6 @@ StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const f mBox = static_cast< TGeoBBox* > ( gpNode.GetShape() ); - - // resize mBox with dx and dy float dz = mBox->GetDZ(); mBox->SetBoxDimensions( dx, dy, dz ); @@ -140,7 +124,6 @@ StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const f if( mDebug ) print(); -// buildMembers(); } void @@ -198,15 +181,6 @@ StETofNode::calcXYPlaneNormal() // transform to global coordinates local2Master( xl, xm ); - // subtract vector pointing to the center - /* - xm[ 0 ] -= mGeoMatrix->GetTranslation()[ 0 ]; - xm[ 1 ] -= mGeoMatrix->GetTranslation()[ 1 ]; - xm[ 2 ] -= mGeoMatrix->GetTranslation()[ 2 ]; - - return StThreeVectorD( xm[ 0 ], xm[ 1 ], xm[ 2 ] ); - */ - StThreeVectorD norm( xm[ 0 ], xm[ 1 ], xm[ 2 ] ); // subtract vector pointing to the center @@ -1642,12 +1616,6 @@ StETofGeometry::readAlignmentDatabase(StMaker* maker){ mAlignmentParameters.push_back( counterAlignmentParameter ); } - if( mAlignmentParameters.size() != 108 ) { - LOG_WARN << "parameter vector for alignments has not the right amount of entries: "; - LOG_WARN << mAlignmentParameters.size() << " instead of 108 !!!!" << endm; - return; - }else{ - return; - } + return; } From e15cf619c56c6ff9550a24778e7d76faee1822fa Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Thu, 9 Jun 2022 07:41:17 -0400 Subject: [PATCH 37/62] further code clean-up in StEtofGeometry.C --- StRoot/StETofUtil/StETofGeometry.cxx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index ba897f18f93..5e57012d95c 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -33,12 +33,10 @@ #include #include "TGeoManager.h" -#include "TGeoNavigator.h" #include "TGeoVolume.h" #include "TGeoPhysicalNode.h" #include "TGeoMatrix.h" #include "TGeoBBox.h" -#include "TRotation.h" #include "StETofUtil/StETofGeometry.h" #include "StMessMgr.h" @@ -175,7 +173,7 @@ StETofNode::calcXYPlaneNormal() // calculate the normal vector to the local XY-plane // i.e. the global representation of the local unit vector (0,0,1) - double xl[ 3 ] = { 0, 0, 1 }; //change to x = 0.0227. PW. + double xl[ 3 ] = { 0, 0, 1 }; double xm[ 3 ]; // transform to global coordinates @@ -646,7 +644,7 @@ StETofGeometry::init(StMaker* maker, TGeoManager* geoManager, const double* safe readAlignmentDatabase(maker); } - geoManager->AddNavigator(); + //geoManager->AddNavigator(); int iCounterAlignment = 0; // loop over sectors @@ -718,7 +716,7 @@ StETofGeometry::init(StMaker* maker, TGeoManager* geoManager, const double* safe if( useHelixSwimmer ) { // get magnetic field map if( !StarMagField::Instance() ) { - LOG_INFO << " no StMagField available ... " << endl; + LOG_INFO << " no StMagField available ... " << endm; } else { mStarBField = StarMagField::Instance(); @@ -885,7 +883,7 @@ StETofGeometry::pointMaster2local( const int moduleId, const int counterId, cons local[ 2 ] = 0; if( !findETofNode( moduleId, counterId ) ) { - LOG_ERROR << "ETOF volume of a hit is not loaded in the geometry" << endl; + LOG_ERROR << "ETOF volume of a hit is not loaded in the geometry" << endm; return; } @@ -901,7 +899,7 @@ StETofGeometry::hitLocal2Master( const int moduleId, const int counterId, const master[ 2 ] = 0; if( !findETofNode( moduleId, counterId ) ) { - LOG_ERROR << "ETOF volume of a hit is not loaded in the geometry" << endl; + LOG_ERROR << "ETOF volume of a hit is not loaded in the geometry" << endm; return; } @@ -920,7 +918,7 @@ StETofGeometry::hitLocal2Master( StETofHit* hit ) int counterId = hit->counter() - 1; if( !findETofNode( moduleId, counterId ) ) { - LOG_ERROR << "ETOF volume of a hit is not loaded in the geometry" << endl; + LOG_ERROR << "ETOF volume of a hit is not loaded in the geometry" << endm; return StThreeVectorD( 0., 0., 0. ); } @@ -948,7 +946,7 @@ StETofGeometry::hitLocal2Master( StPicoETofHit* hit ) int counterId = hit->counter() - 1; if( !findETofNode( moduleId, counterId ) ) { - LOG_ERROR << "ETOF volume of a hit is not loaded in the geometry" << endl; + LOG_ERROR << "ETOF volume of a hit is not loaded in the geometry" << endm; return TVector3( 0., 0., 0. ); } @@ -1550,12 +1548,12 @@ StETofGeometry::getFieldZ( const double& x, const double& y, const double& z ) { void StETofGeometry::readAlignmentParameters(){ - LOG_INFO << "etofAlignParam: filename provided --> use parameter file: " << mFileNameAlignParam.c_str() << endm; + LOG_INFO << "etofAlignParam: filename provided --> use parameter file: " << mFileNameAlignParam << endm; //add check for no alignment set here. ifstream paramFile; - paramFile.open( mFileNameAlignParam.c_str() ); + paramFile.open( mFileNameAlignParam ); if( !paramFile.is_open() ) { LOG_INFO << "unable to get the alignments parameters from file --> file does not exist" << endm; From 6dc29ef66eb5d881eac5e7d6753a07283e15a1c6 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Thu, 9 Jun 2022 07:43:40 -0400 Subject: [PATCH 38/62] Fixed bug where StEvent pointer was commented out --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index d2f1c79c9cf..c874976005c 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -1100,8 +1100,8 @@ StETofCalibMaker::Make() { LOG_DEBUG << "StETofCalibMaker::Make(): starting ..." << endm; - //mEvent = ( StEvent* ) GetInputDS( "StEvent" ); - mEvent = NULL; //don't check for StEvent for genDst.C testing. PW + mEvent = ( StEvent* ) GetInputDS( "StEvent" ); + //mEvent = NULL; //don't check for StEvent for genDst.C testing. PW if ( mEvent ) { LOG_DEBUG << "Make(): running on StEvent" << endm; From a21d08a80ef3fbe9ac51e38bcc6a386967b634ad Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff <36641002+PhilippWeidenkaff@users.noreply.github.com> Date: Thu, 9 Jun 2022 16:38:45 +0200 Subject: [PATCH 39/62] Update StRoot/StETofUtil/StETofGeometry.cxx Co-authored-by: Dmitri Smirnov --- StRoot/StETofUtil/StETofGeometry.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index 5e57012d95c..fd8b77a67ca 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -638,7 +638,7 @@ StETofGeometry::init(StMaker* maker, TGeoManager* geoManager, const double* safe mNValidModules = 0; - if( mFileNameAlignParam != ""){ + if ( !mFileNameAlignParam.empty() ) { readAlignmentParameters(); }else{ readAlignmentDatabase(maker); From b0d013b6e1c4f5808eda47267f390fe2baa807c4 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff <36641002+PhilippWeidenkaff@users.noreply.github.com> Date: Thu, 9 Jun 2022 16:44:26 +0200 Subject: [PATCH 40/62] Update StRoot/StETofUtil/StETofGeometry.cxx Co-authored-by: Dmitri Smirnov --- StRoot/StETofUtil/StETofGeometry.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index fd8b77a67ca..1347f7677fe 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -79,7 +79,7 @@ StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const f // resize mBox with dx and dy float dz = mBox->GetDZ(); - mBox->SetBoxDimensions( dx, dy, dz ); + mBox->SetBoxDimensions( dx, dy, dz ); buildMembers(); } From 88a9d4d535e857c8fd377e458c3767cc480c9023 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff <36641002+PhilippWeidenkaff@users.noreply.github.com> Date: Thu, 9 Jun 2022 16:44:36 +0200 Subject: [PATCH 41/62] Update StRoot/StETofUtil/StETofGeometry.cxx Co-authored-by: Dmitri Smirnov --- StRoot/StETofUtil/StETofGeometry.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index 1347f7677fe..6608f40fe59 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -644,8 +644,6 @@ StETofGeometry::init(StMaker* maker, TGeoManager* geoManager, const double* safe readAlignmentDatabase(maker); } - //geoManager->AddNavigator(); - int iCounterAlignment = 0; // loop over sectors for( int sector = eTofConst::sectorStart; sector <= eTofConst::sectorStop; sector++ ) { From 9937a23a0163ae44b8298413991fe4174cadaa6e Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff <36641002+PhilippWeidenkaff@users.noreply.github.com> Date: Thu, 9 Jun 2022 16:45:17 +0200 Subject: [PATCH 42/62] Update StRoot/StETofUtil/StETofGeometry.cxx Co-authored-by: Dmitri Smirnov --- StRoot/StETofUtil/StETofGeometry.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index 6608f40fe59..3082932c830 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -1590,7 +1590,7 @@ StETofGeometry::readAlignmentDatabase(StMaker* maker){ return; } - dbDataSet = maker->GetDataBase( "Geometry / etof / etofAlign" ); + dbDataSet = StMaker::GetChain()->GetDataBase("Geometry/etof/etofAlign"); St_etofAlign* etofAlign = static_cast< St_etofAlign * > ( dbDataSet->Find( "etofAlign" ) ); if( !etofAlign ) { From 4b6766d927ccbd970463f19a62d87e7642fa8151 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff <36641002+PhilippWeidenkaff@users.noreply.github.com> Date: Thu, 9 Jun 2022 16:45:23 +0200 Subject: [PATCH 43/62] Update StRoot/StETofUtil/StETofGeometry.cxx Co-authored-by: Dmitri Smirnov --- StRoot/StETofUtil/StETofGeometry.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index 3082932c830..5f7e58b6698 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -1611,7 +1611,5 @@ StETofGeometry::readAlignmentDatabase(StMaker* maker){ StThreeVectorD counterAlignmentParameter = StThreeVectorD( tempX, tempY, tempZ ); mAlignmentParameters.push_back( counterAlignmentParameter ); } - - return; } From ee6d03046462db7e03646d4ba412a88bd6b1cbe5 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Thu, 9 Jun 2022 12:48:16 -0400 Subject: [PATCH 44/62] Removed database initialsation from StMaker in StEtofGeometry.cxx and adjusted Matchmaker accordingly. Changed behavior of overloaded init() function in StEtofGeometry to load database alignmnet in any case. --- StRoot/StETofMatchMaker/StETofMatchMaker.cxx | 2 +- StRoot/StETofUtil/StETofGeometry.cxx | 15 +++++---------- StRoot/StETofUtil/StETofGeometry.h | 8 ++++---- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx index 5d05ee9759e..1aa9ad11625 100644 --- a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx +++ b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx @@ -311,7 +311,7 @@ StETofMatchMaker::InitRun( Int_t runnumber ) LOG_DEBUG << " gGeoManager: " << gGeoManager << endm; - mETofGeom->init( (StMaker*)this, gGeoManager, etofProjection::safetyMargins, mUseHelixSwimmer ); //provide backline to initiating maker to load DB tables + mETofGeom->init( gGeoManager, etofProjection::safetyMargins, mUseHelixSwimmer ); //provide backline to initiating maker to load DB tables } if( mDoQA ) { diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index 5f7e58b6698..bb9447394fe 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -615,18 +615,18 @@ void StETofGeometry::init( TGeoManager* geoManager ) { double safetyMargins[ 2 ] = { 0., 0. }; - init( NULL, geoManager, safetyMargins, false ); + init( geoManager, safetyMargins, false ); } void StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins ) { - init( NULL, geoManager, safetyMargins, false ); + init( geoManager, safetyMargins, false ); } void -StETofGeometry::init(StMaker* maker, TGeoManager* geoManager, const double* safetyMargins, const bool& useHelixSwimmer ) +StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins, const bool& useHelixSwimmer ) { if( !geoManager ) { LOG_ERROR << " *** StETofGeometry::Init - cannot find TGeoManager *** " << endm; @@ -641,7 +641,7 @@ StETofGeometry::init(StMaker* maker, TGeoManager* geoManager, const double* safe if ( !mFileNameAlignParam.empty() ) { readAlignmentParameters(); }else{ - readAlignmentDatabase(maker); + readAlignmentDatabase(); } int iCounterAlignment = 0; @@ -1578,18 +1578,13 @@ StETofGeometry::readAlignmentParameters(){ } void -StETofGeometry::readAlignmentDatabase(StMaker* maker){ +StETofGeometry::readAlignmentDatabase(){ LOG_INFO << "No etof alignment file provided --> use database: " << endm; //add check for no alignment set here. TDataSet* dbDataSet = nullptr; - if(!maker){ - LOG_WARN << "No valid pointer to any StMaker given. Do not load alignment from database" << endm; - return; - } - dbDataSet = StMaker::GetChain()->GetDataBase("Geometry/etof/etofAlign"); St_etofAlign* etofAlign = static_cast< St_etofAlign * > ( dbDataSet->Find( "etofAlign" ) ); diff --git a/StRoot/StETofUtil/StETofGeometry.h b/StRoot/StETofUtil/StETofGeometry.h index 0857b189856..b0e6d1ff608 100644 --- a/StRoot/StETofUtil/StETofGeometry.h +++ b/StRoot/StETofUtil/StETofGeometry.h @@ -290,9 +290,9 @@ class StETofGeometry : public TNamed { StETofGeometry( const char* name = "etofGeo", const char* title = "simplified ETOF Geometry" ); ~StETofGeometry(); - void init( TGeoManager* geoManager ); //does not load alignment from local file or database - void init( TGeoManager* geoManager, const double* safetyMargins ); //does not load alignment from local file or database - void init( StMaker* maker, TGeoManager* geoManager, const double* safetyMargins, const bool& useHelixSwimmer ); + void init( TGeoManager* geoManager ); + void init( TGeoManager* geoManager, const double* safetyMargins ); + void init( TGeoManager* geoManager, const double* safetyMargins, const bool& useHelixSwimmer ); void reset(); @@ -365,7 +365,7 @@ class StETofGeometry : public TNamed { unsigned int nValidModules() const; void readAlignmentParameters(); - void readAlignmentDatabase(StMaker* maker); + void readAlignmentDatabase(); void setFileNameAlignParam(std::string FileNameAlignParam); void debugOn(); From 92f55d147a5623c1666ed0b02abe5be04279eab2 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Fri, 10 Jun 2022 06:46:32 -0400 Subject: [PATCH 45/62] Exchanged order of MuDst/StEvent checks in StEtofCalibMaker::CalculatePulserOffsets to avaoid crash on empty StEvent --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 31 ++++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index c874976005c..d389aaadae3 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -1360,11 +1360,11 @@ StETofCalibMaker::processMuDst() }*/ size_t nDigis = mMuDst->numberOfETofDigi(); - //LOG_INFO << "processMuDst() - # fired eTOF digis : " << nDigis << endm; + LOG_INFO << "processMuDst() - # fired eTOF digis : " << nDigis << endm; mTriggerTime = triggerTime( ( StETofHeader* ) etofHeader ); mResetTime = fmod( resetTime( ( StETofHeader* ) etofHeader ), eTofConst::bTofClockCycle ); - //LOG_INFO << "created pulser digi map" << endm; + LOG_INFO << "created pulser digi map" << endm; std::map< unsigned int, std::vector< unsigned int >> pulserCandMap; /// first loop over digis to apply hardware mappping and find the pulsers @@ -1395,6 +1395,7 @@ StETofCalibMaker::processMuDst() //LOG_INFO << "size of pulserCandMap: " << pulserCandMap.size() << endm; calculatePulserOffsets( pulserCandMap ); + LOG_INFO << "still alive" << endm; // collect status bit information and fill good event flag for 2020+ data TClass* headerClass = etofHeader->IsA(); @@ -1596,6 +1597,7 @@ StETofCalibMaker::flagPulserDigis( StETofDigi* aDigi, unsigned int index, std::m void StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< unsigned int > >& pulserDigiMap ) { + LOG_INFO << "calculating pulser offsets" << endm; if( mDebug ) { for( auto it=pulserDigiMap.begin(); it!=pulserDigiMap.end(); it++ ) { LOG_DEBUG << "channel: " << it->first << " nCandidates: " << it->second.size() << endm; @@ -1613,7 +1615,6 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u LOG_INFO << "reference pulser index: " << mReferencePulserIndex << endm; } - std::map< int, double > pulserTimes; mNPulsersCounter.clear(); mPulserPresent.clear(); //clear map of present pulsers in each event @@ -1631,15 +1632,13 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u for( size_t j=0; jsecond.size(); j++ ) { double pulserTime = 0.; double pulserTot = 0.; - if( mEvent ) { - pulserTime = ( mEvent->etofCollection()->etofDigis() )[ it->second.at( j ) ]->rawTime(); - pulserTot = ( mEvent->etofCollection()->etofDigis() )[ it->second.at( j ) ]->rawTot(); - } - else if( mMuDst ) { + if( mMuDst ) { pulserTime = mMuDst->etofDigi( it->second.at( j ) )->rawTime(); pulserTot = mMuDst->etofDigi( it->second.at( j ) )->rawTot(); + } else if( mEvent ) { + pulserTime = ( mEvent->etofCollection()->etofDigis() )[ it->second.at( j ) ]->rawTime(); + pulserTot = ( mEvent->etofCollection()->etofDigis() )[ it->second.at( j ) ]->rawTot(); } - double timeToTrigger = pulserTime - mTriggerTime; double totToPeak = pulserTot - mPulserPeakTot.at( sideIndex ); @@ -1660,18 +1659,18 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u } double pulserTime = 0.; - if( mEvent ) { + + if( mMuDst ) { + pulserTime = mMuDst->etofDigi( it->second.at( candIndex ) )->rawTime(); + + // set calibTot to -999. to exclude it from being calibrated in the next step --> pulser will not be used to build hits + mMuDst->etofDigi( it->second.at( candIndex ) )->setCalibTot( -999. ); + } else if( mEvent ) { pulserTime = ( mEvent->etofCollection()->etofDigis() )[ it->second.at( candIndex ) ]->rawTime(); // set calibTot to -999. to exclude it from being calibrated in the next step --> pulser will not be used to build hits mEvent->etofCollection()->etofDigis() [ it->second.at( candIndex ) ]->setCalibTot( -999. ); } - else if( mMuDst ) { - pulserTime = mMuDst->etofDigi( it->second.at( candIndex ) )->rawTime(); - - // set calibTot to -999. to exclude it from being calibrated in the next step --> pulser will not be used to build hits - mMuDst->etofDigi( it->second.at( candIndex ) )->setCalibTot( -999. ); - } pulserTimes[ sideIndex ] = pulserTime; From 02c45674e74a5762353e80c8c1ed6501acbc14ff Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Mon, 13 Jun 2022 10:16:51 -0400 Subject: [PATCH 46/62] Removed StMaker pointer for database table loading --- StRoot/StETofUtil/StETofGeometry.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/StRoot/StETofUtil/StETofGeometry.h b/StRoot/StETofUtil/StETofGeometry.h index b0e6d1ff608..2d202ad5656 100644 --- a/StRoot/StETofUtil/StETofGeometry.h +++ b/StRoot/StETofUtil/StETofGeometry.h @@ -47,8 +47,6 @@ #include "StETofUtil/StETofConstants.h" -#include "StMaker.h" - class TNamed; class StETofHit; From 51c48ddd284ec306f9c8c673a3dc5de28d2dbb88 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Mon, 13 Jun 2022 10:54:45 -0400 Subject: [PATCH 47/62] reintroduced StMaker include for StMaker::GetChain() in StEtofGeometry.cxx --- StRoot/StETofUtil/StETofGeometry.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index bb9447394fe..84e3363e7ca 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -49,6 +49,8 @@ #include "StarMagField.h" +#include "StMaker.h" + /////////////////////////////////////////////////////////////////////////////////////////////////// // // StETofNode From 4a82d6a48532cca9dd357de8a7011e9182f09aa0 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Mon, 13 Jun 2022 10:59:43 -0400 Subject: [PATCH 48/62] log cleanup in StEtofCalibMaker --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index d389aaadae3..368c4912f3c 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -1364,7 +1364,6 @@ StETofCalibMaker::processMuDst() mTriggerTime = triggerTime( ( StETofHeader* ) etofHeader ); mResetTime = fmod( resetTime( ( StETofHeader* ) etofHeader ), eTofConst::bTofClockCycle ); - LOG_INFO << "created pulser digi map" << endm; std::map< unsigned int, std::vector< unsigned int >> pulserCandMap; /// first loop over digis to apply hardware mappping and find the pulsers @@ -1395,7 +1394,6 @@ StETofCalibMaker::processMuDst() //LOG_INFO << "size of pulserCandMap: " << pulserCandMap.size() << endm; calculatePulserOffsets( pulserCandMap ); - LOG_INFO << "still alive" << endm; // collect status bit information and fill good event flag for 2020+ data TClass* headerClass = etofHeader->IsA(); @@ -1597,7 +1595,6 @@ StETofCalibMaker::flagPulserDigis( StETofDigi* aDigi, unsigned int index, std::m void StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< unsigned int > >& pulserDigiMap ) { - LOG_INFO << "calculating pulser offsets" << endm; if( mDebug ) { for( auto it=pulserDigiMap.begin(); it!=pulserDigiMap.end(); it++ ) { LOG_DEBUG << "channel: " << it->first << " nCandidates: " << it->second.size() << endm; From 2855f859637319d10a2a897c9b80e89bb3eabb55 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff <36641002+PhilippWeidenkaff@users.noreply.github.com> Date: Tue, 14 Jun 2022 13:19:53 +0200 Subject: [PATCH 49/62] Update StRoot/StETofUtil/StETofGeometry.h Co-authored-by: Dmitri Smirnov --- StRoot/StETofUtil/StETofGeometry.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StRoot/StETofUtil/StETofGeometry.h b/StRoot/StETofUtil/StETofGeometry.h index 2d202ad5656..54f93c3e000 100644 --- a/StRoot/StETofUtil/StETofGeometry.h +++ b/StRoot/StETofUtil/StETofGeometry.h @@ -397,7 +397,7 @@ inline void StETofGeometry::debugOn() { mDebug = true; } inline void StETofGeometry::debugOff() { mDebug = false; } inline bool StETofGeometry::isDebugOn() const { return mDebug; } -inline void StETofGeometry::setFileNameAlignParam(std::string FileNameAlignParam) {mFileNameAlignParam = FileNameAlignParam;} +inline void StETofGeometry::setFileNameAlignParam(std::string fileNameAlignParam) {mFileNameAlignParam = fileNameAlignParam;} #endif /// STETOFGEOMETRY_H From 09ce873266e2808de3ce59091b6c7396857cefef Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Thu, 16 Jun 2022 08:29:25 -0400 Subject: [PATCH 50/62] changed function overloads where possible to defaulted args in StEtofGeometry.cxx. Removed all event-level log_info print-outs from eTOF Makers. --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 2 +- StRoot/StETofHitMaker/StETofHitMaker.cxx | 14 ++++----- StRoot/StETofMatchMaker/StETofMatchMaker.cxx | 32 ++++++++++---------- StRoot/StETofUtil/StETofGeometry.cxx | 31 +++++++++---------- StRoot/StETofUtil/StETofGeometry.h | 12 ++++---- 5 files changed, 44 insertions(+), 47 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index 368c4912f3c..1b0318bc619 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -1360,7 +1360,7 @@ StETofCalibMaker::processMuDst() }*/ size_t nDigis = mMuDst->numberOfETofDigi(); - LOG_INFO << "processMuDst() - # fired eTOF digis : " << nDigis << endm; + //LOG_INFO << "processMuDst() - # fired eTOF digis : " << nDigis << endm; mTriggerTime = triggerTime( ( StETofHeader* ) etofHeader ); mResetTime = fmod( resetTime( ( StETofHeader* ) etofHeader ), eTofConst::bTofClockCycle ); diff --git a/StRoot/StETofHitMaker/StETofHitMaker.cxx b/StRoot/StETofHitMaker/StETofHitMaker.cxx index 926da3890d5..f785cb625ae 100644 --- a/StRoot/StETofHitMaker/StETofHitMaker.cxx +++ b/StRoot/StETofHitMaker/StETofHitMaker.cxx @@ -392,7 +392,7 @@ StETofHitMaker::processStEvent() nDigisInStore++; } } - LOG_INFO << "processStEvent() - storage is filled with " << nDigisInStore << " digis" << endm; + // LOG_INFO << "processStEvent() - storage is filled with " << nDigisInStore << " digis" << endm; matchSides(); @@ -413,12 +413,12 @@ StETofHitMaker::processStEvent() if( etofCollection->hitsPresent() ) { StSPtrVecETofHit& etofHits = etofCollection->etofHits(); - LOG_INFO << "processStEvent() - etof hit collection: " << etofHits.size() << " entries" << endm; + //LOG_INFO << "processStEvent() - etof hit collection: " << etofHits.size() << " entries" << endm; fillHitQA( isMuDst, tstart ); } else { - LOG_INFO << "processStEvent() - no hits" << endm; + // LOG_INFO << "processStEvent() - no hits" << endm; } } @@ -461,7 +461,7 @@ StETofHitMaker::processMuDst() nDigisInStore++; } } - LOG_INFO << "processMuDst() - storage is filled with " << nDigisInStore << " digis" << endm; + //LOG_INFO << "processMuDst() - storage is filled with " << nDigisInStore << " digis" << endm; matchSides(); @@ -483,12 +483,12 @@ StETofHitMaker::processMuDst() if( mMuDst->numberOfETofHit() ) { size_t nHits = mMuDst->numberOfETofHit(); - LOG_INFO << "processMuDst() - etof hits: " << nHits << " entries" << endm; + //LOG_INFO << "processMuDst() - etof hits: " << nHits << " entries" << endm; fillHitQA( isMuDst, tstart ); } else { - LOG_INFO << "processMuDst() - no hits" << endm; + //LOG_INFO << "processMuDst() - no hits" << endm; } } //_____________________________________________________________ @@ -1201,7 +1201,7 @@ StETofHitMaker::fillUnclusteredHitQA( const double& tstart, const bool isMuDst ) int nHitsPrinted = 0; int eventTime = ( this->GetTime() / 10000 ) * 3600 + ( ( this->GetTime() % 10000 ) / 100 ) * 60 + ( this->GetTime() % 100 ); - LOG_INFO << "fillUnclusteredHitQA(): -- event time: " << eventTime << endm; + //LOG_INFO << "fillUnclusteredHitQA(): -- event time: " << eventTime << endm; for( const auto& kv : mStoreHit ) { unsigned int detIndex = kv.first; diff --git a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx index 1aa9ad11625..702384d8970 100644 --- a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx +++ b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx @@ -457,7 +457,7 @@ StETofMatchMaker::Make() readETofDetectorHits( detectorHitVec ); if( detectorHitVec.size() == 0 ) { - LOG_INFO << "Make() -- event done ... bye-bye" << endm; + //LOG_INFO << "Make() -- event done ... bye-bye" << endm; return kStOk; } @@ -484,7 +484,7 @@ StETofMatchMaker::Make() findTrackIntersections( intersectionVec, nPrimaryWithIntersection ); if( intersectionVec.size() == 0 ) { - LOG_INFO << "Make() -- event done ... bye-bye" << endm; + //LOG_INFO << "Make() -- event done ... bye-bye" << endm; return kStOk; } @@ -499,7 +499,7 @@ StETofMatchMaker::Make() matchETofHits( detectorHitVec, intersectionVec, matchCandVec ); if( matchCandVec.size() == 0 ) { - LOG_INFO << "Make() -- event done ... bye-bye" << endm; + //LOG_INFO << "Make() -- event done ... bye-bye" << endm; return kStOk; } @@ -514,7 +514,7 @@ StETofMatchMaker::Make() sortSingleMultipleHits( matchCandVec, singleTrackMatchVec, multiTrackMatchVec ); if( singleTrackMatchVec.size() == 0 ) { - LOG_INFO << "Make() -- event done ... bye-bye" << endm; + //LOG_INFO << "Make() -- event done ... bye-bye" << endm; return kStOk; } @@ -527,12 +527,12 @@ StETofMatchMaker::Make() finalizeMatching( singleTrackMatchVec, finalMatchVec ); if( finalMatchVec.size() == 0 ) { - LOG_INFO << "Make() -- event done ... bye-bye" << endm; + //LOG_INFO << "Make() -- event done ... bye-bye" << endm; return kStOk; } else{ - LOG_INFO << "Make() -- number of found matches of eTOF hits with tracks: " << finalMatchVec.size() << endm; + //LOG_INFO << "Make() -- number of found matches of eTOF hits with tracks: " << finalMatchVec.size() << endm; } //......................................................................... @@ -557,7 +557,7 @@ StETofMatchMaker::Make() fillSlewHistograms( finalMatchVec ); - LOG_INFO << "Make() -- event done ... bye-bye" << endm; + //LOG_INFO << "Make() -- event done ... bye-bye" << endm; return kStOk; } @@ -744,16 +744,16 @@ StETofMatchMaker::readETofDetectorHits( eTofHitVec& detectorHitVec ) // event selection ... only continue with events that have eTOF hits if( mIsStEventIn ) { if( !mEvent->etofCollection() ) { - LOG_INFO << "readETofDetectorHits() - no etof collection --> nothing to do ... bye-bye" << endm; + LOG_WARN << "readETofDetectorHits() - no etof collection --> nothing to do ... bye-bye" << endm; return; } if( !mEvent->etofCollection()->hitsPresent() ) { - LOG_INFO << "readETofDetectorHits() - no etof hits present --> nothing to do ... bye-bye" << endm; + LOG_WARN << "readETofDetectorHits() - no etof hits present --> nothing to do ... bye-bye" << endm; return; } nHits = mEvent->etofCollection()->etofHits().size(); - LOG_INFO << " number of ETOF hits: " << nHits << endm; + //LOG_INFO << " number of ETOF hits: " << nHits << endm; } else if( mIsMuDstIn ) { if( !mMuDst->etofArray( muETofHit ) ) { @@ -767,7 +767,7 @@ StETofMatchMaker::readETofDetectorHits( eTofHitVec& detectorHitVec ) } nHits = mMuDst->numberOfETofHit(); - LOG_INFO << " number of ETOF hits: " << nHits << endm; + //LOG_INFO << " number of ETOF hits: " << nHits << endm; } if( mDoQA ) { @@ -1076,7 +1076,7 @@ StETofMatchMaker::findTrackIntersections( eTofHitVec& intersectionVec, int& nPri } } // end of MuDst processing - LOG_INFO << "# tracks in the event: " << nNodes << " ... out of which " << intersectionVec.size() << " intersect with eTOF" << endm; + //LOG_INFO << "# tracks in the event: " << nNodes << " ... out of which " << intersectionVec.size() << " intersect with eTOF" << endm; if( mDoQA ) { mHistograms.at( "intersectionMult" )->Fill( intersectionVec.size() ); @@ -1468,7 +1468,7 @@ StETofMatchMaker::sortSingleMultipleHits( eTofHitVec& matchCandVec, eTofHitVec& } } - LOG_INFO << "nSingleTrackMatch: " << nSingleTrackMatch << " ... nMultiTrackMatch: " << nMultiTrackMatch << endm; + //LOG_INFO << "nSingleTrackMatch: " << nSingleTrackMatch << " ... nMultiTrackMatch: " << nMultiTrackMatch << endm; if( mDoQA ) { mHistograms.at( "singleTrackMatchMult" )->Fill( singleTrackMatchVec.size() ); @@ -2269,8 +2269,8 @@ StETofMatchMaker::startTime( const eTofHitVec& finalMatchVec ) { double t0Diff = moduloDist( tstartETof - tstartBTof, eTofConst::bTofClockCycle ); - LOG_INFO << "startTime(): -- start time comparison: bTOF " << tstartBTof << " eTOF " << tstartETof; - LOG_INFO << " nCand_etofT0: " << nCand_etofT0 << " difference: " << t0Diff << " mT0corr: " << mT0corr << endm; + //LOG_INFO << "startTime(): -- start time comparison: bTOF " << tstartBTof << " eTOF " << tstartETof; + //LOG_INFO << " nCand_etofT0: " << nCand_etofT0 << " difference: " << t0Diff << " mT0corr: " << mT0corr << endm; if( mDoQA && tstartBTof != -9999. && tstartETof != -9999. ) { mHistograms.at( "startTimeDiff" )->Fill( t0Diff ); @@ -2501,7 +2501,7 @@ StETofMatchMaker::fillQaHistograms( eTofHitVec& finalMatchVec ) float pathlength = matchCand.pathLength; float m2 = mom * mom * ( -1 + 1 / ( beta * beta ) ); - LOG_INFO << "momentum: " << mom << " ... beta: " << beta << " ... m^2: " << m2 << " ... dEdx: " << dEdx << endm; + //LOG_INFO << "momentum: " << mom << " ... beta: " << beta << " ... m^2: " << m2 << " ... dEdx: " << dEdx << endm; //LOG_DEBUG << "pathlength: " << pathlength << " ... time-of-flight: " << matchCand.tof << " ... mom: " << mom << " ... beta: " << beta << " ... charge: " << charge << " ... m^2: " << m2 << " ... dEdx: " << dEdx << endm; if( fabs( tof+999. ) < 1.e-5 || fabs( pathlength+999. ) < 1.e-5 ) { diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index 84e3363e7ca..68b539d687c 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -71,7 +71,7 @@ StETofNode::StETofNode( const TGeoPhysicalNode& gpNode ) buildMembers(); } -StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy ) +/*StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy ) : mSafetyMarginX( 0. ), mSafetyMarginY( 0. ), mDebug( false ) @@ -84,9 +84,9 @@ StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const f mBox->SetBoxDimensions( dx, dy, dz ); buildMembers(); -} +}*/ -StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const StThreeVectorD alignment ) +StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const StThreeVectorD alignment = { 0, 0, 0 } ) : mSafetyMarginX( 0. ), mSafetyMarginY( 0. ), mDebug( false ) @@ -392,7 +392,7 @@ StETofGeomModule::StETofGeomModule( const TGeoPhysicalNode& gpNode, const int mo } -void +/*void StETofGeomModule::addCounter( const TGeoPhysicalNode& gpNode, const int moduleId, const int counterId ) { StETofGeomCounter* counter = new StETofGeomCounter( gpNode, moduleId, counterId ); @@ -409,10 +409,10 @@ StETofGeomModule::addCounter( const TGeoPhysicalNode& gpNode, const float& dx, c counter->setSafetyMargins( safetyMargins ); mETofCounter.push_back( counter ); -} +}*/ void -StETofGeomModule::addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins, const StThreeVectorD alignment ) +StETofGeomModule::addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double safetyMargins[2] = (double[2]){ 0, 0 }, const StThreeVectorD alignment = {0,0,0} ) { StETofGeomCounter* counter = new StETofGeomCounter( gpNode, dx, dy, moduleId, counterId, alignment ); @@ -493,7 +493,7 @@ StETofGeomCounter::StETofGeomCounter( const TGeoPhysicalNode& gpNode, const int if( mDebug ) print(); } - +/* StETofGeomCounter::StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId ) : StETofNode( gpNode, dx, dy ), mModuleIndex( moduleId ), @@ -506,9 +506,9 @@ StETofGeomCounter::StETofGeomCounter( const TGeoPhysicalNode& gpNode, const floa createGeomStrips(); if( mDebug ) print(); -} +}*/ -StETofGeomCounter::StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const StThreeVectorD alignment ) +StETofGeomCounter::StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const StThreeVectorD alignment = { 0, 0, 0 } ) : StETofNode( gpNode, dx, dy, alignment ), mModuleIndex( moduleId ), mCounterIndex( counterId ), @@ -612,7 +612,7 @@ StETofGeometry::~StETofGeometry() reset(); } - +/* void StETofGeometry::init( TGeoManager* geoManager ) { @@ -625,10 +625,10 @@ StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins ) { init( geoManager, safetyMargins, false ); } - +*/ void -StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins, const bool& useHelixSwimmer ) +StETofGeometry::init( TGeoManager* geoManager, const double safetyMargins[2] = (double[2]){ 0, 0 }, const bool& useHelixSwimmer = false ) { if( !geoManager ) { LOG_ERROR << " *** StETofGeometry::Init - cannot find TGeoManager *** " << endm; @@ -1572,8 +1572,7 @@ StETofGeometry::readAlignmentParameters(){ paramFile.close(); if( mAlignmentParameters.size() != 108 ) { - LOG_INFO << "parameter file for alignments has not the right amount of entries: "; - LOG_INFO << mAlignmentParameters.size() << " instead of 108 !!!!" << endm; + LOG_WARN << "parameter file for alignments has not the right amount of entries: " << mAlignmentParameters.size() << " instead of 108 !!!!" << endm; return; } @@ -1584,10 +1583,8 @@ StETofGeometry::readAlignmentDatabase(){ LOG_INFO << "No etof alignment file provided --> use database: " << endm; //add check for no alignment set here. - - TDataSet* dbDataSet = nullptr; - dbDataSet = StMaker::GetChain()->GetDataBase("Geometry/etof/etofAlign"); + TDataSet* dbDataSet = StMaker::GetChain()->GetDataBase("Geometry/etof/etofAlign"); St_etofAlign* etofAlign = static_cast< St_etofAlign * > ( dbDataSet->Find( "etofAlign" ) ); if( !etofAlign ) { diff --git a/StRoot/StETofUtil/StETofGeometry.h b/StRoot/StETofUtil/StETofGeometry.h index 54f93c3e000..d38e09d7418 100644 --- a/StRoot/StETofUtil/StETofGeometry.h +++ b/StRoot/StETofUtil/StETofGeometry.h @@ -70,7 +70,7 @@ class StETofNode : public TObject { ~StETofNode() {} StETofNode( const TGeoPhysicalNode& gpNode ); - StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy ); + //StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy ); StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const StThreeVectorD alignment ); void convertPos( StETofNode* from, const double* pos_from, StETofNode* to, double* pos_to ); @@ -167,8 +167,8 @@ class StETofGeomModule : public StETofNode { void addCounter( const TGeoPhysicalNode& gpNode, const int moduleId, const int counterId ); void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId ); - void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins ); - void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins, const StThreeVectorD alignment ); + //void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins ); + void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double safetyMargins[2], const StThreeVectorD alignment ); StETofGeomCounter* counter( const unsigned int i ) const; @@ -228,7 +228,7 @@ class StETofGeomCounter : public StETofNode { ~StETofGeomCounter() {} StETofGeomCounter( const TGeoPhysicalNode& gpNode, const int moduleId, const int counterId ); - StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId ); + //StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId ); StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const StThreeVectorD alignment ); void createGeomStrips(); @@ -289,8 +289,8 @@ class StETofGeometry : public TNamed { ~StETofGeometry(); void init( TGeoManager* geoManager ); - void init( TGeoManager* geoManager, const double* safetyMargins ); - void init( TGeoManager* geoManager, const double* safetyMargins, const bool& useHelixSwimmer ); + //void init( TGeoManager* geoManager, const double* safetyMargins ); + void init( TGeoManager* geoManager, const double safetyMargins[2], const bool& useHelixSwimmer ); void reset(); From b936748979a264429cc249bc4357bd71e5dfb742 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Tue, 21 Jun 2022 07:12:29 -0400 Subject: [PATCH 51/62] fixed default init for safety margins in StEtofGeometry --- StRoot/StETofUtil/StETofGeometry.cxx | 4 ++-- StRoot/StETofUtil/StETofGeometry.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index 68b539d687c..d0d15226249 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -412,7 +412,7 @@ StETofGeomModule::addCounter( const TGeoPhysicalNode& gpNode, const float& dx, c }*/ void -StETofGeomModule::addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double safetyMargins[2] = (double[2]){ 0, 0 }, const StThreeVectorD alignment = {0,0,0} ) +StETofGeomModule::addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins = initializer_list({0, 0}).begin(), const StThreeVectorD alignment = {0,0,0} ) { StETofGeomCounter* counter = new StETofGeomCounter( gpNode, dx, dy, moduleId, counterId, alignment ); @@ -628,7 +628,7 @@ StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins ) */ void -StETofGeometry::init( TGeoManager* geoManager, const double safetyMargins[2] = (double[2]){ 0, 0 }, const bool& useHelixSwimmer = false ) +StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins = initializer_list({0, 0}).begin(), const bool& useHelixSwimmer = false ) { if( !geoManager ) { LOG_ERROR << " *** StETofGeometry::Init - cannot find TGeoManager *** " << endm; diff --git a/StRoot/StETofUtil/StETofGeometry.h b/StRoot/StETofUtil/StETofGeometry.h index d38e09d7418..5d1d740a8ed 100644 --- a/StRoot/StETofUtil/StETofGeometry.h +++ b/StRoot/StETofUtil/StETofGeometry.h @@ -168,7 +168,7 @@ class StETofGeomModule : public StETofNode { void addCounter( const TGeoPhysicalNode& gpNode, const int moduleId, const int counterId ); void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId ); //void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins ); - void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double safetyMargins[2], const StThreeVectorD alignment ); + void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins, const StThreeVectorD alignment ); StETofGeomCounter* counter( const unsigned int i ) const; @@ -290,7 +290,7 @@ class StETofGeometry : public TNamed { void init( TGeoManager* geoManager ); //void init( TGeoManager* geoManager, const double* safetyMargins ); - void init( TGeoManager* geoManager, const double safetyMargins[2], const bool& useHelixSwimmer ); + void init( TGeoManager* geoManager, const double* safetyMargins, const bool& useHelixSwimmer ); void reset(); From b14cceb91986376fea4fb9fa94e490356ee56c3c Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Wed, 22 Jun 2022 13:01:59 -0400 Subject: [PATCH 52/62] removed out-commented legacy code from StEtofGeometry. --- StRoot/StETofUtil/StETofGeometry.cxx | 47 ---------------------------- StRoot/StETofUtil/StETofGeometry.h | 4 --- 2 files changed, 51 deletions(-) diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index d0d15226249..bc058fa6c42 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -391,26 +391,6 @@ StETofGeomModule::StETofGeomModule( const TGeoPhysicalNode& gpNode, const int mo if( mDebug ) print(); } - -/*void -StETofGeomModule::addCounter( const TGeoPhysicalNode& gpNode, const int moduleId, const int counterId ) -{ - StETofGeomCounter* counter = new StETofGeomCounter( gpNode, moduleId, counterId ); - - mETofCounter.push_back( counter ); -} - - -void -StETofGeomModule::addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins ) -{ - StETofGeomCounter* counter = new StETofGeomCounter( gpNode, dx, dy, moduleId, counterId ); - - counter->setSafetyMargins( safetyMargins ); - - mETofCounter.push_back( counter ); -}*/ - void StETofGeomModule::addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins = initializer_list({0, 0}).begin(), const StThreeVectorD alignment = {0,0,0} ) { @@ -493,20 +473,7 @@ StETofGeomCounter::StETofGeomCounter( const TGeoPhysicalNode& gpNode, const int if( mDebug ) print(); } -/* -StETofGeomCounter::StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId ) -: StETofNode( gpNode, dx, dy ), - mModuleIndex( moduleId ), - mCounterIndex( counterId ), - mDebug( false ) -{ - mSector = calcSector( moduleId ); - mPlane = calcPlane( moduleId ); - - createGeomStrips(); - if( mDebug ) print(); -}*/ StETofGeomCounter::StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const StThreeVectorD alignment = { 0, 0, 0 } ) : StETofNode( gpNode, dx, dy, alignment ), @@ -612,20 +579,6 @@ StETofGeometry::~StETofGeometry() reset(); } -/* -void -StETofGeometry::init( TGeoManager* geoManager ) -{ - double safetyMargins[ 2 ] = { 0., 0. }; - init( geoManager, safetyMargins, false ); -} - -void -StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins ) -{ - init( geoManager, safetyMargins, false ); -} -*/ void StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins = initializer_list({0, 0}).begin(), const bool& useHelixSwimmer = false ) diff --git a/StRoot/StETofUtil/StETofGeometry.h b/StRoot/StETofUtil/StETofGeometry.h index 5d1d740a8ed..61664d27b1f 100644 --- a/StRoot/StETofUtil/StETofGeometry.h +++ b/StRoot/StETofUtil/StETofGeometry.h @@ -70,7 +70,6 @@ class StETofNode : public TObject { ~StETofNode() {} StETofNode( const TGeoPhysicalNode& gpNode ); - //StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy ); StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const StThreeVectorD alignment ); void convertPos( StETofNode* from, const double* pos_from, StETofNode* to, double* pos_to ); @@ -167,7 +166,6 @@ class StETofGeomModule : public StETofNode { void addCounter( const TGeoPhysicalNode& gpNode, const int moduleId, const int counterId ); void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId ); - //void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins ); void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins, const StThreeVectorD alignment ); StETofGeomCounter* counter( const unsigned int i ) const; @@ -228,7 +226,6 @@ class StETofGeomCounter : public StETofNode { ~StETofGeomCounter() {} StETofGeomCounter( const TGeoPhysicalNode& gpNode, const int moduleId, const int counterId ); - //StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId ); StETofGeomCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const StThreeVectorD alignment ); void createGeomStrips(); @@ -289,7 +286,6 @@ class StETofGeometry : public TNamed { ~StETofGeometry(); void init( TGeoManager* geoManager ); - //void init( TGeoManager* geoManager, const double* safetyMargins ); void init( TGeoManager* geoManager, const double* safetyMargins, const bool& useHelixSwimmer ); void reset(); From b4994e311904582d29ba496d1b343b6c01bf6702 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Wed, 22 Jun 2022 13:52:34 -0400 Subject: [PATCH 53/62] Adjust white space [skip ci] --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 45 +++--- StRoot/StETofHitMaker/StETofHitMaker.cxx | 20 +-- StRoot/StETofMatchMaker/StETofMatchMaker.cxx | 22 +-- StRoot/StETofUtil/StETofGeometry.cxx | 155 +++++++++---------- StRoot/StETofUtil/StETofGeometry.h | 18 +-- 5 files changed, 123 insertions(+), 137 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index 1b0318bc619..459b27b2c3c 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -1106,26 +1106,25 @@ StETofCalibMaker::Make() if ( mEvent ) { LOG_DEBUG << "Make(): running on StEvent" << endm; - StETofCollection* etofCollection = mEvent->etofCollection(); - - if( !etofCollection ) { //additional check for empty StEvents structures produced by other Makers. Needed for genDst.C - LOG_WARN << "Make() - Found StEvent data structure, but no eTOF collection. Try MuDst processing instead" << endm; - mMuDst = ( StMuDst* ) GetInputDS( "MuDst" ); - - if( mMuDst ) { - LOG_DEBUG << "Make() - running on MuDsts" << endm; - - processMuDst(); - - return kStOk; - } - } + StETofCollection* etofCollection = mEvent->etofCollection(); + + if( !etofCollection ) { //additional check for empty StEvents structures produced by other Makers. Needed for genDst.C + LOG_WARN << "Make() - Found StEvent data structure, but no eTOF collection. Try MuDst processing instead" << endm; + mMuDst = ( StMuDst* ) GetInputDS( "MuDst" ); + + if( mMuDst ) { + LOG_DEBUG << "Make() - running on MuDsts" << endm; + + processMuDst(); + + return kStOk; + } + } processStEvent(); return kStOk; } - else { LOG_DEBUG << "Make(): no StEvent found" << endm; @@ -1368,7 +1367,7 @@ StETofCalibMaker::processMuDst() /// first loop over digis to apply hardware mappping and find the pulsers for( size_t i=0; ietofDigi( i ); if( !aDigi ) { @@ -1376,12 +1375,12 @@ StETofCalibMaker::processMuDst() continue; } /// reset digi to carry only raw information (needed for afterburner mode) - //LOG_INFO << "resetting digi "<< i <<"/"<< nDigis << endm; + //LOG_INFO << "resetting digi "<< i <<"/"<< nDigis << endm; resetToRaw( aDigi ); /// apply hardware mapping from rocId, chipId, channelId to /// sector, zplane, counter, strip, side - //LOG_INFO << "mapping digi: "<< i <<"/"<< nDigis << endm; + //LOG_INFO << "mapping digi: "<< i <<"/"<< nDigis << endm; applyMapping( aDigi ); /// flag pulser digis @@ -1657,12 +1656,12 @@ StETofCalibMaker::calculatePulserOffsets( std::map< unsigned int, std::vector< u double pulserTime = 0.; - if( mMuDst ) { - pulserTime = mMuDst->etofDigi( it->second.at( candIndex ) )->rawTime(); + if( mMuDst ) { + pulserTime = mMuDst->etofDigi( it->second.at( candIndex ) )->rawTime(); - // set calibTot to -999. to exclude it from being calibrated in the next step --> pulser will not be used to build hits - mMuDst->etofDigi( it->second.at( candIndex ) )->setCalibTot( -999. ); - } else if( mEvent ) { + // set calibTot to -999. to exclude it from being calibrated in the next step --> pulser will not be used to build hits + mMuDst->etofDigi( it->second.at( candIndex ) )->setCalibTot( -999. ); + } else if( mEvent ) { pulserTime = ( mEvent->etofCollection()->etofDigis() )[ it->second.at( candIndex ) ]->rawTime(); // set calibTot to -999. to exclude it from being calibrated in the next step --> pulser will not be used to build hits diff --git a/StRoot/StETofHitMaker/StETofHitMaker.cxx b/StRoot/StETofHitMaker/StETofHitMaker.cxx index f785cb625ae..5e0cda88d73 100644 --- a/StRoot/StETofHitMaker/StETofHitMaker.cxx +++ b/StRoot/StETofHitMaker/StETofHitMaker.cxx @@ -310,20 +310,20 @@ StETofHitMaker::Make() if ( mEvent ) { LOG_DEBUG << "Make() - running on StEvent" << endm; - StETofCollection* etofCollection = mEvent->etofCollection(); + StETofCollection* etofCollection = mEvent->etofCollection(); - if( !etofCollection ) { //additional check for empty StEvents structures produced by other Makers. Needed for genDst.C - LOG_WARN << "Make() - Found StEvent data structure, but no eTOF collection. Try MuDst processing instead" << endm; - mMuDst = ( StMuDst* ) GetInputDS( "MuDst" ); + if( !etofCollection ) { //additional check for empty StEvents structures produced by other Makers. Needed for genDst.C + LOG_WARN << "Make() - Found StEvent data structure, but no eTOF collection. Try MuDst processing instead" << endm; + mMuDst = ( StMuDst* ) GetInputDS( "MuDst" ); - if( mMuDst ) { - LOG_DEBUG << "Make() - running on MuDsts" << endm; + if( mMuDst ) { + LOG_DEBUG << "Make() - running on MuDsts" << endm; - processMuDst(); + processMuDst(); - return kStOk; - } - } + return kStOk; + } + } processStEvent(); diff --git a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx index 702384d8970..e2996e9dc22 100644 --- a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx +++ b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx @@ -399,13 +399,13 @@ StETofMatchMaker::Make() if ( mEvent ) { LOG_DEBUG << "Make() - running on StEvent" << endm; - StETofCollection* etofCollection = mEvent->etofCollection(); + StETofCollection* etofCollection = mEvent->etofCollection(); - if( !etofCollection ) { //additional check for empty StEvents structures produced by other Makers. Needed for genDst.C - LOG_WARN << "Make() - Found StEvent data structure, but no eTOF collection. Try MuDst processing instead" << endm; - mMuDst = ( StMuDst* ) GetInputDS( "MuDst" ); + if( !etofCollection ) { //additional check for empty StEvents structures produced by other Makers. Needed for genDst.C + LOG_WARN << "Make() - Found StEvent data structure, but no eTOF collection. Try MuDst processing instead" << endm; + mMuDst = ( StMuDst* ) GetInputDS( "MuDst" ); - if( mMuDst ) { + if( mMuDst ) { LOG_DEBUG << "Make() - running on MuDsts" << endm; mIsMuDstIn = true; @@ -413,12 +413,12 @@ StETofMatchMaker::Make() fillIndexToPrimaryMap(); cleanUpTraits(); - } - }else{ - mIsStEventIn = true; + } + }else{ + mIsStEventIn = true; - cleanUpTraits(); - } + cleanUpTraits(); + } } else { LOG_DEBUG << "Make(): no StEvent found" << endm; @@ -3034,4 +3034,4 @@ ETofTrack::ETofTrack( const StMuTrack* mutrack ) if ( phi < 0. ) phi += 2. * M_PI; } -} +} \ No newline at end of file diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index bc058fa6c42..869ccd0a100 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -65,33 +65,16 @@ StETofNode::StETofNode( const TGeoPhysicalNode& gpNode ) { mGeoMatrix = static_cast< TGeoHMatrix* > ( gpNode.GetMatrix() ); - mBox = static_cast< TGeoBBox* > ( gpNode.GetShape() ); buildMembers(); } -/*StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy ) -: mSafetyMarginX( 0. ), - mSafetyMarginY( 0. ), - mDebug( false ) -{ - mGeoMatrix = static_cast< TGeoHMatrix* > ( gpNode.GetMatrix() ); - mBox = static_cast< TGeoBBox* > ( gpNode.GetShape() ); - - // resize mBox with dx and dy - float dz = mBox->GetDZ(); - mBox->SetBoxDimensions( dx, dy, dz ); - - buildMembers(); -}*/ - StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const StThreeVectorD alignment = { 0, 0, 0 } ) : mSafetyMarginX( 0. ), - mSafetyMarginY( 0. ), + mSafetyMarginY( 0. ), mDebug( false ) { - mGeoMatrix = static_cast< TGeoHMatrix* > ( gpNode.GetMatrix() ); mBox = static_cast< TGeoBBox* > ( gpNode.GetShape() ); @@ -103,13 +86,14 @@ StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const f // modified buildMembers() method. PW; // build member variables: mMinEta, mMaxEta, mMinPhi, mMaxPhi, mCenter, mNormal double xl[3] = { -alignment.x(), -alignment.y(), -alignment.z() }; -//z alignment is positive to reflect the correct direction in which z has to be moved in global coordinates. x and y are negative to match the numbers from hit-intersection + //z alignment is positive to reflect the correct direction in which z has to be moved in global coordinates. x and y are negative to match the numbers from hit-intersection double xm[3]; local2Master( xl, xm ); + mCenter = StThreeVectorD( xm[ 0 ], xm[ 1 ], xm[ 2 ] ); - mGeoMatrix->SetDx(xm[ 0 ]); - mGeoMatrix->SetDy(xm[ 1 ]); - mGeoMatrix->SetDz(xm[ 2 ]); + mGeoMatrix->SetDx(xm[ 0 ]); + mGeoMatrix->SetDy(xm[ 1 ]); + mGeoMatrix->SetDz(xm[ 2 ]); //correct counter rotation is implemented in .XML LOG_DEBUG << "StETofNode::Created physical node at: "<< xm[ 0 ]<<","<< xm[ 1 ]<<"," << xm[ 2 ]<<" with alignments: "<< alignment.x()<<","<< alignment.y()<<"," << alignment.z()<< endm;//debug PW. @@ -123,7 +107,6 @@ StETofNode::StETofNode( const TGeoPhysicalNode& gpNode, const float& dx, const f mPhiMax = calcPhi( -1, 1. ); if( mDebug ) print(); - } void @@ -568,7 +551,7 @@ StETofGeometry::StETofGeometry( const char* name, const char* title ) mInitFlag( false ), mDebug( false ), mStarBField( nullptr ), - mFileNameAlignParam ("") + mFileNameAlignParam("") { } @@ -592,14 +575,13 @@ StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins = ini mNValidModules = 0; - if ( !mFileNameAlignParam.empty() ) { - readAlignmentParameters(); - }else{ - readAlignmentDatabase(); - } + readAlignmentParameters(); + } else { + readAlignmentDatabase(); + } - int iCounterAlignment = 0; + int iCounterAlignment = 0; // loop over sectors for( int sector = eTofConst::sectorStart; sector <= eTofConst::sectorStop; sector++ ) { // loop over planes @@ -612,8 +594,11 @@ StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins = ini continue; } mNValidModules++; + const TGeoPhysicalNode* gpNode = geoManager->MakePhysicalNode( geoPath.c_str() ); + int moduleId = calcModuleIndex( sector, plane ); + mETofModule[ mNValidModules-1 ] = new StETofGeomModule( *gpNode, moduleId ); @@ -650,12 +635,12 @@ StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins = ini LOG_DEBUG << activeVolume->GetDX() << " " << activeVolume->GetDY() << " " << activeVolume->GetDZ() << endm; int counterId = counter - eTofConst::counterStart; - if( mAlignmentParameters.size() == 108 ){ //alignment parameters for all counters available - mETofModule[ mNValidModules-1 ]->addCounter( *gpNode, dx, dy, moduleId, counterId, safetyMargins, mAlignmentParameters.at(iCounterAlignment) ); - iCounterAlignment++; - }else{ - mETofModule[ mNValidModules-1 ]->addCounter( *gpNode, dx, dy, moduleId, counterId, safetyMargins ); - } + if( mAlignmentParameters.size() == 108 ){ //alignment parameters for all counters available + mETofModule[ mNValidModules-1 ]->addCounter( *gpNode, dx, dy, moduleId, counterId, safetyMargins, mAlignmentParameters.at(iCounterAlignment) ); + iCounterAlignment++; + } else { + mETofModule[ mNValidModules-1 ]->addCounter( *gpNode, dx, dy, moduleId, counterId, safetyMargins ); + } } // end of loop over counters @@ -715,19 +700,23 @@ StETofGeometry::formTGeoPath( const TGeoManager* geoManager, int plane, int sect std::ostringstream geoPath; geoPath << "/HALL_1/CAVE_1/MagRefSys_1/ETOF_" << plane << sector; + bool found = geoManager->CheckPath( geoPath.str().c_str() ); + if( !found ) { geoPath.str(""); geoPath.clear(); geoPath << "/HALL_1/CAVE_1/ETOF_" << plane << sector; } + // go deeper if counter is requested if( counter >= 1 ) { geoPath << "/EGAS_1/ECOU_" << counter; } found = geoManager->CheckPath( geoPath.str().c_str() ); + return found ? geoPath.str() : ""; } @@ -1501,62 +1490,60 @@ StETofGeometry::getFieldZ( const double& x, const double& y, const double& z ) { void StETofGeometry::readAlignmentParameters(){ - LOG_INFO << "etofAlignParam: filename provided --> use parameter file: " << mFileNameAlignParam << endm; - - //add check for no alignment set here. - - ifstream paramFile; - paramFile.open( mFileNameAlignParam ); + LOG_INFO << "etofAlignParam: filename provided --> use parameter file: " << mFileNameAlignParam << endm; - if( !paramFile.is_open() ) { - LOG_INFO << "unable to get the alignments parameters from file --> file does not exist" << endm; - return; - } + //add check for no alignment set here. - StThreeVectorD counterAlignmentParameter; - float tempX; - float tempY; - float tempZ; - while( paramFile >> tempX >> tempY >> tempZ ) { - counterAlignmentParameter = StThreeVectorD( tempX, tempY, tempZ ); - mAlignmentParameters.push_back( counterAlignmentParameter ); - } - - paramFile.close(); + ifstream paramFile; + paramFile.open( mFileNameAlignParam ); - if( mAlignmentParameters.size() != 108 ) { - LOG_WARN << "parameter file for alignments has not the right amount of entries: " << mAlignmentParameters.size() << " instead of 108 !!!!" << endm; - return; - } + if( !paramFile.is_open() ) { + LOG_INFO << "unable to get the alignments parameters from file --> file does not exist" << endm; + return; + } + + StThreeVectorD counterAlignmentParameter; + float tempX; + float tempY; + float tempZ; + while( paramFile >> tempX >> tempY >> tempZ ) { + counterAlignmentParameter = StThreeVectorD( tempX, tempY, tempZ ); + mAlignmentParameters.push_back( counterAlignmentParameter ); + } + paramFile.close(); + + if( mAlignmentParameters.size() != 108 ) { + LOG_WARN << "parameter file for alignments has not the right amount of entries: " << mAlignmentParameters.size() << " instead of 108 !!!!" << endm; + return; + } } void StETofGeometry::readAlignmentDatabase(){ - LOG_INFO << "No etof alignment file provided --> use database: " << endm; - - //add check for no alignment set here. + LOG_INFO << "No etof alignment file provided --> use database: " << endm; + + //add check for no alignment set here. - TDataSet* dbDataSet = StMaker::GetChain()->GetDataBase("Geometry/etof/etofAlign"); + TDataSet* dbDataSet = StMaker::GetChain()->GetDataBase("Geometry/etof/etofAlign"); - St_etofAlign* etofAlign = static_cast< St_etofAlign * > ( dbDataSet->Find( "etofAlign" ) ); - if( !etofAlign ) { - LOG_ERROR << "unable to get the align params from the database" << endm; - return; - } - - etofAlign_st* table = etofAlign->GetTable(); - StThreeVectorD counterAlignmentParameter; - float tempX; - float tempY; - float tempZ; - - for( int iCounter = 0; iCounter < eTofConst::nCounters; iCounter++){ - tempX = table[iCounter].detectorAlignX[0]; - tempY = table[iCounter].detectorAlignY[0]; - tempZ = table[iCounter].detectorAlignZ[0]; - StThreeVectorD counterAlignmentParameter = StThreeVectorD( tempX, tempY, tempZ ); - mAlignmentParameters.push_back( counterAlignmentParameter ); - } -} + St_etofAlign* etofAlign = static_cast< St_etofAlign * > ( dbDataSet->Find( "etofAlign" ) ); + if( !etofAlign ) { + LOG_ERROR << "unable to get the align params from the database" << endm; + return; + } + etofAlign_st* table = etofAlign->GetTable(); + StThreeVectorD counterAlignmentParameter; + float tempX; + float tempY; + float tempZ; + + for( int iCounter = 0; iCounter < eTofConst::nCounters; iCounter++){ + tempX = table[iCounter].detectorAlignX[0]; + tempY = table[iCounter].detectorAlignY[0]; + tempZ = table[iCounter].detectorAlignZ[0]; + StThreeVectorD counterAlignmentParameter = StThreeVectorD( tempX, tempY, tempZ ); + mAlignmentParameters.push_back( counterAlignmentParameter ); + } +} \ No newline at end of file diff --git a/StRoot/StETofUtil/StETofGeometry.h b/StRoot/StETofUtil/StETofGeometry.h index 61664d27b1f..d23eb23d3e1 100644 --- a/StRoot/StETofUtil/StETofGeometry.h +++ b/StRoot/StETofUtil/StETofGeometry.h @@ -166,7 +166,7 @@ class StETofGeomModule : public StETofNode { void addCounter( const TGeoPhysicalNode& gpNode, const int moduleId, const int counterId ); void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId ); - void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins, const StThreeVectorD alignment ); + void addCounter( const TGeoPhysicalNode& gpNode, const float& dx, const float& dy, const int moduleId, const int counterId, const double* safetyMargins, const StThreeVectorD alignment ); StETofGeomCounter* counter( const unsigned int i ) const; @@ -285,7 +285,7 @@ class StETofGeometry : public TNamed { StETofGeometry( const char* name = "etofGeo", const char* title = "simplified ETOF Geometry" ); ~StETofGeometry(); - void init( TGeoManager* geoManager ); + void init( TGeoManager* geoManager ); void init( TGeoManager* geoManager, const double* safetyMargins, const bool& useHelixSwimmer ); void reset(); @@ -303,7 +303,7 @@ class StETofGeometry : public TNamed { StETofNode* findETofNode( const int moduleId, const int counter ); - void pointMaster2local( const int moduleId, const int counterId, const double* master, double* local ); + void pointMaster2local( const int moduleId, const int counterId, const double* master, double* local ); void hitLocal2Master( const int moduleId, const int counter, const double* local, double* master ); StThreeVectorD hitLocal2Master( StETofHit* hit ); StThreeVectorD hitLocal2Master( StMuETofHit* hit ); @@ -358,9 +358,9 @@ class StETofGeometry : public TNamed { StETofGeomModule* module( const unsigned int i ); unsigned int nValidModules() const; - void readAlignmentParameters(); - void readAlignmentDatabase(); - void setFileNameAlignParam(std::string FileNameAlignParam); + void readAlignmentParameters(); + void readAlignmentDatabase(); + void setFileNameAlignParam(std::string FileNameAlignParam); void debugOn(); void debugOff(); @@ -376,8 +376,8 @@ class StETofGeometry : public TNamed { StarMagField* mStarBField; - std::string mFileNameAlignParam; - std::vector mAlignmentParameters; + std::string mFileNameAlignParam; + std::vector mAlignmentParameters; ClassDef( StETofGeometry, 1 ) }; @@ -396,4 +396,4 @@ inline bool StETofGeometry::isDebugOn() const { return mDebug; } inline void StETofGeometry::setFileNameAlignParam(std::string fileNameAlignParam) {mFileNameAlignParam = fileNameAlignParam;} -#endif /// STETOFGEOMETRY_H +#endif /// STETOFGEOMETRY_H \ No newline at end of file From 80fe2084b0990cd134cf60e98ce71615f16c6005 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Fri, 24 Jun 2022 08:38:25 -0400 Subject: [PATCH 54/62] changed default start time setting in Matchmaker to use bTOF start time only. Hybrid start time shows a shift of 150 ps compared to bTOF only --- StRoot/StETofMatchMaker/StETofMatchMaker.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx index e2996e9dc22..122e2600b74 100644 --- a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx +++ b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx @@ -166,7 +166,7 @@ StETofMatchMaker::StETofMatchMaker( const char* name ) mIsMuDstIn( false ), mOuterTrackGeometry( true ), mUseHelixSwimmer( false ), - mUseOnlyBTofHeaderStartTime( false ), + mUseOnlyBTofHeaderStartTime( true ), mIsSim( false ), mDoQA( false ), mDebug( false ), @@ -3034,4 +3034,4 @@ ETofTrack::ETofTrack( const StMuTrack* mutrack ) if ( phi < 0. ) phi += 2. * M_PI; } -} \ No newline at end of file +} From 8ef42cd49aba13501709b17af62ad0c6321a0816 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Fri, 24 Jun 2022 10:17:03 -0400 Subject: [PATCH 55/62] improved error handling for non-existing alignment tables in Geometry and MatchMaker. Clearing alignment during reset of geometry now. --- StRoot/StETofMatchMaker/StETofMatchMaker.cxx | 5 +++++ StRoot/StETofUtil/StETofGeometry.cxx | 17 +++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx index 122e2600b74..b15175ed323 100644 --- a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx +++ b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx @@ -314,6 +314,11 @@ StETofMatchMaker::InitRun( Int_t runnumber ) mETofGeom->init( gGeoManager, etofProjection::safetyMargins, mUseHelixSwimmer ); //provide backline to initiating maker to load DB tables } + if( mETofGeom && !mETofGeom->isInitDone() ) { //if initialization attempt above failed. + LOG_ERROR << "Initialization of StEtofGeometry failed" << endm; + return kStErr; + } + if( mDoQA ) { // for geometry debugging for( unsigned int i=0; inValidModules(); i++ ) { diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index 869ccd0a100..ab57c948dfa 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -581,6 +581,11 @@ StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins = ini readAlignmentDatabase(); } + if( mAlignmentParameters.size() != eTofConst::nCounters ){ + LOG_ERROR << "StETofGeometry::Init(...) - Wrong size of counter alignment vector. Either incomplete alignment file or non-existant database table." << endm; + return; + } + int iCounterAlignment = 0; // loop over sectors for( int sector = eTofConst::sectorStart; sector <= eTofConst::sectorStop; sector++ ) { @@ -635,13 +640,8 @@ StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins = ini LOG_DEBUG << activeVolume->GetDX() << " " << activeVolume->GetDY() << " " << activeVolume->GetDZ() << endm; int counterId = counter - eTofConst::counterStart; - if( mAlignmentParameters.size() == 108 ){ //alignment parameters for all counters available - mETofModule[ mNValidModules-1 ]->addCounter( *gpNode, dx, dy, moduleId, counterId, safetyMargins, mAlignmentParameters.at(iCounterAlignment) ); - iCounterAlignment++; - } else { - mETofModule[ mNValidModules-1 ]->addCounter( *gpNode, dx, dy, moduleId, counterId, safetyMargins ); - } - + mETofModule[ mNValidModules-1 ]->addCounter( *gpNode, dx, dy, moduleId, counterId, safetyMargins, mAlignmentParameters.at(iCounterAlignment) ); + iCounterAlignment++; } // end of loop over counters } // end of loop over planes @@ -683,6 +683,7 @@ StETofGeometry::reset() LOG_INFO << "StETofGeometry cleared up ...." << endm; mNValidModules = 0; + mAlignmentParameters.clear(); mInitFlag = false; mStarBField = nullptr; @@ -1546,4 +1547,4 @@ StETofGeometry::readAlignmentDatabase(){ StThreeVectorD counterAlignmentParameter = StThreeVectorD( tempX, tempY, tempZ ); mAlignmentParameters.push_back( counterAlignmentParameter ); } -} \ No newline at end of file +} From b03cb08423345472c9bb25e4bc0ded6b4df27275 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Tue, 28 Jun 2022 10:45:44 -0400 Subject: [PATCH 56/62] fixed vector range crash due to netofCounters constants in StEtofGeometry --- StRoot/StETofUtil/StETofGeometry.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index ab57c948dfa..d9ae2937a18 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -581,7 +581,7 @@ StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins = ini readAlignmentDatabase(); } - if( mAlignmentParameters.size() != eTofConst::nCounters ){ + if( mAlignmentParameters.size() != eTofConst::nCounters * eTofConst::nModules ){ LOG_ERROR << "StETofGeometry::Init(...) - Wrong size of counter alignment vector. Either incomplete alignment file or non-existant database table." << endm; return; } @@ -1540,7 +1540,7 @@ StETofGeometry::readAlignmentDatabase(){ float tempY; float tempZ; - for( int iCounter = 0; iCounter < eTofConst::nCounters; iCounter++){ + for( int iCounter = 0; iCounter < eTofConst::nCounters * eTofConst::nModules; iCounter++){ tempX = table[iCounter].detectorAlignX[0]; tempY = table[iCounter].detectorAlignY[0]; tempZ = table[iCounter].detectorAlignZ[0]; From 95200aec2229dfdb8af8fb1ff9d93ab729043ea6 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Wed, 29 Jun 2022 10:09:40 -0400 Subject: [PATCH 57/62] added additional check for invalid dbDataSet pointer in StEtofGeometry::readAlignmentDatabase() --- StRoot/StETofUtil/StETofGeometry.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index d9ae2937a18..a02f31af3f9 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -1527,6 +1527,10 @@ StETofGeometry::readAlignmentDatabase(){ //add check for no alignment set here. TDataSet* dbDataSet = StMaker::GetChain()->GetDataBase("Geometry/etof/etofAlign"); + if( !dbDataSet ) { + LOG_ERROR << "unable to get the dataset from the database" << endm; + return; + } St_etofAlign* etofAlign = static_cast< St_etofAlign * > ( dbDataSet->Find( "etofAlign" ) ); if( !etofAlign ) { From 153846823be7b9ff0b0d16453d73c8036bcdd450 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Mon, 4 Jul 2022 09:06:29 -0400 Subject: [PATCH 58/62] Replace kStErr returns with kStFatal in StEtofMatchmaker. Changed alignment table accessor in StEtofGeometry.cxx to match readDB macros (This fixes a crash if user version matchmaker is executed with QaFlag set ???! --- StRoot/StETofMatchMaker/StETofMatchMaker.cxx | 4 ++-- StRoot/StETofUtil/StETofGeometry.cxx | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx index b15175ed323..b68aaa591e8 100644 --- a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx +++ b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx @@ -306,7 +306,7 @@ StETofMatchMaker::InitRun( Int_t runnumber ) if( !gGeoManager ) { LOG_ERROR << "Cannot get GeoManager" << endm; - return kStErr; + return kStFatal; } LOG_DEBUG << " gGeoManager: " << gGeoManager << endm; @@ -316,7 +316,7 @@ StETofMatchMaker::InitRun( Int_t runnumber ) if( mETofGeom && !mETofGeom->isInitDone() ) { //if initialization attempt above failed. LOG_ERROR << "Initialization of StEtofGeometry failed" << endm; - return kStErr; + return kStFatal; } if( mDoQA ) { diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index a02f31af3f9..74849dd5730 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -1545,10 +1545,11 @@ StETofGeometry::readAlignmentDatabase(){ float tempZ; for( int iCounter = 0; iCounter < eTofConst::nCounters * eTofConst::nModules; iCounter++){ - tempX = table[iCounter].detectorAlignX[0]; - tempY = table[iCounter].detectorAlignY[0]; - tempZ = table[iCounter].detectorAlignZ[0]; + tempX = table->detectorAlignX[iCounter]; + tempY = table->detectorAlignY[iCounter]; + tempZ = table->detectorAlignZ[iCounter]; StThreeVectorD counterAlignmentParameter = StThreeVectorD( tempX, tempY, tempZ ); mAlignmentParameters.push_back( counterAlignmentParameter ); + //LOG_INFO <<" Setting alignment parameters for counter "<< iCounter << " X: "<< tempX << " Y: "<< tempY <<" Z: "<< tempZ << endm; } } From b9fbd51403dac042b3147d060bc378ca5bcf9e86 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Wed, 6 Jul 2022 11:12:49 -0400 Subject: [PATCH 59/62] Format white space [skip ci] --- StRoot/StETofMatchMaker/StETofMatchMaker.cxx | 8 ++++---- StRoot/StETofUtil/StETofGeometry.cxx | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx index b68aaa591e8..18e6e20ded2 100644 --- a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx +++ b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx @@ -314,10 +314,10 @@ StETofMatchMaker::InitRun( Int_t runnumber ) mETofGeom->init( gGeoManager, etofProjection::safetyMargins, mUseHelixSwimmer ); //provide backline to initiating maker to load DB tables } - if( mETofGeom && !mETofGeom->isInitDone() ) { //if initialization attempt above failed. - LOG_ERROR << "Initialization of StEtofGeometry failed" << endm; - return kStFatal; - } + if ( mETofGeom && !mETofGeom->isInitDone() ) { //if initialization attempt above failed. + LOG_ERROR << "Initialization of StEtofGeometry failed" << endm; + return kStFatal; + } if( mDoQA ) { // for geometry debugging diff --git a/StRoot/StETofUtil/StETofGeometry.cxx b/StRoot/StETofUtil/StETofGeometry.cxx index 74849dd5730..4743e924eeb 100644 --- a/StRoot/StETofUtil/StETofGeometry.cxx +++ b/StRoot/StETofUtil/StETofGeometry.cxx @@ -581,10 +581,10 @@ StETofGeometry::init( TGeoManager* geoManager, const double* safetyMargins = ini readAlignmentDatabase(); } - if( mAlignmentParameters.size() != eTofConst::nCounters * eTofConst::nModules ){ - LOG_ERROR << "StETofGeometry::Init(...) - Wrong size of counter alignment vector. Either incomplete alignment file or non-existant database table." << endm; - return; - } + if( mAlignmentParameters.size() != eTofConst::nCounters * eTofConst::nModules ){ + LOG_ERROR << "StETofGeometry::Init(...) - Wrong size of counter alignment vector. Either incomplete alignment file or non-existant database table." << endm; + return; + } int iCounterAlignment = 0; // loop over sectors @@ -683,7 +683,7 @@ StETofGeometry::reset() LOG_INFO << "StETofGeometry cleared up ...." << endm; mNValidModules = 0; - mAlignmentParameters.clear(); + mAlignmentParameters.clear(); mInitFlag = false; mStarBField = nullptr; From d701a7a33634fc708372da5c559ebc0dfad2e864 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff <36641002+PhilippWeidenkaff@users.noreply.github.com> Date: Wed, 31 Aug 2022 18:20:14 +0200 Subject: [PATCH 60/62] Removed hardcoded old alignment in StEtofMatchmaker.cxx --- StRoot/StETofMatchMaker/StETofMatchMaker.cxx | 32 +++----------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx index 18e6e20ded2..953fdbb60fe 100644 --- a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx +++ b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx @@ -106,34 +106,10 @@ namespace etofProjection { const float maxEtaProjCut = -1.7; - // --> TODO: move to database once alignment procedure is in place - const double deltaXoffset[ 108 ] = { - 2.01, 2.46, 2.91, 2.09, 2.68, 3.34, 2.08, 2.82, 3.46, - 1.68, 2.21, 2.97, 2.03, 2.53, 3.52, 1.99, 2.64, 3.59, - 1.67, 2.17, 2.68, 1.99, 2.69, 3.33, 2.11, 2.80, 3.43, - 1.53, 2.10, 2.59, 1.89, 2.47, 3.19, 2.17, 2.86, 3.60, - 1.35, 1.89, 2.40, 1.75, 2.39, 3.06, 1.97, 2.63, 3.43, - 1.04, 1.78, 2.18, 1.85, 2.34, 3.09, 1.93, 2.56, 3.27, - 1.14, 1.76, 2.27, 1.75, 2.39, 3.05, 1.91, 2.68, 3.28, - 1.34, 1.96, 2.28, 2.02, 2.46, 3.02, 1.88, 2.54, 3.14, - 1.70, 2.22, 2.51, 2.08, 2.65, 3.24, 2.05, 2.78, 3.32, - 1.91, 2.41, 2.86, 2.20, 2.79, 3.35, 2.20, 2.91, 3.50, - 1.97, 2.40, 2.87, 2.08, 2.64, 3.28, 2.06, 2.77, 3.35, - 2.08, 2.52, 3.07, 2.03, 2.67, 3.31, 2.04, 2.74, 3.39 }; - - const double deltaYoffset[ 108 ] = { - 0.79, 0.83, 0.65, 0.18, 0.62, 1.03, -0.22, -0.10, -0.15, - 0.50, 0.63, 0.77, 0.11, 0.53, 1.11, -0.10, -0.24, 0.08, - 0.35, 0.49, 0.36, -0.03, 0.26, 0.84, -0.24, -0.28, -0.15, - 0.20, 0.05, 0.08, -0.24, 0.04, 0.37, -0.41, -0.62, -0.75, - 0.50, 0.63, 0.48, -0.08, 0.28, 0.47, -0.36, -0.39, -0.39, - 0.62, 0.67, 1.03, 0.13, 0.49, 0.75, -0.36, -0.29, -0.30, - 1.05, 1.12, 1.06, 0.15, 0.50, 0.69, -0.29, -0.05, -0.23, - 1.39, 1.17, 1.22, 0.39, 0.63, 0.93, -0.17, -0.50, -0.36, - 1.27, 1.22, 0.89, 0.29, 0.22, 1.06, -0.35, -0.57, -0.54, - 1.67, 1.51, 1.16, 0.33, 0.70, 1.04, 0.09, -0.11, -0.28, - 1.38, 1.31, 0.94, 0.22, 0.49, 0.54, -0.21, -0.26, -0.28, - 1.06, 1.12, 1.29, 0.30, 0.70, 1.34, -0.01, 0.16, -0.03 }; + // Legacy hardcoded alignment. Moved to database. + const double deltaXoffset[ 108 ] = { 0 }; + + const double deltaYoffset[ 108 ] = { 0 }; const double deltaRcut = 4.; } From 591cba1201307720b3a6ddc9916fb314e6575d00 Mon Sep 17 00:00:00 2001 From: Philipp Weidenkaff Date: Thu, 20 Oct 2022 16:24:38 -0400 Subject: [PATCH 61/62] Fixed filling loop for eTOF good event flag in StPicoDst --- StRoot/StPicoEvent/StPicoEvent.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StRoot/StPicoEvent/StPicoEvent.cxx b/StRoot/StPicoEvent/StPicoEvent.cxx index f39454a0013..5cb21f6b1d8 100644 --- a/StRoot/StPicoEvent/StPicoEvent.cxx +++ b/StRoot/StPicoEvent/StPicoEvent.cxx @@ -360,7 +360,7 @@ void StPicoEvent::setETofGoodEventFlag( std::vector flagVec ) { if( flagVec.size() != 108 ){ LOG_INFO << "StPicoEvent::setETofGoodEventFlag() - eTof flag vector wrong size " << flagVec.size() <<" / 108"<< endm; }else{ - for( auto iterCounter : flagVec ){ + for( int iterCounter = 0; iterCounter < flagVec.size(); iterCounter++ ){ mETofGoodEventFlag[iterCounter] = flagVec[iterCounter]; } } From 6e5a9cb7920c69aa02d8188ee99df80dabb831e9 Mon Sep 17 00:00:00 2001 From: PhilippWeidenkaff <36641002+PhilippWeidenkaff@users.noreply.github.com> Date: Fri, 21 Oct 2022 14:29:53 +0200 Subject: [PATCH 62/62] Update StPicoEvent.cxx --- StRoot/StPicoEvent/StPicoEvent.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/StRoot/StPicoEvent/StPicoEvent.cxx b/StRoot/StPicoEvent/StPicoEvent.cxx index 5cb21f6b1d8..2913c2572ed 100644 --- a/StRoot/StPicoEvent/StPicoEvent.cxx +++ b/StRoot/StPicoEvent/StPicoEvent.cxx @@ -360,8 +360,6 @@ void StPicoEvent::setETofGoodEventFlag( std::vector flagVec ) { if( flagVec.size() != 108 ){ LOG_INFO << "StPicoEvent::setETofGoodEventFlag() - eTof flag vector wrong size " << flagVec.size() <<" / 108"<< endm; }else{ - for( int iterCounter = 0; iterCounter < flagVec.size(); iterCounter++ ){ - mETofGoodEventFlag[iterCounter] = flagVec[iterCounter]; - } + std::copy(flagVec.begin(), flagVec.end(), mETofGoodEventFlag); } }