Skip to content

Commit

Permalink
Merge branch 'main' into QA_FCS
Browse files Browse the repository at this point in the history
  • Loading branch information
genevb authored Mar 26, 2024
2 parents 3faae9a + ffa7b94 commit 2ec9cc9
Show file tree
Hide file tree
Showing 15 changed files with 1,107 additions and 168 deletions.
9 changes: 9 additions & 0 deletions StRoot/StBFChain/BigFullChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,15 @@ Bfc_st BFC[] = { // standard chains
"B2023a,ITTF,BAna,iTpcIT,hitfilt,VFMinuit,etofa,btof,mtd,l3onl,emcDY2,epdHit,trgd,ZDCvtx,analysis",
"","", "Base chain for year 2023 AA data - CorrY (+ l3, epd, mtd, b/etof, b-emc)",kFALSE},

// 2024 initial chains
{"B2024a" ,"","",
"ry2024a,in,tpcX,UseXgeom,iTpcIT,CorrY,AgML,tpcDB,TpcHitMover,Idst,tags,Tree,picoWrite,picoVtxDefault,picoCovMtxWrite",
"","", "Base chain for run 2024 data (tpc)",kFALSE},

{"pp2024a","" ,"",
"B2024a,ITTF,BAna,hitfilt,ppOpt,ImpBToFt0Mode,VFPPVnoCTB,beamline3D,l3onl,epdhit,btof,mtd,emcDY2,ftt,fcs,trgd,ZDCvtx,analysis",
"","","Production chain for year 2024 pp data - CorrY (+ l3, epd, mtd, btof, fcs, ftt, e/b-emc)",kFALSE},


// Other chains/Calibration
{"LaserCal0","" ,"","db,detDb,tpc_daq,tpcDb,tcl,globT,laser,LaserTest","",""
Expand Down
42 changes: 13 additions & 29 deletions StRoot/StBTofCalibMaker/StBTofCalibMaker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2835,36 +2835,20 @@ void StBTofCalibMaker::writePPPAHistograms()
//_____________________________________________________________________________
float StBTofCalibMaker::tofCellResolution(const Int_t itray, const Int_t iModuleChan)
{
float resolution(0.013); // 0.013 by default - 1/beta resolution
if (itray<0){return resolution;}

float resolution(0.013); // 0.013 by default - 1/beta resolution
if (itray<0){return resolution;}

int module = iModuleChan/6 + 1;
int cell = iModuleChan%6 + 1;
// mBTofRes::timeres_tof() reports in picoseconds
float stop_resolution = mBTofRes->timeres_tof(itray, module, cell)/1000.;

float start_resolution(0);
if (mUseVpdStart){

// For VPD timing determine the VPD starttime by combing the resolutions of
// tray == 122 (east)
// mSimParams[singleHit.tubeId-1+19].singleTubeRes
// tray 121 (west)
// mSimParams[singleHit.tubeId-1].singleTubeRes
//
// needs to be implemented

}
else {
// combine an average BTOF resolution based on NT0
// more sophisticated: figure out what BTOF cells actually went into the NT0 count.

// mBTofRes::timeres_tof() reports in picoseconds
start_resolution = mBTofRes->average_timeres_tof()/sqrt(mNTzero)/1000.;
}
int module = iModuleChan/6 + 1;
int cell = iModuleChan%6 + 1;
// mBTofRes::timeres_tof() reports in picoseconds
float stop_resolution = mBTofRes->timeres_tof(itray, module, cell)/1000.;

resolution = sqrt(stop_resolution*stop_resolution + start_resolution*start_resolution);
float start_resolution = 0.0;
if (mUseVpdStart)
start_resolution = mVpdResConfig->singleTubeRes(mVPDHitPatternEast, mVPDHitPatternWest)/1000.;
else
start_resolution = mBTofRes->average_timeres_tof()/sqrt(mNTzero)/1000.;
resolution = sqrt(stop_resolution*stop_resolution + start_resolution*start_resolution);

return resolution;
return resolution;
}
38 changes: 26 additions & 12 deletions StRoot/StBTofUtil/StVpdSimConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,35 @@ class StVpdSimConfig : public StMaker {
//! structure containing tube parameters
struct SingleTubeParams{
float singleTubeRes; //!< Resolution of a particular Vpd tube in ps
int tubeId; //!< Tube Id (number) [0,37] with west Vpd [0,18] and east Vpd [19,37]
int tubeStatusFlag; //!< Status flag for whether tube was active (1) or inactive (0)
int tubeTriggerFlag; //!< Status flag for whether tube was triggered on (1) or not (0)
int tubeId, //!< Tube Id (number) [0,37] with west Vpd [0,18] and east Vpd [19,37]
tubeStatusFlag, //!< Status flag for whether tube was active (1) or inactive (0)
tubeTriggerFlag; //!< Status flag for whether tube was triggered on (1) or not (0)
};

/// calculate correct resolution based on those tubes that were used
double singleTubeRes(UInt_t mVPDHitPatternEast, UInt_t mVPDHitPatternWest){
double vpdResSumSqr(0.), vpdresolution(0.);
for (int i=0; i<19; i++){
if (1 << i && mVPDHitPatternEast) vpdResSumSqr += (mSimParams[i].singleTubeRes)*(mSimParams[i].singleTubeRes);
if (1 << i && mVPDHitPatternWest) vpdResSumSqr += (mSimParams[i+19].singleTubeRes)*(mSimParams[i+19].singleTubeRes);
/**
* @brief Calculate correct resolution based on those tubes that were used.
*
* @param mVPDHitPatternEast 9 digit binary number specifying hit pattern of east VPD tubes.
* @param mVPDHitPatternWest 9 digit binary number specifying hit pattern of west VPD tubes.
* @return double vpd resolution.
*/
double singleTubeRes(UInt_t mVPDHitPatternEast, UInt_t mVPDHitPatternWest){
double vpdResSumSqr(0.),
vpdresolution(0.);
int total_vpd_hits = 0; //Total number of vpd tubes used.
for (int i=0; i<19; i++){
if (1 << i & mVPDHitPatternEast) {
vpdResSumSqr += (mSimParams[i].singleTubeRes)*(mSimParams[i].singleTubeRes);
total_vpd_hits += 1;
}
if (1 << i & mVPDHitPatternWest) {
vpdResSumSqr += (mSimParams[i+19].singleTubeRes)*(mSimParams[i+19].singleTubeRes);
total_vpd_hits += 1;
}
}
vpdresolution = sqrt(vpdResSumSqr);
return vpdresolution;
}
vpdresolution = sqrt(vpdResSumSqr)/total_vpd_hits;
return vpdresolution;
}

/**
* Calculates the average resolution across all 38 tubes (discounts inactive tubes)
Expand Down
4 changes: 2 additions & 2 deletions StRoot/StChain/GeometryDbAliases.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ static const DbAlias_t fDbAlias[] = {// geometry Comment old
{ "y2023", 20230410, 0, "y2023", "y2023 first cut geometry, AgML,xgeometry"},
{ "y2023a", 20230410, 1, "y2023a", "y2023a production geometry, AgML,xgeometry"},

{ "y2023", 20231210, 0, "y2024", "y2024 first cut geometry, AgML,xgeometry"},
{ "y2023a", 20231210, 1, "y2024a", "y2024a production geometry, AgML,xgeometry"},
{ "y2024", 20231210, 0, "y2024", "y2024 first cut geometry, AgML,xgeometry"},
{ "y2024a", 20231210, 1, "y2024a", "y2024a production geometry, AgML,xgeometry"},

{"dev2021", 21201210, 1, "dev2021", "-deprecated- geometry for 2021+ forward program,AgML,xgeometry"},
{"dev2022", 21211210, 1, "dev2022", "development geometry for 2022+ forward program,AgML,xgeometry"},
Expand Down
119 changes: 60 additions & 59 deletions StRoot/StETofCalibMaker/StETofCalibMaker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1233,37 +1233,32 @@ StETofCalibMaker::processStEvent()
// 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<bool> 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);
std::vector<bool> goodEventFlagVec;
std::vector<bool> hasPulsersVec;

//drag along pulser information
for( unsigned int iCounter = 0; iCounter < 108; iCounter++){
if ( !(mNPulsersCounter.count(iCounter) ) ){
hasPulsersVec.push_back(false);
}else{
hasPulsersVec.push_back(mNPulsersCounter[iCounter] == 2);
}
}
if (hasPulsersVec.size() == 108){
//etofHeader->setHasPulsersVec(hasPulsersVec); // not working but not of relevance at the moment
}

//fill good event flag into header
for( unsigned int iGet4 = 0; iGet4 < 1728; iGet4++){
goodEventFlagVec.push_back(!etofHeader->missMatchFlagVec().at(iGet4));
}

if (goodEventFlagVec.size() == 1728){
etofHeader->setGoodEventFlagVec(goodEventFlagVec);
}
}
}


/// second loop to apply calibrations to (non-pulser) digis inside the timing window
StructStuckFwDigi current = { -1, -1., -1. };
Expand Down Expand Up @@ -1368,6 +1363,7 @@ StETofCalibMaker::processMuDst()
mResetTime = fmod( resetTime( ( StETofHeader* ) etofHeader ), eTofConst::bTofClockCycle );
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; i<nDigis; i++ ) {
//LOG_INFO << "accessing etof digis: "<< i <<"/"<< nDigis << endm;
Expand All @@ -1381,56 +1377,56 @@ StETofCalibMaker::processMuDst()
//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;
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;

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<bool> goodEventFlagVec;
std::vector<bool> hasPulsersVec;//

//drag along pulser information
for( unsigned int iCounter = 0; iCounter < 108; iCounter++){
if ( !(mNPulsersCounter.count(iCounter) ) ){
hasPulsersVec.push_back(false);
}else{
hasPulsersVec.push_back(mNPulsersCounter[iCounter] == 2);
}
}

if (hasPulsersVec.size() == 108){
etofHeader->setHasPulsersVec(hasPulsersVec);
}

//fill good event flag into header
for( unsigned int iGet4 = 0; iGet4 < 1728; iGet4++){
goodEventFlagVec.push_back(!etofHeader->missMatchFlagVec().at(iGet4));
}

std::vector<bool> 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() == 1728){
etofHeader->setGoodEventFlagVec(goodEventFlagVec);
}
if (goodEventFlagVec.size() == 108){
etofHeader->setGoodEventFlagVec(goodEventFlagVec);
}
}
}

/// second loop to apply calibrations to (non-pulser) digis inside the timing window
StructStuckFwDigi current = { -1, -1., -1. };
Expand Down Expand Up @@ -1470,7 +1466,6 @@ StETofCalibMaker::processMuDst()
prev = current;
}


/// calculate calibrated time and tot for the digi
/// only for digis inside the timing window
applyCalibration( aDigi, etofHeader );
Expand Down Expand Up @@ -1569,22 +1564,28 @@ StETofCalibMaker::flagPulserDigis( StETofDigi* aDigi, unsigned int index, std::m

unsigned int key = aDigi->sector() * 1000 + aDigi->zPlane() * 100 + aDigi->counter() * 10 + aDigi->side();


// pulser channel
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 || fabs( totToHalfPeak ) < 10 ) {
isPulserCand = true;
}
}
}


if( isPulserCand ) {
pulserDigiMap[ key ].push_back( index );
}

}


Expand Down
Loading

0 comments on commit 2ec9cc9

Please sign in to comment.