Skip to content

Commit

Permalink
Adding FCS online gain used on DEP in offline DB (star-bnl#668)
Browse files Browse the repository at this point in the history
Adding FCS online gain used on DEP in offline DB which will be used for
offline trigger emulation (StFcsTriggerSimMaker). Offline DB already has
tables pushed. Here is code needed to reading of those tables, and using
them. Assorted macros to push those into DB and input files are also in
here for future reference/updates. Those gainOnline tables will be only
useful for trigger emulation in offline, and other analysis only uses
gain and gaincorr for offline energy gain calibrations.
  • Loading branch information
akioogawa committed May 8, 2024
1 parent 2677be0 commit 7a22206
Show file tree
Hide file tree
Showing 23 changed files with 20,141 additions and 50 deletions.
94 changes: 90 additions & 4 deletions StRoot/StFcsDbMaker/StFcsDb.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,28 @@ void StFcsDb::setFcsPresValley(fcsPresValley_st* t){
else { memcpy(&mFcsPresValley,t,sizeof(fcsPresValley_st)); }
}

void StFcsDb::setFcsEcalGainOnline(fcsEcalGainOnline_st* t){
if(!t) { memset(&mFcsEcalGainOnline,0,sizeof(fcsEcalGainOnline_st)); }
else { memcpy(&mFcsEcalGainOnline,t,sizeof(fcsEcalGainOnline_st)); }
}

void StFcsDb::setFcsHcalGainOnline(fcsHcalGainOnline_st* t){
if(!t) { memset(&mFcsHcalGainOnline,0,sizeof(fcsHcalGainOnline_st)); }
else { memcpy(&mFcsHcalGainOnline,t,sizeof(fcsHcalGainOnline_st)); }
}

void StFcsDb::setFcsPresThreshold(fcsPresThreshold_st* t){
if(!t) { memset(&mFcsPresThreshold,0,sizeof(fcsPresThreshold_st)); }
else { memcpy(&mFcsPresThreshold,t,sizeof(fcsPresThreshold_st)); }
}

int StFcsDb::InitRun(int runNumber) {
LOG_INFO << "StFcsDb::InitRun - run = " << runNumber << endm;
mRun=runNumber;
if(mEtGainMode==0){
if(20000000<mRun && mRun<23027048) mEtGainMode=1;
else mEtGainMode=2;
}

if(mRun19>0){
makeMap2019();
Expand Down Expand Up @@ -354,8 +373,31 @@ int StFcsDb::InitRun(int runNumber) {
readGainCorrFromText();
}

int ie=0, ih=0, ip=0, ehp, ns, crt, slt, dep, ch;
for(int ins=0; ins<kFcsNorthSouth; ins++){
int det=kFcsEcalNorthDetId+ins;
for(int id=0; id<maxId(det); id++){
getDepfromId(det,id,ehp,ns,crt,slt,dep,ch);
mGainOnline[ehp][ns][dep][ch]=mFcsEcalGainOnline.gainOnline[ie];
ie++;
}
det=kFcsHcalNorthDetId+ins;
for(int id=0; id<maxId(det); id++){
getDepfromId(det,id,ehp,ns,crt,slt,dep,ch);
mGainOnline[ehp][ns][dep][ch]=mFcsHcalGainOnline.gainOnline[ih];
ih++;
}
det=kFcsPresNorthDetId+ins;
for(int id=0; id<maxId(det); id++){
getDepfromId(det,id,ehp,ns,crt,slt,dep,ch);
mGainOnline[ehp][ns][dep][ch]=mFcsPresThreshold.threshold[ip];
ip++;
}
}

// Get beamline
TDataSet* dbDataSet = StMaker::GetChain()->GetDataBase("Calibrations/rhic/vertexSeed");
//TDataSet* dbDataSet = StMaker::GetChain()->GetDataBase("Calibrations/rhic/vertexSeed");
TDataSet* dbDataSet = 0;
if(dbDataSet){
vertexSeed_st* vSeed = ((St_vertexSeed*) (dbDataSet->FindObject("vertexSeed")))->GetTable();
if(vSeed){
Expand Down Expand Up @@ -935,6 +977,36 @@ float StFcsDb::getPresValley(int det, int id) const {
return getGainCorrection(det,id);
}

float StFcsDb::getGainOnline(StFcsHit* hit) const {
return getGainOnline(hit->detectorId(), hit->id());
}

float StFcsDb::getGainOnline(int det, int id) const {
switch(mGainOnlineMode){
case GAINMODE::FORCED :
if(det<=kFcsEcalSouthDetId) return mForceUniformGainOnlineEcal;
if(det<=kFcsHcalSouthDetId) return mForceUniformGainOnlineHcal;
if(det<=kFcsPresSouthDetId) return mForceUniformGainOnlinePres;
case GAINMODE::DB :
default:
if(det>=0 && det<kFcsNDet && id>=0 && id<maxId(det)) {
int ehp,ns,dep,ch,crt,slt;
getDepfromId(det,id,ehp,ns,crt,slt,dep,ch);
return mGainOnline[ehp][ns][dep][ch];
}
}
return 1.0;
}

float StFcsDb::getPresThreshold(StFcsHit* hit) const {
return getGainCorrection(hit->detectorId(), hit->id());
}

float StFcsDb::getPresThreshold(int det, int id) const {
return getGainCorrection(det,id);
}


float StFcsDb::getGain8(StFcsHit* hit) const {
return getGain8(hit->detectorId(), hit->id());
}
Expand Down Expand Up @@ -1942,19 +2014,33 @@ float StFcsDb::getEtGain(int det, int id, float factor) const{
}

void StFcsDb::printEtGain(){
// double norm[2]={0.24711, 0.21781}; // [MeV/coint]
// double norm[2]={0.24711, 0.21781}; // [MeV/coint]
double norm[2]={0.24711, 0.24711};
double xoff[2]={6.570*2.54 - 6.850*2.54, 7.430*2.54-8.380*2.54};
double yoff[2]={-5.26,1.80};
double gain=0.0053;
if(mEtGainMode==1){
gain/=0.7;
norm[1]=0.24711;
}
for(int det=0; det<kFcsNDet; det++){
int eh=det/2;
double gain=getGain(det,0);
int ns=det%2;
for(int i=0; i<maxId(det); i++){
double ratio=1.0;
if(eh<2){ //PRES stays 1.0
StThreeVectorD xyz=getStarXYZ(det,i);
double r=xyz.perp();
if(mEtGainMode==1) {
if(ns==0) xyz.setX(xyz.x()-xoff[eh]);
else xyz.setX(xyz.x()+xoff[eh]);
xyz.setY(xyz.y()+yoff[eh]);
}
double r=xyz.perp();
double l=xyz.mag();
double ptch=gain/l*r;
ratio=ptch/norm[eh]*1000;
//printf("BBB det=%1d id=%3d gain=%8.5f xyz=%6.2f %6.2f %6.2f r=%6.2f l=%6.2f ptch=%6.2f ratio==%6.2f\n",
//det,i,gain,xyz.x(),xyz.y(),xyz.z(),r,l,ptch,ratio);
}
mEtGain[det][i]=ratio;
}
Expand Down
29 changes: 28 additions & 1 deletion StRoot/StFcsDbMaker/StFcsDb.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
#include "tables/St_fcsEcalGainCorr_Table.h"
#include "tables/St_fcsHcalGainCorr_Table.h"
#include "tables/St_fcsPresValley_Table.h"
#include "tables/St_fcsEcalGainOnline_Table.h"
#include "tables/St_fcsHcalGainOnline_Table.h"
#include "tables/St_fcsPresThreshold_Table.h"
#include "tables/St_vertexSeed_Table.h"
#include "tables/St_g2t_track_Table.h"
#include "tables/St_g2t_vertex_Table.h"
Expand All @@ -125,7 +128,8 @@ class StFcsDb : public TDataSet {
void setRun(int run); //! set run#
void setRun19(int v=1); //! set run19 geometry, otherwise final run21
void setLeakyHcal(int v=1); //! set leaky Hcal

void setEtGainMode(int v=0) {mEtGainMode=v;} //! set Et Gain Setting 0=Auto from run#, 1=Old, 2=New(23027048)

//! Setting DB table
void setFcsDetectorPosition(fcsDetectorPosition_st* t); //! set fcsDetectorPosition_st*
void setFcsEcalGain(fcsEcalGain_st*); //! set fcsEcalGain_st*
Expand All @@ -134,6 +138,9 @@ class StFcsDb : public TDataSet {
void setFcsEcalGainCorr(fcsEcalGainCorr_st*); //! set fcsEcalGainCorr_st*
void setFcsHcalGainCorr(fcsHcalGainCorr_st*); //! set fcsHcalGainCorr_st*
void setFcsPresValley(fcsPresValley_st*); //! set fcsPresValley_st*
void setFcsEcalGainOnline(fcsEcalGainOnline_st*); //! set fcsEcalGainOnline_st*
void setFcsHcalGainOnline(fcsHcalGainOnline_st*); //! set fcsHcalGainOnline_st*
void setFcsPresThreshold(fcsPresThreshold_st*); //! set fcsPresThreshold_st*

//! Utility functions related to FCS ChannelGeometry
int maxDetectorId() const; //! 6
Expand Down Expand Up @@ -216,6 +223,10 @@ class StFcsDb : public TDataSet {
float getGainCorrection(StFcsHit* hit) const; //! get the gain correction for the channel
float getPresValley(int det, int id) const; //! get the pres valley position for cut
float getPresValley(StFcsHit* hit) const; //! get the pres valley position for cut
float getGainOnline(int det, int id) const; //! get the gain correction for the channel
float getGainOnline(StFcsHit* hit) const; //! get the gain correction for the channel
float getPresThreshold(int det, int id) const; //! get the pres valley position for cut
float getPresThreshold(StFcsHit* hit) const; //! get the pres valley position for cut

enum GAINMODE { FIXED, DB, FORCED, TXT }; //! Gain mode switch
void forceFixGain() {mGainMode=GAINMODE::FIXED;} //! fixed default gain
Expand All @@ -232,6 +243,12 @@ class StFcsDb : public TDataSet {
mForceUniformGainCorrectionHcal=hcal;
mForceUniformGainCorrectionPres=pres;
}
void forceUniformGainOnline(float ecal, float hcal=1.0, float pres=0.5){
mGainCorrMode=GAINMODE::FORCED; //! force a specified value
mForceUniformGainOnlineEcal=ecal;
mForceUniformGainOnlineHcal=hcal;
mForceUniformGainOnlinePres=pres;
}

//! reading gain from text files
void setReadGainFromText(const char* file="fcsgain.txt") {strcpy(mGainFilename,file); mGainMode=GAINMODE::TXT;}
Expand Down Expand Up @@ -308,6 +325,7 @@ class StFcsDb : public TDataSet {
int mDebug=0; //! >0 dump tables to text files
int mRun19=0; //! run19 flag
int mLeakyHcal=0; //! LeakyHcal has different center positions
int mEtGainMode=0; //! ET Gain Setting

GAINMODE mGainMode = GAINMODE::DB; //! Gain mode selection
float mForceUniformGainEcal=-1.0; //! forcing a value
Expand All @@ -322,11 +340,17 @@ class StFcsDb : public TDataSet {
float mForceUniformGainCorrectionPres=-1.0; //! forcing a value
char mGainCorrFilename[256]; //! gaincorr filename
void readGainCorrFromText();

GAINMODE mGainOnlineMode = GAINMODE::DB; //! GainOnline mode selection
float mForceUniformGainOnlineEcal=-1.0; //! forcing a value
float mForceUniformGainOnlineHcal=-1.0; //! forcing a value
float mForceUniformGainOnlinePres=-1.0; //! forcing a value

//DEP sorted ped/gain/corr
float mPed[kFcsEHP][kFcsNorthSouth][kFcsMaxDepBd][kFcsMaxDepCh]; //! Pedestal
float mGain[kFcsEHP][kFcsNorthSouth][kFcsMaxDepBd][kFcsMaxDepCh]; //! Gain
float mGainCorr[kFcsEHP][kFcsNorthSouth][kFcsMaxDepBd][kFcsMaxDepCh]; //! GainCorr (Valley value for PRES)
float mGainOnline[kFcsEHP][kFcsNorthSouth][kFcsMaxDepBd][kFcsMaxDepCh]; //! GainOnline (Threshold value for PRES)

//Beam line parameters
double mVx=0.0; //! beamline x offset
Expand All @@ -344,6 +368,9 @@ class StFcsDb : public TDataSet {
fcsEcalGainCorr_st mFcsEcalGainCorr;
fcsHcalGainCorr_st mFcsHcalGainCorr;
fcsPresValley_st mFcsPresValley;
fcsEcalGainOnline_st mFcsEcalGainOnline;
fcsHcalGainOnline_st mFcsHcalGainOnline;
fcsPresThreshold_st mFcsPresThreshold;

/// Getting pointer to parent & primary g2t_track from StFcsCluster
/// mode=0 for parent, and mode=1 for primary
Expand Down
31 changes: 31 additions & 0 deletions StRoot/StFcsDbMaker/StFcsDbMaker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
#include "tables/St_fcsEcalGainCorr_Table.h"
#include "tables/St_fcsHcalGainCorr_Table.h"
#include "tables/St_fcsPresValley_Table.h"
#include "tables/St_fcsEcalGainOnline_Table.h"
#include "tables/St_fcsHcalGainOnline_Table.h"
#include "tables/St_fcsPresThreshold_Table.h"
#include "tables/St_vertexSeed_Table.h"

ClassImp(StFcsDbMaker)
Expand Down Expand Up @@ -196,6 +199,9 @@ int StFcsDbMaker::InitRun(int runNumber) {
St_fcsEcalGainCorr *dbFcsEcalGainCorr =0;
St_fcsHcalGainCorr *dbFcsHcalGainCorr =0;
St_fcsPresValley *dbFcsPresValley =0;
St_fcsEcalGainOnline *dbFcsEcalGainOnline =0;
St_fcsHcalGainOnline *dbFcsHcalGainOnline =0;
St_fcsPresThreshold *dbFcsPresThreshold =0;
DBcalib = GetInputDB("Calibrations/fcs");
if(!DBcalib){
LOG_ERROR << "StFcsDbMaker::InitRun - No Calibration/fcs"<<endm;
Expand All @@ -206,6 +212,9 @@ int StFcsDbMaker::InitRun(int runNumber) {
dbFcsEcalGainCorr = (St_fcsEcalGainCorr*) DBcalib->Find("fcsEcalGainCorr");
dbFcsHcalGainCorr = (St_fcsHcalGainCorr*) DBcalib->Find("fcsHcalGainCorr");
dbFcsPresValley = (St_fcsPresValley*) DBcalib->Find("fcsPresValley");
dbFcsEcalGainOnline = (St_fcsEcalGainOnline*)DBcalib->Find("fcsEcalGainOnline");
dbFcsHcalGainOnline = (St_fcsHcalGainOnline*)DBcalib->Find("fcsHcalGainOnline");
dbFcsPresThreshold = (St_fcsPresThreshold*) DBcalib->Find("fcsPresThreshold");
}

//Ecal Gain
Expand Down Expand Up @@ -250,6 +259,28 @@ int StFcsDbMaker::InitRun(int runNumber) {
}else{
mFcsDb->setFcsPresValley((fcsPresValley_st*) dbFcsPresValley->GetTable());
}

//Ecal GainOnline
if(!dbFcsEcalGainOnline) {
LOG_ERROR << "StFcsDbMaker::InitRun - No Calibration/fcs/fcsEcalGainOnline"<<endm;
mFcsDb->setFcsEcalGainOnline(0);
}else{
mFcsDb->setFcsEcalGainOnline((fcsEcalGainOnline_st*) dbFcsEcalGainOnline->GetTable());
}
//Hcal GainOnline
if(!dbFcsHcalGainOnline) {
LOG_ERROR << "StFcsDbMaker::InitRun - No Calibration/fcs/fcsHcalGainOnline"<<endm;
mFcsDb->setFcsHcalGainOnline(0);
}else{
mFcsDb->setFcsHcalGainOnline((fcsHcalGainOnline_st*) dbFcsHcalGainOnline->GetTable());
}
//Pres Threshold
if(!dbFcsPresThreshold) {
LOG_ERROR << "StFcsDbMaker::InitRun - No Calibration/fcs/fcsPresThreshold"<<endm;
mFcsDb->setFcsPresThreshold(0);
}else{
mFcsDb->setFcsPresThreshold((fcsPresThreshold_st*) dbFcsPresThreshold->GetTable());
}
}

mFcsDb->InitRun(runNumber);
Expand Down
Loading

0 comments on commit 7a22206

Please sign in to comment.