Skip to content

Commit

Permalink
Merge pull request #2 from LucasEhinger/dig_dev
Browse files Browse the repository at this point in the history
Merge dig_dev into main. Allows for full replay of digitized hodo (and now gem) detectors
  • Loading branch information
LucasEhinger authored Feb 6, 2025
2 parents 8d0b208 + 219f371 commit 59492b4
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 59 deletions.
51 changes: 31 additions & 20 deletions src/LADSimDecoder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -553,35 +553,35 @@ Int_t LADSimDecoder::LoadDetector(std::map<Decoder::THaSlotData *, std::vector<U
}
}

if (strcmp(detname.c_str(), "bb.gem") == 0) {
if (strcmp(detname.c_str(), "L.gem") == 0) {
// cout << fPx << " " << fPy << " " << fPz << " " << fVz << endl;
samps.clear();
strips.clear();
// cout << " ouh " << detname.c_str() << " " << simev->Tlad->Earm_BBGEM_dighit_nstrips << endl;
assert(simev->Tlad->b_Earm_BBGEM_dighit_nstrips);
for (int j = 0; j < simev->Tlad->Earm_BBGEM_dighit_nstrips; j++) {
// cout << " ouh " << detname.c_str() << " " << simev->Tlad->LAD_GEM_dighit_nstrips << endl;
assert(simev->Tlad->b_LAD_GEM_dighit_nstrips);
for (int j = 0; j < simev->Tlad->LAD_GEM_dighit_nstrips; j++) {
loadevt = false;
mod = simev->Tlad->Earm_BBGEM_dighit_module->at(j);
lchan = simev->Tlad->Earm_BBGEM_dighit_strip->at(j);
mod = simev->Tlad->LAD_GEM_dighit_module->at(j);
lchan = simev->Tlad->LAD_GEM_dighit_strip->at(j);
apvnum = APVnum(detname, mod, lchan, crate, slot, chan);

if (simev->Tlad->Earm_BBGEM_dighit_samp->at(j) >= 0) {
if (simev->Tlad->LAD_GEM_dighit_samp->at(j) >= 0) {
strips.push_back(chan);
samps.push_back(simev->Tlad->Earm_BBGEM_dighit_adc->at(j));
samps.push_back(simev->Tlad->LAD_GEM_dighit_adc->at(j));
}

if (fDebug > 3)
cout << " mod " << mod << " lchan " << lchan << " crate " << crate << " slot " << slot << " apvnum " << apvnum
<< " chan " << chan << " samp " << simev->Tlad->Earm_BBGEM_dighit_samp->at(j) << " adc "
<< simev->Tlad->Earm_BBGEM_dighit_adc->at(j) << endl;
// if(mod>=26 && simev->Tlad->Earm_BBGEM_dighit_samp->at(j)==5)cout << mod << " " << lchan << " " << apvnum <<
<< " chan " << chan << " samp " << simev->Tlad->LAD_GEM_dighit_samp->at(j) << " adc "
<< simev->Tlad->LAD_GEM_dighit_adc->at(j) << endl;
// if(mod>=26 && simev->Tlad->LAD_GEM_dighit_samp->at(j)==5)cout << mod << " " << lchan << " " << apvnum <<
// endl;

if (j == simev->Tlad->Earm_BBGEM_dighit_nstrips - 1) {
if (j == simev->Tlad->LAD_GEM_dighit_nstrips - 1) {
loadevt = true;
} else if (mod != simev->Tlad->Earm_BBGEM_dighit_module->at(j + 1) ||
// fabs(lchan-simev->Tlad->Earm_BBGEM_dighit_strip->at(j+1))>=128
floor(simev->Tlad->Earm_BBGEM_dighit_strip->at(j + 1) / 128) != floor(lchan / 128)) {
} else if (mod != simev->Tlad->LAD_GEM_dighit_module->at(j + 1) ||
// fabs(lchan-simev->Tlad->LAD_GEM_dighit_strip->at(j+1))>=128
floor(simev->Tlad->LAD_GEM_dighit_strip->at(j + 1) / 128) != floor(lchan / 128)) {
loadevt = true;
}

Expand Down Expand Up @@ -652,7 +652,8 @@ void LADSimDecoder::SetDetectors() {
// If the following works, we should be gold:
// TDatime rundate;
// rundate.Set(GetRunTime()); // GetRunTime() gives the run time as a UNIX time
TDatime rundate(124, 1, 1, 0, 0, 0); // FIXME: this is a hack, but it should work for now
// TDatime rundate(124, 1, 1, 0, 0, 0); // FIXME: this is a hack, but it should work for now
TDatime rundate(134, 1, 1, 0, 0, 0); // FIXME: this is a hack, but it should work for now

rundate.Print();

Expand All @@ -668,9 +669,16 @@ void LADSimDecoder::SetDetectors() {
// AddDetector(Form("%s.%s",app->GetName(), det->GetName()),
// (app->GetDetector(det->GetName()))->GetInitDate());

// AddDetector(Form("%s.%s", app->GetName(), det->GetName()), rundate);
string tmp = "L.hod"; //TODO: FIXME. This is hard coded
AddDetector(tmp, rundate); // FIXME: this is a hack, but it should work for now
AddDetector(Form("%s.%s", app->GetName(), det->GetName()), rundate);
// string tmp;// = "L.hod"; //TODO: FIXME. This is hard coded. Should delete.
// if (strcmp(det->GetName(), "hod") == 0) {
// tmp = "L.hod"; //TODO: FIXME. This is hard coded
// }
// else{
// tmp = "bb.gem"; //TODO: FIXME. This is hard coded
// }

// AddDetector(tmp, rundate); // FIXME: this is a hack, but it should work for now
}
}
}
Expand All @@ -689,7 +697,8 @@ Int_t LADSimDecoder::ReadDetectorDB(std::string detname, TDatime date) {
// const string &fileName = path + "db_" + detname + ".dat";

// const string fileName = "DBASE/LAD/general.param"; // TODO: FIXME. This is hard coded
const string fileName = "MAPS/LAD/DETEC/HODO/lhodo_mc.map"; // TODO: FIXME. This is hard coded
// const string fileName = "MAPS/LAD/DETEC/HODO/lhodo_mc_input.map"; // TODO: FIXME. This is hard coded
const string fileName = "MAPS/LAD/DETEC/GEM/lgem_mc_input.map"; // TODO: FIXME. This is hard coded

const string prefix = detname + ".";
// First, open the common db file and parse info there, later, the
Expand Down Expand Up @@ -1020,6 +1029,8 @@ int LADSimDecoder::APVnum(const std::string &detname, Int_t mod, Int_t h_chan, I
// << h_chan << ", " << chan << ", " << n << ")" << std::endl;

assert((size_t)mod < fInvGEMDetMap.at(detname).size());
// cout << "mod " << mod << " size " << fInvGEMDetMap.at(detname).size() << endl;
// cout << "n " << n << " size " << (fInvGEMDetMap.at(detname)[mod]).size() << endl;
assert((size_t)n < (fInvGEMDetMap.at(detname)[mod]).size());

// if( mod>fInvGEMDetMap.at(detname).size() ){
Expand Down
2 changes: 1 addition & 1 deletion src/LADSimFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Int_t LADSimFile::Init()
// Initialize the run. Sets run date, reads run database etc.

// TODO: get date from MC production file?
//fDate.Set(2012,1,1,0,0,0);
fDate.Set(2012,1,1,0,0,0);
fAssumeDate = kTRUE;
fDataSet |= kDate;

Expand Down
2 changes: 1 addition & 1 deletion src/THcLADGEMModule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ Int_t THcLADGEMModule::ReadDatabase( const TDatime& date )

const DBRequest list[] = {
{ "lgem_chanmap_file", &fChanMapFileName, kString},
{ "is_mc", &fIsMC, kInt, 0,1},
{0}
};
gHcParms->LoadParmValues((DBRequest*)&list, "");
Expand Down Expand Up @@ -809,7 +810,6 @@ Int_t THcLADGEMModule::Decode( const THaEvData& evdata )

rawStrip[iraw] = strip;
Strip[iraw] = GetStripNumber( strip, it->pos, it->invert );

rawADC[iraw] = ADC;

double ped = (axis == LADGEM::kUaxis ) ? fPedestalU[Strip[iraw]] : fPedestalV[Strip[iraw]];
Expand Down
12 changes: 8 additions & 4 deletions src/THcLADHodoPlane.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ Int_t THcLADHodoPlane::ReadDatabase(const TDatime &date) {
{"hodo_SampNSB", &fSampNSB, kInt, 0, 1},
{"hodo_OutputSampWaveform", &fOutputSampWaveform, kInt, 0, 1},
{"hodo_UseSampWaveform", &fUseSampWaveform, kInt, 0, 1},
{"is_simulation", &fIsSimulation, kInt, 0, 1},
{0}};

// Set Default values
Expand All @@ -454,9 +453,14 @@ Int_t THcLADHodoPlane::ReadDatabase(const TDatime &date) {
fSampNSAT = 2; // default value in THcRawHit::SetF250Params
fOutputSampWaveform = 0; // 0= no output , 1 = output Sample Waveform
fUseSampWaveform = 0; // 0= do not use , 1 = use Sample Waveform
fIsSimulation = 0;

gHcParms->LoadParmValues((DBRequest *)&list, prefix);

DBRequest list5[] = {{"is_mc", &fIsMC, kInt, 0, 1}, {0}};
fIsMC = 0;
gHcParms->LoadParmValues((DBRequest *)&list5, "");



if (fCosmicFlag == 1)
cout << " setup for cosmics in scint plane" << endl;
Expand Down Expand Up @@ -965,7 +969,7 @@ Int_t THcLADHodoPlane::ProcessHits(TClonesArray *rawhits, Int_t nexthit) {
if (fSampNSB == 0)
fSampNSB = rawTopAdcHit.GetF250_NSB();

if (!fIsSimulation)
if (!fIsMC)
rawTopAdcHit.SetF250Params(fSampNSA, fSampNSB, 4); // Set NPED =4

if (fSampNSAT != 2)
Expand Down Expand Up @@ -1086,7 +1090,7 @@ Int_t THcLADHodoPlane::ProcessHits(TClonesArray *rawhits, Int_t nexthit) {
if (fSampNSB == 0)
fSampNSB = rawBtmAdcHit.GetF250_NSB();

if (!fIsSimulation)
if (!fIsMC)
rawBtmAdcHit.SetF250Params(fSampNSA, fSampNSB, 4); // Set NPED =4

if (fSampNSAT != 2)
Expand Down
2 changes: 1 addition & 1 deletion src/THcLADHodoPlane.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class THcLADHodoPlane : public THaSubDetector {
Int_t fSampNSB;
Int_t fOutputSampWaveform;
Int_t fUseSampWaveform;
Int_t fIsSimulation;
Int_t fIsMC;

Double_t fPosBtm;
Double_t fPosTop;
Expand Down
28 changes: 16 additions & 12 deletions src/THcLADHodoscope.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ Int_t THcLADHodoscope::ReadDatabase(const TDatime &date) {
// we will need to use the detector name to load parameters
// for each detector -- to be updated
fNPaddle = new Int_t[fNPlanes];
fFPTime = new Double_t[fNPlanes];
for (int ip = 0; ip < fNPlanes; ip++) {
string parname = "hodo_" + string(fPlanes[ip]->GetName()) + "_nr";
DBRequest list2[] = {{parname.c_str(), &fNPaddle[ip], kInt}, {0}};
Expand Down Expand Up @@ -321,19 +322,21 @@ Int_t THcLADHodoscope::ReadDatabase(const TDatime &date) {
{"hodo_TopAdcTimeWindowMax", fHodoTopAdcTimeWindowMax, kDouble, (UInt_t)fMaxHodoScin, 1},
{"hodo_BtmAdcTimeWindowMin", fHodoBtmAdcTimeWindowMin, kDouble, (UInt_t)fMaxHodoScin, 1},
{"hodo_BtmAdcTimeWindowMax", fHodoBtmAdcTimeWindowMax, kDouble, (UInt_t)fMaxHodoScin, 1},
{"is_simulation", &fIsSimulation, kInt, 0, 1},
{0}};

fCosmicFlag = 0;
fCosmicFlag = 0;
fNumPlanesBetaCalc = 2;
fTofTolerance = 3.0;
fScinTdcMin = 0;
fScinTdcMax = 0;
fScinTdcToTime = 0;
fIsSimulation = 0;
fTofTolerance = 3.0;
fScinTdcMin = 0;
fScinTdcMax = 0;
fScinTdcToTime = 0;

gHcParms->LoadParmValues((DBRequest *)&list3, prefix);

DBRequest list5[] = {{"is_mc", &fIsMC, kInt, 0, 1}, {0}};
fIsMC = 0;
gHcParms->LoadParmValues((DBRequest *)&list5, "");

DBRequest list[] = {{"hodo_vel_light", &fHodoVelLight[0], kDouble, (UInt_t)fMaxHodoScin, 1}, {0}};
gHcParms->LoadParmValues((DBRequest *)&list, prefix);

Expand Down Expand Up @@ -381,11 +384,11 @@ Int_t THcLADHodoscope::Decode(const THaEvData &evdata) {
present = *fPresentP;
}

if (fIsSimulation) {
fNSA=1;
fNSB=0;
fNPED=1;
fHaveFADCInfo=true;
if (fIsMC) {
fNSA = 1;
fNSB = 0;
fNPED = 1;
fHaveFADCInfo = true;
}

fNHits = DecodeToHitList(evdata, !present);
Expand Down Expand Up @@ -420,6 +423,7 @@ Int_t THcLADHodoscope::Decode(const THaEvData &evdata) {
//_________________________________________________________________
Int_t THcLADHodoscope::CoarseProcess(TClonesArray &tracks) {

return 0; // short term fix
Int_t ntracks = tracks.GetLast() + 1; // Number of reconstructed tracks

if (ntracks > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/THcLADHodoscope.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class THcLADHodoscope : public THaNonTrackingDetector, public THcHitList {
Int_t *fTdcOffset;
Double_t *fAdcTdcOffset;
Double_t *fHodoSlop;
Int_t fIsSimulation;
Int_t fIsMC;

Double_t *fHodoVelLight;

Expand Down
38 changes: 19 additions & 19 deletions src/lad_tree_digitized.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ class lad_tree_digitized {
std::vector<double> *LAD_Hodo_dighit_adc_time;

// LAD GEM Digitized
Int_t Earm_BBGEM_dighit_nstrips;
std::vector<int> *Earm_BBGEM_dighit_module;
std::vector<int> *Earm_BBGEM_dighit_strip;
std::vector<int> *Earm_BBGEM_dighit_adc;
std::vector<int> *Earm_BBGEM_dighit_samp;
Int_t LAD_GEM_dighit_nstrips;
std::vector<int> *LAD_GEM_dighit_module;
std::vector<int> *LAD_GEM_dighit_strip;
std::vector<int> *LAD_GEM_dighit_adc;
std::vector<int> *LAD_GEM_dighit_samp;

// List of branches
TBranch *b_ev; //!
Expand Down Expand Up @@ -232,11 +232,11 @@ class lad_tree_digitized {
TBranch *b_LAD_Hodo_dighit_adc_amp; //!
TBranch *b_LAD_Hodo_dighit_adc_time; //!

TBranch *b_Earm_BBGEM_dighit_nstrips; //!
TBranch *b_Earm_BBGEM_dighit_module; //!
TBranch *b_Earm_BBGEM_dighit_strip; //!
TBranch *b_Earm_BBGEM_dighit_adc; //!
TBranch *b_Earm_BBGEM_dighit_samp; //!
TBranch *b_LAD_GEM_dighit_nstrips; //!
TBranch *b_LAD_GEM_dighit_module; //!
TBranch *b_LAD_GEM_dighit_strip; //!
TBranch *b_LAD_GEM_dighit_adc; //!
TBranch *b_LAD_GEM_dighit_samp; //!

lad_tree_digitized(TTree *tree = 0);
virtual ~lad_tree_digitized();
Expand Down Expand Up @@ -400,10 +400,10 @@ void lad_tree_digitized::Init(TTree *tree) {
LAD_Hodo_dighit_adc_time = 0;

// LAD GEM Digitized
// Earm_BBGEM_dighit_module = 0;
// Earm_BBGEM_dighit_strip = 0;
// Earm_BBGEM_dighit_adc = 0;
// Earm_BBGEM_dighit_samp = 0;
LAD_GEM_dighit_module = 0;
LAD_GEM_dighit_strip = 0;
LAD_GEM_dighit_adc = 0;
LAD_GEM_dighit_samp = 0;

// Set branch addresses and branch pointers
if (!tree)
Expand Down Expand Up @@ -516,11 +516,11 @@ void lad_tree_digitized::Init(TTree *tree) {
fChain->SetBranchAddress("LAD.Hodo.dighit.amp", &LAD_Hodo_dighit_adc_amp, &b_LAD_Hodo_dighit_adc_amp);
fChain->SetBranchAddress("LAD.Hodo.dighit.adc_time", &LAD_Hodo_dighit_adc_time, &b_LAD_Hodo_dighit_adc_time);
// LAD GEM Digitized
// fChain->SetBranchAddress("Earm.BBGEM.dighit.nstrips", &Earm_BBGEM_dighit_nstrips, &b_Earm_BBGEM_dighit_nstrips);
// fChain->SetBranchAddress("Earm.BBGEM.dighit.module", &Earm_BBGEM_dighit_module, &b_Earm_BBGEM_dighit_module);
// fChain->SetBranchAddress("Earm.BBGEM.dighit.strip", &Earm_BBGEM_dighit_strip, &b_Earm_BBGEM_dighit_strip);
// fChain->SetBranchAddress("Earm.BBGEM.dighit.adc", &Earm_BBGEM_dighit_adc, &b_Earm_BBGEM_dighit_adc);
// fChain->SetBranchAddress("Earm.BBGEM.dighit.samp", &Earm_BBGEM_dighit_samp, &b_Earm_BBGEM_dighit_samp);
fChain->SetBranchAddress("LAD.GEM.dighit.nstrips", &LAD_GEM_dighit_nstrips, &b_LAD_GEM_dighit_nstrips);
fChain->SetBranchAddress("LAD.GEM.dighit.module", &LAD_GEM_dighit_module, &b_LAD_GEM_dighit_module);
fChain->SetBranchAddress("LAD.GEM.dighit.strip", &LAD_GEM_dighit_strip, &b_LAD_GEM_dighit_strip);
fChain->SetBranchAddress("LAD.GEM.dighit.adc", &LAD_GEM_dighit_adc, &b_LAD_GEM_dighit_adc);
fChain->SetBranchAddress("LAD.GEM.dighit.samp", &LAD_GEM_dighit_samp, &b_LAD_GEM_dighit_samp);
Notify();
}

Expand Down

0 comments on commit 59492b4

Please sign in to comment.