Skip to content

Commit

Permalink
Provide manual timecut control for fast offline production and calibr… (
Browse files Browse the repository at this point in the history
#686)

…ation

This allows the StFttClusterMaker to be set to manually override DB
timeline cuts for processing fast offline and for running calibrations

---------

Co-authored-by: Dmitri Smirnov <[email protected]>
  • Loading branch information
jdbrice and plexoos committed Jun 24, 2024
1 parent 75ca35d commit 9811528
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 13 deletions.
58 changes: 46 additions & 12 deletions StRoot/StFttClusterMaker/StFttClusterMaker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <map>
#include <array>
#include <algorithm> // std::is_sorted

#include <climits>

#include "StEvent.h"
#include "StEnumerations.h"
Expand Down Expand Up @@ -209,18 +209,52 @@ void StFttClusterMaker::InjectTestData(){
} // InjectTestData


/**
* @brief Checks if a hit passes the time cut.
*
* This function checks if a given hit passes the time cut based on
* the current time cut mode.
* - mTimeCutMode = kTimeCutModeAcceptAll: accept all hits
* - mTimeCutMode = kTimeCutModeDB: use the time cut from the database
* - mTimeCutMode = kTimeCutModeCalibratedTime: use the calibrated time cut
* set by the user
* - mTimeCutMode = kTimeCutModeTimebin: use the timebin cut set by the user
*
* if unrecognized time cut mode is set, the function will return true accepting all hits
*
* @param hit Pointer to the StFttRawHit object to be checked.
* @return true if the hit passes the time cut, false otherwise.
*/
bool StFttClusterMaker::PassTimeCut( StFttRawHit * hit ){
int time_cut0 = -999;
int time_cut1 = 999;
int time_cutm = 0;
// in principle it could vary VMM to VMM;
mFttDb->getTimeCut(hit, time_cutm, time_cut0, time_cut1);
if ( time_cutm == 0 ) // default, cut on bunch crossing
return (hit->time() <= time_cut1 && hit->time() >= time_cut0);

// cut on timebin
return (hit->tb() <= time_cut1 && hit->tb() >= time_cut0);
}
if (mTimeCutMode == kTimeCutModeAcceptAll)
return true;
else if (mTimeCutMode == kTimeCutModeDB ) {
int timeCutMin = INT_MIN;
int timeCutMax = INT_MAX;
int hitTimeMode = (int)kHitCalibratedTime;

mFttDb->getTimeCut(hit, hitTimeMode, timeCutMin, timeCutMax);
LOG_DEBUG << TString::Format( "StFttClusterMaker::PassTimeCut - DB gave hit time mode: %d, time cut min: %d, time cut max: %d", hitTimeMode, timeCutMin, timeCutMax ) << endm;
if (hitTimeMode == kHitCalibratedTime) {
return (hit->time() >= timeCutMin && hit->time() <= timeCutMax);
} else if ( hitTimeMode == kHitTimebin ) {
return (hit->tb() >= timeCutMin && hit->tb() <= timeCutMax);
} else {
LOG_WARN << "StFttClusterMaker::PassTimeCut - Unknown hit time mode from database: " << hitTimeMode << endm;
LOG_WARN << "Accepting all hits" << endm;
return true;
}
} else if (mTimeCutMode == kTimeCutModeCalibratedTime) {
return (hit->time() >= mTimeCutMin && hit->time() <= mTimeCutMax);
} else if (mTimeCutMode == kTimeCutModeTimebin) {
return (hit->tb() >= mTimeCutMin && hit->tb() <= mTimeCutMax);
} else {
LOG_WARN << "StFttClusterMaker::PassTimeCut - Unknown time cut mode: " << mTimeCutMode << endm;
LOG_WARN << "Accepting all hits" << endm;
return true; // Default return value if no conditions are met
}
return true;
} // PassTimeCut


StFttRawHit * StFttClusterMaker::FindMaxAdc( std::vector<StFttRawHit *> hits, size_t &pos ){
Expand Down
22 changes: 21 additions & 1 deletion StRoot/StFttClusterMaker/StFttClusterMaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class StFttClusterMaker: public StMaker {
int Finish();
int Make();

void SetTimeCut( int mode, int min, int max ) {
mTimeCutMode = mode;
mTimeCutMin = min;
mTimeCutMax = max;
}

private:
void ApplyHardwareMap();
std::vector<StFttCluster*> FindClusters( std::vector<StFttRawHit * > );
Expand All @@ -51,8 +57,22 @@ class StFttClusterMaker: public StMaker {
bool mDebug;
StFttDb* mFttDb;

enum HitTimeModes {
kHitCalibratedTime = 0,
kHitTimebin = 1
};
enum TimeCutModes {
kTimeCutModeDB = 0,
kTimeCutModeAcceptAll = 1,
kTimeCutModeCalibratedTime = 2,
kTimeCutModeTimebin = 3
};
int mTimeCutMin = -40; // value from Run22 - Run24 online QA approximately 1 bx
int mTimeCutMax = 100; // value from Run22 - Run24 online QA approximately 1 bx
int mTimeCutMode = 0; //default - kTimeCutModeDB, CINT cant use the enum directly


ClassDef( StFttClusterMaker, 1 )
ClassDef( StFttClusterMaker, 0 )
};

#endif // STFTTCLUSTERMAKER_H

0 comments on commit 9811528

Please sign in to comment.