From 8c67f7db63eeebd3b055846ef1c37f454e2876c9 Mon Sep 17 00:00:00 2001 From: akioogawa <85249930+akioogawa@users.noreply.github.com> Date: Thu, 21 Dec 2023 14:54:16 -0500 Subject: [PATCH 01/25] Adding fcsDataPresent flag (#596) Adding a flag to tell if FCS data was present or not. --------- Co-authored-by: Akio Ogawa Co-authored-by: Akio Ogawa --- StRoot/StEvent/StFcsCollection.h | 7 ++- .../StFcsRawDaqReader/StFcsRawDaqReader.cxx | 55 ++++++++++--------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/StRoot/StEvent/StFcsCollection.h b/StRoot/StEvent/StFcsCollection.h index bec1c4abc1a..5dbc2465d0b 100644 --- a/StRoot/StEvent/StFcsCollection.h +++ b/StRoot/StEvent/StFcsCollection.h @@ -53,6 +53,9 @@ class StFcsCollection : public StObject { const StSPtrVecFcsPoint& points(unsigned int det) const; // Return the point list unsigned int numberOfPoints(unsigned int det) const; // Return the number of points + void setDataExist(int v) {mDataExist=v;} + int isDataExist() {return mDataExist;} + int fcsReconstructionFlag() const; void setFcsReconstructionFlag(int v); @@ -64,9 +67,9 @@ class StFcsCollection : public StObject { StSPtrVecFcsPoint mPoints[kFcsNDet]; Int_t mFcsReconstructionFlag=0; // undefined for now + Int_t mDataExist=0; // if FCS data existed in daq file - ClassDef(StFcsCollection,1) - + ClassDef(StFcsCollection,2) }; inline int StFcsCollection::fcsReconstructionFlag() const {return mFcsReconstructionFlag;} diff --git a/StRoot/StSpinPool/StFcsRawDaqReader/StFcsRawDaqReader.cxx b/StRoot/StSpinPool/StFcsRawDaqReader/StFcsRawDaqReader.cxx index a5acdd6f601..78ee20a42ad 100644 --- a/StRoot/StSpinPool/StFcsRawDaqReader/StFcsRawDaqReader.cxx +++ b/StRoot/StSpinPool/StFcsRawDaqReader/StFcsRawDaqReader.cxx @@ -33,7 +33,7 @@ #include "RTS/src/DAQ_STGC/daq_stgc.h" #include "RTS/src/DAQ_READER/daq_dta.h" #include "StRoot/StEvent/StTriggerData.h" -#include "StRoot/StEvent/StTriggerData2019.h" +#include "StRoot/StEvent/StTriggerData2022.h" #include "StRoot/StEvent/StFcsCollection.h" #include "StRoot/StEvent/StFcsHit.h" #include "StRoot/StFcsDbMaker/StFcsDbMaker.h" @@ -87,7 +87,7 @@ Int_t StFcsRawDaqReader::Init(){ struct tm* local = localtime((const time_t*)&unixtime); int date=(local->tm_year+1900)*10000 + (local->tm_mon+1)*100 + local->tm_mday; int time=local->tm_hour*10000 + local->tm_min*100 + local->tm_sec; - printf("Event Unix Time = %d %0d %06d\n",mRdr->evt_time,date,time); + LOG_INFO << Form("Event Unix Time = %d %0d %06d",mRdr->evt_time,date,time) << endm; StFcsDbMaker* mFcsDbMkr = static_cast(GetMaker("fcsDbMkr")); if(!mFcsDbMkr){ @@ -154,7 +154,7 @@ Int_t StFcsRawDaqReader::Make() { if(trgcmd != 4 && trgcmd !=10){ // 4=phys/ped 10=LED nskip++; nskiptot++; - if(mDebug) printf("trgcmd=%d skipping nskip=%d nskiptot=%d\n",trgcmd,nskip,nskiptot); + if(mDebug) LOG_INFO << Form("trgcmd=%d skipping nskip=%d nskiptot=%d",trgcmd,nskip,nskiptot)<trgcmd; if(trgcmd != 4 && trgcmd !=10){ // 4=phys/ped 10=LED - printf("This should not happen!!! trgcmd=%d skipping nskip=%d nskiptot=%d\n",trgcmd,nskip,nskiptot); + LOG_INFO << Form("This should not happen!!! trgcmd=%d skipping nskip=%d nskiptot=%d",trgcmd,nskip,nskiptot)<0){ @@ -209,10 +209,10 @@ Int_t StFcsRawDaqReader::Make() { dd = mRdr->det("trg")->get("raw"); int startrg=0,fcstrg=0; if(!dd){ - //printf("trg/raw not found\n"); + LOG_WARN << "trg/raw not found" << endm; }else{ while(dd->iterate()) { - uint8_t *trg_raw = dd->Byte; + u_char *trg_raw = dd->Byte; struct simple_desc { short len ; char evt_desc ; @@ -220,16 +220,16 @@ Int_t StFcsRawDaqReader::Make() { } *desc ; desc = (simple_desc *) trg_raw ; //printf("Trigger: raw bank has %d bytes: ver 0x%02X, desc %d, len %d\n",dd->ncontent,desc->ver,desc->evt_desc,desc->len); - if(desc->ver==0x46){ - TriggerDataBlk2019* trgdata2019 = (TriggerDataBlk2019*)dd->Byte; - LOG_DEBUG << "Creating StTriggerData for ver=0x46 (2019) with run="<setTriggerData((StTriggerData*)new StTriggerData2019(trgdata2019,mRun,1,mDebug)); + if(desc->ver==0x47){ + TriggerDataBlk2022* trgdata2022 = (TriggerDataBlk2022*)dd->Byte; + LOG_INFO << "Creating StTriggerData for ver=0x47 (2022) with run="<setTriggerData((StTriggerData*)new StTriggerData2022(trgdata2022,mRun,1,mDebug)); LOG_DEBUG << "Added StTriggerData to StEvent"<GetObject()); - //mTrg = mEvent->triggerData(); - //LOG_DEBUG << "Got back Dataset StTriggerData addr="<GetObject()); + mTrg = mEvent->triggerData(); + LOG_DEBUG << "Got back Dataset StTriggerData addr="<lastDSM(5); //unsigned short lastdsm4 = mTrg->lastDSM(4); @@ -247,9 +247,9 @@ Int_t StFcsRawDaqReader::Make() { LOG_DEBUG << Form("FCS TCU Bits = 0x%04x",mFcsTcuBit)<l2sum(); - startrg = (l2sum & 0xFF8000FFFFFFFFFF)?1:0; - fcstrg = (l2sum & 0x007FFF0000000000)?1:0; - LOG_DEBUG << Form("L2SUM = 0x%016llx STAR=%1d FCS=%1d",l2sum,startrg,fcstrg) << endm; + //startrg = (l2sum & 0xFF8000FFFFFFFFFF)?1:0; + //fcstrg = (l2sum & 0x007FFF0000000000)?1:0; + //LOG_DEBUG << Form("L2SUM = 0x%016llx STAR=%1d FCS=%1d",l2sum,startrg,fcstrg) << endm; }else{ printf("Unknown StTriggerData version = %x\n",desc->ver); @@ -272,8 +272,8 @@ Int_t StFcsRawDaqReader::Make() { //printf("DEPIO EHP=%1d NS=%1d DEP=%02d CH=%02d N=%d\n", // ehp,ns,dep,ch,dd->ncontent); if(ehp==3 && ns==0 && dep==0 && (ch==4 || ch==5)){ - uint32_t n=dd->ncontent; - uint16_t *d16 = (uint16_t *)dd->Void; + u_int n=dd->ncontent; + u_short *d16 = (u_short *)dd->Void; if(ch==4) mFcsDepOut += (d16[96] & 0xFF); if(ch==5) mFcsDepOut += (d16[96] & 0xFF) << 8; //for(int i=0; idet("fcs")->get(mode[mReadMode].c_str()); - if(dd){ + if(!dd){ + mFcsCollectionPtr->setDataExist(0); + }else{ + mFcsCollectionPtr->setDataExist(1); while(dd->iterate()) { int sec = ((dd->sec >> 11) & 0x1F) + 1; int rdo = ((dd->sec >> 8) & 0x7) + 1; @@ -299,12 +302,12 @@ Int_t StFcsRawDaqReader::Make() { int ns = (dd->sec >> 5) & 1; int dep = dd->row ; int ch = dd->pad ; - uint32_t n=dd->ncontent; + u_int n=dd->ncontent; int detid,id,crt,sub; mFcsDb->getIdfromDep(ehp,ns,dep,ch,detid,id,crt,sub); //printf("EHP=%1d NS=%1d DEP=%02d CH=%02d DET=%1d id=%4d\n",ehp,ns,dep,ch,detid,id); //if(ch>=32) continue; - uint16_t *d16 = (uint16_t *)dd->Void; + u_short *d16 = (u_short *)dd->Void; StFcsHit* hit=0; unsigned short tmp[1024]; if(mReadMode==0){ @@ -312,9 +315,9 @@ Int_t StFcsRawDaqReader::Make() { }else{ /* if(startrg==0 && fcstrg==1){ - for(uint32_t i=0; iadc[i].tb; - uint32_t data = dd->adc[i].adc; + for(u_int i=0; iadc[i].tb; + u_int data = dd->adc[i].adc; tmp[i*2 ]=data; tmp[i*2+1]=tb + 8; //printf("AAA %4d : %4d %4d : %4d %4d\n",i,data&0xfff,d16[i*2]&0xfff,tb,d16[i*2+1]); @@ -330,7 +333,7 @@ Int_t StFcsRawDaqReader::Make() { if(detid<6) nvaliddata++; if(mDebug){ - printf("FCS %3s : S%d:%d [det %d, ns %d, dep %d ch %d] det=%d id=%3d : size=%d : adc=", + printf("FCS %3s : S%2d:%2d [det%1d ns%1d dep%2d ch%2d] det=%d id=%3d size=%3d adc=", mode[mReadMode].c_str(),sec,rdo,ehp,ns,dep,ch,detid,id,n) ; for(unsigned int tb=0; tbnTimeBin(); tb++) printf("%4d ", hit->adc(tb)); //for(int tb=0; tb<3; tb++) printf("%4d ", hit->adc(tb)); @@ -353,7 +356,7 @@ Int_t StFcsRawDaqReader::Make() { dd = mRdr->det("stgc")->get("altro",r) ; while(dd && dd->iterate()) { //per xing and per RDO if(mDebug) printf("STGC ALTRO: stgc%02d(sec) RDO=%1d ALTRO=%03d(row) Ch=%02d(pad)\n",dd->sec,r,dd->row,dd->pad); - for(uint32_t i=0; incontent; i++) { + for(u_int i=0; incontent; i++) { if(mDebug) printf(" TB=%3d ADC=%4d",dd->adc[i].tb,dd->adc[i].adc) ; ndata++; } From 08d209bc4cd1e539ac8e833132087667fdde3c61 Mon Sep 17 00:00:00 2001 From: akioogawa <85249930+akioogawa@users.noreply.github.com> Date: Sat, 30 Dec 2023 23:22:58 -0500 Subject: [PATCH 02/25] Spin pool fcs trg qa (#637) Update FCS trigger monitoring code for online QA. It useful for offline example, but will not be in BFC. So in SpinPool. --- .../StFcsTrgQaMaker/StFcsTrgQaMaker.cxx | 444 +++++++++--------- .../StFcsTrgQaMaker/StFcsTrgQaMaker.h | 71 +-- 2 files changed, 268 insertions(+), 247 deletions(-) diff --git a/StRoot/StSpinPool/StFcsTrgQaMaker/StFcsTrgQaMaker.cxx b/StRoot/StSpinPool/StFcsTrgQaMaker/StFcsTrgQaMaker.cxx index 7b8780d635a..b84b2f6a04e 100644 --- a/StRoot/StSpinPool/StFcsTrgQaMaker/StFcsTrgQaMaker.cxx +++ b/StRoot/StSpinPool/StFcsTrgQaMaker/StFcsTrgQaMaker.cxx @@ -1,3 +1,4 @@ + /* * * \class StFcsTrgQaMaker @@ -40,72 +41,87 @@ Int_t StFcsTrgQaMaker::Init(){ LOG_FATAL << "Error finding StFcsTrgSimMaker"<< endm; return kStFatal; } + fcs_trg_base* trg=mFcsTrgSimMkr->getTriggerEmu(); + if(!trg){ + LOG_FATAL << "Error finding fcs_trg_base from StFcsTrgSimMaker"<< endm; + return kStFatal; + } if(mRun>0){ int yday=mRun/1000; sprintf(mFilename,"%d/%d.trgQa.root",yday,mRun); }else if(mFilename==0){ - static char* fname = const_cast("fcs.trgqa.root"); + char* fname = "fcs.trgqa.root"; mFilename=fname; } printf("StFcsTrgQaMaker::Init - Opening %s\n",mFilename); mFile=new TFile(mFilename,"RECREATE"); - const char* cname[4]={"All","SIM","DEP","TCU"}; - for(int i=0; i<4; i++){ - mETot[i] = new TH1F(Form("ETot%s", cname[i]), Form("ETot%s", cname[i]),256,0,1024); - mHTot[i] = new TH1F(Form("HTot%s", cname[i]), Form("HTot%s", cname[i]),256,0,512); - mEHT [i] = new TH1F(Form("EHT%s", cname[i]), Form("EHT%s", cname[i]),256,0,256); - mHHT [i] = new TH1F(Form("HHT%s", cname[i]), Form("HHT%s", cname[i]),256,0,256); - mJP[0][i] = new TH1F(Form("JP2%s", cname[i]), Form("JP2%s", cname[i]),256,0,1024); - mJP[1][i] = new TH1F(Form("JP1%s", cname[i]), Form("DiJP1%s", cname[i]),256,0,1024); - - mPOR [i] = new TH1F(Form("POR%s", cname[i]), Form("POR%s", cname[i]),256,0,512); - mE4b4[i] = new TH1F(Form("E4b4%s",cname[i]), Form("E4b4%s", cname[i]),256,0,256); - mH4b4[i] = new TH1F(Form("H4b4%s",cname[i]), Form("H4b4%s", cname[i]),256,0,256); - - mSum[0][i] = new TH1F(Form("Sum%s", cname[i]), Form("E+H%s", cname[i]),256,0,256); - mEHR[0][i] = new TH1F(Form("EHR%s", cname[i]), Form("EHRatio%s", cname[i]), 64,0,1.05); - mSum[1][i] = new TH1F(Form("Had%s", cname[i]), Form("E+H%s", cname[i]),256,0,256); - mEHR[1][i] = new TH1F(Form("RHad%s",cname[i]), Form("EHRatio%s", cname[i]), 64,0,1.05); - mSum[2][i] = new TH1F(Form("EM%s", cname[i]), Form("E+H%s", cname[i]),256,0,256); - mEHR[2][i] = new TH1F(Form("REM%s", cname[i]), Form("EHRatio%s", cname[i]), 64,0,1.05); - mSum[3][i] = new TH1F(Form("Gam%s", cname[i]), Form("E+H%s", cname[i]),256,0,256); - mEHR[3][i] = new TH1F(Form("RGam%s",cname[i]), Form("EHRatio%s", cname[i]), 64,0,1.05); - mSum[4][i] = new TH1F(Form("Ele%s", cname[i]), Form("E+H%s", cname[i]),256,0,256); - mEHR[4][i] = new TH1F(Form("REle%s",cname[i]), Form("EHRatio%s", cname[i]), 64,0,1.05); - - mDEm [i] = new TH2F(Form("DEm%s", cname[i]),Form("DiEM%s", cname[i]),256,0,256,256,0,256); - mDHad[i] = new TH2F(Form("DHad%s",cname[i]),Form("DiHadron%s", cname[i]),256,0,256,256,0,256); - mDGam[i] = new TH2F(Form("DGam%s",cname[i]),Form("DiGamma%s", cname[i]),256,0,256,256,0,256); - mDEle[i] = new TH2F(Form("DEle%s",cname[i]),Form("DiElectron%s",cname[i]),256,0,256,256,0,256); - mDJP [i] = new TH2F(Form("DJP%s", cname[i]),Form("DiJP%s", cname[i]),256,0,256,256,0,256); - } - mSumTot[0] = new TH2F("SumEtot","SumEtot;E4x4+H4x4;Etot",256,0,256,256,0,1024); - mSumTot[1] = new TH2F("SumHtot","SumHtot;E4x4+H4x4;Htot",256,0,256,256,0,512); - const char* NS[2]={"N","S"}; - for(int ns=0; nsJPATHR2,trg->JPBCTHR2,trg->JPDETHR2),11,-5.5,5.5); + mJPMap[1] = new TH1F("JP1",Form("JP1 THR A=%d,BC=%d,DE=%d",trg->JPATHR1,trg->JPBCTHR1,trg->JPDETHR1),11,-5.5,5.5); + mJPMap[2] = new TH1F("JP0",Form("JP0 THR A=%d,BC=%d,DE=%d",trg->JPATHR0,trg->JPBCTHR0,trg->JPDETHR0),11,-5.5,5.5); + + mE4x4 = new TH1F("E4x4", "MAX E4x4", 256,0,256); + mEM4x4 = new TH1F("EM4x4", "MAX EM4x4", 256,0,256); + mELE4x4 = new TH1F("ELE4x4", "MAX ELE4x4", 256,0,256); + mERatio = new TH1F("EMRatio", "MAX EM Ratio=E/(E+Hmax)", 64,0,1.05); + mELERatio = new TH1F("ELERatio","MAX ELE Ratio=E/(E+Hmax)", 64,0,1.05); + + mH4x4 = new TH1F("H4x4", "MAX H4x4", 256,0,256); + mEH4x4 = new TH1F("EH4x4", "MAX E+H4x4", 256,0,256); + mHAD4x4 = new TH1F("HAD4x4", "MAX Had4x4", 256,0,256); + mHRatio = new TH1F("HRatio", "MAX E+H Ratio=E/(E+H)", 64,0,1.05); + mHADRatio = new TH1F("HADRatio","MAX Had Ratio=E/(E+H)", 64,0,1.05); + + mE4x4Map[0] = new TH2F("EM4x4MapEM2", Form("EM EM2=%d",trg->EMTHR2), 19,-9.5,9.5,15,-15.5,-0.5); + mE4x4Map[1] = new TH2F("EM4x4MapEM1", Form("EM EM1=%d",trg->EMTHR1), 19,-9.5,9.5,15,-15.5,-0.5); + mE4x4Map[2] = new TH2F("EM4x4MapEM0", Form("EM EM0=%d",trg->EMTHR0), 19,-9.5,9.5,15,-15.5,-0.5); + mE4x4Map[3] = new TH2F("EM4x4MapELE2", Form("EM ELE2=%d",trg->ELETHR2),19,-9.5,9.5,15,-15.5,-0.5); + + mELE4x4Map[0] = new TH2F("ELE4x4MapELE2",Form("ELE ELE2=%d",trg->ELETHR2), 19,-9.5,9.5,15,-15.5,-0.5); + mELE4x4Map[1] = new TH2F("ELE4x4MapELE1",Form("ELE ELE1=%d",trg->ELETHR1), 19,-9.5,9.5,15,-15.5,-0.5); + + mEH4x4Map[0] = new TH2F("EHMapHAD2", Form("E+H HAD2=%d",trg->HADTHR2), 19,-9.5,9.5,15,-15.5,-0.5); + mEH4x4Map[1] = new TH2F("EHMapHAD1", Form("E+H HAD1=%d",trg->HADTHR1), 19,-9.5,9.5,15,-15.5,-0.5); + mEH4x4Map[2] = new TH2F("EHMapHAD0", Form("E+H HAD0=%d",trg->HADTHR0), 19,-9.5,9.5,15,-15.5,-0.5); + + mDsmOut = new TH1F("DsmOut","DsmOut",33,0,33); + mDepOut = new TH1F("DepOut","DepOut",33,0,33); + mTcuBit = new TH1F("TcuBit","TcuBit",33,0,33); + mTcuDep = new TH1F("TcuDep","TcuDepMismatch",33,0,33); + mSimDep = new TH1F("SimDep","SimDepMismatch",33,0,33); + + const float maxadc=500; + mAdc[0]=new TH2F("EN_Id_Adc","EcalNorth; Id; ADC",mFcsDb->maxId(0),0.0,mFcsDb->maxId(0),500,0.0,maxadc); + mAdc[1]=new TH2F("ES_Id_Adc","EcalSouth; Id; ADC",mFcsDb->maxId(1),0.0,mFcsDb->maxId(1),500,0.0,maxadc); + mAdc[2]=new TH2F("HN_Id_Adc","HcalNorth; Id; ADC",mFcsDb->maxId(2),0.0,mFcsDb->maxId(2),500,0.0,maxadc); + mAdc[3]=new TH2F("HS_Id_Adc","HcalSouth; Id; ADC",mFcsDb->maxId(3),0.0,mFcsDb->maxId(3),500,0.0,maxadc); + mAdc[4]=new TH2F("PN_Id_Adc","PresNorth; Id; ADC",mFcsDb->maxId(4),0.0,mFcsDb->maxId(4),500,0.0,maxadc); + mAdc[5]=new TH2F("PS_Id_Adc","PresSouth; Id; ADC",mFcsDb->maxId(5),0.0,mFcsDb->maxId(5),500,0.0,maxadc); return kStOK; }; @@ -116,30 +132,6 @@ Int_t StFcsTrgQaMaker::Make() { return kStFatal; } - //Getting Trigger Data - TObjectSet *os = (TObjectSet*)GetDataSet("StTriggerData"); - StTriggerData* trgd=0; - if(os){ - trgd = (StTriggerData*)os->GetObject(); - if(trgd){ - //LOG_INFO << "got StTriggerData addr="<lastDSM(5); - - //TCU bits - for(int i=0; i<16; i++) if((tcubit >> i) & 0x1) mTcuBit->Fill(i); - - //DSM out - int dsmout=trg->dsmout; - for(int i=0; i<16; i++) if((dsmout >> i) & 0x1) mDsmOut->Fill(i); - //Getting StEvent and FcsCollection StEvent* event= (StEvent*)GetInputDS("StEvent"); StFcsCollection *fcs = 0; @@ -152,6 +144,36 @@ Int_t StFcsTrgQaMaker::Make() { LOG_INFO << "No StFcsCollection found" << endm; return kStErr; } + if(fcs->isDataExist()==0) { + LOG_INFO << "No FCS data in this event" << endm; + return kStOk; + } + //Getting Trigger Data + StTriggerData* trgd = event->triggerData(); + if(!trgd){ + TObjectSet *os = (TObjectSet*)GetDataSet("StTriggerData"); + if(os){ + trgd = (StTriggerData*)os->GetObject(); + if(trgd){ + //LOG_INFO << "got StTriggerData addr="<lastDSM(2) + (trgd->lastDSM(5)<<16); + + //TCU bits + for(int i=0; i<32; i++) if((tcubit >> i) & 0x1) mTcuBit->Fill(i); + + //DSM out + unsigned int dsmout=trg->dsmout; + for(int i=0; i<32; i++) if((dsmout >> i) & 0x1) mDsmOut->Fill(i); + mDsmOut->Fill(32); //DEP out int depout=0; @@ -164,202 +186,184 @@ Int_t StFcsTrgQaMaker::Make() { int ns = hits[i]->ns(); int dep = hits[i]->dep(); int ch = hits[i]->channel(); - //printf("DEP TRG data = %1d %1d %02d %02d\n",ehp,ns,dep,ch); - if(ehp!=3) continue; - if(ns!=0) continue; - if(dep!=0) continue; - if(ch==4 || ch==5){ + if(ehp!=3) continue; //DEPIO boards only + if(dep==0 && (ch==4 || ch==5) ){ //stage3 DEP to TCU int ntb = hits[i]->nTimeBin(); for(int j=0; jadc(j); unsigned short tb = hits[i]->timebin(j); - //if(tb>=96-8 && tb<=96+8) - //if(tb>=96-8){ - if(0){ - printf("DEPIO data = d%1d ns%1d dep%2d ch%2d tb%3d 0x%x",ehp,ns,dep,ch,tb,adc); - if(ch==5 && (adc&0x1)) printf(" ELE2"); - printf("\n");; - } + //printf("DEPIO3 data = ehp%1d ns%1d dep%2d ch%2d tb%3d 0x%x\n",ehp,ns,dep,ch,tb,adc); if(tb!=mS3off) continue; if(ch==4) depout += adc; if(ch==5) depout += (adc << 8); + } + } + if(dep==1 && ch==36){ //stage2 north/south DEP to TCU + int ntb = hits[i]->nTimeBin(); + for(int j=0; jadc(j); + unsigned short tb = hits[i]->timebin(j); + //printf("DEPIO2 data = ehp%1d ns%1d dep%02d ch%02d tb%03d 0x%x\n",ehp,ns,dep,ch,tb,adc); + if(tb!=mS2off) continue; + if(ns==0) depout += (adc&0xff) << 16; + if(ns==1) depout += (adc&0xff) << 24; } - } + } + } + for(int i=0; i<32; i++) if((depout >> i) & 0x1) mDepOut->Fill(i); + + const char* BIT[32]={"HAD0","HAD1","HAD2", + "EM0","EM1","EM2", + "JP2","JPA1","JPBC1","JPDE1","JPA0","JPBC0","JPDE0", + "DiJP","DiJPAsy","DiELEA", + "ELE0-N","ELE1-N","ELE2-N","EM3-N","EHT-N","HHT-N","ETOT-N","HTOT-N", + "ELE0-S","ELE1-S","ELE2-S","EM3-S","EHT-S","HHT-S","ETOT-S","HTOT-S"}; + if(GetDebug()){ + LOG_INFO << Form("FCSBits SIM = %08x ",dsmout); + for(int i=0; i<32; i++){ if((dsmout>>i)&1) {LOG_INFO << BIT[i] << " ";} } LOG_INFO<>i)&1) {LOG_INFO << BIT[i] << " ";} } LOG_INFO<>i)&1) {LOG_INFO << BIT[i] << " ";} } LOG_INFO<> i) & 0x1) mDepOut->Fill(i); //Mismatch - for(int i=0; i<16; i++) if((depout >> i) != (tcubit >> i)) mTcuDep->Fill(i); - for(int i=0; i<16; i++) if((depout >> i) != (dsmout >> i)) mSimDep->Fill(i); + LOG_INFO << Form("FCSBitsMM DEP-TCU Mismatch "); + for(int i=0; i<32; i++) if(((depout>> i)&1) != ((tcubit>>i)&1)) {mTcuDep->Fill(i); LOG_INFO << BIT[i] << " ";} + LOG_INFO<>i)&1) != ((depout>>i)&1)) {mSimDep->Fill(i); LOG_INFO << BIT[i] << " ";} + LOG_INFO<numberOfHits(det); + StSPtrVecFcsHit& hits = fcs->hits(det); + for (int i=0; iid(); + int ehp = hits[i]->ehp(); + int ns = hits[i]->ns(); + int c = mFcsDb->getColumnNumber(det,id); + int r = mFcsDb->getRowNumber(det,id); + float cc = c * (ns*2-1); + float rr = - r; + mTow[ehp]->Fill(cc,rr,hits[i]->energy()); + } + } unsigned int max; int maxns,maxc,maxr; - + int maxns2,maxc2,maxr2; + int maxns3,maxc3,maxr3; + int maxns4,maxc4,maxr4; + int maxns5,maxc5,maxr5; //Ecal HT 2x2 - max=0; for(int ns=0; nse2x2[ns][r][c]>max){ //find max Ecal 2x2 - max=trg->e2x2[ns][r][c]; maxns=ns; maxr=r; maxc=c; + max=trg->e2x2[ns][r][c]; maxr=r; maxc=c; } } } + if(max>0){ + mEHT[ns]->Fill(max); + mEHTMap->Fill((maxc+1)*(ns*2-1),-maxr-1); + } } - mEHT[0]->Fill(max); - if((dsmout>>0)&0x1) mEHT[1]->Fill(max); - if((depout>>0)&0x1) mEHT[2]->Fill(max); - if((tcubit>>0)&0x1) mEHT[3]->Fill(max); //Hcal HT 2x2 - max=0; for(int ns=0; nsh2x2[ns][r][c]>max){ //find max Hcal 2x2 - max=trg->h2x2[ns][r][c]; maxns=ns; maxr=r; maxc=c; + max=trg->h2x2[ns][r][c]; maxr=r; maxc=c; } } } + if(max>0){ + mHHT[ns]->Fill(max); + mHHTMap->Fill((maxc+1)*(ns*2-1),-maxr-1); + } } - mHHT[0]->Fill(max); - if((dsmout>>1)&0x1) mHHT[1]->Fill(max); - if((depout>>1)&0x1) mHHT[2]->Fill(max); - if((tcubit>>1)&0x1) mHHT[3]->Fill(max); //Ecal Tot - max=trg->etot[0]; - if(trg->etot[1] > max) max=trg->etot[1]; - mETot[0]->Fill(max); - if((dsmout>>2)&0x1) mETot[1]->Fill(max); - if((depout>>2)&0x1) mETot[2]->Fill(max); - if((tcubit>>2)&0x1) mETot[3]->Fill(max); + mETot[0]->Fill(trg->etot[0]); + mETot[1]->Fill(trg->etot[1]); //Hcal Tot - max=trg->htot[0]; - if(trg->htot[1] > max) max=trg->htot[1]; - mHTot[0]->Fill(max); - if((dsmout>>3)&0x1) mHTot[1]->Fill(max); - if((depout>>3)&0x1) mHTot[2]->Fill(max); - if((tcubit>>3)&0x1) mHTot[3]->Fill(max); + mHTot[0]->Fill(trg->htot[0]); + mHTot[1]->Fill(trg->htot[1]); //JP - max=0; for(int ns=0; nsjet[ns][r]>max){ //find max JP - max=trg->jet[ns][r]; maxns=ns; maxr=r; - } + for(int j=0; j<5; j++){ + if(trg->jet[ns][j]>max){ //find max JP + mJP[ns][j]->Fill(trg->jet[ns][j]); + if((trg->d_out.s2[ns].s2_to_s3[0].d[1]>>j)&0x1) mJPMap[0]->Fill((j+1)*(ns*2-1)); + if((trg->d_out.s2[ns].s2_to_s3[1].d[1]>>j)&0x1) mJPMap[1]->Fill((j+1)*(ns*2-1)); + if((trg->d_out.s2[ns].s2_to_s3[0].d[2]>>j)&0x1) mJPMap[2]->Fill((j+1)*(ns*2-1)); + } } - } - mJP[0][0]->Fill(max); - if((dsmout>>4)&0x1) mJP[0][1]->Fill(max); - if((depout>>4)&0x1) mJP[0][2]->Fill(max); - if((tcubit>>4)&0x1) mJP[0][3]->Fill(max); - mJP[1][0]->Fill(max); - if((dsmout>>9)&0x1) mJP[1][1]->Fill(max); - if((depout>>9)&0x1) mJP[1][2]->Fill(max); - if((tcubit>>9)&0x1) mJP[1][3]->Fill(max); - - //ecal 4x4 - max=0; + } + + //Ecal 4x4 for(int ns=0; nsesum[ns][r][c]>max){ //find max Ecal 4x4 - max=trg->esum[ns][r][c]; maxns=ns; maxr=r; maxc=c; + int esum=trg->esum[ns][r][c]; + int sum=trg->sum[ns][r][c]; + if(esum>max){ //find max Ecal 4x4 + max=esum; maxns=ns; maxr=r; maxc=c; } - } - } - } - mE4b4[0]->Fill(max); - - //Fill only for max ecal 4x4 - if(max>0){ - int id=maxr*kFcsEcal4x4NCol + maxc; - float pt=max*mPtCh; - mEcal[maxns]->Fill(id,pt); - if(pt>mEcalPtThr){ - mEcalNorm[maxns]->Fill(id); - for(int dep=0; dep<6; dep++){ - for(int ch=0; ch<32; ch++){ - if(trg->phit[maxns][dep][ch]>0){ - int idp=dep*32 + ch; - mEPmap[maxns]->Fill(id,idp); - } + if(esum>emmax && trg->ratiomax[ns][r][c] > 1.0/(1.0+(float)trg->EM_HERATIO_THR/128)){ + emmax=esum; maxns2=ns; maxr2=r; maxc2=c; } - } - } - } - - //hcal - max=0; - for(int ns=0; nshsum[ns][r][c]==0) continue; - int id=r*kFcsHcal4x4NCol + c; - mHcal[ns]->Fill(id,trg->hsum[ns][r][c]*0.0316); - if(trg->hsum[ns][r][c]>max){ //find max Ecal 4x4 - max=trg->esum[ns][r][c]; maxns=ns; maxr=r; maxc=c; + if(esum>elemax && trg->ratiomax[ns][r][c] > 1.0/(1.0+(float)trg->EM_HERATIO_THR/128) && trg->epdcoin[ns][r][c]){ + elemax=esum; maxns3=ns; maxr3=r; maxc3=c; } - } - } - } - mH4b4[0]->Fill(max); - - //Pres ADC - max=0; - for(int ns=0; nspadc[ns][dep][ch]>0){ - int idp=dep*32 + ch; - mPres[ns]->Fill(idp,trg->padc[ns][dep][ch]/150.0); + if(sum>summax){ + summax=sum; maxns4=ns; maxr4=r; maxc4=c; } - if(trg->padc[ns][dep][ch]>max){ //find max Ecal 4x4 - max=trg->padc[ns][dep][ch]; maxns=ns; maxr=dep; maxc=ch; + if(sum>hadmax && trg->ratio[ns][r][c] < 1.0/(1.0+(float)trg->HAD_HERATIO_THR/128)){ + hadmax=sum; maxns5=ns; maxr5=r; maxc5=c; } - } - } - } - mPOR[0]->Fill(max); - - //ecal+hcal 4x4 - max=0; - for(int ns=0; nssum[ns][r][c]>max){ //find max Ecal 4x4 - max=trg->sum[ns][r][c]; maxns=ns; maxr=r; maxc=c; + int cc=(c+1)*(ns*2-1); + int rr=-r-1; + if(esum > trg->EMTHR2) mE4x4Map[0]->Fill(cc,rr); + if(esum > trg->EMTHR1) mE4x4Map[1]->Fill(cc,rr); + if(esum > trg->EMTHR0) mE4x4Map[2]->Fill(cc,rr); + if(esum > trg->ELETHR2) mE4x4Map[3]->Fill(cc,rr); + if(trg->epdcoin[ns][r][c]){ + if(esum > trg->ELETHR2) mELE4x4Map[0]->Fill(cc,rr); + if(esum > trg->ELETHR1) mELE4x4Map[1]->Fill(cc,rr); } + if(sum > trg->HADTHR2) mEH4x4Map[0]->Fill(cc,rr); + if(sum > trg->HADTHR1) mEH4x4Map[1]->Fill(cc,rr); + if(sum > trg->HADTHR0) mEH4x4Map[2]->Fill(cc,rr); } } - } - if(max>0){ - mSum[0][0]->Fill(max); - mSumTot[0]->Fill(max,trg->etot[maxns]); - mSumTot[1]->Fill(max,trg->htot[maxns]); - mEHR[0][0]->Fill(trg->ratio[maxns][maxr][maxc]); - if(trg->had[maxns][maxr][maxc]){ - mSum[1][0]->Fill(max); - mEHR[1][0]->Fill(trg->ratio[maxns][maxr][maxc]); - } - if(trg->em[maxns][maxr][maxc]){ - mSum[2][0]->Fill(max); - mEHR[2][0]->Fill(trg->ratio[maxns][maxr][maxc]); - if(trg->epdcoin[maxns][maxr][maxc]==0){ - mSum[3][0]->Fill(max); - mEHR[3][0]->Fill(trg->ratio[maxns][maxr][maxc]); - } - if(trg->epdcoin[maxns][maxr][maxc]==1){ - mSum[4][0]->Fill(max); - mEHR[4][0]->Fill(trg->ratio[maxns][maxr][maxc]); - } - } + if(max>0) mE4x4->Fill(max); + if(emmax>0) mEM4x4->Fill(emmax); + if(elemax>0) mELE4x4->Fill(elemax); + if(summax>0) mEH4x4->Fill(summax); + if(hadmax>0) mHAD4x4->Fill(summax); + if(max>0) mERatio->Fill(trg->ratiomax[maxns][maxr][maxc]); + if(elemax>0) mELERatio->Fill(trg->ratiomax[maxns3][maxr3][maxc3]); + if(summax>0) mHRatio->Fill(trg->ratio[maxns4][maxr4][maxc4]); + if(hadmax>0) mHADRatio->Fill(trg->ratio[maxns5][maxr5][maxc5]); } + + for(int det=0; dethits(det); + int nh=fcs->numberOfHits(det); + for(int i=0; iFill(hits[i]->id(),(float)hits[i]->adcSum()); + } + return kStOK; }; diff --git a/StRoot/StSpinPool/StFcsTrgQaMaker/StFcsTrgQaMaker.h b/StRoot/StSpinPool/StFcsTrgQaMaker/StFcsTrgQaMaker.h index 84b6ec44d3c..7ead1958a63 100644 --- a/StRoot/StSpinPool/StFcsTrgQaMaker/StFcsTrgQaMaker.h +++ b/StRoot/StSpinPool/StFcsTrgQaMaker/StFcsTrgQaMaker.h @@ -30,6 +30,7 @@ class StFcsTrgQaMaker : public StMaker { void setPtCh(float v) {mPtCh=v;} void setEcalPtThr(float v) {mEcalPtThr=v;} void setS3off(int v) {mS3off=v;} + void setS2off(int v) {mS2off=v;} protected: @@ -41,33 +42,47 @@ class StFcsTrgQaMaker : public StMaker { int mRun=0; float mPtCh=0.0316; float mEcalPtThr=1.5; - int mS3off=96; - - TH1F* mETot[4]; - TH1F* mHTot[4]; - TH1F* mEHT[4]; - TH1F* mHHT[4]; - TH1F* mJP[2][4]; - - TH1F* mE4b4[4]; - TH1F* mH4b4[4]; - TH1F* mPOR[4]; - - TH1F* mSum[5][4]; - TH1F* mEHR[5][4]; - TH2F* mSumTot[2]; - - TH2F* mDEm[4]; - TH2F* mDHad[4]; - TH2F* mDGam[4]; - TH2F* mDEle[4]; - TH2F* mDJP[4]; - - TH2F* mEcal[kFcsNorthSouth]; - TH2F* mHcal[kFcsNorthSouth]; - TH2F* mPres[kFcsNorthSouth]; - TH2F* mEPmap[kFcsNorthSouth]; - TH1F* mEcalNorm[kFcsNorthSouth]; + + //marker.adc_start = 7 + //marker.s1_out_start = marker.adc_start + 11 = 18 + //marker.s2_in_start = marker.s1_out_start + 2 = 20 + //marker.s2_to_s3_start = marker.s2_in_start + 15 = 35 + //marker.s3_in_start = marker.s2_to_s3_start + 8 = 43 + //marker.dsm_out_start=marker.s3_in_start + 14 = 57 + //So... DEPIO DSM out is 50 tb later than ADC + //center trig tb=50 => tb=47~54 and 47=marker.adc_start(7)+5xing*8tb/xing + //Thus.... mS3off=47+50 = 97 + int mS3off=97; + int mS2off=97; //Tonko says same as S3off + + TH2F* mTow[2]; + + TH1F* mETot[2]; + TH1F* mHTot[2]; + + TH1F* mEHT[2]; + TH2F* mEHTMap; + TH1F* mHHT[2]; + TH2F* mHHTMap; + + TH1F* mJP[2][5]; + TH1F* mJPMap[3]; + + TH1F* mE4x4; + TH1F* mEM4x4; + TH1F* mELE4x4; + TH1F* mERatio; + TH1F* mELERatio; + + TH1F* mH4x4; + TH1F* mEH4x4; + TH1F* mHAD4x4; + TH1F* mHRatio; + TH1F* mHADRatio; + + TH2F* mE4x4Map[4]; + TH2F* mELE4x4Map[2]; + TH2F* mEH4x4Map[3]; TH1F* mDsmOut; TH1F* mDepOut; @@ -75,6 +90,8 @@ class StFcsTrgQaMaker : public StMaker { TH1F* mTcuDep; TH1F* mSimDep; + TH2F* mAdc[3]; + ClassDef(StFcsTrgQaMaker,1); }; From 6df0792080e466516c42fa4f553bc21134a08b58 Mon Sep 17 00:00:00 2001 From: mrosales2016 <106255801+mrosales2016@users.noreply.github.com> Date: Mon, 15 Jan 2024 20:13:23 -0500 Subject: [PATCH 03/25] Updating StFcsTriggerSimMake to include StMuFcsCollection hit information for trigger reconstruction in simulation. (#638) The updates include StMuFcsCollection so that users of this maker may be able to use either StEvent fcsHit information or MuDst fcsHit information for trigger reconstruction in simulation. Co-authored-by: Manuel A. Rosales Aguilar --- .../StFcsTriggerSimMaker.cxx | 149 ++++++++++++------ .../StFcsTriggerSimMaker.h | 8 + 2 files changed, 111 insertions(+), 46 deletions(-) diff --git a/StRoot/StSpinPool/StFcsTriggerSimMaker/StFcsTriggerSimMaker.cxx b/StRoot/StSpinPool/StFcsTriggerSimMaker/StFcsTriggerSimMaker.cxx index cd58c43b242..1ffeebf0de8 100644 --- a/StRoot/StSpinPool/StFcsTriggerSimMaker/StFcsTriggerSimMaker.cxx +++ b/StRoot/StSpinPool/StFcsTriggerSimMaker/StFcsTriggerSimMaker.cxx @@ -50,6 +50,16 @@ #include "StRoot/RTS/src/TRG_FCS/fcs_trg_base.h" +#include "StMaker.h" +#include "StChain.h" +#include "StMuDSTMaker/COMMON/StMuDst.h" +#include "StMuDSTMaker/COMMON/StMuEvent.h" +#include "StMuDSTMaker/COMMON/StMuFcsCollection.h" +#include "StMuDSTMaker/COMMON/StMuFcsHit.h" +#include "StMuDSTMaker/COMMON/StMuTypes.hh" +#include "StMuDSTMaker/COMMON/StMuEvent.h" +#include "StMuDSTMaker/COMMON/StMuFcsCollection.h" + namespace { enum {kMaxNS=2, kMaxDet=3, kMaxDep=24, kMaxCh=32, kMaxEcalDep=24, kMaxHcalDep=8, kMaxPresDep=4, kMaxLink2=2}; uint32_t fcs_trg_sim_adc[kMaxNS][kMaxDet][kMaxDep][kMaxCh] ; @@ -184,17 +194,17 @@ int StFcsTriggerSimMaker::InitRun(int runNumber){ mTree->Branch("trg",&mTrg,"trg/I"); } if(mQaHistFilename){ - mQaHistFile=new TFile(mQaHistFilename,"RECREATE"); - mTrgRate = new TH1F("FcsTrgRate","FcsTrgRate",mNTRG+1,0,mNTRG+1); + mQaHistFile=new TFile(mQaHistFilename,"RECREATE"); + mTrgRate = new TH1F("FcsTrgRate","FcsTrgRate",mNTRG+1,0,mNTRG+1); } //Write Text event file & gainfile FILE* gainfile=0; FILE* gainfile2=0; if(mFilename){ - mFile = fopen(mFilename,"w"); - gainfile=fopen("fcs_et_gain.txt","w"); - gainfile2=fopen("fcs_et_gain2.txt","w"); + mFile = fopen(mFilename,"w"); + gainfile=fopen("fcs_et_gain.txt","w"); + gainfile2=fopen("fcs_et_gain2.txt","w"); } //Fill ETgain, GainCorr and Pedestal @@ -266,11 +276,27 @@ int StFcsTriggerSimMaker::Finish(){ } int StFcsTriggerSimMaker::Make(){ - StEvent* event = (StEvent*)GetInputDS("StEvent"); - if(!event) {LOG_ERROR << "StFcsTriggerSimMaker::Make did not find StEvent"<fcsCollection(); - if(!mFcsColl) {LOG_ERROR << "StFcsTriggerSimMaker::Make did not find StEvent->StFcsCollection"<StFcsCollection"<start_event(); //Feed ADC @@ -279,35 +305,40 @@ int StFcsTriggerSimMaker::Make(){ memset(fcs_trg_sim_adc,0,sizeof(fcs_trg_sim_adc)); int n=0; for(int det=0; det<=kFcsNDet; det++){ - StSPtrVecFcsHit& hits = mFcsColl->hits(det); - int ns = mFcsDb->northSouth(det); - int ehp = mFcsDb->ecalHcalPres(det); - int nh = mFcsColl->numberOfHits(det); - for(int i=0; idep(); - unsigned short ch = hit->channel(); - //printf("ns=%1d ehp=%1d dep=%2d ch=%2d adc=%4d sim=\n",ns,ehp,dep,ch,hit->adc(0),mSimMode); - if(ehp<0 || ch>=32) continue; - fcs_trg_sim_adc[ns][ehp][dep][ch] = hit->adc(0); - if(mSimMode==0){ - int ntb=hit->nTimeBin(); - for(int t=0; ttimebin(t); - if(tb>=mTrgTimebin-3 && tb<=mTrgTimebin+4){ - data[tb-mTrgTimebin+3] = hit->adc(t); - //printf("tb=%3d i=%2d adc=%4d\n",tb,tb-mTrgTimebin+3,hit->adc(t)); - } - } - mTrgSim->fill_event(ehp,ns,dep,ch,data,8) ; - }else{ - data[1] = hit->adc(0)-1; //removing 1 to add at tb6 - data[6] = 1; //add this so tb6>tb7 - mTrgSim->fill_event(ehp,ns,dep,ch,data,8) ; - } - if(mFile) fprintf(mFile,"%2d %2d %2d %2d %5d\n",ns,ehp,dep,ch,hit->adc(0)); - n++; - } + + int ns = mFcsDb->northSouth(det); + int ehp = mFcsDb->ecalHcalPres(det); + + if((event)&&(mFcsColl)){ + StSPtrVecFcsHit& hits = mFcsColl->hits(det); + + int nh = mFcsColl->numberOfHits(det); + + for(int i=0; ichannel(); + + if(ehp<0 || ch>=32) continue; + feedADC(hit, ns, ehp, data); + n++; + } + + }else if((muevent)&&(mMuFcsColl)){ //Use StMuDst info instead of StEvent for Trigger Reconstruction + + int nh = mMuFcsColl->numberOfHits(det); + int det_hit_index = mMuFcsColl->indexOfFirstHit(det); + + for(int i=0; igetHit(hit_index); + unsigned short ch = hit->channel(); + + if(ehp<0 || ch>=32) continue; + feedADC(hit, ns, ehp, data); + n++; + } + } } if(mFile) fprintf(mFile,"%2d %2d %2d %2d %5d\n",-1,0,0,0,0); LOG_INFO << Form("StFcsTriggerSimMaker feeded %d hits",n) << endm;; @@ -315,7 +346,7 @@ int StFcsTriggerSimMaker::Make(){ //Run Trigger Simulation // uint16_t dsm_out = fcs_trg_run(mTrgSelect, mDebug); uint32_t dsm_out = mTrgSim->end_event(); - + //QA Tree mFlt=0; StarPrimaryMaker* pmkr= static_cast(GetMaker("PrimaryMaker")); @@ -327,7 +358,7 @@ int StFcsTriggerSimMaker::Make(){ } mTcu=dsm_out; if(mQaTreeFile) mTree->Fill(); - + //Results LOG_INFO << Form("Output to TCU = 0x%08x Filter=0x%08x",mTcu,mFlt)<Fill(mNTRG); NTRG[mNTRG]++; - for(int i=0; iFill(i); - NTRG[i]++; - } + for(int i=0; iFill(i); + NTRG[i]++; + } } - + LOG_INFO << "Triggers = "; for(int i=0; i void StFcsTriggerSimMaker::feedADC(T* hit, int ns, int ehp, uint16_t data_array[]){ + + unsigned short dep = hit->dep(); + unsigned short ch = hit->channel(); + +// printf("ns=%1d ehp=%1d dep=%2d ch=%2d adc=%4d sim=%d\n",ns,ehp,dep,ch,hit->adc(0),mSimMode); + fcs_trg_sim_adc[ns][ehp][dep][ch] = hit->adc(0); + if(mSimMode==0){ + int ntb=hit->nTimeBin(); + for(int t=0; ttimebin(t); + if(tb>=mTrgTimebin-3 && tb<=mTrgTimebin+4){ + data_array[tb-mTrgTimebin+3] = hit->adc(t); +// printf("tb=%3d i=%2d adc=%4d\n",tb,tb-mTrgTimebin+3,hit->adc(t)); + } + } + mTrgSim->fill_event(ehp,ns,dep,ch,data_array,8) ; + }else{ + data_array[1] = hit->adc(0)-1; //removing 1 to add at tb6 + data_array[6] = 1; //add this so tb6>tb7 + mTrgSim->fill_event(ehp,ns,dep,ch,data_array,8) ; + } + if(mFile) fprintf(mFile,"%2d %2d %2d %2d %5d\n",ns,ehp,dep,ch,hit->adc(0)); + +} diff --git a/StRoot/StSpinPool/StFcsTriggerSimMaker/StFcsTriggerSimMaker.h b/StRoot/StSpinPool/StFcsTriggerSimMaker/StFcsTriggerSimMaker.h index 306e759a37a..9d5fec4f7e6 100644 --- a/StRoot/StSpinPool/StFcsTriggerSimMaker/StFcsTriggerSimMaker.h +++ b/StRoot/StSpinPool/StFcsTriggerSimMaker/StFcsTriggerSimMaker.h @@ -8,15 +8,19 @@ #define STAR_StFcsTriggerSimMaker_HH #include "StMaker.h" +#include class StFcsDb; class StFcsCollection; +class StMuFcsCollection; class TFile; class fcs_trg_base; class link_t; class geom_t; class TTree; class TH1F; +class StFcsHit; +class StMuFcsHit; class StFcsTriggerSimMaker : public StMaker{ public: @@ -42,6 +46,8 @@ class StFcsTriggerSimMaker : public StMaker{ void setEtGain(float v) {mEtFactor=v;} fcs_trg_base* getTriggerEmu() {return mTrgSim;} + + template void feedADC(T* hit, int ns, int ehp, uint16_t data_array[]); //this is for just running stage2 from macro void runStage2(link_t ecal[], link_t hcal[], link_t pres[], geom_t &geo, link_t output[]); @@ -49,6 +55,8 @@ class StFcsTriggerSimMaker : public StMaker{ private: StFcsDb* mFcsDb=0; StFcsCollection* mFcsColl=0; + StMuFcsCollection* mMuFcsColl = 0; + int mTrgSelect=0; int mDebug=0; char* mFilename=0; From 4298c802127dc5d61ad4288925e56ddb00724aef Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Wed, 31 Jan 2024 16:38:02 -0500 Subject: [PATCH 04/25] refactor: move StiCA functionality to Sti package (#640) Resolves #628 --- StRoot/StBFChain/BigFullChain.h | 2 +- StRoot/{StiCA => Sti}/StiCATpcSeedFinder.cxx | 2 -- StRoot/{StiCA => Sti}/StiCATpcSeedFinder.h | 8 -------- StRoot/{StiCA => Sti}/StiCATpcTrackerInterface.cxx | 0 StRoot/{StiCA => Sti}/StiCATpcTrackerInterface.h | 0 StRoot/Sti/StiDefaultToolkit.cxx | 7 ++----- mgr/Conscript-standard | 2 +- 7 files changed, 4 insertions(+), 17 deletions(-) rename StRoot/{StiCA => Sti}/StiCATpcSeedFinder.cxx (97%) rename StRoot/{StiCA => Sti}/StiCATpcSeedFinder.h (91%) rename StRoot/{StiCA => Sti}/StiCATpcTrackerInterface.cxx (100%) rename StRoot/{StiCA => Sti}/StiCATpcTrackerInterface.h (100%) diff --git a/StRoot/StBFChain/BigFullChain.h b/StRoot/StBFChain/BigFullChain.h index 64c9c046cf0..917dd831eaa 100644 --- a/StRoot/StBFChain/BigFullChain.h +++ b/StRoot/StBFChain/BigFullChain.h @@ -1715,7 +1715,7 @@ Bfc_st BFC[] = { // standard chains // Sti/Stv chains {"Sti" ,"Sti","","StiLib,StiLibs,SCL,StEvent,StDbT,TpcIT,compend,sim_T,tbutil","StiMaker" , "StEventUtilities,StiUtilities,StiMaker","Sti tracker",kFALSE}, - {"StiCA" ,"Sti","","Sti","StiMaker","TPCCATracker,StiCA" ,"StiCA tracker",kFALSE}, + {"StiCA" ,"Sti","","Sti","StiMaker","TPCCATracker" ,"StiCA tracker",kFALSE}, {"StiCAPerf","","","","", "TPCCATrackerPerformance", "CA Performance",kFALSE}, {"StiCA" ,"Sti","","Sti,StiLib,StiCALib,StiLibs,SCL,StEvent,StDbT,TpcIT,compend,tbutil","StiMaker" , "StEventUtilities,libEG,StiUtilities,StiMaker","Sti+CA tracker",kFALSE}, diff --git a/StRoot/StiCA/StiCATpcSeedFinder.cxx b/StRoot/Sti/StiCATpcSeedFinder.cxx similarity index 97% rename from StRoot/StiCA/StiCATpcSeedFinder.cxx rename to StRoot/Sti/StiCATpcSeedFinder.cxx index 575a487efb8..eeefe44b25c 100644 --- a/StRoot/StiCA/StiCATpcSeedFinder.cxx +++ b/StRoot/Sti/StiCATpcSeedFinder.cxx @@ -192,5 +192,3 @@ StiDebug::Count("Reused_Pct",reUsed, pct); } mEnded = 3; return 0; } -//________________________________________________________________________________ -StiCATpcSeedFinder* StiCALoader::New() { return new StiCATpcSeedFinder;} diff --git a/StRoot/StiCA/StiCATpcSeedFinder.h b/StRoot/Sti/StiCATpcSeedFinder.h similarity index 91% rename from StRoot/StiCA/StiCATpcSeedFinder.h rename to StRoot/Sti/StiCATpcSeedFinder.h index daf0a0bda8f..e300cbfcf18 100644 --- a/StRoot/StiCA/StiCATpcSeedFinder.h +++ b/StRoot/Sti/StiCATpcSeedFinder.h @@ -42,12 +42,4 @@ class StiCATpcSeedFinder: public StiTrackFinder std::vector *mSeeds; }; -class StiCALoader { -public: -static StiCATpcSeedFinder* New(); -#if 0 -ClassDef(StiCALoader,0) -#endif -}; - #endif diff --git a/StRoot/StiCA/StiCATpcTrackerInterface.cxx b/StRoot/Sti/StiCATpcTrackerInterface.cxx similarity index 100% rename from StRoot/StiCA/StiCATpcTrackerInterface.cxx rename to StRoot/Sti/StiCATpcTrackerInterface.cxx diff --git a/StRoot/StiCA/StiCATpcTrackerInterface.h b/StRoot/Sti/StiCATpcTrackerInterface.h similarity index 100% rename from StRoot/StiCA/StiCATpcTrackerInterface.h rename to StRoot/Sti/StiCATpcTrackerInterface.h diff --git a/StRoot/Sti/StiDefaultToolkit.cxx b/StRoot/Sti/StiDefaultToolkit.cxx index 7851fea4aac..8e203daceb3 100644 --- a/StRoot/Sti/StiDefaultToolkit.cxx +++ b/StRoot/Sti/StiDefaultToolkit.cxx @@ -390,6 +390,7 @@ #include "Sti/StiDefaultTrackFilter.h" #include "Sti/StiDetectorGroup.h" #include "Sti/StiDetectorGroups.h" +#include "Sti/StiCATpcSeedFinder.h" #include "StDetectorDbMaker/StiHitErrorCalculator.h" #include "StiTpc/StiTpcHitLoader.h" #include "StiSvt/StiSvtHitLoader.h" @@ -639,11 +640,7 @@ StiTrackFinder * StiDefaultToolkit::getTrackSeedFinderKNN() //______________________________________________________________________________ StiTrackFinder * StiDefaultToolkit::getTrackSeedFinderCA() { - gSystem->Load("TPCCATracker"); - gSystem->Load("StiCA"); - auto *mySeed = (StiTrackFinder*)gROOT->ProcessLineFast("StiCALoader::New()"); - assert(mySeed); - return mySeed; + return new StiCATpcSeedFinder(); } //______________________________________________________________________________ diff --git a/mgr/Conscript-standard b/mgr/Conscript-standard index 0df341f33a7..db1f9b9204b 100644 --- a/mgr/Conscript-standard +++ b/mgr/Conscript-standard @@ -895,7 +895,7 @@ if ( $pkg !~ /^sim$/ && $pkg !~ /^gen$/ ) { $CPPPATH = "#StarVMC" . $main::PATH_SEPARATOR . $CPPPATH; # print "StarVMC change CPPPATH to $CPPPATH =========\n"; - } elsif ($pkg eq "TPCCATracker" or $pkg eq "StiCA") { + } elsif ($pkg eq "TPCCATracker" or $pkg eq "Sti") { $CPPPATH .= $main::PATH_SEPARATOR . "#" . $Dir . $main::PATH_SEPARATOR . "#" . $Dir . "/code"; From d966bc27afa15bddb298c1c9a6b1934ab6fa3fa0 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Wed, 31 Jan 2024 18:17:40 -0500 Subject: [PATCH 05/25] refactor: do not inline map accessor (#641) Resolves #620 Co-authored-by: klendathu2k --- StarVMC/StarAgmlLib/AgBlock.cxx | 3 +++ StarVMC/StarAgmlLib/AgBlock.h | 2 +- StarVMC/StarAgmlLib/AgMLExtension.cxx | 2 ++ StarVMC/StarAgmlLib/AgMLExtension.h | 2 +- StarVMC/StarAgmlLib/AgModule.cxx | 2 ++ StarVMC/StarAgmlLib/AgModule.h | 2 +- StarVMC/StarAgmlLib/AgShape.cxx | 2 ++ StarVMC/StarAgmlLib/AgShape.h | 2 +- StarVMC/StarAgmlLib/StarAgmlStacker.cxx | 6 ++++++ StarVMC/StarAgmlLib/StarAgmlStacker.h | 5 +---- mgr/Dyson/Export/AgROOT.py | 4 +++- 11 files changed, 23 insertions(+), 9 deletions(-) diff --git a/StarVMC/StarAgmlLib/AgBlock.cxx b/StarVMC/StarAgmlLib/AgBlock.cxx index f6801e47086..5c96915bdef 100644 --- a/StarVMC/StarAgmlLib/AgBlock.cxx +++ b/StarVMC/StarAgmlLib/AgBlock.cxx @@ -98,6 +98,9 @@ void AgBlock::AddGroup( const Char_t *name ) ;//{ mGroups.push_back( name ); } +void AgBlock::AddCut( TString cut, double value ){ mGstpar[cut] = value; } + + // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> WHY IS THIS COMMENTED OUT??? void AgBlock::Inherit() { diff --git a/StarVMC/StarAgmlLib/AgBlock.h b/StarVMC/StarAgmlLib/AgBlock.h index 653b60e9510..be59cca0b61 100644 --- a/StarVMC/StarAgmlLib/AgBlock.h +++ b/StarVMC/StarAgmlLib/AgBlock.h @@ -153,7 +153,7 @@ class AgBlock : public TNamed int numberBranches() const { return mNumberBranches; } void branch(){ mNumberBranches++; } - void AddCut( TString cut, double value ){ mGstpar[cut] = value; } + void AddCut( TString cut, double value ); std::map& GetCuts() { return mGstpar; } private: diff --git a/StarVMC/StarAgmlLib/AgMLExtension.cxx b/StarVMC/StarAgmlLib/AgMLExtension.cxx index 5287b9bdb3f..de85e142434 100644 --- a/StarVMC/StarAgmlLib/AgMLExtension.cxx +++ b/StarVMC/StarAgmlLib/AgMLExtension.cxx @@ -13,3 +13,5 @@ AgMLExtension::AgMLExtension() : TGeoRCExtension(), { Grab(); } + +void AgMLExtension::AddCut( TString cut, double value ){ mGstpar[cut] = value; } diff --git a/StarVMC/StarAgmlLib/AgMLExtension.h b/StarVMC/StarAgmlLib/AgMLExtension.h index 3d1d0bbef11..e379749d116 100644 --- a/StarVMC/StarAgmlLib/AgMLExtension.h +++ b/StarVMC/StarAgmlLib/AgMLExtension.h @@ -57,7 +57,7 @@ class AgMLExtension : public TGeoRCExtension { std::vector GetUserHits(){ return mHitScoring; } - void AddCut( TString cut, double value ){ mGstpar[cut] = value; } + void AddCut( TString cut, double value ); std::map& GetCuts() { return mGstpar; } diff --git a/StarVMC/StarAgmlLib/AgModule.cxx b/StarVMC/StarAgmlLib/AgModule.cxx index 95c41d06912..29465ba7618 100644 --- a/StarVMC/StarAgmlLib/AgModule.cxx +++ b/StarVMC/StarAgmlLib/AgModule.cxx @@ -25,6 +25,8 @@ TDataSet *AgModule::Geom() else return mGeomSet; }; +void AgModule::AddHitScoring( TString name, AgMLScoring* sc ){ mHitScoring[name] = sc; } + // --------------------------------------------------------------------------------------------- AgBlock *AgModule::AddBlock( const Char_t *name, AgBlock *_block ) { diff --git a/StarVMC/StarAgmlLib/AgModule.h b/StarVMC/StarAgmlLib/AgModule.h index dd0f3f5a1f6..c69e5a3d61d 100644 --- a/StarVMC/StarAgmlLib/AgModule.h +++ b/StarVMC/StarAgmlLib/AgModule.h @@ -40,7 +40,7 @@ class AgModule : public AgBlock void SetTrackingFlag( int flag ){ mTrackingFlag = flag; } int GetTrackingFlag(){ return mTrackingFlag; } - void AddHitScoring( TString name, AgMLScoring* sc ){ mHitScoring[name] = sc; } + void AddHitScoring( TString name, AgMLScoring* sc ); std::map GetHitScoring(){ return mHitScoring; } private: diff --git a/StarVMC/StarAgmlLib/AgShape.cxx b/StarVMC/StarAgmlLib/AgShape.cxx index 66a0fd26a38..5ca97db14c9 100644 --- a/StarVMC/StarAgmlLib/AgShape.cxx +++ b/StarVMC/StarAgmlLib/AgShape.cxx @@ -626,6 +626,8 @@ Bool_t AgShape::morphed() return true; // No shapes match } +std::vector< TString > &AgShape::parList(){ return mParList[mId]; } + // ============================================================================================================= Bool_t AgShape::parameterized() { diff --git a/StarVMC/StarAgmlLib/AgShape.h b/StarVMC/StarAgmlLib/AgShape.h index 63ab9a840a5..a58c8e9f7e0 100644 --- a/StarVMC/StarAgmlLib/AgShape.h +++ b/StarVMC/StarAgmlLib/AgShape.h @@ -67,7 +67,7 @@ class AgShape : public TNamed, public AgParameterList Bool_t morphed(); /// Return a list of the parameters which define this shape - std::vector< TString > &parList(){ return mParList[mId]; } + std::vector< TString > &parList(); /// Returns true if the shape's parameters are to be set /// when positioned diff --git a/StarVMC/StarAgmlLib/StarAgmlStacker.cxx b/StarVMC/StarAgmlLib/StarAgmlStacker.cxx index 0e1bc6d1c07..a79aebeb2bd 100644 --- a/StarVMC/StarAgmlLib/StarAgmlStacker.cxx +++ b/StarVMC/StarAgmlLib/StarAgmlStacker.cxx @@ -129,6 +129,12 @@ TString StarAgmlStacker::realname( TString nname ) return mRealnames[nname]; } + +const std::vector &StarAgmlStacker::nicknames(const Char_t *name) +{ + return mNicknames[ TString(name) ]; +} + // --------------------------------------------------------------------------------------------------- void StarAgmlStacker::Debug( const Char_t *name, const Char_t *flag ) { diff --git a/StarVMC/StarAgmlLib/StarAgmlStacker.h b/StarVMC/StarAgmlLib/StarAgmlStacker.h index ea323dbaed6..809b6496682 100644 --- a/StarVMC/StarAgmlLib/StarAgmlStacker.h +++ b/StarVMC/StarAgmlLib/StarAgmlStacker.h @@ -35,10 +35,7 @@ class StarAgmlStacker : public TNamed virtual Bool_t SearchVolume( const AgShape &shape, const AgAttribute &attr )=0; - const std::vector &nicknames(const Char_t *name) - { - return mNicknames[ TString(name) ]; - } + const std::vector &nicknames(const Char_t *name); void Debug( const Char_t *name, const Char_t *flag="position" ); diff --git a/mgr/Dyson/Export/AgROOT.py b/mgr/Dyson/Export/AgROOT.py index 314ecc42791..8934d724515 100644 --- a/mgr/Dyson/Export/AgROOT.py +++ b/mgr/Dyson/Export/AgROOT.py @@ -687,7 +687,7 @@ class StarGeometry { /// Construct geometry with the specified tag, and return wrapped in a TDataSet static TDataSet* Construct( const char* name = "%s"); static bool List ( const char* name = "%s"); - static void Whitelist( const char* name, int value=1 ){ whitelist[name]=value; } + static void Whitelist( const char* name, int value=1 ); static void InitAgML ( const char* stacker="StarTGeoStacker"); StarGeometry(){ /* nada */ }; virtual ~StarGeometry(){ /* nada */ } @@ -718,6 +718,8 @@ class Geometry : public StarGeometry { std::map StarGeometry::whitelist= {{"all",1}}; + void StarGeometry::Whitelist(const char* name, int value){ whitelist[name]=value; } + TDataSet* StarGeometry::Construct( const char* name ) { std::string tag = name; From 28c5002bf1dd4c46480cacf1ca20e1ca52a392ea Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Wed, 31 Jan 2024 21:21:20 -0500 Subject: [PATCH 06/25] refactor: do not clone geometry for Sti detector builder (#642) --- StRoot/Sti/StiMasterDetectorBuilder.cxx | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/StRoot/Sti/StiMasterDetectorBuilder.cxx b/StRoot/Sti/StiMasterDetectorBuilder.cxx index 8f146366e14..0c8aca51886 100644 --- a/StRoot/Sti/StiMasterDetectorBuilder.cxx +++ b/StRoot/Sti/StiMasterDetectorBuilder.cxx @@ -25,7 +25,6 @@ void StiMasterDetectorBuilder::build(StMaker&source) { if (! gGeoManager) StiVMCToolKit::GetVMC(); - TGeoManager *gGeoManagerSV = gGeoManager; gGeoManager = 0; StMaker *chain=StMaker::GetChain(); LOG_INFO << "We are StiMasterDetectorBuilder::build() and will clone the geometry if exists" << endm; @@ -35,12 +34,6 @@ void StiMasterDetectorBuilder::build(StMaker&source) } #if 1 - if ( gGeoManagerSV ){ - LOG_INFO << "Create a clone of VmcGeometry for reconstruction" << endm; - gGeoManagerSV->Clone("CloneGeom"); - } else { - LOG_INFO << "Could not get a pointer to gGeoManager " << endm; - } #else if ( chain ) { LOG_INFO << "StiMasterDetectorBuilder::build() : Create clone of VmcGeometry by reinitialization for reconstruction" < Date: Thu, 1 Feb 2024 20:40:06 -0500 Subject: [PATCH 07/25] Disable logging outside of local domain, with no other changes (#644) Clean version of the pull request disabling DAQ logging when compiling outside of the local domain. --- StRoot/RTS/include/rtsLog.h | 45 +++++++-------------------------- StRoot/RTS/src/LOG/Makefile | 3 ++- StRoot/RTS/src/LOG/rtsLog.C | 2 +- StRoot/RTS/src/LOG/rtsLogUnix.c | 34 ++++++++++++++++++++++--- StRoot/RTS/src/rtsmakefile.def | 36 +++++++++++++++++++++++--- 5 files changed, 75 insertions(+), 45 deletions(-) diff --git a/StRoot/RTS/include/rtsLog.h b/StRoot/RTS/include/rtsLog.h index be8b087ab84..c93e3cd42bb 100755 --- a/StRoot/RTS/include/rtsLog.h +++ b/StRoot/RTS/include/rtsLog.h @@ -93,41 +93,14 @@ void rtsLogAddJmlFile (char *fname); -/*Tonko: not used Special (mis)handling for STAR Offline Code -#ifdef __ROOT__ -#define RTS_DISABLE_LOG -#endif -*/ -#ifdef RTS_DISABLE_LOG - -#define RTS_ASSERT(expr) assert(expr) - - - #define LOG(SEV,STRING,ARGS...) \ - do { \ - const char *const yada = SEV ; \ - if((*yada == 'E')) { \ - fprintf(stderr,"" ANSI_RED "RTS_" SEV ": " __FILE__ " [line %d]: " STRING "" ANSI_RESET "\n" , __LINE__ , ##ARGS) ;\ - } \ - else if((*yada == 'C')) { \ - fprintf(stderr,"" ANSI_RED "" ANSI_REVERSE "RTS_" SEV ": " __FILE__ " [line %d]: " STRING "" ANSI_RESET "\n" , __LINE__ , ##ARGS) ;\ - } \ - else if((*yada == 'I')) { \ - fprintf(stderr,"" ANSI_BLUE "" ANSI_BOLD "RTS_" SEV ": " __FILE__ " [line %d]: " STRING "" ANSI_RESET "\n" , __LINE__ , ##ARGS) ;\ - } \ - else if((*yada == 'T')) { \ - fprintf(stderr,"" ANSI_GREEN "" ANSI_BOLD "RTS_" SEV ": " __FILE__ " [line %d]: " STRING "" ANSI_RESET "\n" , __LINE__ , ##ARGS) ;\ - } \ - else if((*yada == 'W')) { \ - fprintf(stderr,"" ANSI_CYAN "" ANSI_BOLD "RTS_" SEV ": " __FILE__ " [line %d]: " STRING "" ANSI_RESET "\n" , __LINE__ , ##ARGS) ;\ - } \ - else if((*yada == 'O')) { \ - fprintf(stderr,"" ANSI_BLUE "" ANSI_REVERSE "RTS_" SEV ": " __FILE__ " [line %d]: " STRING "" ANSI_RESET "\n" , __LINE__ , ##ARGS) ;\ - } \ - } while(0) \ +#ifndef RTS_ENABLE_LOG +#define RTS_ASSERT(expr) assert(expr) +#define LOG(SEV,STRING,ARGS...) +#define rtsLogUnix_v(str, ...) +#define rtsLogAddCmd(x) // the following become noops... @@ -136,7 +109,7 @@ void rtsLogAddJmlFile (char *fname); #define rtsLogLevelInt(x) #define rtsLogOutput(x) -#else /* RTS_DISABLE_LOG */ +#else /* RTS_ENABLE_LOG */ #ifdef __GNUC__ @@ -270,12 +243,12 @@ INLINE_HACK void rtsLogLevel(const char *level) -#endif +#endif /* RTS_LOG_COLORED */ -#endif +#endif /* __vxworks */ -#endif /* RTS_DISABLE_LOG */ +#endif /* RTS_ENABLE_LOG */ #ifdef __cplusplus } diff --git a/StRoot/RTS/src/LOG/Makefile b/StRoot/RTS/src/LOG/Makefile index 8107ebe358f..c1447ead38a 100755 --- a/StRoot/RTS/src/LOG/Makefile +++ b/StRoot/RTS/src/LOG/Makefile @@ -2,6 +2,7 @@ include ../rtsmakefile.def include ../rtsplus.def + # zap LDLIBS LDLIBS = @@ -28,7 +29,7 @@ rtsLog.o : rtsLog.C rtsLog: rtsLog.o rtsLogUnix.o $(CXX) $(CXXFLAGS) rtsLogUnix.o rtsLog.o -o rtsLog - + #operDisplay.sh: diff --git a/StRoot/RTS/src/LOG/rtsLog.C b/StRoot/RTS/src/LOG/rtsLog.C index 481ebdfe1b6..b9aa11ed557 100644 --- a/StRoot/RTS/src/LOG/rtsLog.C +++ b/StRoot/RTS/src/LOG/rtsLog.C @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) use_stdin = 0 ; rtsLogLevel(DBG) ; - rtsLogOutput(RTS_LOG_NET) ; + //rtsLogOutput(RTS_LOG_NET) ; memset(logstr,0,sizeof(logstr)) ; diff --git a/StRoot/RTS/src/LOG/rtsLogUnix.c b/StRoot/RTS/src/LOG/rtsLogUnix.c index 7e65ca77188..6d63e49c7ea 100755 --- a/StRoot/RTS/src/LOG/rtsLogUnix.c +++ b/StRoot/RTS/src/LOG/rtsLogUnix.c @@ -29,6 +29,30 @@ extern "C" { volatile int tonkoLogLevel = 2 ; + + + + +#ifdef RTS_ENABLE_LOG +#warning "DAQ logging is enabled" +#ifdef RTS_LOG_DEFAULT_NET +#warning "DAQ logging defaults to daqman" +#else +#warning "DAQ logging defaults to STDERR" +#endif /* RTS_LOG_DEFAULT_NET */ +#else +#warning "DAQ logging is disabled" +#endif /* RTS_ENABLE_LOG */ + + +#ifdef RTS_ENABLE_LOG + +#ifdef RTS_LOG_DEFAULT_NET +static int output_flag = RTS_LOG_NET ; +#else +static int output_flag = RTS_LOG_STDERR ; +#endif + static const char *getCmd(void) ; static int odesc = -1 ; static int handchange ; @@ -42,7 +66,7 @@ static char servER[80] = RTS_LOG_HOST ; #endif static int port = RTS_LOG_PORT ; -static int output_flag = RTS_LOG_NET ; + static char cmd[1024] ; /* @@ -113,7 +137,6 @@ void rtsLogAddJmlFile (char *fname) jml_fname = _g_fname; } - int rtsLogUnix_v(const char *str, ...) { /* common to all threads */ @@ -328,8 +351,6 @@ int rtsLogUnix_v(const char *str, ...) return 0 ; } - - static const char *getCmd(void) { @@ -370,6 +391,11 @@ static const char *getCmd(void) #endif } + +#endif + + + #ifdef __cplusplus } #endif diff --git a/StRoot/RTS/src/rtsmakefile.def b/StRoot/RTS/src/rtsmakefile.def index 2b345a55a73..7f0b82f740c 100755 --- a/StRoot/RTS/src/rtsmakefile.def +++ b/StRoot/RTS/src/rtsmakefile.def @@ -17,6 +17,8 @@ ifeq ($(HOST_NAME),daqman.starp.bnl.gov) endif +HOSTDOMAIN = $(shell hostname -d) + # jml... TARGET_CPU_STRING to mean the full string... # go from "uname" to gcc -mcpu=TARGET_CPU variant @@ -373,14 +375,38 @@ DEFINES = -D_REENTRANT ${RTS_DAQMAN_FLAGS} -DRTS_HOST_NAME=\"${HOST_NAME}\" -DTA # Set strict errors in LINUX -BASEFLAGS = -O3 -Wall -Werror -Wno-error=strict-overflow -Wno-error=maybe-uninitialized -Wno-error=unused-label -Wno-error=unused-value -Wno-error=unused-variable -Wno-error=unused-function -Wno-unused-but-set-variable -pipe -fverbose-asm ${HOSTFLAGS} +BASEFLAGS = -O3 -Wall -Wno-error=strict-overflow -Wno-error=maybe-uninitialized -Wno-error=unused-label -Wno-error=unused-value -Wno-error=unused-variable -Wno-error=unused-function -Wno-unused-but-set-variable -pipe -fverbose-asm ${HOSTFLAGS} + +#-O3 ifneq (${TARGET_SYSTEM}, LINUX) - BASEFLAGS = -O3 -Wall -pipe -fverbose-asm ${HOSTFLAGS} + BASEFLAGS = -Wall -pipe -fverbose-asm ${HOSTFLAGS} endif ifeq (${HOST_NAME},xvme01.daq.bnl.local) - BASEFLAGS = -O3 -Wall -Werror -Wno-error=strict-overflow -Wno-error=unused-label -Wno-error=unused-value -Wno-error=unused-variable -Wno-error=unused-function -Wno-unused-but-set-variable -pipe -fverbose-asm ${HOSTFLAGS} + BASEFLAGS = -O3 -Wall -Wno-error=strict-overflow -Wno-error=unused-label -Wno-error=unused-value -Wno-error=unused-variable -Wno-error=unused-function -Wno-unused-but-set-variable -pipe -fverbose-asm ${HOSTFLAGS} +endif + +# if not compiling on one of the standard domains, then +# use the default log destination of std_err +# if compiling on local domain, write to daqman +# +# if compiling somewhere else for writing to daqman these defines +ifeq (${HOSTDOMAIN},starp.bnl.gov) + DEFINES += -DRTS_LOG_DEFAULT_NET + DEFINES += -DRTS_ENABLE_LOG +else ifeq (${HOSTDOMAIN},daq.bnl.local) + DEFINES += -DRTS_LOG_DEFAULT_NET + DEFINES += -DRTS_ENABLE_LOG +else ifeq (${HOSTDOMAIN},daq2.bnl.local) + DEFINES += -DRTS_LOG_DEFAULT_NET + DEFINES += -DRTS_ENABLE_LOG +else ifeq (${HOSTDOMAIN},trg.bnl.local) + DEFINES += -DRTS_LOG_DEFAULT_NET + DEFINES += -DRTS_ENABLE_LOG +else ifeq (${HOSTDOMAIN},l4.bnl.local) + DEFINES += -DRTS_LOG_DEFAULT_NET + DEFINES += -DRTS_ENABLE_LOG endif CCFLAGS = ${BASEFLAGS} ${USRCCFLAGS} ${DEFINES} ${INCLUDES} @@ -396,6 +422,10 @@ ifeq ($(RTS_PROJECT),PP2PP) endif endif + + + + # noticed problems on Linux where the default linker gcc doesn't work well for g++ compiled # files LINK.o = $(CXX) $(LDFLAGS) $(TARGET_ARCH) From 6ce806c4a7773fda1ea1937250dabc39f2cf4637 Mon Sep 17 00:00:00 2001 From: Yuri Fisyak Date: Fri, 8 Mar 2024 09:36:39 -0500 Subject: [PATCH 08/25] remove TPC calibration files from StarDb (#662) [Remove TpcnPad && TpcnTbk tables from StarDb/Calibrations/tpc --- StarDb/Calibrations/tpc/TpcnPad.C | 13 ------------- StarDb/Calibrations/tpc/TpcnPad.y2019.C | 17 ----------------- StarDb/Calibrations/tpc/TpcnTbk.C | 13 ------------- 3 files changed, 43 deletions(-) delete mode 100644 StarDb/Calibrations/tpc/TpcnPad.C delete mode 100644 StarDb/Calibrations/tpc/TpcnPad.y2019.C delete mode 100644 StarDb/Calibrations/tpc/TpcnTbk.C diff --git a/StarDb/Calibrations/tpc/TpcnPad.C b/StarDb/Calibrations/tpc/TpcnPad.C deleted file mode 100644 index 2f9baa82704..00000000000 --- a/StarDb/Calibrations/tpc/TpcnPad.C +++ /dev/null @@ -1,13 +0,0 @@ -#include "tables/St_tpcCorrection_Table.h" - -TDataSet *CreateTable() { - if (!gROOT->GetClass("St_tpcCorrection")) return 0; - Int_t nrows = 2; - tpcCorrection_st row; - St_tpcCorrection *tableSet = new St_tpcCorrection("TpcnPad",nrows); - memset(&row,0,tableSet->GetRowSize()); - tableSet->AddAt(&row);// Outer - tableSet->AddAt(&row);// Inner - // ----------------- end of code --------------- - return (TDataSet *)tableSet; -} diff --git a/StarDb/Calibrations/tpc/TpcnPad.y2019.C b/StarDb/Calibrations/tpc/TpcnPad.y2019.C deleted file mode 100644 index 36786a650ff..00000000000 --- a/StarDb/Calibrations/tpc/TpcnPad.y2019.C +++ /dev/null @@ -1,17 +0,0 @@ -#include "tables/St_tpcCorrection_Table.h" - -TDataSet *CreateTable() { - if (!gROOT->GetClass("St_tpcCorrection")) return 0; - Int_t nrows = 1; - tpcCorrection_st row; - St_tpcCorrection *tableSet = new St_tpcCorrection("TpcnPad",nrows); - memset(&row,0,tableSet->GetRowSize()); - row.idx = 1; - row.nrows = nrows; - row.type = 200; - row.min = 1.5; - row.max = 16.5; - tableSet->AddAt(&row);// Outer & Inner - // ----------------- end of code --------------- - return (TDataSet *)tableSet; -} diff --git a/StarDb/Calibrations/tpc/TpcnTbk.C b/StarDb/Calibrations/tpc/TpcnTbk.C deleted file mode 100644 index 7e5d984757b..00000000000 --- a/StarDb/Calibrations/tpc/TpcnTbk.C +++ /dev/null @@ -1,13 +0,0 @@ -#include "tables/St_tpcCorrection_Table.h" - -TDataSet *CreateTable() { - if (!gROOT->GetClass("St_tpcCorrection")) return 0; - Int_t nrows = 2; - tpcCorrection_st row; - St_tpcCorrection *tableSet = new St_tpcCorrection("TpcnTbk",nrows); - memset(&row,0,tableSet->GetRowSize()); - tableSet->AddAt(&row);// Outer - tableSet->AddAt(&row);// Inner - // ----------------- end of code --------------- - return (TDataSet *)tableSet; -} From b6dc337559298c32dc60643ef49358d5c9653e28 Mon Sep 17 00:00:00 2001 From: Dmitry Arkhipkin Date: Mon, 11 Mar 2024 18:23:56 -0400 Subject: [PATCH 09/25] new FCS tables for Akio (#665) Subj. New table definitions as requested by FCS expert. --- StDb/idl/fcsEcalGainOnline.idl | 10 ++++++++++ StDb/idl/fcsHcalGainOnline.idl | 10 ++++++++++ StDb/idl/fcsPresThreshold.idl | 10 ++++++++++ 3 files changed, 30 insertions(+) create mode 100644 StDb/idl/fcsEcalGainOnline.idl create mode 100644 StDb/idl/fcsHcalGainOnline.idl create mode 100644 StDb/idl/fcsPresThreshold.idl diff --git a/StDb/idl/fcsEcalGainOnline.idl b/StDb/idl/fcsEcalGainOnline.idl new file mode 100644 index 00000000000..66881b83450 --- /dev/null +++ b/StDb/idl/fcsEcalGainOnline.idl @@ -0,0 +1,10 @@ +/* fcsEcalGainOnline.idl + * + * Table: fcsEcalGainOnline + * + * description: // FCS ECal gain online + */ + +struct fcsEcalGainOnline { + float gainOnline[1496]; /* gaincorr 2*748 */ +}; diff --git a/StDb/idl/fcsHcalGainOnline.idl b/StDb/idl/fcsHcalGainOnline.idl new file mode 100644 index 00000000000..ec43e0fbe01 --- /dev/null +++ b/StDb/idl/fcsHcalGainOnline.idl @@ -0,0 +1,10 @@ +/* fcsHcalGainOnline.idl + * + * Table: fcsHcalGainOnline + * + * description: // FCS HCal gain online + */ + +struct fcsHcalGainOnline { + float gainOnline[520]; /* gaincorr 2*260 */ +}; diff --git a/StDb/idl/fcsPresThreshold.idl b/StDb/idl/fcsPresThreshold.idl new file mode 100644 index 00000000000..acc495d977b --- /dev/null +++ b/StDb/idl/fcsPresThreshold.idl @@ -0,0 +1,10 @@ +/* fcsPresThreshold.idl + * + * Table: fcsPresThreshold + * + * description: // FCS Pres Threshold online + */ + +struct fcsPresThreshold { + float threshold[384]; /* valley position 2*192 */ +}; From 83934025825953a7345ccbe79f96d634ec0c1fe8 Mon Sep 17 00:00:00 2001 From: Xilin Liang <64381828+xilinliang@users.noreply.github.com> Date: Thu, 14 Mar 2024 10:40:52 -0400 Subject: [PATCH 10/25] Move and modify StFcsPi0FinderForECal to StRoot (#667) We are asked from production team to Move StRoot/StSpinPool/StFcsPi0FinderForECal maker to StRoot/ In addition, we comment out 2 lines in "include" header for the StFcsPi0FinderForECal.cxx The StFcsPi0FinderForECal maker is for calibrating the forward upgrade FCS ECal and for monitoring the gain for FCS ECal from pi0 reconstruction. --------- Co-authored-by: Gene Van Buren --- StRoot/{StSpinPool => }/StFcsPi0FinderForEcal/README | 0 .../StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.cxx | 5 +++-- .../StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.h | 0 StRoot/St_QA_Maker/StEventQAMaker.cxx | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) rename StRoot/{StSpinPool => }/StFcsPi0FinderForEcal/README (100%) rename StRoot/{StSpinPool => }/StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.cxx (99%) rename StRoot/{StSpinPool => }/StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.h (100%) diff --git a/StRoot/StSpinPool/StFcsPi0FinderForEcal/README b/StRoot/StFcsPi0FinderForEcal/README similarity index 100% rename from StRoot/StSpinPool/StFcsPi0FinderForEcal/README rename to StRoot/StFcsPi0FinderForEcal/README diff --git a/StRoot/StSpinPool/StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.cxx b/StRoot/StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.cxx similarity index 99% rename from StRoot/StSpinPool/StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.cxx rename to StRoot/StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.cxx index bc3fce6b328..365ddc7d667 100644 --- a/StRoot/StSpinPool/StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.cxx +++ b/StRoot/StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.cxx @@ -3,6 +3,7 @@ // //critical plots for offline QA: h1_inv_mass_cluster , h1_two_cluster_energy_allcut , h1_dgg_cluster , h2_cluster_dgg_vs_E1pE2 // +//Update 3/12/24: move the StFcsPi0FinderForEcal to StRoot , no dependent on StSpinPool , also comment out 2 unused head file // #include "StFcsPi0FinderForEcal.h" @@ -16,8 +17,8 @@ #include "StFcsDbMaker/StFcsDbMaker.h" #include "StMessMgr.h" #include "StMuDSTMaker/COMMON/StMuTypes.hh" -#include "StSpinPool/StFcsQaMaker/StFcsQaMaker.h" -#include "StSpinPool/StFcsRawDaqReader/StFcsRawDaqReader.h" +//#include "StSpinPool/StFcsQaMaker/StFcsQaMaker.h" +//#include "StSpinPool/StFcsRawDaqReader/StFcsRawDaqReader.h" #include "StThreeVectorF.hh" #include "Stypes.h" #include "TBox.h" diff --git a/StRoot/StSpinPool/StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.h b/StRoot/StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.h similarity index 100% rename from StRoot/StSpinPool/StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.h rename to StRoot/StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.h diff --git a/StRoot/St_QA_Maker/StEventQAMaker.cxx b/StRoot/St_QA_Maker/StEventQAMaker.cxx index 458c77c2424..e89040a8f3e 100644 --- a/StRoot/St_QA_Maker/StEventQAMaker.cxx +++ b/StRoot/St_QA_Maker/StEventQAMaker.cxx @@ -47,7 +47,7 @@ //fcs #define SKIPDefImp -#include "StSpinPool/StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.cxx" +#include "StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.cxx" #undef SKIPDefImp #include "StEvent/StTpcRawData.h" From fa8046fd771c564e2bd77331c23a2f9771e03a3f Mon Sep 17 00:00:00 2001 From: klendathu2k <56083924+klendathu2k@users.noreply.github.com> Date: Wed, 20 Mar 2024 10:59:09 -0400 Subject: [PATCH 11/25] Add Be8 decays to 2 alphas... (#666) https://en.wikipedia.org/wiki/Beryllium-8 --- pams/sim/gstar/gstar_part.g | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pams/sim/gstar/gstar_part.g b/pams/sim/gstar/gstar_part.g index 8e05456952a..4fbe246aed6 100644 --- a/pams/sim/gstar/gstar_part.g +++ b/pams/sim/gstar/gstar_part.g @@ -524,6 +524,22 @@ MODULE gstar_part Is the STAR Particle Database pdg = -PDG_ION_ID(2,3) , trktyp = kGtHION + + * requested by JieZhao ... Be8 (alpha clusters) decay into 2 alphas + + Particle Be8s0 code = 50060 TrkTyp=8, mass = 7.45485, charge=4, tlife=1.1817e-19, + pdg=PDG_ION_ID(4,8) bratio={1,} mode={ 4747,} + Particle Be8s2 code = 50061 TrkTyp=8, mass = 7.45788, charge=4, tlife=4.3502e-22, + pdg=PDG_ION_ID(4,8) bratio = {1,} mode={47 47,} + Particle Be8s4 code = 50062 TrkTyp=8, mass = 7.46620, charge=4, tlife=1.8805e-22, + pdg=PDG_ION_ID(4,8) bratio = {1,} mode={47 47,} + Particle C12hs code = 50063 TrkTyp=8, mass =11.18251, charge=6, tlife=7.0773e-17, + pdg=PDG_ION_ID(6,6) bratio = {1,} mode={50060 47,} + + uw = { 0, 50060, 47 } + Call GSPART( %code, %title, %trktyp, %mass, %charge, %tlife, uw, nw ) + + PARTICLE Deuteron code = 51045 , mass = 1.876 , charge = 1.0 , From 06198bcf6b472ce10760f0d3f412d935cbdadc32 Mon Sep 17 00:00:00 2001 From: klendathu2k <56083924+klendathu2k@users.noreply.github.com> Date: Fri, 22 Mar 2024 09:18:33 -0400 Subject: [PATCH 12/25] Fix cut-and-paste errors in geometry definitions. (#670) --- StRoot/StChain/GeometryDbAliases.h | 4 ++-- StarVMC/xgeometry/xgeometry.age | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/StRoot/StChain/GeometryDbAliases.h b/StRoot/StChain/GeometryDbAliases.h index fd7c5bd7dc7..c72964d3ddf 100644 --- a/StRoot/StChain/GeometryDbAliases.h +++ b/StRoot/StChain/GeometryDbAliases.h @@ -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"}, diff --git a/StarVMC/xgeometry/xgeometry.age b/StarVMC/xgeometry/xgeometry.age index a275c12c4b3..abe543f0072 100644 --- a/StarVMC/xgeometry/xgeometry.age +++ b/StarVMC/xgeometry/xgeometry.age @@ -2542,8 +2542,8 @@ If LL>0 case y2023 { y2023: y2023 first cut geometry; Geom = 'y2023 '; call geom_y2023;} case y2023a { y2023a: y2023a production tag; Geom = 'y2023a '; call geom_y2023a;} - case y2023 { y2024: y2024 first cut geometry; Geom = 'y2024 '; call geom_y2024;} - case y2023a { y2024a: y2024a production tag; Geom = 'y2024a '; call geom_y2024a;} + case y2024 { y2024: y2024 first cut geometry; Geom = 'y2024 '; call geom_y2024;} + case y2024a { y2024a: y2024a production tag; Geom = 'y2024a '; call geom_y2024a;} case dev2021 { dev2021: First cut forward upgrades; Geom = 'dev2021 '; call geom_dev2021;} case dev2022 { dev2022: First cut forward upgrades; Geom = 'dev2022 '; call geom_dev2022;} From 023cca566f1dc9148fed67bca8be8dcc5e391423 Mon Sep 17 00:00:00 2001 From: Daniel Torres Valladares <81983942+DanielTorres98@users.noreply.github.com> Date: Mon, 25 Mar 2024 10:33:29 -0500 Subject: [PATCH 13/25] Vpd start mode integrated (#645) # Description StBTofCalibMaker::tofCellResolution function can now use VPD start resolution if UseVpdStart is set to TRUE. Additionally, singleTubeRes was fixed to compute the VPD resolution correctly based on which tubes were used. --------- Co-authored-by: Daniel Torres Valladares --- StRoot/StBTofCalibMaker/StBTofCalibMaker.cxx | 42 ++++++-------------- StRoot/StBTofUtil/StVpdSimConfig.h | 38 ++++++++++++------ 2 files changed, 39 insertions(+), 41 deletions(-) diff --git a/StRoot/StBTofCalibMaker/StBTofCalibMaker.cxx b/StRoot/StBTofCalibMaker/StBTofCalibMaker.cxx index afc052abba5..c82328a3523 100644 --- a/StRoot/StBTofCalibMaker/StBTofCalibMaker.cxx +++ b/StRoot/StBTofCalibMaker/StBTofCalibMaker.cxx @@ -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; } diff --git a/StRoot/StBTofUtil/StVpdSimConfig.h b/StRoot/StBTofUtil/StVpdSimConfig.h index 26176a355bd..69d6ee0be95 100644 --- a/StRoot/StBTofUtil/StVpdSimConfig.h +++ b/StRoot/StBTofUtil/StVpdSimConfig.h @@ -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) From d1fecb6fb6b6a142ed6b0d603f0b551414f65cc4 Mon Sep 17 00:00:00 2001 From: YannickSoehngen <60179883+YannickSoehngen@users.noreply.github.com> Date: Mon, 25 Mar 2024 23:13:50 +0100 Subject: [PATCH 14/25] Match update and event flag fix (#661) Fixed GoodEventFlag, increased granularity from counter to Get4 level, added pulser Flag (previous part of GoodEventFlag) and implementation of Single-Sided-Matches --------- Co-authored-by: Yannick Soehngen Co-authored-by: Yannick Soehngen Co-authored-by: Dmitri Smirnov Co-authored-by: Yannick Soehngen Co-authored-by: Yannick Soehngen Co-authored-by: Yannick Soehngen Co-authored-by: Yannick Soehngen Co-authored-by: Yannick Soehngen Co-authored-by: Yannick Soehngen --- StRoot/StETofCalibMaker/StETofCalibMaker.cxx | 119 +-- StRoot/StETofHitMaker/StETofHitMaker.cxx | 83 +- StRoot/StETofMatchMaker/StETofMatchMaker.cxx | 865 +++++++++++++++++- StRoot/StETofMatchMaker/StETofMatchMaker.h | 17 +- StRoot/StEvent/StETofHeader.cxx | 25 +- StRoot/StEvent/StETofHeader.h | 9 +- StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx | 11 +- StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h | 7 +- StRoot/StPicoEvent/StPicoEvent.cxx | 17 +- StRoot/StPicoEvent/StPicoEvent.h | 25 +- 10 files changed, 1055 insertions(+), 123 deletions(-) diff --git a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx index e8ab1b96049..b706e396426 100644 --- a/StRoot/StETofCalibMaker/StETofCalibMaker.cxx +++ b/StRoot/StETofCalibMaker/StETofCalibMaker.cxx @@ -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 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 goodEventFlagVec; + std::vector 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. }; @@ -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; 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; + std::vector 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 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. }; @@ -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 ); @@ -1569,12 +1564,16 @@ 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; @@ -1582,9 +1581,11 @@ StETofCalibMaker::flagPulserDigis( StETofDigi* aDigi, unsigned int index, std::m } } + if( isPulserCand ) { pulserDigiMap[ key ].push_back( index ); } + } diff --git a/StRoot/StETofHitMaker/StETofHitMaker.cxx b/StRoot/StETofHitMaker/StETofHitMaker.cxx index f5c4b7cf612..f32dabff026 100644 --- a/StRoot/StETofHitMaker/StETofHitMaker.cxx +++ b/StRoot/StETofHitMaker/StETofHitMaker.cxx @@ -104,7 +104,7 @@ StETofHitMaker::StETofHitMaker( const char* name ) mMaxYPos( 15. ), mMergingRadius( 1. ), mSigVel(), - mSoftwareDeadTime( 5. ), + mSoftwareDeadTime( 150. ), mDoClockJumpShift( true ), mDoDoubleClockJumpShift( true ), mClockJumpDirection(), @@ -338,13 +338,13 @@ StETofHitMaker::InitRun( Int_t runnumber ) } // -------------------------------------------------------------------------------------------- - for( int i=0; i containedDigiIndices; // double posX = 0.0; double posY = 0.0; double time = 0.0; @@ -992,6 +992,53 @@ StETofHitMaker::matchSides() if( mDoQA && digiVec->size() == 1 ) { mHistograms.at( histNameDigisErased )->Fill( 2 ); } + + + //single sided digi hit building + if( digiVec->size() == 1 ) { + + // create the hit candidate: + StETofDigi* xDigiA = digiVec->at( 0 ); + StETofDigi* xDigiB = digiVec->at( 0 ); + + //get get4flag statistics + // StMuETofHeader* etofHeader = mMuDst->etofHeader(); + // TClass* headerClass = etofHeader->IsA(); + // std::vector< Bool_t > vMissmatchVec = etofHeader->missMatchFlagVec(); + // std::vector< bool > goodEventFlagVec = mMuDst->etofHeader()->goodEventFlagVec(); + + // the "strip" time is the mean time between each end + time = 0.5 * ( xDigiA->calibTime() + xDigiB->calibTime() ); + //TODO: Afterpulse handling: correct hit time by the time difference between the first and second digi on the same side + if(!mIsSim && mApCorr){//merge skip corrections for simulation + time += t_corr_afterpulse; + }//merge + // weight of merging of hits (later) is the total charge => sum of both ends ToT + totSum = xDigiA->calibTot() + xDigiB->calibTot(); + + if(xDigiA->side() == 1){ + posY = 1; + }else{ + posY = -1; + } + + + // use local coordinates... (0,0,0) is in the center of counter + posX = ( -1 * eTofConst::nStrips / 2. + strip - 0.5 ) * eTofConst::stripPitch; + + unsigned int clusterSize = 1000; + + StETofHit* constructedHit = new StETofHit( sector, plane, counter, time, totSum, clusterSize, posX, posY ); + + mStoreHit[ detIndex ].push_back( constructedHit ); + + containedDigiIndices.push_back( mMapDigiIndex.at( xDigiA ) ); + containedDigiIndices.push_back( mMapDigiIndex.at( xDigiB ) ); + + mMapHitDigiIndices[ constructedHit ] = containedDigiIndices; + + } + // loop over digis on the same strip while( digiVec->size() > 1 ) { @@ -1259,7 +1306,7 @@ StETofHitMaker::matchSides() int mode = mModMatrix.at(detIndex); modifyHit(mode, posX , posY , time); } - + StETofHit* constructedHit = new StETofHit( sector, plane, counter, time, totSum, clusterSize, posX, posY ); //Check for "same direction double clockjumps" and update FlagMap @@ -1311,7 +1358,7 @@ StETofHitMaker::matchSides() tof += eTofConst::coarseClockCycle; } } - } + } // push hit into intermediate collection mStoreHit[ detIndex ].push_back( constructedHit ); @@ -1571,10 +1618,15 @@ StETofHitMaker::mergeClusters( const bool isMuDst ) int highestStrip = lowestStrip; bool hasClockJump = false; - if( pHit->clusterSize() > 100 ) { + if( pHit->clusterSize() > 100 && pHit->clusterSize() < 999) { hasClockJump = true; } + bool isSingleSided = false; + if(pHit->clusterSize() > 999){ + isSingleSided = true; + } + unsigned int index = 1; while( hitVec->size() > 1 ) { if( mDebug ) { @@ -1603,10 +1655,19 @@ StETofHitMaker::mergeClusters( const bool isMuDst ) isLowerAdjacentStip = true; } + double MergingRadius = 0; + + // dont merge single sided matches here!! has to happen after matching!! + if(pMergeHit->clusterSize() > 500 || pHit->clusterSize() > 500){ + MergingRadius = 0; + }else{ + MergingRadius = mMergingRadius; + } + // check merging condition: X is not convoluted into the clusterbuilding radius // since it is not supposed to be zero --> check if X position is on a adjacent strip if( ( isHigherAdjacentStip || isLowerAdjacentStip ) && - ( sqrt( timeDiff * timeDiff + posYDiff * posYDiff ) ) < mMergingRadius ) + ( sqrt( timeDiff * timeDiff + posYDiff * posYDiff ) ) < MergingRadius ) // { if( mDebug ) { LOG_DEBUG << "mergeClusters() - merging is going on" << endm; @@ -1633,7 +1694,7 @@ StETofHitMaker::mergeClusters( const bool isMuDst ) weightsTotSum += hitWeight; clusterSize++; - if( pMergeHit->clusterSize() > 100 ) { + if( pMergeHit->clusterSize() > 100 && pMergeHit->clusterSize() < 200) { hasClockJump = true; } @@ -1710,6 +1771,10 @@ StETofHitMaker::mergeClusters( const bool isMuDst ) clusterSize += 100; } + if(isSingleSided){ + clusterSize += 1000; + } + if( mDebug ) { LOG_DEBUG << "mergeClusters() - MERGED HIT: "; LOG_DEBUG << "sector: " << sector << " plane: " << plane << " counter: " << counter << "\n"; diff --git a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx index 7f6e1c47eb1..ac1472fcfa4 100644 --- a/StRoot/StETofMatchMaker/StETofMatchMaker.cxx +++ b/StRoot/StETofMatchMaker/StETofMatchMaker.cxx @@ -86,6 +86,7 @@ #include "StMuDSTMaker/COMMON/StMuETofHit.h" #include "StMuDSTMaker/COMMON/StMuETofPidTraits.h" #include "StMuDSTMaker/COMMON/StMuETofDigi.h" +#include "StMuDSTMaker/COMMON/StMuETofHeader.h" #include "StETofMatchMaker.h" #include "StETofHitMaker/StETofHitMaker.h" @@ -160,9 +161,13 @@ StETofMatchMaker::StETofMatchMaker( const char* name ) mLocalYmax(16.), mClockJumpCand(), mClockJumpDirection(), - mHistFileName( "" ), - mHistograms(), - mHistograms2d() + mHistFileName( "" ), + mHistograms(), + mHistograms2d(), + dx_3sig(2.5), + dy_3sig(4.0), + dt_3sig(0.22), + dy_max(5.0) { mT0corrVec.reserve( 500 ); mTrackCuts.push_back( 0. ); // nHitsFit @@ -171,6 +176,7 @@ StETofMatchMaker::StETofMatchMaker( const char* name ) } + //--------------------------------------------------------------------------- StETofMatchMaker::~StETofMatchMaker() { @@ -267,7 +273,6 @@ StETofMatchMaker::InitRun( Int_t runnumber ) // -------------------------------------------------------------------------------------------- - // -------------------------------------------------------------------------------------------- // initializie etof geometry // -------------------------------------------------------------------------------------------- @@ -498,7 +503,12 @@ StETofMatchMaker::Make() return kStOk; } + + //Single Sided Hit Matching and clustering + eTofHitVec finalMatchVec; + sortandcluster(matchCandVec , detectorHitVec , intersectionVec , finalMatchVec); + //......................................................................... // D. sort matchCand vector and deal with (discard) hits matched by multiple tracks // @@ -506,20 +516,18 @@ StETofMatchMaker::Make() eTofHitVec singleTrackMatchVec; vector< eTofHitVec > multiTrackMatchVec; - sortSingleMultipleHits( matchCandVec, singleTrackMatchVec, multiTrackMatchVec ); + //sortSingleMultipleHits( matchCandVec, singleTrackMatchVec, multiTrackMatchVec ); // old matching procedure - if( singleTrackMatchVec.size() == 0 ) { - //LOG_INFO << "Make() -- event done ... bye-bye" << endm; - - return kStOk; - } + //if( singleTrackMatchVec.size() == 0 ) { + //LOG_INFO << "Make() -- event done ... bye-bye" << endm + // return kStOk; + // } //......................................................................... // E. sort singleTrackMatchVector for multiple hits associated to single tracks and determine the best match // - eTofHitVec finalMatchVec; - - finalizeMatching( singleTrackMatchVec, finalMatchVec ); + + //finalizeMatching( singleTrackMatchVec, finalMatchVec ); // old matching procedure if( finalMatchVec.size() == 0 ) { //LOG_INFO << "Make() -- event done ... bye-bye" << endm; @@ -533,14 +541,14 @@ StETofMatchMaker::Make() //......................................................................... // F. fill ETofPidTraits for global and primary tracks and assign associated track to hits // - fillPidTraits( finalMatchVec ); + fillPidTraits( finalMatchVec ); //......................................................................... // G. calculate pid variables for primary tracks and update PidTraits // - int nPrimaryWithPid = 0; + int nPrimaryWithPid = 0; - calculatePidVariables( finalMatchVec, nPrimaryWithPid ); + calculatePidVariables( finalMatchVec, nPrimaryWithPid ); mHistograms.at( "primaryIntersect_validMatch" )->Fill( nPrimaryWithIntersection, nPrimaryWithPid ); @@ -838,6 +846,10 @@ StETofMatchMaker::readETofDetectorHits( eTofHitVec& detectorHitVec ) detectorHit.index2ETofHit = i; detectorHitVec.push_back( detectorHit ); + + + + } } @@ -1267,8 +1279,10 @@ StETofMatchMaker::matchETofHits( eTofHitVec& detectorHitVec, eTofHitVec& interse bool isMatch = false; // deltaX, deltaY (subtract offset until alignment is done properly) - float deltaX = detHitIter->localX - interIter->localX; - float deltaY = detHitIter->localY - interIter->localY; + float deltaX = detHitIter->localX - interIter->localX; + float deltaY = detHitIter->localY - interIter->localY; + double tstart = startTimeBTof(); //no eToF start time available here! + double deltaT = detHitIter->hitTime - tstart; //basic cut to reject hits far of in time int counterIndex = ( detHitIter->sector - eTofConst::sectorStart ) * eTofConst::nPlanes * eTofConst::nCounters + ( detHitIter->plane - eTofConst::zPlaneStart ) * eTofConst::nCounters @@ -1277,18 +1291,45 @@ StETofMatchMaker::matchETofHits( eTofHitVec& detectorHitVec, eTofHitVec& interse deltaX -= etofProjection::deltaXoffset[ counterIndex ]; deltaY -= etofProjection::deltaYoffset[ counterIndex ]; + bool corrTime=false; // for single sided hit time corr + if( detHitIter->sector == interIter->sector ) { - if( detHitIter->plane == interIter->plane ) { - if( detHitIter->counter == interIter->counter ) { - if( fabs( deltaX ) < mMatchDistX ) { - if( fabs( deltaY ) < mMatchDistY ) { - isMatch = true; - } - } - } - } - } + if( detHitIter->plane == interIter->plane ) { + if( detHitIter->counter == interIter->counter ) { + + if(detHitIter->clusterSize < 999){ + + // if( fabs( deltaX ) < mMatchDistX ) { + // if( fabs( deltaY ) < mMatchDistY ) { + + if( ( ( (deltaY*deltaY) / (mMatchDistY*mMatchDistY) ) + ( (deltaX*deltaX) / (mMatchDistX*mMatchDistX) ) ) < 2. ) { + if( fabs( deltaT ) < mMatchDistT ) { + isMatch = true; + } + } + }else{ + + float mMatchDistYSingleSided = 15; + + + if( fabs( deltaX ) < mMatchDistX ) { + if( fabs( deltaY ) < mMatchDistYSingleSided ) { + if( fabs( deltaT ) < mMatchDistT ) { + + + isMatch = true; + deltaY = 27; // keep SHs out of NHs way while sorting + corrTime = true; + + } + } + } + } + } + } + } + if( isMatch ) { StructETofHit matchCand; @@ -1302,12 +1343,14 @@ StETofMatchMaker::matchETofHits( eTofHitVec& detectorHitVec, eTofHitVec& interse matchCand.tot = detHitIter->tot; matchCand.clusterSize = detHitIter->clusterSize; matchCand.index2ETofHit = detHitIter->index2ETofHit; + matchCand.IdTruthHit = detHitIter->IdTruth; matchCand.globalPos = interIter->globalPos; matchCand.trackId = interIter->trackId; matchCand.theta = interIter->theta; matchCand.pathLength = interIter->pathLength; matchCand.isPrimary = interIter->isPrimary; + matchCand.IdTruth = interIter->IdTruth; matchCand.matchFlag = 0; matchCand.deltaX = deltaX; @@ -1316,6 +1359,36 @@ StETofMatchMaker::matchETofHits( eTofHitVec& detectorHitVec, eTofHitVec& interse matchCand.tof = -999.; matchCand.beta = -999.; + // correct single sided matches + if(corrTime){ + matchCand.localY = interIter->localY; + + // if side A + double corr ; + float tcorr = 0; + if(sector == 15 || sector == 17 || sector == 21 || sector == 22 ){ + tcorr = 16.49; + }else{ + tcorr = 18.23; + } + if(detHitIter->localY < 0){ + matchCand.hitTime = detHitIter->hitTime - (((13.5 + interIter->localY ) / tcorr )) + (13.5/tcorr); + // matchCand.totDiff = 1; + corr = (((13.5 - interIter->localY ) / tcorr )); + // if side B + }else{ + matchCand.hitTime = detHitIter->hitTime - (((13.5 - interIter->localY ) / tcorr )) + (13.5/tcorr); + // matchCand.totDiff = -1; + corr = (((13.5 + interIter->localY ) / tcorr )); + } + + matchCand.totDiff = matchCand.totDiff * corr; + + // cout << "interIter->localY " << interIter->localY<< endl; + // cout << "corr " << corr << endl; + // cin.get(); + + } matchCandVec.push_back( matchCand ); @@ -1954,7 +2027,9 @@ StETofMatchMaker::calculatePidVariables( eTofHitVec& finalMatchVec, int& nPrimar StMuETofPidTraits pidTraits = gTrack->etofPidTraits(); - double tof = timeOfFlight( tstart, aHit->time() ); + //double tof = timeOfFlight( tstart, aHit->time() ); + double tof = timeOfFlight( tstart, matchCand.hitTime ); + // set time-of-flight matchCand.tof = tof; @@ -2016,6 +2091,15 @@ StETofMatchMaker::calculatePidVariables( eTofHitVec& finalMatchVec, int& nPrimar // set beta matchCand.beta = beta; + + if( matchCand.clusterSize > 999 ){ + + mHistograms.at( "AAA_beta_mom_SD")->Fill( pTrack->momentum().mag() , 1/beta ); + + } + + + if( mDebug ) { LOG_INFO << "calculatePidVariables() - pathlength: " << pathLength << " time-of-flight: " << tof << " and beta: " << beta << " are set" << endm; } @@ -2434,6 +2518,7 @@ StETofMatchMaker::expectedTimeOfFlight( const double& pathLength, const double& void StETofMatchMaker::fillQaHistograms( eTofHitVec& finalMatchVec ) { + vector< int > nPidMatches( 36 ); for( auto& matchCand : finalMatchVec ) { @@ -2441,6 +2526,10 @@ StETofMatchMaker::fillQaHistograms( eTofHitVec& finalMatchVec ) int charge; float mom; + // int sector = 0; // + // int plane = 0; // + // int counter = 0; // + float dEdx = -999.; float nSigmaPion = -999; @@ -2474,6 +2563,10 @@ StETofMatchMaker::fillQaHistograms( eTofHitVec& finalMatchVec ) StMuTrack* pTrack = aHit->primaryTrack(); if( !pTrack ) continue; + //sector = aHit->sector(); + //plane = aHit->zPlane(); + //counter = aHit->counter(); + charge = pTrack->charge(); mom = pTrack->momentum().mag(); @@ -2517,6 +2610,7 @@ StETofMatchMaker::fillQaHistograms( eTofHitVec& finalMatchVec ) mHistograms.at( "matchCand_m2_mom" )->Fill( mom, m2 ); mHistograms.at( "matchCand_m2_signmom" )->Fill( sign * mom, m2 ); + // plots per counter std::string histName_beta_mom = "matchCand_beta_mom_s" + std::to_string( matchCand.sector ) + "m" + std::to_string( matchCand.plane ) + "c" + std::to_string( matchCand.counter ); @@ -2723,6 +2817,22 @@ StETofMatchMaker::bookHistograms() for( int sector = eTofConst::sectorStart; sector <= eTofConst::sectorStop; sector++ ) { for( int plane = eTofConst::zPlaneStart; plane <= eTofConst::zPlaneStop; plane++ ) { for( int counter = eTofConst::counterStart; counter <= eTofConst::counterStop; counter++ ) { + + //single sided matching qa + std::string histName_t0corr_mom_zoom = "matched_t0corr_mom_zoom_s" + std::to_string( sector ) + "m" + std::to_string( plane ) + "c" + std::to_string( counter ); + + mHistograms2d[ histName_t0corr_mom_zoom ] = new TH2F( Form( "T_matched_t0corr_mom_zoom_s%dm%dc%d", sector, plane, counter ), Form( "measured tof - tof_{#pi} vs. momentum in sector %d module %d counter %d;mom (GeV/c);#Delta time (ns)", sector, plane, counter ), 200, 0., 3., 500, -5., 5. ); + + + std::string histName_t0corr_mom_zoom_SD = "matched_t0corr_mom_zoom_SD_s" + std::to_string( sector ) + "m" + std::to_string( plane ) + "c" + std::to_string( counter ); + + mHistograms2d[ histName_t0corr_mom_zoom_SD ] = new TH2F( Form( "T_matched_t0corr_mom_zoom_SD_s%dm%dc%d", sector, plane, counter ), Form( "measured tof - tof_{#pi} vs. momentum in sector %d module %d counter %d;mom (GeV/c);#Delta time (ns)", sector, plane, counter ), 200, 0., 3., 500, -5., 5. ); + + + + + + std::string histName_hit_localXY = "eTofHits_localXY_s" + std::to_string( sector ) + "m" + std::to_string( plane ) + "c" + std::to_string( counter ); std::string histName_hit_globalXY = "eTofHits_globalXY_s" + std::to_string( sector ) + "m" + std::to_string( plane ) + "c" + std::to_string( counter ); std::string histName_hit_eta_phi = "eTofHits_phi_eta_s" + std::to_string( sector ) + "m" + std::to_string( plane ) + "c" + std::to_string( counter ); @@ -3120,3 +3230,700 @@ void StETofMatchMaker::checkClockJumps() mETofHitMaker->updateClockJumpMap( mClockJumpDirection ); } } + +//--------------------------------------------------------------------------- +void +StETofMatchMaker::sortMatchCases( eTofHitVec inputVec , std::map< Int_t, eTofHitVec >& outputMap ) +{ + + + // sort & flag Match candidates + + // define temporary vectors for iterating through matchCandVec + eTofHitVec tempVec = inputVec; + eTofHitVec erasedVec = tempVec; + eTofHitVec tempMMVec; + tempMMVec.clear(); + std::map< Int_t, eTofHitVec > MMMap; + MMMap.clear(); + + eTofHitVec ssVec; + + // get multi Hit sets + // int deltaSize = 0; + + eTofHitVecIter tempIter = tempVec.begin(); + eTofHitVecIter erasedIter = erasedVec.begin(); + + + if(tempVec.size() < 1 ) return; + + while( tempVec.size() != 0 ) { + + tempIter = tempVec.begin(); + erasedIter = erasedVec.begin(); + + + tempMMVec.push_back(*tempIter); + erasedVec.erase( erasedIter ); + + // int sizeOld = tempMMVec.size(); + int count =0; + int countwhile = 0; + + for(unsigned int s =0; s < tempMMVec.size(); s++){ + + count++; + + erasedIter = erasedVec.begin(); + + if(erasedVec.size() <= 0 ) continue; + + countwhile = 0; + + while( erasedIter != erasedVec.end() ) { + + countwhile++; + + if(tempMMVec.at(s).trackId == erasedIter->trackId && tempMMVec.at(s).index2ETofHit == erasedIter->index2ETofHit){ + + erasedVec.erase( erasedIter ); + erasedIter++; + continue;} + if(tempMMVec.at(s).trackId == erasedIter->trackId || tempMMVec.at(s).index2ETofHit == erasedIter->index2ETofHit){ + if(!mIsSim){ + // erasedIter->matchFlag = 0; + } + tempMMVec.push_back(*erasedIter); + + erasedVec.erase( erasedIter ); + + } + if( erasedVec.size() <= 0 ) break; + if( erasedIter == erasedVec.end()) break; + erasedIter++; + + } //while inner + + }// for + + // deltaSize = sizeOld - tempMMVec.size(); + + MMMap[tempMMVec.begin()->trackId] = tempMMVec; + tempMMVec.clear(); + + tempVec = erasedVec; + } + + + outputMap = MMMap; + + +} +//--------------------------------------------------------------------------- +void +StETofMatchMaker::sortandcluster(eTofHitVec& matchCandVec , eTofHitVec& detectorHitVec , eTofHitVec& intersectionVec , eTofHitVec& finalMatchVec){ + + + //flag Overlap-Hits ------------------------------------------------------------------- + std::map< Int_t, eTofHitVec > overlapHitMap; + eTofHitVec overlapHitVec; + eTofHitVec tempVecOL = matchCandVec; + eTofHitVecIter detHitIter; + eTofHitVecIter detHitIter2; + + for( auto detHitIter = tempVecOL.begin(); detHitIter != tempVecOL.end(); ) { + + detHitIter = tempVecOL.begin(); + detHitIter2 = tempVecOL.begin(); + + bool isOverlap = false; + int counterId1 = (detHitIter->sector*100) + (detHitIter->plane*10) + (detHitIter->counter); + + for( auto detHitIter2 = tempVecOL.begin(); detHitIter2 != tempVecOL.end(); ) { + + int counterId2 = (detHitIter2->sector*100) + (detHitIter2->plane*10) + (detHitIter2->counter); + + if(counterId1 != counterId2 && detHitIter->trackId == detHitIter2->trackId){ + + int mf2 = counterId2 ; + + detHitIter2->matchFlag = mf2; + + matchCandVec.at(detHitIter2 - tempVecOL.begin()).matchFlag = 1; + + overlapHitVec.push_back(*detHitIter2); + tempVecOL.erase(detHitIter2); + + isOverlap = true; + } + + if( tempVecOL.size() <= 0 ) break; + if( detHitIter2 == tempVecOL.end()) break; + detHitIter2++; + + } + + if(isOverlap){ + + detHitIter->matchFlag = counterId1; + + matchCandVec.at(detHitIter - tempVecOL.begin()).matchFlag = 1; + + overlapHitVec.push_back(*detHitIter); + + //fill map + overlapHitMap[overlapHitVec.begin()->trackId] = overlapHitVec; + + overlapHitVec.clear(); + + } + tempVecOL.erase(detHitIter); + + if( tempVecOL.size() <= 0 ) break; + if( detHitIter == tempVecOL.end()) break; + detHitIter++; + + } + + // fill match cand vec counter wise + std::vector< eTofHitVec > matchCandVecCounter(108); + + for(int i =0; i < 108; i++){ + + for(unsigned int n = 0; n < matchCandVec.size(); n++){ + + int sector = matchCandVec.at(n).sector; + int plane = matchCandVec.at(n).plane; + int counter = matchCandVec.at(n).counter; + + int counterId = 9*(sector - 13) + 3*(plane - 1) + (counter -1); + + if(counterId == i ) { + matchCandVecCounter.at(i).push_back(matchCandVec.at(n)); + } + }//loop over hits + }//loop over counters + + + // loop over counters + for(int counterNr = 0; counterNr < 108; counterNr++){ + + // sort & flag Match candidates + eTofHitVec tempVec = matchCandVecCounter.at(counterNr); + eTofHitVec tempVec2 = matchCandVecCounter.at(counterNr); + std::map< Int_t, eTofHitVec > MMMap; + + sortMatchCases(tempVec, MMMap); + + // final containers + std::map< Int_t, eTofHitVec > MultMultMap; + std::map< Int_t, eTofHitVec > SingleHitMap; + std::map< Int_t, eTofHitVec > SingleTrackMap; + eTofHitVec ssVec; + + map::iterator it; + + for (it = MMMap.begin(); it != MMMap.end(); it++) + { + int nTracks = 1; + int nHits = 1; + + for(unsigned int l =0; l< it->second.size(); l++){ + for(unsigned int j = l; j< it->second.size(); j++){ + + if( it->second.at(l).trackId != it->second.at(j).trackId) nTracks++; + if( it->second.at(l).index2ETofHit != it->second.at(j).index2ETofHit ) nHits++; + + } // for inner + } //for outer + + + // cases:: + // Single Hit - Single Track + if(nTracks == 1 && nHits == 1) { + + ssVec.push_back(it->second.front() ); + + int isMerged = 10; // 10 codes for normal hit + int isOl = it->second.front().matchFlag; + + if( it->second.front().clusterSize > 999 ) { + + isMerged = 20; // 20 codes for single hit + it->second.front().clusterSize = 1; + } + + it->second.front().matchFlag = 100 + isMerged + isOl; + finalMatchVec.push_back(it->second.front()); + } + + + // Single Hit - Multi Track + if( nTracks > 1 && nHits == 1) { + + double dr = 0.0; + double dr_best = 99999.0; // dy for SHs at 27 + unsigned int ind = 0; + unsigned int ind_best = 0; + + for(unsigned int l =0; l < it->second.size(); l++){ + + dr = (it->second.at(l).deltaX * it->second.at(l).deltaX) + (it->second.at(l).deltaY * it->second.at(l).deltaY); + ind = l; + + if(dr <= dr_best){ + dr_best = dr; + ind_best = ind; + } + } + + SingleHitMap[it->first] = it->second; + + //pick closest track and push to finalMatchVec + int isMerged = 10; + int isOl = it->second.at(ind_best).matchFlag; + + if( it->second.at(ind_best).clusterSize > 999 ){ + + isMerged = 20; + it->second.at(ind_best).clusterSize = 1; + } + + it->second.at(ind_best).matchFlag = 300 + isMerged + isOl; + finalMatchVec.push_back(it->second.at(ind_best)); + } + + + // Multi Hit - Single Track + if( nTracks ==1 && nHits > 1) { + + bool isN = false; + bool isS = false; + + for(unsigned int l =0; l < it->second.size(); l++){ + + if(it->second.at(l).clusterSize < 999){ + isN = true; + }else{ + isS = true; + } + } + + SingleTrackMap[it->first] = it->second; + + // sort by merge cases :: SS, NN, SN + //NN + if(isN && (!isS)){ + + std::vector< std::vector > mergeIndVec(it->second.size()); + + double dr_sum=0; + double dr_diff = 0; + double dr_mean=0; + + double dr = 0.0; + double dr_best = 99999.0; // dy for SHs at 27 + unsigned int ind = 0; + unsigned int ind_best = 0; + + for(unsigned int l =0; l < it->second.size(); l++){ + + dr = sqrt((it->second.at(l).deltaX * it->second.at(l).deltaX) + (it->second.at(l).deltaY * it->second.at(l).deltaY)); + ind = l; + + dr_sum += abs(dr); + + if(dr <= dr_best){ + dr_best = dr; + ind_best = ind; + } + } + + dr_mean = dr_sum / it->second.size(); + + for(unsigned int c =0; c < it->second.size(); c++){ + + dr = sqrt((it->second.at(c).deltaX * it->second.at(c).deltaX) + (it->second.at(c).deltaY * it->second.at(c).deltaY)); + dr_diff += abs(dr - dr_mean); + } + + // NN Hits already merged in HitMaker + + int mergedCluSz = 0; + int mergedMatchFlag = 0; + int isMerged = 0; + int isOl = it->second.at(ind_best).matchFlag; + + if(it->second.at(ind_best).clusterSize > 100 && it->second.at(ind_best).clusterSize < 200){ + + mergedCluSz = it->second.at(ind_best).clusterSize % 100; + + }else{ + + mergedCluSz = it->second.at(ind_best).clusterSize; + } + + if(mergedCluSz > 1){ isMerged = 30; // 30 codes for normal-normal-merge + }else{ + isMerged = 10; + } + + mergedMatchFlag = 200 + isMerged + isOl; // 200 codes for SingleTrackMultiHit + it->second.at(ind_best).matchFlag = mergedMatchFlag; + + finalMatchVec.push_back(it->second.at(ind_best)); + } + + //SS + if(isS && (!isN)){ + + std::vector< std::vector > mergeIndVec(it->second.size()); + + for(unsigned int l =0; l < it->second.size(); l++){ + mergeIndVec.at(l).push_back(0); + } + + double dr = 0.0; + double dr_best = 99999.0; // dy for SHs at 27 + unsigned int ind = 0; + unsigned int ind_best = 0; + + for(unsigned int l =0; l < it->second.size(); l++){ + + // localY doesnt contain any ETOF information -> not usefull for merging single sided hits + dr = it->second.at(l).deltaX; + ind = l; + + if(dr <= dr_best){ + dr_best = dr; + ind_best = ind; + } + } + + // merge MatchCands + + eTofHitVec hitVec = it->second ; + + double mergedTime = it->second.at(ind_best).hitTime; + double mergedToT = it->second.at(ind_best).tot; + double mergedPosY = it->second.at(ind_best).localY; + double mergedPosX = it->second.at(ind_best).localX; + int mergedCluSz = 1; + int mergedMatchFlag = 0; + int mergedIdTruth = it->second.at(ind_best).IdTruth; + + for(unsigned int j=0; j < hitVec.size(); j++) { + + if( j == ind_best) continue; + + double dx = it->second.at(ind_best).localX - hitVec.at(j).localX; + double dy = it->second.at(ind_best).localY - hitVec.at(j).localY; + double dt = abs( it->second.at(ind_best).hitTime - hitVec.at(j).hitTime); + + // merge + if( abs(dx) < dx_3sig && abs(dy) < dy_3sig && abs(dt) < dt_3sig ){ + + mergedTime += hitVec.at(j).hitTime; + mergedToT += hitVec.at(j).tot; + mergedPosY += hitVec.at(j).localY; + mergedPosX += hitVec.at(j).localX; + mergedCluSz++; + + if(mergedIdTruth != hitVec.at(j).IdTruth) mergedIdTruth =0; + + } + } + + // create mergend hit and MC; + mergedTime /= mergedCluSz; + mergedToT /= mergedCluSz; + mergedPosY /= mergedCluSz; + mergedPosX /= mergedCluSz; + int isMerged = 0; + int isOl = it->second.at(ind_best).matchFlag; + + if(mergedCluSz > 1){ isMerged = 40; // codes for sigle-single-merge + }else{ + isMerged = 20; + } + + mergedMatchFlag = 200 + isMerged + isOl; // 200 codes for SingleTrackMultiHit + + // use only the floating point remainder of the time with respect the the bTof clock range + mergedTime = fmod( mergedTime, eTofConst::bTofClockCycle ); + if( mergedTime < 0 ) mergedTime += eTofConst::bTofClockCycle; + + it->second.at(ind_best).hitTime = mergedTime; + it->second.at(ind_best).tot = mergedToT; + it->second.at(ind_best).localX = mergedPosX; + it->second.at(ind_best).localY = mergedPosY; + it->second.at(ind_best).IdTruth = mergedIdTruth; + it->second.at(ind_best).matchFlag = mergedMatchFlag; + it->second.at(ind_best).clusterSize = mergedCluSz; + + + finalMatchVec.push_back(it->second.at(ind_best)); + } + + //SN + if(isN && isS){ + + std::vector< std::vector > mergeIndVec(it->second.size()); + + for(unsigned int l =0; l < it->second.size(); l++){ + mergeIndVec.at(l).push_back(0); + } + + double dr = 0.0; + double dr_best = 99999.0; // dy for SHs at 27 + unsigned int ind = 0; + unsigned int ind_best = 0; + + for(unsigned int l =0; l < it->second.size(); l++){ + + if(it->second.at(l).clusterSize > 999) continue; + + // localY doesnt contain any ETOF information for singleSidedHits-> not usefull for merging later on + dr = it->second.at(l).deltaX*it->second.at(l).deltaX + it->second.at(l).deltaY*it->second.at(l).deltaY; + ind = l; + + if(dr <= dr_best){ + dr_best = dr; + ind_best = ind; + } + } + + + // merge MatchCands + eTofHitVec hitVec = it->second ; + + double mergedTime = it->second.at(ind_best).hitTime; + double mergedToT = it->second.at(ind_best).tot; + double mergedPosY = it->second.at(ind_best).localY; + double mergedPosX = it->second.at(ind_best).localX; + int mergedCluSz = 1; + int mergedMatchFlag = 0; + int mergedIdTruth = it->second.at(ind_best).IdTruth; + + for(unsigned int j=0; j < hitVec.size(); j++) { + + if( j == ind_best) continue; + + double dx = it->second.at(ind_best).localX - hitVec.at(j).localX; + double dy = it->second.at(ind_best).localY - hitVec.at(j).localY; + double dt = abs( it->second.at(ind_best).hitTime - hitVec.at(j).hitTime); + + // merge + if( abs(dx) < dx_3sig && abs(dy) < dy_3sig && abs(dt) < dt_3sig ){ + + mergedTime += hitVec.at(j).hitTime; + mergedToT += hitVec.at(j).tot; + mergedPosY += hitVec.at(j).localY; + mergedPosX += hitVec.at(j).localX; + mergedCluSz++; + + if(mergedIdTruth != hitVec.at(j).IdTruth) mergedIdTruth =0; + } + } + + // create mergend hit and MC + mergedTime /= mergedCluSz; + mergedToT /= mergedCluSz; + mergedPosY /= mergedCluSz; + mergedPosX /= mergedCluSz; + int isMerged = 0; + int isOl = it->second.at(ind_best).matchFlag; + + if(mergedCluSz > 1){ isMerged = 50; // codes for sigle-normal-merge + }else{ + isMerged = 10; + } + + mergedMatchFlag = 200 + isMerged + isOl; // 200 codes for SingleTrackMultiHit + + // use only the floating point remainder of the time with respect the the bTof clock range + mergedTime = fmod( mergedTime, eTofConst::bTofClockCycle ); + if( mergedTime < 0 ) mergedTime += eTofConst::bTofClockCycle; + + it->second.at(ind_best).hitTime = mergedTime; + it->second.at(ind_best).tot = mergedToT; + it->second.at(ind_best).localX = mergedPosX; + it->second.at(ind_best).localY = mergedPosY; + it->second.at(ind_best).IdTruth = mergedIdTruth; + it->second.at(ind_best).matchFlag = mergedMatchFlag; + it->second.at(ind_best).clusterSize = mergedCluSz ; + + finalMatchVec.push_back(it->second.at(ind_best)); + } + } // multi-hit-single-track + + + // Multi Hit - Multi Track + if(nTracks > 1 && nHits > 1) { + + // for each track pick closest hit + eTofHitVec hitVec = it->second ; + eTofHitVec bestMatchVec; + eTofHitVec mergeCandVec; + eTofHitVec ambigVec; + std::map< Int_t, StructETofHit > bestMatchMap; + std::map< Int_t, eTofHitVec > mergeCandMap; + std::map< Int_t, eTofHitVec > mergeCandMap2; + std::map< Int_t, eTofHitVec > ambigMap; + std::vector indVec; + + for(unsigned int l =0; l < it->second.size(); l++){ + + double dr = it->second.at(l).deltaX*it->second.at(l).deltaX + it->second.at(l).deltaY*it->second.at(l).deltaY; + double dr_best = 99999.0; // dy for SHs at 27 + unsigned int ind = 0; + unsigned int ind_best = l; + int trackId = it->second.at(l).trackId; + int vcnt = 0; + + if(std::find(indVec.begin(), indVec.end(), trackId) != indVec.end()) continue; + + for(unsigned int n = 0; n < it->second.size(); n++){ + + if(it->second.at(n).trackId != trackId) continue; + + // localY doesnt contain any ETOF information for sHits-> take nHit if possible + dr = it->second.at(n).deltaX*it->second.at(n).deltaX + it->second.at(n).deltaY*it->second.at(n).deltaY; + ind = n; + + if(dr < dr_best){ + + if(vcnt){ + mergeCandVec.push_back(it->second.at(ind_best)); + }else{ + vcnt++; + } + dr_best = dr; + ind_best = ind; + + }else{ + + mergeCandVec.push_back(it->second.at(n)); + } + } + + indVec.push_back(trackId); + bestMatchMap[trackId] = it->second.at(ind_best); + bestMatchVec.push_back(it->second.at(ind_best)); + } + + + std::vector indVecBMtrack; + std::vector indVecBMhit; + + for(unsigned int b =0; b < bestMatchVec.size() ; b++){ + indVecBMtrack.push_back(bestMatchVec.at(b).trackId); + indVecBMhit.push_back(bestMatchVec.at(b).index2ETofHit); + } + + std::vector indVecUsedTrack; + std::vector indVecReplaceTrack; + std::vector indVecUsedHit; + eTofHitVec MatchVecTemp = bestMatchVec; + eTofHitVec finalbestMatchVec; + + while(MatchVecTemp.size() > 0){ + + double dr = 0.0; + double dr_best = 99999.0; // dy for SHs at 27 + unsigned int ind = 0; + unsigned int ind_best = 0; + for(unsigned int b =0; b < MatchVecTemp.size() ; b++){ + + ind = b; + + dr = MatchVecTemp.at(b).deltaX * MatchVecTemp.at(b).deltaX + MatchVecTemp.at(b).deltaY * MatchVecTemp.at(b).deltaY; + if(dr <= dr_best){ + dr_best = dr; + ind_best = ind; + } + } + + finalbestMatchVec.push_back(MatchVecTemp.at(ind_best)); + indVecUsedTrack.push_back(MatchVecTemp.at(ind_best).trackId); + indVecUsedHit.push_back(MatchVecTemp.at(ind_best).index2ETofHit); + MatchVecTemp.erase(MatchVecTemp.begin() + ind_best); + + //remove all matches with same hit id + for(unsigned int b =0; b < MatchVecTemp.size() ; b++){ + + if(std::find(indVecUsedHit.begin(), indVecUsedHit.end(), MatchVecTemp.at(b).index2ETofHit) != indVecUsedHit.end()) { + + indVecReplaceTrack.push_back(MatchVecTemp.at(b).trackId); + MatchVecTemp.erase(MatchVecTemp.begin() + b); + b = -1; + } + } + + //check for replacement + std::sort( indVecReplaceTrack.begin(), indVecReplaceTrack.end() ); + indVecReplaceTrack.erase( unique( indVecReplaceTrack.begin(), indVecReplaceTrack.end() ), indVecReplaceTrack.end() ); + + bool found1 = false; + double dx1 = 0; + double dy1 = 0; + double dx_best1 = 99999.0; + double dy_best1 = 99999.0; + unsigned int ind1 = 0; + unsigned int ind_best1 = 0; + for(unsigned int i = 0; i < mergeCandVec.size();i++){ + + ind1 = i; + + if(!(std::find(indVecReplaceTrack.begin(), indVecReplaceTrack.end(), mergeCandVec.at(i).trackId) != indVecReplaceTrack.end())) continue; + if(std::find(indVecUsedTrack.begin(), indVecUsedTrack.end(), mergeCandVec.at(i).index2ETofHit) != indVecUsedTrack.end()) continue; + if(std::find(indVecUsedHit.begin(), indVecUsedHit.end(), mergeCandVec.at(i).index2ETofHit) != indVecUsedHit.end()) continue; + if(std::find(indVecBMhit.begin(), indVecBMhit.end(), mergeCandVec.at(i).index2ETofHit) != indVecBMhit.end()) continue; + + dx1 = mergeCandVec.at(i).deltaX; + dy1 = mergeCandVec.at(i).deltaY; + + if(dy1 < dy_best1){ dy_best1 = dy1;} + + if(dx1 < dx_best1){ + dx_best1 = dx1; + ind_best1 = ind1; + found1 = true; + } else if(dx1 == dx_best1){ + + if(dy1 < dy_best1 && dy1 < dy_max && dy1 != 27.0){ + ind_best1 = ind1; + found1 = true; + } else if( dy1 == 27.0){ + ind_best1 = ind1; + found1 = true; + } + } + } + + if(found1){ + + finalbestMatchVec.push_back(mergeCandVec.at(ind_best1)); + indVecUsedTrack.push_back(mergeCandVec.at(ind_best1).trackId); + indVecUsedHit.push_back(mergeCandVec.at(ind_best1).index2ETofHit); + mergeCandVec.erase(mergeCandVec.begin() + ind_best1); + } + + bestMatchVec = finalbestMatchVec; + + for(unsigned int i=0;i< bestMatchVec.size();i++){ + + if(bestMatchVec.at(i).clusterSize < 999 ){ + bestMatchVec.at(i).matchFlag = 410; + }else{ + bestMatchVec.at(i).matchFlag = 420; + bestMatchVec.at(i).clusterSize -= 1000; + } + finalMatchVec.push_back(bestMatchVec.at(i)); + } + } + } + }// loop over MMMap + }//loop over counters +} diff --git a/StRoot/StETofMatchMaker/StETofMatchMaker.h b/StRoot/StETofMatchMaker/StETofMatchMaker.h index 0a5020fbafb..ecd274085eb 100644 --- a/StRoot/StETofMatchMaker/StETofMatchMaker.h +++ b/StRoot/StETofMatchMaker/StETofMatchMaker.h @@ -87,7 +87,7 @@ class StETofMatchMaker : public StMaker { Double_t localX; Double_t localY; Double_t tot; - Double_t clusterSize; + Int_t clusterSize; Int_t index2ETofHit; StThreeVectorD globalPos; Int_t trackId; @@ -99,6 +99,10 @@ class StETofMatchMaker : public StMaker { Double_t beta; Double_t pathLength; Double_t tof; + Int_t IdTruth; + Int_t IdTruthHit; + Double_t totDiff; + }; typedef std::vector< StructETofHit > eTofHitVec; @@ -160,6 +164,9 @@ class StETofMatchMaker : public StMaker { void fillPidTraits( eTofHitVec& finalMatchVec ); void calculatePidVariables( eTofHitVec& finalMatchVec, int& nPrimaryWithPid ); + void sortandcluster(eTofHitVec& matchCandVec , eTofHitVec& detectorHitVec , eTofHitVec& intersectionVec , eTofHitVec& finalMatchVec); + void sortMatchCases( eTofHitVec inputVec , std::map< Int_t, eTofHitVec >& outputMap ); + double startTimeBTof(); double startTimeETof( const eTofHitVec& finalMatchVec, unsigned int& nCand_etofT0 ); @@ -220,9 +227,17 @@ class StETofMatchMaker : public StMaker { std::map< Int_t, Int_t > mClockJumpDirection; std::string mHistFileName; + std::map< std::string, TH1* > mHistograms; std::map< std::string, TH2* > mHistograms2d; + // used for single sided match cases + Double_t dx_3sig; + Double_t dy_3sig; + Double_t dt_3sig; + Double_t dy_max; + + virtual const Char_t *GetCVS() const { static const char cvs[]="Tag $Name: $Id: built " __DATE__ " " __TIME__ ; return cvs; } ClassDef( StETofMatchMaker, 0 ) diff --git a/StRoot/StEvent/StETofHeader.cxx b/StRoot/StEvent/StETofHeader.cxx index 2588562ef5d..6c594ffdcce 100644 --- a/StRoot/StEvent/StETofHeader.cxx +++ b/StRoot/StEvent/StETofHeader.cxx @@ -38,7 +38,8 @@ StETofHeader::StETofHeader() mStarTrgCmdIn( 0 ), mEventStatusFlag( 0 ), mMissMatchFlagVec( eTofConst::nGet4sInSystem, false ), - mGoodEventFlagVec( eTofConst::nCountersInSystem, false ) + mGoodEventFlagVec( eTofConst::nGet4sInSystem, false ), + mHasPulsersVec( eTofConst::nCountersInSystem, false ) { mRocGdpbTs.clear(); mRocStarTs.clear(); @@ -56,7 +57,8 @@ StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime mStarTrgCmdIn( starTrgCmdIn ), mEventStatusFlag( eventStatusFlag ), mMissMatchFlagVec( eTofConst::nGet4sInSystem, false ), - mGoodEventFlagVec( eTofConst::nCountersInSystem, false ) + mGoodEventFlagVec( eTofConst::nGet4sInSystem, false ), + mHasPulsersVec( eTofConst::nCountersInSystem, false ) { setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); @@ -73,7 +75,8 @@ StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime mStarTrgCmdIn( starTrgCmdIn ), mEventStatusFlag( eventStatusFlag ), mMissMatchFlagVec( MissMatchFlagVec ), - mGoodEventFlagVec( eTofConst::nCountersInSystem, false ) + mGoodEventFlagVec( eTofConst::nGet4sInSystem, false ), + mHasPulsersVec( eTofConst::nCountersInSystem, false ) { setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); @@ -82,7 +85,7 @@ StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime 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 ) + const uint64_t& eventStatusFlag, const std::vector& MissMatchFlagVec, const std::vector& GoodEventFlagVec, const std::vector& HasPulsersVec ) : mTrgGdpbFullTime( trgGdpbTime ), mTrgStarFullTime( trgStarTime ), mStarToken( starToken ), @@ -90,7 +93,8 @@ StETofHeader::StETofHeader( const double& trgGdpbTime, const double& trgStarTime mStarTrgCmdIn( starTrgCmdIn ), mEventStatusFlag( eventStatusFlag ), mMissMatchFlagVec( MissMatchFlagVec ), - mGoodEventFlagVec( GoodEventFlagVec ) + mGoodEventFlagVec( GoodEventFlagVec ), + mHasPulsersVec( HasPulsersVec ) { setRocGdpbTs( gdpbTs ); setRocStarTs( starTs ); @@ -169,6 +173,11 @@ StETofHeader::goodEventFlagVec() const { return mGoodEventFlagVec; } +std::vector +StETofHeader::hasPulsersVec() const +{ + return mHasPulsersVec; +} void StETofHeader::setTrgGdpbFullTime( const double& gdpbFullTime ) @@ -230,3 +239,9 @@ StETofHeader::setGoodEventFlagVec( const std::vector& FlagVec ) { mGoodEventFlagVec = FlagVec; } + +void +StETofHeader::setHasPulsersVec( const std::vector& PulserVec ) +{ + mHasPulsersVec = PulserVec; +} diff --git a/StRoot/StEvent/StETofHeader.h b/StRoot/StEvent/StETofHeader.h index 8daaa42f7a9..c19e50d8526 100644 --- a/StRoot/StEvent/StETofHeader.h +++ b/StRoot/StEvent/StETofHeader.h @@ -55,7 +55,7 @@ class StETofHeader : public StObject { ** @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& ); + const unsigned int&, const unsigned int&, const unsigned int&, const uint64_t&, const std::vector&, const std::vector& , const std::vector& ); ~StETofHeader(); @@ -78,6 +78,8 @@ class StETofHeader : public StObject { **/ std::vector goodEventFlagVec() const; + std::vector hasPulsersVec() const; + void setTrgGdpbFullTime( const double& gdpbFullTime ); void setTrgStarFullTime( const double& starFullTime ); @@ -92,7 +94,7 @@ class StETofHeader : public StObject { void setEventStatusFlag( const uint64_t& statusFlag ); void setGoodEventFlagVec( const std::vector& FlagVec ); void setGoodEventFlagVec( int blubb ) {return;} - // void setGoodEventFlagVec( const std::vector& FlagVec ); + void setHasPulsersVec( const std::vector& PulserVec ); private: Double_t mTrgGdpbFullTime; @@ -109,8 +111,9 @@ class StETofHeader : public StObject { std::vector< Bool_t > mMissMatchFlagVec; std::vector< Bool_t > mGoodEventFlagVec; + std::vector< Bool_t > mHasPulsersVec; - ClassDef( StETofHeader, 3 ) + ClassDef( StETofHeader, 4 ) }; #endif // STETOFHEADER_H diff --git a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx index 5f655a2a041..d100bcdb752 100644 --- a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx +++ b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.cxx @@ -178,7 +178,11 @@ StMuETofHeader::goodEventFlagVec() const { return mGoodEventFlagVec; } - +std::vector +StMuETofHeader::hasPulsersVec() const +{ + return mHasPulsersVec; +} void StMuETofHeader::setTrgGdpbFullTime( const double& gdpbFullTime ) @@ -240,3 +244,8 @@ StMuETofHeader::setGoodEventFlagVec( const std::vector& FlagVec ) { mGoodEventFlagVec = FlagVec; } +void +StMuETofHeader::setHasPulsersVec( const std::vector& PulserVec ) +{ + mHasPulsersVec = PulserVec; +} diff --git a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h index d29262cdc55..85f212e5302 100644 --- a/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h +++ b/StRoot/StMuDSTMaker/COMMON/StMuETofHeader.h @@ -87,6 +87,7 @@ class StMuETofHeader : public TObject { **/ std::vector goodEventFlagVec() const; + std::vector hasPulsersVec() const; void setTrgGdpbFullTime( const double& gdpbFullTime ); void setTrgStarFullTime( const double& starFullTime ); @@ -100,6 +101,7 @@ class StMuETofHeader : public TObject { void setEventStatusFlag( const uint64_t& statusFlag ); void setGoodEventFlagVec( const std::vector& FlagVec ); + void setHasPulsersVec( const std::vector& PulserVec ); private: Double_t mTrgGdpbFullTime; @@ -115,9 +117,10 @@ class StMuETofHeader : public TObject { ULong64_t mEventStatusFlag; std::vector< Bool_t > mMissMatchFlagVec; - std::vector< Bool_t > mGoodEventFlagVec; + std::vector< Bool_t > mGoodEventFlagVec; + std::vector< Bool_t > mHasPulsersVec; - ClassDef( StMuETofHeader, 3 ) + ClassDef( StMuETofHeader, 4 ) }; #endif // STMUETOFHEADER_H diff --git a/StRoot/StPicoEvent/StPicoEvent.cxx b/StRoot/StPicoEvent/StPicoEvent.cxx index 2913c2572ed..403a96dabf9 100644 --- a/StRoot/StPicoEvent/StPicoEvent.cxx +++ b/StRoot/StPicoEvent/StPicoEvent.cxx @@ -147,9 +147,12 @@ StPicoEvent::StPicoEvent(const StPicoEvent &event) : TObject() { mJetPatchThreshold[iIter] = event.mJetPatchThreshold[iIter]; } - for(int iIter=0; iIter<108; iIter++) { + for(int iIter=0; iIter<1728; iIter++) { mETofGoodEventFlag[iIter] = event.mETofGoodEventFlag[iIter]; } + for(int iIter=0; iIter<108; iIter++) { + mETofHasPulsersFlag[iIter] = event.mETofHasPulsersFlag[iIter]; + } } //_________________ @@ -339,7 +342,7 @@ void StPicoEvent::setBunchId(Int_t id) { } //_________________ -bool StPicoEvent::eTofGoodEventFlag( UShort_t iSector, UShort_t iModule, UShort_t iCounter ) const { +bool StPicoEvent::eTofGoodEventFlag( UShort_t iSector, UShort_t iModule, UShort_t iCounter , UShort_t iGet4) const { if( iSector < 13 || iSector > 24 ){ LOG_INFO << "StPicoEvent::eTofGoodEventFlag() - non-existing sector id " << iSector <<" -> return false"<< endm; return false; @@ -352,13 +355,17 @@ bool StPicoEvent::eTofGoodEventFlag( UShort_t iSector, UShort_t iModule, UShort LOG_INFO << "StPicoEvent::eTofGoodEventFlag() - non-existing counter id " << iCounter <<" -> return false"<< endm; return false; } + if( iGet4 < 1 || iGet4 > 16 ){ + LOG_INFO << "StPicoEvent::eTofGoodEventFlag() - non-existing Get4 id " << iGet4 <<" -> return false"<< endm; + return false; + } - return (bool) mETofGoodEventFlag[ 9*(iSector-13) + 3*(iModule-1) + (iCounter-1) ]; + return (bool) mETofGoodEventFlag[ 3*3*16*(iSector-13) + 3*16*(iModule-1) + 16*(iCounter-1)+ (iGet4 - 1) ]; } //_________________ void StPicoEvent::setETofGoodEventFlag( std::vector flagVec ) { - if( flagVec.size() != 108 ){ - LOG_INFO << "StPicoEvent::setETofGoodEventFlag() - eTof flag vector wrong size " << flagVec.size() <<" / 108"<< endm; + if( flagVec.size() != 1728 ){ + LOG_INFO << "StPicoEvent::setETofGoodEventFlag() - eTof flag vector wrong size " << flagVec.size() <<" / 1728"<< endm; }else{ std::copy(flagVec.begin(), flagVec.end(), mETofGoodEventFlag); } diff --git a/StRoot/StPicoEvent/StPicoEvent.h b/StRoot/StPicoEvent/StPicoEvent.h index 3ff0b07a231..30c6863ccdc 100644 --- a/StRoot/StPicoEvent/StPicoEvent.h +++ b/StRoot/StPicoEvent/StPicoEvent.h @@ -141,10 +141,14 @@ 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 + /// Return goodEventFlag for a specific eTOF Get4 + bool eTofGoodEventFlag( UShort_t iSector, UShort_t iModule, UShort_t iCounter , UShort_t iGet4) const; + /// Return goodEventFlag by array entry bool eTofGoodEventFlag( UShort_t iDet ) const { return (bool) mETofGoodEventFlag[ iDet ]; } + /// Return pulser status for a specific eTOF counter (true if both pulsers present) + bool eTofPulserStatus( UShort_t iSector, UShort_t iModule, UShort_t iCounter ) const; + /// Return pulser ststus by array entry + bool eTofPulserStatus( 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) @@ -279,9 +283,11 @@ class StPicoEvent : public TObject { /// 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( bool flag, UShort_t iSector, UShort_t iModule, UShort_t iCounter, UShort_t iGet4 ) { mETofGoodEventFlag[ 3*3*16*(iSector-1) + 3*16*(iModule-1) + 16*(iCounter-1) + (iGet4-1)] = flag; } + /// Full setter goodEventFlag all specific eTOF Get4. Used to copy over MuDst data void setETofGoodEventFlag( std::vector flagVec ); + /// Full setter pulserStatusFlag all specific eTOF counter. Used to copy over MuDst data + void setETofHasPulsersFlag( std::vector pulserVec ); /// Set number of primary tracks void setNumberOfPrimaryTracks(UShort_t mult) { mNumberOfPrimaryTracks = (UShort_t)mult; } @@ -609,8 +615,9 @@ 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]; + /// Flag to mark if the event is good for physics analysis for each Get4. A Get4 is considered good in each event when there are zero missmatch flags set. Get4 efficiency should be constant between good events. As additional sanity check one can request that both pulsers were present for any given event and counter. Best performance to be expected with zero status bits and both pulsers. Here: CounterNr = 9*(sector-13) + 3*(module-1) + counter. Get4Nr = 3*3*16*(sector-13)+ 3*16*(module -1) + 16*(counter -1) + Get4. + bool mETofGoodEventFlag[1728]; + bool mETofHasPulsersFlag[108]; /// Number of primary tracks UShort_t mNumberOfPrimaryTracks; @@ -619,9 +626,9 @@ class StPicoEvent : public TObject { UShort_t mZdcUnAttenuated[2]; #if defined (__TFG__VERSION__) - ClassDef(StPicoEvent, 9) + ClassDef(StPicoEvent, 10) #else /* ! __TFG__VERSION__ */ - ClassDef(StPicoEvent, 7) + ClassDef(StPicoEvent, 8) #endif }; From ffa7b94c7b0ef3df050dbefda4ead722fc923204 Mon Sep 17 00:00:00 2001 From: Gene Van Buren <85305093+genevb@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:41:35 -0400 Subject: [PATCH 15/25] First chains for 2024 (no ETOF) (#671) Initial chains for pp200 in 2024, needed for FastOffline coming in just a few weeks. Another update with a chain for AA processing may be needed later if it becomes certain that we will acquire AuAu200 data. --- StRoot/StBFChain/BigFullChain.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/StRoot/StBFChain/BigFullChain.h b/StRoot/StBFChain/BigFullChain.h index 917dd831eaa..ae8294bd260 100644 --- a/StRoot/StBFChain/BigFullChain.h +++ b/StRoot/StBFChain/BigFullChain.h @@ -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","","" From 2e60a9d2fd09be29f0e0b4bab389522814cd9bef Mon Sep 17 00:00:00 2001 From: Daniel Torres Valladares <81983942+DanielTorres98@users.noreply.github.com> Date: Tue, 26 Mar 2024 20:38:23 -0500 Subject: [PATCH 16/25] Delete warinings BTofSimMaker.cxx (#675) This branch is to address mentioned here: [Issue 149](https://github.com/star-bnl/star-sw/issues/149) --------- Co-authored-by: Daniel Torres Valladares Co-authored-by: Dmitri Smirnov --- StRoot/StBTofSimMaker/StBTofSimMaker.cxx | 22 +++++++++++----------- mgr/warnoff_dirs.txt | 1 - 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/StRoot/StBTofSimMaker/StBTofSimMaker.cxx b/StRoot/StBTofSimMaker/StBTofSimMaker.cxx index 8fc44ea2c74..9d95dddd4b3 100644 --- a/StRoot/StBTofSimMaker/StBTofSimMaker.cxx +++ b/StRoot/StBTofSimMaker/StBTofSimMaker.cxx @@ -296,7 +296,10 @@ int StBTofSimMaker::CellResponse(g2t_ctf_hit_st* tofHitsFromGeant, g2t_track_st *tof_track = g2t_track->GetTable(); int no_tracks= g2t_track->GetNRows(); - double beta; + // Initialize beta to be a large negative value. This is a flag in case the following if + // condition is not satisfied and meaning there is something wrong with the beta value. + // + double beta = -999.; int trackId = -1; for(int j=0;jtrack_p==tof_track[j].id){ @@ -803,7 +806,11 @@ int StBTofSimMaker::FastCellResponse(g2t_ctf_hit_st* tofHitsFromGeant, StBTofCol int no_tracks= g2t_track->GetNRows(); StMcTrack *partnerTrk = 0; - int partnerTrkId; + + // Initialize partnerTrkId to be a negative value. This is a flag in case the following if + // condition is not satisfied and meaning there is something wrong with the track ID. + // + int partnerTrkId = -1; for(int j=0;jtrack_p==tof_track[j].id){ partnerTrk = new StMcTrack(&(tof_track[j])); @@ -820,15 +827,8 @@ int StBTofSimMaker::FastCellResponse(g2t_ctf_hit_st* tofHitsFromGeant, StBTofCol double pathL = tofHitsFromGeant->s_track; double q = 0.; - double Rawtof = tofHitsFromGeant->tof*1000./nanosecond; - float Rawbeta=pathL/Rawtof/3e-2; - double momentum=partnerTrk->momentum().mag(); - double mass=partnerTrk->fourMomentum().m(); - double calcTof=pathL/(3e-2)/sqrt(1 - mass*mass/(momentum*momentum + mass*mass)); - double time_blur = ranGauss.shoot()*mSimResDb->timeres_tof(itray, imodule, icell)*1e-9/nanosecond; double tof = tofHitsFromGeant->tof*1000./nanosecond + time_blur; //! 85ps per channel - if ( mVpdSim ) { // VpdSimMaker present, assume vpdstart tof += mVpdSimConfig->getMcClock()*1000; } @@ -851,9 +851,9 @@ int StBTofSimMaker::FastCellResponse(g2t_ctf_hit_st* tofHitsFromGeant, StBTofCol } } - // tof = tof - mSimDb->toffset(); // Apply offset correction. + // tof = tof - mSimDb->toffset(); // Apply offset correction. double t0 = tofHitsFromGeant->tof*1000./nanosecond; - float beta=pathL/tof/3e-2; + // float beta=pathL/tof/3e-2; StMcBTofHit *mcBTofHit = new StMcBTofHit(itray,imodule,icell,de,pathL,t0,tof,q); mcBTofHit->setPosition(local); diff --git a/mgr/warnoff_dirs.txt b/mgr/warnoff_dirs.txt index 74a46211c86..e6ddc18ff2a 100644 --- a/mgr/warnoff_dirs.txt +++ b/mgr/warnoff_dirs.txt @@ -3,7 +3,6 @@ StRoot/RTS StRoot/StAnalysisMaker StRoot/StAssociationMaker StRoot/StBTofPool.* -StRoot/StBTofSimMaker StRoot/StChain StRoot/StDaqLib StRoot/StDbLib From 2e0982686339b1162c3a98c2b4fac0f28846ce19 Mon Sep 17 00:00:00 2001 From: Daniel Brandenburg Date: Wed, 27 Mar 2024 11:27:24 -0400 Subject: [PATCH 17/25] Updates to StFwdTrackMaker to allow running without XML config file (#635) This update makes the StFwdTrackMaker fully configurable from the ROOT macro without the need for any external XML config file. Changes: - FwdTrackerConfig: new functionality to allow loading a config from a string (instead of a file) and new functions for setting arbitrary values in the config - StFwdTrackMaker: many new functions for setting configuration parameters - New logic to use a default configuration if set for Data or Mc, else load from a config file The default config file is embedded for consistency. In the future BFC options can be used to toggle parameters if they need to change from one production to the next. --- StRoot/StFwdTrackMaker/FwdTrackerConfig.cxx | 68 +++++++- StRoot/StFwdTrackMaker/FwdTrackerConfig.h | 135 +++++++++++++--- StRoot/StFwdTrackMaker/StFwdTrackMaker.cxx | 93 +++++++++-- StRoot/StFwdTrackMaker/StFwdTrackMaker.h | 171 ++++++++++++++++++++ 4 files changed, 430 insertions(+), 37 deletions(-) diff --git a/StRoot/StFwdTrackMaker/FwdTrackerConfig.cxx b/StRoot/StFwdTrackMaker/FwdTrackerConfig.cxx index 901c0e8c96f..cf070d4f3f2 100644 --- a/StRoot/StFwdTrackMaker/FwdTrackerConfig.cxx +++ b/StRoot/StFwdTrackMaker/FwdTrackerConfig.cxx @@ -9,7 +9,48 @@ std::stringstream FwdTrackerConfig::sstr; // template specializations //// -// Specialization for string to avoid extra conversions +/** + * @brief write a value to path + * + * @tparam template specialization for std::string + * @param path path to write, if it DNE it is created + * @param v value (of type string) to write + */ +template <> +void FwdTrackerConfig::set( std::string path, std::string v ) { + + FwdTrackerConfig::canonize( path ); + // convrt from string to type T and return + mNodes[ path ] = v; +} + +/** + * @brief write a value to path + * + * @tparam template specialization for bool + * @param path path to write, if it DNE it is created + * @param bv boolean to write + */ +template <> +void FwdTrackerConfig::set( std::string path, bool bv ) { + + FwdTrackerConfig::canonize( path ); + // convrt from string to type T and return + std::string v = "false"; + if (bv) + v = "true"; + mNodes[ path ] = v; +} + +// +/** + * @brief Get a value from the path + * + * @tparam Specialization for string to avoid extra conversions + * @param path path to lookup + * @param dv default value if path DNE + * @return std::string value at path or default + */ template <> std::string FwdTrackerConfig::get( std::string path, std::string dv ) const { // return default value if path DNE @@ -20,13 +61,26 @@ std::string FwdTrackerConfig::get( std::string path, std::string dv ) const { return ( mNodes.at( path ) ); } -// conversion to string is a noop +/** + * @brief conversion to string is a noop + * + * @tparam string specialization + * @param str input + * @return std::string output (unchanged) + */ template <> std::string FwdTrackerConfig::convert( std::string str ) const { return str; } -// specialization for bool adds recognition of strings "true" and "false" (lower case) +/** + * @brief specialization for bool adds recognition of strings "true" and "false" (lower case) + * + * @tparam bool specialization, fallback to int check + * @param str input string + * @return true for "true" + * @return false for "false" + */ template <> bool FwdTrackerConfig::convert( std::string str ) const { @@ -39,7 +93,13 @@ bool FwdTrackerConfig::convert( std::string str ) const { return static_cast(convert( str )); } -// get as ROOT TString +/** + * @brief get as ROOT TString + * + * @tparam TString specialization + * @param str input value + * @return TString output as ROOT TString + */ template <> TString FwdTrackerConfig::convert(std::string str) const { TString r(str); diff --git a/StRoot/StFwdTrackMaker/FwdTrackerConfig.h b/StRoot/StFwdTrackMaker/FwdTrackerConfig.h index 130640b31db..fcc1c1bb0b6 100644 --- a/StRoot/StFwdTrackMaker/FwdTrackerConfig.h +++ b/StRoot/StFwdTrackMaker/FwdTrackerConfig.h @@ -26,9 +26,13 @@ class FwdTrackerConfig { std::map mNodes; static std::stringstream sstr; // reused for string to numeric conversion - // assumes bare path and adds [i] until DNE - // reports lowest non-existant index - // starts at 1 since 0 is checked on existance + /** + * @brief get lowest non-existing path index + * assumes bare path and adds [i] until DNE + * starts at 1 since 0 is checked on existance + * @param path base path to check + * @return size_t index, starts at 1 + */ size_t pathCount( const std::string path ){ size_t index = 1; std::string p = path + TString::Format( "[%zu]", index ).Data(); @@ -39,6 +43,14 @@ class FwdTrackerConfig { return index; } + /** + * @brief Reads an xml document and writes it into map + * + * @param xml xml document to map + * @param node starting node - allows recursive mapping + * @param level the integer index of the level of current parsing + * @param path the path for the current node + */ void mapFile(TXMLEngine &xml, XMLNodePointer_t node, Int_t level, std::string path = "") { using namespace std; // add the path delimeter above top level @@ -83,7 +95,11 @@ class FwdTrackerConfig { } // mapFile public: - // sanitizes a path to its canonical form + /** + * @brief Returns a path in its cannonical form + * + * @param path Path to cannoize, returned in place by reference + */ static void canonize( std::string &path ) { // remove whitespace path.erase(std::remove_if(path.begin(), path.end(), static_cast(std::isspace)), path.end()); @@ -98,7 +114,11 @@ class FwdTrackerConfig { return; } - // dump config to a basic string representation - mostly for debugging + /** + * @brief dump config to a basic string representation - mostly for debugging + * + * @return std::string + */ std::string dump() const { using namespace std; FwdTrackerConfig::sstr.str(""); @@ -109,8 +129,14 @@ class FwdTrackerConfig { return FwdTrackerConfig::sstr.str(); } - // Does a path exist - // Either node or attribute - used to determine if default value is used + /** + * @brief returns whether or not a path exist + * Either node or attribute - used to determine if default value is used + * + * @param path - the path to check + * @return true : path exists + * @return false : path DNE + */ bool exists( std::string path ) const { FwdTrackerConfig::canonize( path ); if ( 0 == mNodes.count( path ) ) @@ -118,8 +144,14 @@ class FwdTrackerConfig { return true; } - // generic conversion to type T from std::string - // override this for special conversions + /** + * @brief Generic conversion of type T from string + * override this for special conversions + * + * @tparam T : Type to convert to and return + * @param s : input string to use for conversion + * @return T converted value of type T + */ template T convert( std::string s ) const { T rv; @@ -130,10 +162,30 @@ class FwdTrackerConfig { return rv; } - + /** + * @brief Generic conversion of type T to a string + * + * @tparam T : type to convert + * @param v : value of type T + * @return std::string output string with representation of T + */ + template + std::string convertTo( T v ) const { + FwdTrackerConfig::sstr.str(""); + FwdTrackerConfig::sstr.clear(); + FwdTrackerConfig::sstr << v; + return FwdTrackerConfig::sstr.str(); + } - // template function for getting any type that can be converted from string via stringstream + /** + * @brief template function for getting any type that can be converted from string via stringstream + * + * @tparam T type to return + * @param path path to lookup + * @param dv default value to return if the node DNE + * @return T return value of type T + */ template T get( std::string path, T dv ) const { @@ -146,8 +198,28 @@ class FwdTrackerConfig { return convert( mNodes.at( path ) ); } + /** + * @brief Writes a value of type T to the map + * Uses convertTo to convert type T to a string rep + * @tparam T type of value to write + * @param path path to write to + * @param v value of type T + */ + template + void set( std::string path, T v ) { + FwdTrackerConfig::canonize( path ); + // convrt from string to type T and return + mNodes[ path ] = convertTo( v ); + } - + /** + * @brief Get a Vector object from config + * + * @tparam T type of value for the vector object + * @param path path to lookup + * @param dv default value, can use initializer list + * @return std::vector vector of type T returned + */ template std::vector getVector( std::string path, std::vector dv ) const { if ( !exists( path ) ) @@ -176,7 +248,12 @@ class FwdTrackerConfig { return result; } - // list the paths of children nodes for a given node + /** + * @brief list the paths of children nodes for a given node + * + * @param path path to search for children + * @return std::vector list of full paths to the children nodes + */ std::vector childrenOf( std::string path ) const { using namespace std; vector result; @@ -204,17 +281,28 @@ class FwdTrackerConfig { return result; } - // Constructor is noop, use load(...) + /** + * @brief Constructor is noop, use load(...) + * + */ FwdTrackerConfig() {} - // constructor that immediately loads an xml file + /** + * @brief Construct a new Fwd Tracker Config object and load a file + * + * @param filename + */ FwdTrackerConfig(std::string filename) { load( filename ); } - // Main setup routine. - // Loads the given XML file and maps it - void load( std::string filename ) { + /** + * @brief Main setup routine + * Loads the given XML file (or string) and maps it + * @param filename filename (or xml string) to load. If file the content is loaded as an xml doc + * @param asString false: filename is loaded and contents treated as xml doc, true: treat the string `filename` directly as an xml doc + */ + void load( std::string filename, bool asString = false ) { using namespace std; // empty the map of mNodes @@ -224,7 +312,12 @@ class FwdTrackerConfig { TXMLEngine xml; // Now try to parse xml file - XMLDocPointer_t xmldoc = xml.ParseFile(filename.c_str()); + XMLDocPointer_t xmldoc; + if (asString) + xmldoc = xml.ParseString(filename.c_str()); + else + xmldoc = xml.ParseFile(filename.c_str()); + if (!xmldoc) { // parse failed, TODO inform of error mErrorParsing = true; return; @@ -249,5 +342,9 @@ template <> TString FwdTrackerConfig::convert(std::string str) const; template <> std::string FwdTrackerConfig::get( std::string path, std::string dv ) const; +template <> +void FwdTrackerConfig::set( std::string path, std::string v ); +template <> +void FwdTrackerConfig::set( std::string path, bool bv ); #endif diff --git a/StRoot/StFwdTrackMaker/StFwdTrackMaker.cxx b/StRoot/StFwdTrackMaker/StFwdTrackMaker.cxx index 46d9313eb16..a2881f3f660 100644 --- a/StRoot/StFwdTrackMaker/StFwdTrackMaker.cxx +++ b/StRoot/StFwdTrackMaker/StFwdTrackMaker.cxx @@ -76,6 +76,8 @@ float BDTCrit2::Crit2_DeltaRho = -999; float BDTCrit2::Crit2_DeltaPhi = -999; float BDTCrit2::Crit2_StraightTrackRatio = -999; + + //_______________________________________________________________________________________ class GenfitUtils{ public: @@ -86,7 +88,6 @@ class GenfitUtils{ }; // GenfitUtils - // Basic sanity cuts on genfit tracks template<> bool GenfitUtils::accept( genfit::Track *track ) { @@ -148,9 +149,7 @@ template<> bool GenfitUtils::accept( genfit::Track *track ) }; - //______________________________________________________________________________________ - class SiRasterizer { public: SiRasterizer() {} @@ -226,8 +225,6 @@ class ForwardTracker : public ForwardTrackMaker { } }; - - //________________________________________________________________________ StFwdTrackMaker::StFwdTrackMaker() : StMaker("fwdTrack"), mGenHistograms(false), mGenTree(false), mForwardTracker(nullptr), mForwardData(nullptr){ SetAttr("useFtt",1); // Default Ftt on @@ -244,6 +241,7 @@ int StFwdTrackMaker::Finish() { // output file name string name = mFwdConfig.get("Output:url", "fwdTrackerOutput.root"); + LOG_INFO << "Saving StFwdTrackMaker Histograms to ROOT file: " << name << endm; TFile *fOutput = new TFile(name.c_str(), "RECREATE"); fOutput->cd(); @@ -268,18 +266,29 @@ int StFwdTrackMaker::Finish() { return kStOk; } +void StFwdTrackMaker::LoadConfiguration() { + if (mConfigFile.length() < 5){ + LOG_INFO << "Forward Tracker is using default config for "; + if ( defaultConfig == defaultConfigData ){ + LOG_INFO << " DATA" << endm; + } else { + LOG_INFO << " Simulation" << endm; + } + mFwdConfig.load( defaultConfig, true ); + } else { + LOG_INFO << "Forward Tracker is using config from file : " << mConfigFile << endm; + mFwdConfig.load( mConfigFile ); + } + configLoaded = true; +} + //________________________________________________________________________ int StFwdTrackMaker::Init() { - // Initialize configuration file - std::string configFile = SAttr("config"); - if (mConfigFile.length() > 4) { - configFile = mConfigFile; - LOG_INFO << "Forward Tracker is using config file : " << mConfigFile << endm; + if ( !configLoaded ){ + LoadConfiguration(); } - mFwdConfig.load( configFile ); - if (mGenTree) { mTreeFile = new TFile("fwdtree.root", "RECREATE"); mTree = new TTree("fwd", "fwd tracking tree"); @@ -581,8 +590,6 @@ void StFwdTrackMaker::loadFttHits( FwdDataSource::McTrackMap_t &mcTrackMap, FwdD } } // loadFttHits - - void StFwdTrackMaker::loadFttHitsFromStEvent( FwdDataSource::McTrackMap_t &mcTrackMap, FwdDataSource::HitMap_t &hitMap, int count ){ LOG_DEBUG << "Loading FTT Hits from Data" << endm; StEvent *event = (StEvent *)GetDataSet("StEvent"); @@ -1686,3 +1693,61 @@ void StFwdTrackMaker::ProcessFwdTracks( ){ } } } + + +std::string StFwdTrackMaker::defaultConfigIdealSim = R"( + + + + + + + + + +)"; + + + +std::string StFwdTrackMaker::defaultConfigData = R"( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.99 + 0.001 + + + + + + + + + +)"; \ No newline at end of file diff --git a/StRoot/StFwdTrackMaker/StFwdTrackMaker.h b/StRoot/StFwdTrackMaker/StFwdTrackMaker.h index 5be3f4f0f11..e04c158bb45 100644 --- a/StRoot/StFwdTrackMaker/StFwdTrackMaker.h +++ b/StRoot/StFwdTrackMaker/StFwdTrackMaker.h @@ -117,7 +117,9 @@ class StFwdTrackMaker : public StMaker { void SetConfigFile(std::string n) { mConfigFile = n; + LoadConfiguration(); } + void LoadConfiguration(); void SetGenerateHistograms( bool _genHisto ){ mGenHistograms = _genHisto; } void SetGenerateTree(bool _genTree) { mGenTree = _genTree; } void SetVisualize( bool _viz ) { mVisualize = _viz; } @@ -182,6 +184,175 @@ class StFwdTrackMaker : public StMaker { void FillTTree(); // if debugging ttree is turned on (mGenTree) void FitVertex(); + static std::string defaultConfigIdealSim; + static std::string defaultConfigData; + std::string defaultConfig; + bool configLoaded = false; + + // Helper functions for modifying configuration + // NOTE: to override configuration, call individual functions after setConfigForXXX + public: + /**@brief Setup the StFwdTrackMaker for running on Data + * Load the default configuration for Data. + * Note: Apply any overrides after calling this + */ + void setConfigForData() { defaultConfig = defaultConfigData; LoadConfiguration(); } + /**@brief Setup the StFwdTrackMaker for running on Data + * Load the default configuration for IDEAL simulation. + * This runs with MC track finding and MC-seeded track fitting. + * - MC track finding uses the MCTrackId to collect stgc/fst hits into track seeds + * - MC-seeded track fitting uses the MC particle momentum to seed the track fit + * - Also uses the simulated MC primary vertex with smearing according to the simgaXY,Z + * Note: Apply any overrides after calling this + */ + void setConfigForIdealSim() { defaultConfig = defaultConfigIdealSim; LoadConfiguration(); } + + /**@brief Setup the StFwdTrackMaker for running on Data + * Load the default configuration for Realistic simulation. + * This runs tracking on simulation using the same parameters / approach as on data. + * Note: Apply any overrides after calling this + */ + void setConfigForRealisticSim() { + defaultConfig = defaultConfigData; + LoadConfiguration(); + // Note: Once the slow sims work this override will not be needed + // because the slow sims will put hits into StEvent just like (data) reco chain + setFttHitSource( "GEANT" ); + } + + + /**@brief Set the filename for output ROOT file + * @param fn : filename of output ROOT file + */ + void setOutputFilename( std::string fn ) { mFwdConfig.set( "Output:url", fn ); } + /**@brief Set the data source for FTT hits + * + * @param source : {DATA, GEANT}, DATA means read from StEvent, GEANT means read directly from the GEANT hits + */ + void setFttHitSource( std::string source ) { mFwdConfig.set( "Source:ftt", source ); } + + /**@brief Enable or disable the Fst Rasterizer + * @param use : if true, load FST hits from GEANT and raster them according to r, phi resolutions. + */ + void setUseFstRasteredGeantHits( bool use = true ){ mFwdConfig.set( "SiRasterizer:active", use ); } + /**@brief Set the resolution in R for rasterizing FST hits (from fast sim) + * Only used when the Rasterizer is enabled, which results from reading FST hits from GEANT + * @param r : resolution in r (cm) + */ + void setFstRasterR( double r = 3.0 /*cm*/ ){ mFwdConfig.set( "SiRasterizer:r", r ); } + /**@brief Set the resolution in phi for rasterizing FST hits (from fast sim) + * Only used when the Rasterizer is enabled, which results from reading FST hits from GEANT + * @param phi : resolution in phi (rad) + */ + void setFstRasterPhi( double phi = 0.00409 /*2*pi/(12*128)*/ ){ mFwdConfig.set( "SiRasterizer:phi", phi ); } + + //Track Finding + /**@brief Use Ftt hits in the Seed Finding + * + */ + void setSeedFindingWithFtt() { mFwdConfig.set( "TrackFinder:source", "ftt" ); } + /**@brief Use Fst hits in the Seed Finding + * + */ + void setSeedFindingWithFst() { mFwdConfig.set( "TrackFinder:source", "fst" ); } + /**@brief Set the number of track finding iterations + * @param n : number of iterations to run + */ + void setSeedFindingNumInterations( int n = 1 ) { mFwdConfig.set("TrackFinder:nIterations", n); } + /**@brief Set the number of phi slices to split the track iterations into + * @param n : number of slices of equal size (2pi)/n + */ + void setSeedFindingNumPhiSlices( int n = 8 ) { mFwdConfig.set("TrackFinder.Iteration:nPhiSlices", n); } + /**@brief Set the connector distance for track finding + * @param d : distance between planes (1 = adjacent) + */ + void setSeedFindingConnectorDistance( int d = 1 ) { mFwdConfig.set( "TrackFinder.Connector:distance", d ); } + /**@brief Enable or disable the SubsetNN + * @param use : if true, enables the subsetNN which find the most compatible set of tracks without shared hits + * if false, all tracks are reported regardless of shared hits + */ + void setSeedFindingUseSubsetNN( bool use = true ) { mFwdConfig.set( "TrackFinder.SubsetNN:active", use ); } + /**@brief Enable or disable the SubsetNN + * @param n : minimum number of hits on a track seed. Seeds with fewer hits are discarded + */ + void setSeedFindingMinHitsOnTrack( int n = 3 ) { mFwdConfig.set( "TrackFinder.SubsetNN:min-hits-on-track", n ); } + /**@brief Enable or disable the HitRemover + * @param use : if true, enables the hit remover which removes any hits from the hitmap that were used in a track + * if false, hits are not removed after each iteration + */ + void setSeedFindingUseHitRemover( bool use = true ) { mFwdConfig.set( "TrackFinder.HitRemover:active", use ); } + /**@brief Enable or disable the Truth Seed finding + * @param use : if true, use Mc info to group hits into track seeds + * if false, seed finding uses options as in the case for data + */ + void setUseTruthSeedFinding( bool use = true ) { mFwdConfig.set( "TrackFinder:active", !use ); } + + // Track Fitting + /**@brief Turn off track fitting + * Useful if you want to speed up the run but dont need fitting (testing seed finding) + */ + void setTrackFittingOff() { mFwdConfig.set( "TrackFitter:active", "false" ); } + /**@brief Enable / disable material effects + * Material effects in kalman filter + */ + void setFittingMaterialEffects( bool mat = true) { mFwdConfig.set( "TrackFitter:materialEffects", mat ); } + /**@brief Set the resolution for the Primary Vertex in XY + * @params sXY : sigma in XY (cm) + */ + void setPrimaryVertexSigmaXY( double sXY ) { mFwdConfig.set( "TrackFitter.Vertex:sigmaXY", sXY ); } + /**@brief Set the resolution for the Primary Vertex in Z + * @params sZ : sigma in Z (cm) + */ + void setPrimaryVertexSigmaZ( double sZ ) { mFwdConfig.set( "TrackFitter.Vertex:sigmaZ", sZ ); } + // TODO: add options for beamline constraint + + /**@brief Include or exclude the Primary Vertex in fit + * @param pvf : if true, use PRimary Vertex in fit + */ + void setIncludePrimaryVertexInFit( bool pvf = true ) { mFwdConfig.set( "TrackFitter.Vertex:includeInFit", pvf ); } + /**@brief Set B-field to zero (for zero field running) + * @param zeroB : if true, use Zero B field + */ + void setZeroB( bool zeroB = true ) { mFwdConfig.set( "TrackFitter:zeroB", zeroB ); } + /**@brief Set B-field to constant (even outside of TPC) + * @param constB : if true, use const 0.5T B field + */ + void setConstB( bool constB = true ) { mFwdConfig.set( "TrackFitter:constB", constB ); } + /**@brief Force the use of McSeed for fit + * @param mcSeed : if true, use mc momentum as the seed for the track fitter + */ + void setUseMcSeedForFit( bool mcSeed = true ) { mFwdConfig.set( "TrackFitter:mcSeed", mcSeed ); } + + /**@brief Sets the tracking to refit + * This adds compatible hits from whichever detector was NOT used in seed finding + * if FTT seeding -> project to and add FST hits + * if FST seeding -> project to and add FTT hits + * @param refit : true, perform refit, false do not + */ + void setTrackRefit( bool refit = true) { mFwdConfig.set( "TrackFitter:refit", refit ); } + + /**@brief Sets the maximum number of hits that can be considered failed before the entire track fit fails + * @param n : number of failed hits allowed, -1 = no limit + */ + void setMaxFailedHitsInFit( int n = -1 /*no lim*/ ) {mFwdConfig.set("TrackFitter.KalmanFitterRefTrack:MaxFailedHits", n);} + /**@brief Sets Fitter debug level + * @param level : 0 = no output, higher numbers are more verbose + */ + void setFitDebugLvl( int level = 0 /*0=no output*/ ) {mFwdConfig.set("TrackFitter.KalmanFitterRefTrack:DebugLvl", level); } + /**@brief Sets Max fit iterations before failing + * @param n : num iterations + */ + void setFitMaxIterations( int n=4 ) {mFwdConfig.set("TrackFitter.KalmanFitterRefTrack:MaxIterations", n); } + /**@brief Sets Min fit iterations before converging + * @param n : num iterations + */ + void setFitMinIterations( int n = 1) {mFwdConfig.set("TrackFitter.KalmanFitterRefTrack:MinIterations", n); } + + /**@brief Enables smearing of the MC Primary Vertex according to sigmaXY,Z + * @param pvs : if true, smear vertex + */ + void setSmearMcPrimaryVertex( bool pvs = true ) { mFwdConfig.set( "TrackFitter.Vertex:smearMcVertex", pvs ); } + }; #endif From 267ec8eb0a43ff3ebe74abf4afc54652d1ffe21a Mon Sep 17 00:00:00 2001 From: jml985 <44065529+jml985@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:25:39 -0400 Subject: [PATCH 18/25] RtsLoggingUpdate (#673) updates to allow RTS logging in Jevp while leaving it disabled in general offline computing --- OnlTools/Jevp/level.source | 5 ++++- StRoot/RTS/include/rtsLog.h | 34 +++++++++------------------------ StRoot/RTS/src/LOG/rtsLogUnix.c | 22 --------------------- mgr/Conscript-standard | 5 +++-- 4 files changed, 16 insertions(+), 50 deletions(-) diff --git a/OnlTools/Jevp/level.source b/OnlTools/Jevp/level.source index 5d6ad67bccd..e4bbe2620c8 100644 --- a/OnlTools/Jevp/level.source +++ b/OnlTools/Jevp/level.source @@ -1,4 +1,7 @@ # STAR LEVEL for EVP code -starver SL23b +starver SL23c #starver SL21b + + +unsetenv DB_SERVER_LOCAL_CONFIG diff --git a/StRoot/RTS/include/rtsLog.h b/StRoot/RTS/include/rtsLog.h index c93e3cd42bb..fb9e310ae6e 100755 --- a/StRoot/RTS/include/rtsLog.h +++ b/StRoot/RTS/include/rtsLog.h @@ -92,25 +92,10 @@ void rtsLogAddJmlFile (char *fname); - - - #ifndef RTS_ENABLE_LOG - #define RTS_ASSERT(expr) assert(expr) #define LOG(SEV,STRING,ARGS...) -#define rtsLogUnix_v(str, ...) -#define rtsLogAddCmd(x) - - -// the following become noops... -#define rtsLogLevel(x) -#define rtsLogAddDest(x,y) -#define rtsLogLevelInt(x) -#define rtsLogOutput(x) - -#else /* RTS_ENABLE_LOG */ - +#endif #ifdef __GNUC__ #define INLINE_HACK extern __inline__ @@ -182,7 +167,7 @@ INLINE_HACK void rtsLogLevel(const char *level) #define sbLOG(args...) #endif - +#ifdef RTS_ENABLE_LOG #define LOG(SEV,STRING,A1,A2,A3,A4,A5) \ do { \ const char *const yada = SEV ; \ @@ -195,15 +180,17 @@ INLINE_HACK void rtsLogLevel(const char *level) logMsg((char *)"" SEV ": " __FILE__ " [line %d]: " STRING "\n",__LINE__,(unsigned int)A1,(unsigned int)A2,(unsigned int)A3,(unsigned int)A4,(unsigned int)A5) ; \ sbLOG((char *)"" SEV ": " __FILE__ " [line %d]: " STRING "\n",__LINE__,(unsigned int)A1,(unsigned int)A2,(unsigned int)A3,(unsigned int)A4,(unsigned int)A5) ; \ } \ - } while(0) \ + } while(0) +#endif // RTS_ENABLE_LOG #define rtsLogOutput(x) #else /* unix */ +#ifdef RTS_ENABLE_LOG #define RTS_ASSERT(expr) LOG(CRIT,"assert(%s) true -- certain death follows",__STRING(expr)) - +#endif extern int rtsLogUnix_v(const char *str, ...) ; extern int rtsLogOutput(int flag) ; @@ -212,6 +199,7 @@ INLINE_HACK void rtsLogLevel(const char *level) extern int rtsLogAddFile(char *fname) ; +#ifdef RTS_ENABLE_LOG #ifdef RTS_LOG_COLORED #define LOG(SEV,STRING,ARGS...) \ @@ -242,16 +230,12 @@ INLINE_HACK void rtsLogLevel(const char *level) } while(0) \ - #endif /* RTS_LOG_COLORED */ - +#endif /* ENABLE LOG */ #endif /* __vxworks */ - -#endif /* RTS_ENABLE_LOG */ - #ifdef __cplusplus } -#endif +#endif /* __cplusplus */ #endif /* _RTS_LOG_H */ diff --git a/StRoot/RTS/src/LOG/rtsLogUnix.c b/StRoot/RTS/src/LOG/rtsLogUnix.c index 6d63e49c7ea..e02f1c8c3e7 100755 --- a/StRoot/RTS/src/LOG/rtsLogUnix.c +++ b/StRoot/RTS/src/LOG/rtsLogUnix.c @@ -30,23 +30,6 @@ volatile int tonkoLogLevel = 2 ; - - - -#ifdef RTS_ENABLE_LOG -#warning "DAQ logging is enabled" -#ifdef RTS_LOG_DEFAULT_NET -#warning "DAQ logging defaults to daqman" -#else -#warning "DAQ logging defaults to STDERR" -#endif /* RTS_LOG_DEFAULT_NET */ -#else -#warning "DAQ logging is disabled" -#endif /* RTS_ENABLE_LOG */ - - -#ifdef RTS_ENABLE_LOG - #ifdef RTS_LOG_DEFAULT_NET static int output_flag = RTS_LOG_NET ; #else @@ -391,11 +374,6 @@ static const char *getCmd(void) #endif } - -#endif - - - #ifdef __cplusplus } #endif diff --git a/mgr/Conscript-standard b/mgr/Conscript-standard index db1f9b9204b..ab1f1a4a7b1 100644 --- a/mgr/Conscript-standard +++ b/mgr/Conscript-standard @@ -197,7 +197,8 @@ if ( $pkg eq "Jevp") { . $main::PATH_SEPARATOR . "#OnlTools/Jevp/StJevpBuilders" . $main::PATH_SEPARATOR . "#OnlTools/Jevp/StJevpViewer" . $main::PATH_SEPARATOR . $CPPPATH; - $CPPFLAGS .= " -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_NO_DEBUG "; + $CPPFLAGS .= " -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_NO_DEBUG -DRTS_ENABLE_LOG "; + } #$CPPFLAGS .= " -DNEW_DAQ_READER -D__NO_STRANGE_MUDST__ "; @@ -1432,7 +1433,7 @@ if ( $#src > -1 ) { } } if ($pkg eq "RTS") { - my $cppflags = "-DRTS_PROJECT_STAR -DTPXREADER -DRTS_LITTLE_ENDIAN"; + my $cppflags = "-DRTS_PROJECT_STAR -DTPXREADER -DRTS_LITTLE_ENDIAN "; my $cpppath = $main::PATH_SEPARATOR . "#StRoot/RTS/include" . $main::PATH_SEPARATOR . "#StRoot/RTS/trg/include" . $main::PATH_SEPARATOR . "#StRoot/RTS/include/TPC" From 87ec6b164be585fdafcf088309ddb1a339135ee5 Mon Sep 17 00:00:00 2001 From: jml985 <44065529+jml985@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:27:09 -0400 Subject: [PATCH 19/25] Eliminate some compile warnings (#672) Commented out lines that have no effect. Original authors desired behavior is unclear --- OnlTools/Jevp/StJevpBuilders/fttBuilder.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OnlTools/Jevp/StJevpBuilders/fttBuilder.cxx b/OnlTools/Jevp/StJevpBuilders/fttBuilder.cxx index 53a62bb71a9..c34ced10c03 100644 --- a/OnlTools/Jevp/StJevpBuilders/fttBuilder.cxx +++ b/OnlTools/Jevp/StJevpBuilders/fttBuilder.cxx @@ -439,10 +439,17 @@ void fttBuilder::drawStrip( TH2 * h2, int row, int strip, VMMHardwareMap::Quadra int ix0 = ax->FindBin( x0 + row * rLength ); int ix1 = ax->FindBin( x0 + (row + 1) * rLength - 1 ); + + /* This code does nothing! ---------------------- + Most likely it was intended to adjust the indexes for this specific + region of the detector, but not known if needed; -jml 3/25/24 + if ( VMMHardwareMap::Quadrant::C == q || VMMHardwareMap::Quadrant::D == q ){ int ix0 = ax->FindBin( x0 + (row - 1) * rLength ); int ix1 = ax->FindBin( x0 + (row) * rLength - 1 ); } + */ + const int iy0 = ay->FindBin( y0 + strip * sPitch ); const int iy1 = ay->FindBin( y0 + (strip) * sPitch ); floodFill( h2, ix0, iy0, ix1, iy1 ); From 358a58c0172b51f61d4babe21845973f35c0ee18 Mon Sep 17 00:00:00 2001 From: Gene Van Buren <85305093+genevb@users.noreply.github.com> Date: Wed, 10 Apr 2024 12:25:10 -0400 Subject: [PATCH 20/25] Fix for crashes in tracking (#676) On 2016-11-07, Victor committed some code modifications to address three trouble tickets: 664250f8272bce312682ce03d17f6f5727b9b42b In his commit note, he listed an additional 4th item: "4. Simplified code in refitL()". This particular code change in [`Sti/StiKalmanTrack.cxx::refitL()`](https://github.com/star-bnl/star-sw/blob/2e0982686339b1162c3a98c2b4fac0f28846ce19/StRoot/Sti/StiKalmanTrack.cxx#L1653) did a little more than simplify: it modified the behavior, though I cannot tell if that was intentional from the comment. The new behavior appears to allow the re-fit to continue along a track when invalid track nodes are encountered (the invalid nodes are excluded from the refit, I believe), for whatever reason a node may be considered invalid. Previously, the entire remainder of the track would be ignored once an invalid node was encountered. The modification Victor made introduced a potential way for a job to crash for the case when the first node fails validity checks, but the second node doesn't get checked to the same degree and may have invalid content. This shows up in logs as: ` root4star: .sl73_gcc485/OBJ/StRoot/Sti/StiTrackNodeHelper.cxx:670: int StiTrackNodeHelper::save(): Assertion 'fabs(mPredPars.hz()-mTargetHz)<=1e-10' failed. ` (which is a test of the predicted parameters from the previous node versus the current node) The crash happens for only a tiny fraction of tracks, but a single failure from all the tracks contained in a single DAQ file is enough to crash a production job and lose all of its data. This particularly seems to be more common in pp500 data where there are more invalid nodes due to large TPC distortion corrections (though whether all of them should be invalid is a separate question not to answer here at this time), but I have seen this crash in various other datasets from time to time over recent years too. A very rough estimation is that this might cost us ~2% of all our Run 22 pp500 data. Two candidate fixes to consider: 1. Revert the code to where it was before Victor's "simplification". 2. Apply the same validity checks to any potential first used node on a track, not just the initial node. I have run a track-by-track comparison with each on ~200k tracks, and the impacted tracks are very few in number, at the level of ~10 tracks in solution 1, and 1 track in solution 2 (that one track changing by only a single hit). Given that solution 2 appears to be very close to having no impact other than allowing jobs to run that would otherwise crash, this PR implements that solution. --- StRoot/Sti/StiKalmanTrack.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/StRoot/Sti/StiKalmanTrack.cxx b/StRoot/Sti/StiKalmanTrack.cxx index 47a29f58213..b1a47c6a98c 100644 --- a/StRoot/Sti/StiKalmanTrack.cxx +++ b/StRoot/Sti/StiKalmanTrack.cxx @@ -1657,7 +1657,8 @@ static int nCall=0;nCall++; StiKTNIterator source; StiKalmanTrackNode *pNode = 0,*targetNode; - int iNode=0, status = 0,isStarted=0; + int iNode=0, status = 0; + bool isStarted=false; sTNH.setDir(1); for (source=rbegin();source!=rend();source++) { iNode++; @@ -1668,15 +1669,15 @@ static int nCall=0;nCall++; if ( targetNode->getChi2()>1000) targetNode->setInvalid(); if (!targetNode->isValid()) continue; } - isStarted++; sTNH.set(pNode,targetNode); status = sTNH.makeFit(0); - if (status) continue; + if (status) {targetNode->setInvalid();continue;} if (!targetNode->isValid()) continue; + isStarted = true; pNode = targetNode; }//end for of nodes - pNode = 0; iNode=0;isStarted=0; + pNode = 0; iNode=0;isStarted=false; sTNH.setDir(0); for (source=begin();source!=end();source++) { iNode++; @@ -1686,11 +1687,11 @@ static int nCall=0;nCall++; if ( targetNode->getChi2()>1000) targetNode->setInvalid(); if (!targetNode->isValid()) continue; } - isStarted++; sTNH.set(pNode,targetNode); status = sTNH.makeFit(1); - if (status) continue; + if (status) {targetNode->setInvalid();continue;} if (!targetNode->isValid()) continue; + isStarted = true; pNode = targetNode; }//end for of nodes return 0; From edeb538a768c24aa9e49c1cb6f12fcda7672dcd7 Mon Sep 17 00:00:00 2001 From: jml985 <44065529+jml985@users.noreply.github.com> Date: Wed, 10 Apr 2024 13:00:41 -0400 Subject: [PATCH 21/25] reader updates (#674) Co-authored-by: Dmitri Smirnov --- StRoot/RTS/src/DAQ_FCS/fcs_data_c.cxx | 2 + StRoot/RTS/src/DAQ_FCS/fcs_data_c.h | 2 + StRoot/RTS/src/DAQ_ITPC/daq_itpc.cxx | 9 +- StRoot/RTS/src/DAQ_ITPC/daq_itpc.h | 1 + StRoot/RTS/src/DAQ_ITPC/itpcFCF.cxx | 12 +- StRoot/RTS/src/DAQ_STGC/stgc_data_c.cxx | 14 ++ StRoot/RTS/src/DAQ_TPC23/itpc23.cxx | 181 ++++++++++++++++------- StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx | 3 +- StRoot/RTS/src/DAQ_TPC23/tpc23_base.h | 5 +- StRoot/RTS/src/DAQ_TPC23/tpx23.cxx | 126 +++++++++++++--- StRoot/RTS/src/DAQ_TPX/Makefile | 2 + StRoot/RTS/src/DAQ_TPX/daq_tpx.cxx | 4 + StRoot/RTS/src/DAQ_TPX/daq_tpx.h | 4 + StRoot/RTS/src/RTS_EXAMPLE/rts_example.C | 8 +- 14 files changed, 284 insertions(+), 89 deletions(-) diff --git a/StRoot/RTS/src/DAQ_FCS/fcs_data_c.cxx b/StRoot/RTS/src/DAQ_FCS/fcs_data_c.cxx index 6ce48b1ee93..3b4f6b45365 100644 --- a/StRoot/RTS/src/DAQ_FCS/fcs_data_c.cxx +++ b/StRoot/RTS/src/DAQ_FCS/fcs_data_c.cxx @@ -39,6 +39,7 @@ u_int fcs_data_c::run_type ; // for ZS float fcs_data_c::n_sigma ; +float fcs_data_c::n_sigma_hcal ; float fcs_data_c::n_sigma_epd ; short fcs_data_c::n_pre ; short fcs_data_c::n_post ; @@ -267,6 +268,7 @@ int fcs_data_c::zs_start(u_short *buff) float sigma ; if(hdr_det==2) sigma = n_sigma_epd ; + else if(hdr_det==1) sigma = n_sigma_hcal ; else sigma = n_sigma ; // trigger channels are special so figure this out diff --git a/StRoot/RTS/src/DAQ_FCS/fcs_data_c.h b/StRoot/RTS/src/DAQ_FCS/fcs_data_c.h index a48833c8fc1..5c80194279b 100644 --- a/StRoot/RTS/src/DAQ_FCS/fcs_data_c.h +++ b/StRoot/RTS/src/DAQ_FCS/fcs_data_c.h @@ -36,6 +36,7 @@ class fcs_data_c { run_number = 0 ; n_sigma = 4.0 ; + n_sigma_hcal = 4.0 ; n_sigma_epd = 4.0 ; n_pre = 8 ; n_post = 8 ; @@ -235,6 +236,7 @@ class fcs_data_c { // for ZS static float n_sigma ; static float n_sigma_epd ; + static float n_sigma_hcal ; static short n_pre ; static short n_post ; static short n_cou ; diff --git a/StRoot/RTS/src/DAQ_ITPC/daq_itpc.cxx b/StRoot/RTS/src/DAQ_ITPC/daq_itpc.cxx index 53ac60448bb..54633601947 100644 --- a/StRoot/RTS/src/DAQ_ITPC/daq_itpc.cxx +++ b/StRoot/RTS/src/DAQ_ITPC/daq_itpc.cxx @@ -76,10 +76,8 @@ daq_itpc::daq_itpc(daqReader *rts_caller) it23 = 0 ; // assume we won't use it online = 0 ; + mode = 0 ; -// it23 = new itpc23 ; -// it23->no_cld = 1 ; -// it23->log_level = 2 ; memset(fcf,0,sizeof(fcf)) ; fcf_det_type = 1 ; // ITPC @@ -535,6 +533,7 @@ daq_dta *daq_itpc::handle_sampa(int sec, int rdo, int in_adc) it23->run_type = 3 ; // NO CLUSTER FINDER PLEASE it23->no_cld = 1 ; it23->log_level = 0 ; + it23->mode = mode ; } it23->data_c = &sampa_c ; @@ -559,6 +558,10 @@ daq_dta *daq_itpc::handle_sampa(int sec, int rdo, int in_adc) //LOG(WARN,"S%02d:%d: rdo_fmt %d -- scan will fail",s,r,rdo_fmt) ; it23->set_rdo(s,r) ; ret = it23->rdo_scan((char *)dta,words) ; + + if((it23->err || ret) && mode) { + LOG(ERR,"S%02d:%d: rdo_scan 0x%X, err 0x%X, words %d",s,r,ret,it23->err,words) ; + } } else { ret = it->rdo_scan_top(dta,words) ; diff --git a/StRoot/RTS/src/DAQ_ITPC/daq_itpc.h b/StRoot/RTS/src/DAQ_ITPC/daq_itpc.h index 5175a3a1907..7e79d096337 100644 --- a/StRoot/RTS/src/DAQ_ITPC/daq_itpc.h +++ b/StRoot/RTS/src/DAQ_ITPC/daq_itpc.h @@ -74,6 +74,7 @@ class daq_itpc : public daq_det { static int no_sw16 ; int online ; + int mode ; int rdo_fmt ; } ; diff --git a/StRoot/RTS/src/DAQ_ITPC/itpcFCF.cxx b/StRoot/RTS/src/DAQ_ITPC/itpcFCF.cxx index 3816e7e305f..8dde24ef71f 100644 --- a/StRoot/RTS/src/DAQ_ITPC/itpcFCF.cxx +++ b/StRoot/RTS/src/DAQ_ITPC/itpcFCF.cxx @@ -1250,7 +1250,7 @@ int itpc_fcf_c::do_blobs_stage2(int row) int b_ix = blob_ix[ix] ; - LOG(TERR," using bix %d %d",ix,b_ix) ; + //LOG(TERR," using bix %d %d",ix,b_ix) ; if(b_ix != ix) { LOG(WARN,"Can't be: %d %d, RP %d:%d",b_ix,ix,row,p) ; } @@ -1347,7 +1347,7 @@ int itpc_fcf_c::do_blobs_stage2(int row) -#if 1 +#if 0 LOG(TERR,"Blobs OK %d/%d in row %d",blob_ok,blob_cou,row) ; for(int i=0;i>29 ; +#if 0 + if(rdo1==2) { + switch(feb_id) { + case 1 : + case 3 : + case 5 : + LOG(WARN,"%d: FEB %d\n",rdo1,feb_id) ; + break ; + } + } +#endif + datum_ix++ ; @@ -732,6 +744,8 @@ int stgc_data_c::event() } else { +// printf("%d: ROD %d, FEB %d\n",rdo1,rod_id,feb_id) ; + vmm.feb_vmm = ((feb_id-1)<<2)|(vmm_id-4) ; vmm.ch = channel ; vmm.adc = pdo ; diff --git a/StRoot/RTS/src/DAQ_TPC23/itpc23.cxx b/StRoot/RTS/src/DAQ_TPC23/itpc23.cxx index 66ebfc5e071..11920eac5ee 100644 --- a/StRoot/RTS/src/DAQ_TPC23/itpc23.cxx +++ b/StRoot/RTS/src/DAQ_TPC23/itpc23.cxx @@ -94,7 +94,9 @@ int itpc23::from22to23(char *c_dta, int words) if((data[0]&0xFFFF000F) != 0x98000004) { run_errors++ ; - if(run_errors<5 && online) LOG(ERR,"start 0 0x98 = 0x%08X",data[0]) ; + if(mode || (online && run_errors<10)) { + LOG(ERR,"start 0 0x98 = 0x%08X",data[0]) ; + } err |= 0x10000000 ; } @@ -141,7 +143,7 @@ int itpc23::from22to23(char *c_dta, int words) if(!found) { run_errors++ ; err |= 0x20000000 ; - if(run_errors<5) LOG(ERR,"%d: can't find data_end!",rdo1) ; + if(mode || (online && run_errors<10)) LOG(ERR,"%d: can't find data_end!",rdo1) ; } #endif @@ -162,7 +164,9 @@ int itpc23::from22to23(char *c_dta, int words) if(!found) { run_errors++ ; err |= 0x20000000 ; - if(run_errors<5) LOG(ERR,"%d: data_end 0x98 not found = 0x%08X",rdo1,data_end[0]) ; + if(mode || (online && (run_errors<10))) { + LOG(ERR,"%d: data_end 0x98 not found = 0x%08X",rdo1,data_end[0]) ; + } } n_words = data_end - data ; @@ -198,7 +202,7 @@ int itpc23::from22to23(char *c_dta, int words) if(l_fee_mask != fee_mask) { err |= 0x40000000 ; run_errors++ ; - if(run_errors<5) LOG(ERR,"%d: FEE mask 0x%X, expect 0x%X, words %d/%d",rdo1,l_fee_mask,fee_mask,words,n_words) ; + if(online && run_errors<10) LOG(ERR,"%d: FEE mask 0x%X, expect 0x%X, words %d/%d",rdo1,l_fee_mask,fee_mask,words,n_words) ; free(d_use) ; return 0 ; } @@ -254,7 +258,7 @@ int itpc23::from22to23(char *c_dta, int words) if(ix>(n_words)) { run_errors++ ; err |= 0x80000000 ; - if(run_errors<5) LOG(ERR,"%d: words %d, ix %d",rdo1,n_words,ix) ; + if(mode || (online && run_errors<10)) LOG(ERR,"%d: words %d, ix %d",rdo1,n_words,ix) ; free(d_use) ; return 0 ; } @@ -268,7 +272,7 @@ int itpc23::from22to23(char *c_dta, int words) if(ix>(n_words)) { run_errors++ ; - if(run_errors<5) LOG(ERR,"%d: words %d, ix %d",rdo1,n_words,ix) ; + if(mode || (online && run_errors<10)) LOG(ERR,"%d: words %d, ix %d",rdo1,n_words,ix) ; err |= 0x80000000 ; free(d_use) ; return 0 ; @@ -277,7 +281,7 @@ int itpc23::from22to23(char *c_dta, int words) if(n_words<12) { run_errors++ ; - if(run_errors<5) LOG(ERR,"%d: n_words %d",rdo1,n_words) ; + if(mode || (online && run_errors<10)) LOG(ERR,"%d: n_words %d",rdo1,n_words) ; err |= 0x80000000 ; free(d_use) ; return 0 ; @@ -329,14 +333,17 @@ int itpc23::init(daq_dta *gain) return 9 ; } - +// We are at the SAMPA(fee_ix):channel header u_int *itpc23::ch_scan(u_int *start) { u_short w[6] ; u_int *d = start ; int row, pad ; + int is_error = 0 ; // we are at the SAMPA header + retry_fix:; + w[0] = (d[0]>>20)&0x3FF ; w[1] = (d[0]>>10)&0x3FF ; w[2] = (d[0]>>00)&0x3FF ; @@ -356,7 +363,7 @@ u_int *itpc23::ch_scan(u_int *start) if(unlikely(words10==1023)) { // channel skipped because of prog-full! prog_fulls++ ; - if(online) LOG(ERR,"%d: ch_scan %d:%d: SAMPA%d:%d -- prog-full",rdo1,fee_ix,ch_ix,sampa_id,sampa_ch) ; + if(mode || (online && run_errors<10)) LOG(ERR,"%d: ch_scan %d:%d: SAMPA%d:%d -- prog-full",rdo1,fee_ix,ch_ix,sampa_id,sampa_ch) ; words10 = 0 ; } @@ -364,10 +371,39 @@ u_int *itpc23::ch_scan(u_int *start) if(unlikely(pkt!=4 || sampa_ch>31 || words10>512)) { err |= 0x1000000 ; - fee_errs++ ; - if(fee_errs<10) LOG(ERR,"%d: ch_scan %d:%d: pkt %d, sampa_ch %2d, words10 %d [0x%08X]",rdo1,fee_ix,ch_ix, - pkt,sampa_ch,words10, - d[0]) ; + is_error = 1 ; + run_errors++ ; + if(mode || (online && run_errors<20)) { + LOG(ERR,"%d: ch_scan %d:%d:%d: pkt %d, sampa %d:%d, words10 %d [0x%08X: 0x%08X 0x%08X], err 0x%X",rdo1,fee_ix,lane_ix, + ch_ix, + pkt,sampa_id,sampa_ch,words10, + d[0],d[-1],d[1],err) ; + +// LOG(ERR,"err 0x%08X",err) ; + + //int ppk[2] ; + + //ppk[0] = (((d[-1]>>20)&0x3FF)>>7)&0x7 ; + //ppk[1] = (((d[1]>>20)&0x3FF)>>7)&0x7 ; + + //LOG(ERR,"%d %d",ppk[0],ppk[1]) ; + //d++ ; + //goto retry_fix ; + + } + if(d>9)&1) ; @@ -377,9 +413,13 @@ u_int *itpc23::ch_scan(u_int *start) } else { if(unlikely(bx != bx_count)) { - err |= 0x2000000 ; - fee_errs++ ; - if(fee_errs<10) LOG(ERR,"%d: ch_scan %d:%d: bx %d, expect %d",rdo1,fee_ix,ch_ix,bx,bx_count) ; + if(abs(bx-bx_count)>1) { + err |= 0x2000000 ; + run_errors++ ; + if(mode || (online && run_errors<10)) { + LOG(ERR,"%d: ch_scan %d:%d: bx %d, expect %d",rdo1,fee_ix,ch_ix,bx,bx_count) ; + } + } } } @@ -440,9 +480,11 @@ u_int *itpc23::ch_scan(u_int *start) // tb_cou, tb_start, adc, adc, adc x tb_cou times // from low tb_start to high if(unlikely(d[i]&0xC0000000)) { - fee_errs++ ; - if(fee_errs<10) LOG(ERR,"%d: ch_scan %d:%d: SAMPA %d:%d: bad word 0x%08X",rdo1,fee_ix,ch_ix, - sampa_id,sampa_ch,d[i]) ; + run_errors++ ; + if(mode || (online && run_errors<10)) { + LOG(ERR,"%d: ch_scan %d:%d: SAMPA %d:%d: bad word 0x%08X",rdo1,fee_ix,ch_ix, + sampa_id,sampa_ch,d[i]) ; + } } if(log_level>=2) LOG(TERR,"FEE %d:%d -- %d = 0x%08X",fee_ix,ch_ix,i,d[i]) ; @@ -462,8 +504,10 @@ u_int *itpc23::ch_scan(u_int *start) if(log_level>=100) LOG(TERR," tb_cou %d",tb_cou) ; if(unlikely(tb_cou>500)) { - fee_errs++ ; - if(fee_errs<10) LOG(ERR,"%d: rp %d:%d: tb_cou %d [0x%08X,%d]",rdo1,row,pad,tb_cou,d[i],i) ; + run_errors++ ; + if(mode || (online && run_errors<10)) { + LOG(ERR,"%d: rp %d:%d: tb_cou %d [0x%08X,%d]",rdo1,row,pad,tb_cou,d[i],i) ; + } } ix = 1 ; break ; @@ -472,7 +516,7 @@ u_int *itpc23::ch_scan(u_int *start) *dd++ = tb_start ; if(seq_ix>=(SEQ_MAX-1)) { - if(online) LOG(ERR,"too many seqs %d",seq_ix) ; + if(mode || online) LOG(ERR,"too many seqs %d",seq_ix) ; goto done_ch ; } @@ -492,16 +536,16 @@ u_int *itpc23::ch_scan(u_int *start) if(unlikely(log_level>=100)) LOG(TERR," tb_start %d",tb_start) ; if(unlikely(tb_start<=tb_last)) { - fee_errs++ ; - if(fee_errs<10) LOG(ERR,"%d: rp %d:%d: tb_start %d, tb_last %d",rdo1,row,pad,tb_start,tb_last) ; + run_errors++ ; + if(mode || (online && run_errors<10))LOG(ERR,"%d: rp %d:%d: tb_start %d, tb_last %d",rdo1,row,pad,tb_start,tb_last) ; } tb_last = tb_start + tb_cou ; if(unlikely(tb_last>500)) { - fee_errs++ ; - if(fee_errs<10) LOG(ERR,"%d: rp %d:%d: tb_last %d [0x%08X,%d]",rdo1,row,pad,tb_last,d[i],i) ; + run_errors++ ; + if(mode || (online && run_errors<10)) LOG(ERR,"%d: rp %d:%d: tb_last %d [0x%08X,%d]",rdo1,row,pad,tb_last,d[i],i) ; } @@ -619,16 +663,31 @@ u_int *itpc23::lane_scan(u_int *start) { u_int *d = start ; + retry_fix:; + if(log_level>=1) LOG(TERR,"%d: lane scan %d: 0x%08X",rdo1,lane_ix,d[0]) ; // should be at start of lane 0xB.... if((d[0]&0xF0000000)!=0xB0000000) { // start of lane - err |= 0x100000 ; - if(online) LOG(ERR,"%d: lane_scan %d:%d: unknown start 0x%08X",rdo1,fee_ix,lane_ix,d[0]) ; + if((online && run_errors<10) || mode) { + LOG(ERR,"%d: lane_scan %d:%d: unknown start 0x%08X [0x%08X 0x%08X]",rdo1,fee_ix,lane_ix,d[0],d[-1],d[1]) ; + } + + if(d[0]==d[-1]) { + if(mode || (online && run_errors<10)) { + LOG(WARN,"%d: lane_scan %d:%d: retrying fix",rdo1,fee_ix,lane_ix) ; + } + d++ ; + goto retry_fix ; + } + else { + err |= 0x100000 ; + } + } else if((d[0]>>26)&0x3) { // SAMPA FIFOs overwritten! err |= 0x200000 ; - if(online) LOG(ERR,"%d: lane_scan %d:%d: SAMPA FIFO overwritten 0x%08X",rdo1,fee_ix,lane_ix,d[0]) ; + if(online || mode) LOG(ERR,"%d: lane_scan %d:%d: SAMPA FIFO overwritten 0x%08X",rdo1,fee_ix,lane_ix,d[0]) ; } d++ ; // skip 0xB.... @@ -642,8 +701,9 @@ u_int *itpc23::lane_scan(u_int *start) // should be at end of lane 0x7.... if((d[0]&0xF0000000)!=0x70000000) { // end of lane - err |= 0x400000 ; - if(online) LOG(ERR,"%d: lane_scan %d:%d: unknown end 0x%08X",rdo1,fee_ix,lane_ix,d[0]) ; + err |= 0x400000 ; + run_errors++ ; + if((online && run_errors<20)|| mode) LOG(ERR,"%d: lane_scan %d:%d: unknown end 0x%08X",rdo1,fee_ix,lane_ix,d[0]) ; } d++ ; // skip 0x7... @@ -658,7 +718,7 @@ u_int *itpc23::fee_non_trgd(u_int *start) int fee_words = 0 ; if(fee_evt_type != 0x02) { // no clue - if(online) LOG(ERR,"%d: fee_non_trgd %d: evt_type 0x%02X",rdo1,fee_ix,fee_evt_type) ; + if(online || mode) LOG(ERR,"%d: fee_non_trgd %d: evt_type 0x%02X",rdo1,fee_ix,fee_evt_type) ; while(d=1) LOG(TERR,"%d: T %d(%d,%d)",rdo1,token,trg_cmd,daq_cmd) ; if(log_level>=10) { - for(int i=0;i<8;i++) { - LOG(TERR,"rdo_scan %d/%d = 0x%08X",i,words,d[i]) ; - } + for(int i=0;i<8;i++) { + LOG(TERR,"rdo_scan %d/%d = 0x%08X",i,words,d[i]) ; + } } u_int mhz_start = d[3] ; @@ -893,7 +959,6 @@ int itpc23::rdo_scan(char *c_addr, int iwords) u_int fee_xoff = d[5]>>16 ; // actually prog_full u_int rdo_stuff = d[5]&0xFFFF ; u_int fee_empty = d[6]&0xFFFF ; -// u_int sig = d[7] ; l_fee_mask = 0 ; @@ -923,13 +988,17 @@ int itpc23::rdo_scan(char *c_addr, int iwords) // fee_mask,fee_synced,fee_overrun,fee_xoff,rdo_stuff,fee_empty,sig) ; if((fee_synced&fee_mask)!=fee_mask) { - if(online) LOG(ERR,"%d: evt %d: fee sync error 0x%04X, expect 0x%04X",rdo1,evt,fee_synced,fee_mask) ; + if(mode || (online)) LOG(ERR,"%d: evt %d: fee sync error 0x%04X, expect 0x%04X",rdo1,evt,fee_synced,fee_mask) ; // STOP: auto-recovery err |= 0x10 ; } if(fee_overrun&fee_mask) { - if(online) LOG(ERR,"%d: %d: RDOs fee FIFO overrun 0x%04X",rdo1,evt,fee_overrun&fee_mask) ; + if(mode || online) { + LOG(ERR,"%d: %d: RDOs fee FIFO overrun 0x%04X: words %d: 0x%04X 0x%04X 0x%04X 0x%04X", + rdo1,evt,fee_overrun&fee_mask,words, + fee_mask,l_fee_mask,fee_xoff,fee_empty) ; + } // STOP: auto-recovery err |= 0x10 ; } @@ -965,10 +1034,14 @@ int itpc23::rdo_scan(char *c_addr, int iwords) } if(got_it != 3) { - if(online) LOG(ERR,"%d: %d: no trailer (0x%08X), %d",rdo1,evt,trl[0],got_it) ; + if(mode || online) { + LOG(ERR,"%d: evt %d: no trailer (0x%08X), %d, words %d",rdo1,evt,trl[0],got_it,words) ; +// LOG(ERR," 0x%X 0x%X 0x%X",trl[1],trl[2],trl[3]) ; + } // STOP: auto-recovery err |= 0x2 ; -// for(int i=0;i>28)!=0xF)||((*d&0xFFFF)!=fee_mask)) { - if(online) LOG(ERR,"%d: evt %d: Bad FEE_START 0x%08X, expect 0x%08X",rdo1,evt,*d,0xF0000000|fee_mask) ; + if(mode || (online && run_errors<10)) LOG(ERR,"%d: evt %d: Bad FEE_START 0x%08X, expect 0x%08X",rdo1,evt,*d,0xF0000000|fee_mask) ; err |= 0x20 ; goto done ; } @@ -1089,7 +1162,7 @@ int itpc23::rdo_scan(char *c_addr, int iwords) if(err||prog_fulls) { - if(online) LOG(ERR,"%d: evt %d/%d: T %d,%d,%d: error 0x%08X, prog_fulls %d: words %d, %d us",rdo1,evt_trgd,evt, + if(online || mode) LOG(ERR,"%d: evt %d/%d: T %d,%d,%d: error 0x%08X, prog_fulls %d: words %d, %d us",rdo1,evt_trgd,evt, token,trg_cmd,daq_cmd, err, prog_fulls, @@ -1296,8 +1369,6 @@ itpc23::itpc23() data_c = 0 ; - fee_errs = 0 ; // just in case - fmt = 0 ; } diff --git a/StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx b/StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx index 2e857ee015a..cb3f90594d1 100644 --- a/StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx +++ b/StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx @@ -1353,7 +1353,7 @@ int tpc23_base::run_start() evt_trgd = 0 ; run_errors = 0 ; - fee_errs = 0 ; +// fee_errs = 0 ; return 0 ; @@ -1384,6 +1384,7 @@ tpc23_base::tpc23_base() s2_words = 0 ; no_cld = 0 ; + mode = 0 ; // rp_gain_tpx = 0 ; // rp_gain_itpc = 0 ; diff --git a/StRoot/RTS/src/DAQ_TPC23/tpc23_base.h b/StRoot/RTS/src/DAQ_TPC23/tpc23_base.h index 61862750698..0959eefa492 100644 --- a/StRoot/RTS/src/DAQ_TPC23/tpc23_base.h +++ b/StRoot/RTS/src/DAQ_TPC23/tpc23_base.h @@ -25,7 +25,7 @@ class tpc23_base { virtual int rdo_scan(char *mem, int words) ; virtual int from22to23(char *dta, int words) ; // rewrite the old FY22 raw data foramt to FY23 - int fee_errs ; +// int fee_errs ; u_char rts_id ; // tpx, itpc u_char fmt ; // 22: old data format, 23: FY23 data format @@ -49,6 +49,9 @@ class tpc23_base { u_char no_cld ; + + u_char mode ; // for various debugging steering + u_int last_ix ; int sequence_cou ; diff --git a/StRoot/RTS/src/DAQ_TPC23/tpx23.cxx b/StRoot/RTS/src/DAQ_TPC23/tpx23.cxx index 61c46c559b4..d46919a79fa 100644 --- a/StRoot/RTS/src/DAQ_TPC23/tpx23.cxx +++ b/StRoot/RTS/src/DAQ_TPC23/tpx23.cxx @@ -58,10 +58,11 @@ int tpx23::fee_scan() { u_int *h ; err = 0 ; // in class + int id_pre = -1 ; + int ch_pre = -1 ; + int s_cou ; + char retry ; -// u_char altro_present[256][16] ; - - get_token((char *)d_start,words) ; TLOG() ; @@ -85,16 +86,12 @@ int tpx23::fee_scan() // last valid FEE word is at d_end h = d_end ; - -// memset(altro_present,0,sizeof(altro_present)) ; - if(hdr_version) { - - - } - TLOGX(rdo1) ; - if(log_level>0) LOG(TERR,"%d: fee_scan",rdo1) ; + if(log_level>0) LOG(TERR,"%d: fee_scan",rdo1) ; + + u_int *h_to_continue ; + retry = 0 ; // NOTE: ALTRO scans from the end!!! while(h>(d_start+2)) { @@ -108,13 +105,85 @@ int tpx23::fee_scan() hi &= 0xFFFFF ; int wc = ((hi&0x3F)<<4)|((lo&0xF0000)>>16) ; // altro's word count - if(wc==0) continue ; + int id = (lo&0xFF0) >> 4 ; // altro id int ch = lo & 0xF ; + // sanity checks: 0xAAA & 0xA + u_int aaa = hi>>6 ; + u_int a = (lo>>12)&0xF ; + + + if((aaa!= 0x2AAA)||(a!=0xA)||(wc>437)) { + run_errors++ ; + if(run_errors<20) { + if((online || mode) && retry==0) { + LOG(ERR,"S%02d:%d: aid %d:%d, %d:%d: aaa 0x%X, a 0x%X, wc %d, %d", + sector1,rdo1,id,ch,id_pre,ch_pre,aaa,a,wc,d_end-h) ; + } + } + if(1) { + h++ ; + //LOG(ERR,"Retry aaa") ; + retry = 1 ; + continue ; + } + } + + if(wc==0) { + id_pre = id ; + ch_pre = ch ; + continue ; + } + + TLOGX(id) ; + +// if(mode & 3) { // debugging! + u_int aa = ((h[1]&0xFFFFF)>>10) ; + + //LOG(TERR,"aid %d:%d: 0x%X 0x%X",id,ch,h[0]&0xFFFFF,h[1]&0xFFFFF) ; + + if(aa != 0x2AA) { + run_errors++ ; + if(run_errors<20) { + if((online || mode) && retry==0) { + LOG(ERR,"S%02d:%d: aid %d:%d, %d:%d: aaa 0x%X, a 0x%X, aa 0x%X, wc %d", + sector1,rdo1,id,ch,id_pre,ch_pre,aaa,a,aa,wc) ; + } + } + + if(1) { + h++ ; + //LOG(ERR,"Retry aa") ; + retry = 1 ; + continue ; + } + } + else { + //LOG(WARN,"S%02d:%d: aid %d:%d, %d:%d: aaa 0x%X, a 0x%X, aa 0x%X, wc %d", + // sector1,rdo1,id,ch,id_pre,ch_pre,aaa,a,aa,wc) ; + + + } + +// } + + if(retry) { + if(online || mode) { + if(run_errors<20) { + LOG(WARN,"S%02d:%d: aid %d:%d, %d:%d: aaa 0x%X, a 0x%X, wc %d, %d -- OK", + sector1,rdo1,id,ch,id_pre,ch_pre,aaa,a,wc,d_end-h) ; + } + } + } + + retry = 0 ; + + h_to_continue = h ; // h+1 + for(int i=0;i437) { // garbage in the event... and now what??? run_errors++ ; if(run_errors<10) { - if(online) LOG(ERR,"S%02d:%d: rp %d:%d (aid %d:%d) : wc %d",sector1,rdo1,row,pad,id,ch,wc) ; + if(online) LOG(ERR,"S%02d:%d: rp %d:%d (aid %d:%d, %d:%d) : wc %d",sector1,rdo1,row,pad, + id,ch,id_pre,ch_pre, wc) ; } //err |= 0x10000 ; // signal an error because I am breaking out break ; } +#endif while(wc%4) wc++ ; @@ -260,12 +332,19 @@ int tpx23::fee_scan() if(t_len>440 || t_hi>440 || t_lo>440) { run_errors++ ; if(run_errors<20) { - if(online) LOG(ERR,"S%02d:%d: rp %d:%d (aid %d:%d), t_len %d, t_lo %d, t_hi %d",sector1,rdo1,row,pad, - id,ch, - t_len,t_lo,t_hi) ; + if(online||mode) LOG(ERR,"S%02d:%d: rp %d:%d (aid %d:%d, %d:%d), t_len %d, t_lo %d, t_hi %d; wc %d, ix %d, seq %d, %d", + sector1,rdo1,row,pad, + id,ch,id_pre,ch_pre, + t_len,t_lo,t_hi,wc,ix,seq_ix,d_end-h) ; } - if(t_len>510 || t_hi>510 || t_lo>510) { + if(t_len>440 || t_hi>440 || t_lo>440) { //err |= 0x20000 ; + if(1) { + //LOG(ERR,"Retry rp") ; + h = h_to_continue ; + retry = 1 ; + goto end_loop ; + } break ; } @@ -365,7 +444,7 @@ int tpx23::fee_scan() //LOG(TERR,"Here 2") ; - int s_cou = 0 ; + s_cou = 0 ; dd = d ; seq = s1[row][pad].seq ; @@ -417,8 +496,10 @@ int tpx23::fee_scan() } #endif - + id_pre = id ; + ch_pre = ch ; + end_loop:; } @@ -797,7 +878,7 @@ int tpx23::log_dump(char *c_addr, int wds) if(strstr(tmpbuff+st,"FEE power BAD")) { //err_status |= DET_ERR_OPER_PS ; - LOG(ERR,"---> [S%d:%d LOG] FEE power BAD -- powercycle (ignored)",s_real,r_real) ; + //LOG(ERR,"---> [S%d:%d LOG] FEE power BAD -- powercycle (ignored)",s_real,r_real) ; //err = -1 ; } } @@ -843,6 +924,7 @@ int tpx23::log_dump(char *c_addr, int wds) if(strstr(tmpbuff+st,"altro error")) { err = -1 ; + err_status |= 3 ; LOG(ERR,"---> [%d LOG] altro error -- restart run",rdo) ; } @@ -852,7 +934,9 @@ int tpx23::log_dump(char *c_addr, int wds) //LOG(WARN,"---> [%d LOG] ERR ALTRO -- CHECK THIS",rdo) ; } - + if(strstr(tmpbuff+st,"ERR: expired")) { + err = -1 ; + } if(err<0) { diff --git a/StRoot/RTS/src/DAQ_TPX/Makefile b/StRoot/RTS/src/DAQ_TPX/Makefile index 47ee919ace2..e77d0c8c11c 100644 --- a/StRoot/RTS/src/DAQ_TPX/Makefile +++ b/StRoot/RTS/src/DAQ_TPX/Makefile @@ -69,6 +69,8 @@ daq_tpx.o: tpxFCF_flags.h daq_tpx.o: tpxFCF_2D.h daq_tpx.o: ../DAQ_TPX/tpxFCF.h daq_tpx.o: tpxStat.h +daq_tpx.o: ../DAQ_TPC23/tpx23.h +daq_tpx.o: ../DAQ_TPC23/tpc23_base.h tpxCore.o: ../../../../StRoot/RTS/include/rtsLog.h tpxCore.o: ../../../../StRoot/RTS/include/TPX/tpx_altro_to_pad.h tpxCore.o: ../../../../StRoot/RTS/include/DAQ1000/ddl_struct.h diff --git a/StRoot/RTS/src/DAQ_TPX/daq_tpx.cxx b/StRoot/RTS/src/DAQ_TPX/daq_tpx.cxx index 77028f52d96..eaf2cf34655 100644 --- a/StRoot/RTS/src/DAQ_TPX/daq_tpx.cxx +++ b/StRoot/RTS/src/DAQ_TPX/daq_tpx.cxx @@ -89,6 +89,8 @@ daq_tpx::daq_tpx(daqReader *rts_caller) sfs_name = "tpx" ; caller = rts_caller ; + mode = 0 ; + if(caller) caller->insert(this, rts_id) ; // create now! @@ -973,6 +975,8 @@ daq_dta *daq_tpx::handle_adc(int sec, int rdo) t23->no_cld = 1 ; t23->log_level = 0 ; + t23->mode = mode ; + t23->data_c = 0 ; // &altro_c ; t23->tpx_d = 0 ; } diff --git a/StRoot/RTS/src/DAQ_TPX/daq_tpx.h b/StRoot/RTS/src/DAQ_TPX/daq_tpx.h index c0376570886..ad596ac44ca 100644 --- a/StRoot/RTS/src/DAQ_TPX/daq_tpx.h +++ b/StRoot/RTS/src/DAQ_TPX/daq_tpx.h @@ -79,6 +79,8 @@ class daq_tpx : public daq_det { tpx23 *t23 ; + + protected: public: @@ -91,6 +93,8 @@ class daq_tpx : public daq_det { char fcf_run_compatibility ; char fcf_do_cuts ; + u_char mode ; + // for use by simulation int sim_row_count ; unsigned char *sim_tpx_rowlen ; diff --git a/StRoot/RTS/src/RTS_EXAMPLE/rts_example.C b/StRoot/RTS/src/RTS_EXAMPLE/rts_example.C index 5c5572597ac..6b60b037afc 100644 --- a/StRoot/RTS/src/RTS_EXAMPLE/rts_example.C +++ b/StRoot/RTS/src/RTS_EXAMPLE/rts_example.C @@ -1874,10 +1874,14 @@ static int tinfo_doer(daqReader *rdr, const char *do_print) bx64 = (bx64 << 32) + bx_low; float bx_sec = bx64/9.3e6; int bx7 = bx64 % 120; - + + int addBits = swap16(evtDesc->addBits); + int trg_tkn = swap16(evtDesc->TrgToken) ; - printf("tinfo: token %d, pre %d, post %d\n",trg_tkn,pre,post) ; + if(addBits != 0) { + printf("tinfo: token %d, pre %d, post %d, 0x%016llx 0x%04x\n",trg_tkn,pre,post, rdr->daqbits64, addBits) ; + } int crate_sz[MAX_CONF_NUM]; int crate_internal_usec[MAX_CONF_NUM]; From 46e0ac71370317682c9d689f826810668580a39c Mon Sep 17 00:00:00 2001 From: dkapukchyan Date: Wed, 10 Apr 2024 10:24:37 -0700 Subject: [PATCH 22/25] Small fix for StFcsDb and StFcsWaveformFitMaker (#664) Got rid of unneeded cout statement in StFcsDb.cxx. Fixed StFcsWaveformFitMaker to not overwrite data in StFcsHit object when mAnaWaveform is false. --- StRoot/StFcsDbMaker/StFcsDb.cxx | 1 - StRoot/StFcsWaveformFitMaker/StFcsWaveformFitMaker.cxx | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/StRoot/StFcsDbMaker/StFcsDb.cxx b/StRoot/StFcsDbMaker/StFcsDb.cxx index e6e1feec7e3..bea6dc30797 100644 --- a/StRoot/StFcsDbMaker/StFcsDb.cxx +++ b/StRoot/StFcsDbMaker/StFcsDb.cxx @@ -756,7 +756,6 @@ StThreeVectorD StFcsDb::projectTrack(int det, const g2t_track_st* g2ttrk, const double linedir[3] = {g2ttrk->p[0],g2ttrk->p[1],g2ttrk->p[2]}; if( g2tvert!=0 ){ int vertind = g2ttrk->start_vertex_p - 1; //To correct for offset by one between fortran array and c array. 0 start index means it was generated at the starting vertex - std::cout << "+++++ DEBUG: vertind = " << vertind << " +++++" << std::endl; double linestart[3] = {g2tvert[vertind].ge_x[0],g2tvert[vertind].ge_x[1],g2tvert[vertind].ge_x[2]}; if( vertind >= 0 ){//Since start index==0 means no start then vertind<0 will default to using origin return projectLine(det, linedir, linestart, showermaxz); diff --git a/StRoot/StFcsWaveformFitMaker/StFcsWaveformFitMaker.cxx b/StRoot/StFcsWaveformFitMaker/StFcsWaveformFitMaker.cxx index d2e01307dd0..e7b3375110c 100644 --- a/StRoot/StFcsWaveformFitMaker/StFcsWaveformFitMaker.cxx +++ b/StRoot/StFcsWaveformFitMaker/StFcsWaveformFitMaker.cxx @@ -501,11 +501,11 @@ int StFcsWaveformFitMaker::Make() { if( mAnaWaveform ){ integral = analyzeWaveform(mEnergySelect[ehp],hits[i],res,func,res[6]); hits[i]->setAdcSum(integral); + hits[i]->setFitPeak(res[2]); + hits[i]->setFitSigma(res[3]); + hits[i]->setFitChi2(res[4]); + hits[i]->setNPeak(res[5]); } - hits[i]->setFitPeak(res[2]); - hits[i]->setFitSigma(res[3]); - hits[i]->setFitChi2(res[4]); - hits[i]->setNPeak(res[5]); //apply gain and update energy float gain = mDb->getGain(hits[i]); float gaincorr = mDb->getGainCorrection(hits[i]); From 4741177b4117a47e170546409bf5d08cac6ece51 Mon Sep 17 00:00:00 2001 From: Gene Van Buren <85305093+genevb@users.noreply.github.com> Date: Thu, 11 Apr 2024 17:13:22 -0400 Subject: [PATCH 23/25] Catch a memory leak in a TList (#681) This modification is to remove a memory leak that existed from creating a `TList` that was never cleared in `StHistUtil`. This is not used in production, but is used by some Offline QA macros, so those macros have been appropriately updated in this PR. --- StRoot/StAnalysisUtilities/StHistUtil.cxx | 9 +++++++++ StRoot/StAnalysisUtilities/StHistUtil.h | 2 ++ StRoot/macros/analysis/bfcread_hist_files_add.C | 13 +++++-------- .../macros/analysis/bfcread_hist_integrated_to_ps.C | 2 +- StRoot/macros/analysis/bfcread_hist_prefixes_add.C | 1 + .../analysis/bfcread_hist_prefixes_add_to_ps.C | 1 + 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/StRoot/StAnalysisUtilities/StHistUtil.cxx b/StRoot/StAnalysisUtilities/StHistUtil.cxx index c7501765c16..3d12eda3d6c 100644 --- a/StRoot/StAnalysisUtilities/StHistUtil.cxx +++ b/StRoot/StAnalysisUtilities/StHistUtil.cxx @@ -476,6 +476,9 @@ StHistUtil::StHistUtil(){ m_PaperHeight = 0; m_Detectors = ""; + + m_ItemsToClear = new TList(); + m_ItemsToClear->SetOwner(); } //_____________________________________________________________________________ @@ -500,6 +503,11 @@ StHistUtil::~StHistUtil(){ for (int ijk=0; ijkClear(); } //_____________________________________________________________________________ void StHistUtil::SetOutFile(const Char_t *fileName, const Char_t* type) { @@ -1789,6 +1797,7 @@ TList* StHistUtil::TrimListByPrefix(TList* dList, const Char_t* withPrefix) { (obj->InheritsFrom("TH1") && m_ListOfPrint->FindObject(obj->GetName())))) dList2->AddLast(obj); } + m_ItemsToClear->Add(dList2); return dList2; } //_____________________________________________________________________________ diff --git a/StRoot/StAnalysisUtilities/StHistUtil.h b/StRoot/StAnalysisUtilities/StHistUtil.h index fe96a562a47..1c366df2546 100644 --- a/StRoot/StAnalysisUtilities/StHistUtil.h +++ b/StRoot/StAnalysisUtilities/StHistUtil.h @@ -134,6 +134,7 @@ class StHistUtil { const Char_t** possibleSuffixes; //! TString m_Detectors; // List of detectors UInt_t m_PrintMode; // Which output files to print + TList* m_ItemsToClear; // List of items to clear at some intervals // For reference analyses: Bool_t m_analMode; @@ -154,6 +155,7 @@ class StHistUtil { public: StHistUtil(); virtual ~StHistUtil(); + virtual void Clear(); virtual void SetDebug(Bool_t dbg=kTRUE) { debug=dbg; } virtual Bool_t Debug() { return debug; } virtual Int_t DrawHists(const Char_t *dirName="EventQA"); diff --git a/StRoot/macros/analysis/bfcread_hist_files_add.C b/StRoot/macros/analysis/bfcread_hist_files_add.C index f75a5875a9a..716483f3fd3 100644 --- a/StRoot/macros/analysis/bfcread_hist_files_add.C +++ b/StRoot/macros/analysis/bfcread_hist_files_add.C @@ -229,9 +229,6 @@ void bfcread_hist_files_add( cout << "bfcread_hist_files_add.C, # histograms copied = " << hCCount << endl; - HM[bnum]->SetHArraySize(HU[bnum]->getNewHistSize()); - HM[bnum]->SetHArray(HU[bnum]->getNewHist()); - HM[bnum]->Make(); } // first time else { @@ -243,13 +240,13 @@ void bfcread_hist_files_add( cout << "bfcread_hist_files_add.C, # histograms added = " << hCCount << endl; - HM[bnum]->SetHArraySize(HU[bnum]->getNewHistSize()); - HM[bnum]->SetHArray(HU[bnum]->getNewHist()); - HM[bnum]->Make(); - } //else (ifl not #1) - dirList->Delete(); + + HM[bnum]->SetHArraySize(HU[bnum]->getNewHistSize()); + HM[bnum]->SetHArray(HU[bnum]->getNewHist()); + HM[bnum]->Make(); + HU[bnum]->Clear(); // to see an example of histograms being added together: // TH1** kathyArray = HU[bnum]->getNewHist(); diff --git a/StRoot/macros/analysis/bfcread_hist_integrated_to_ps.C b/StRoot/macros/analysis/bfcread_hist_integrated_to_ps.C index a39b473555f..422e408e3d2 100644 --- a/StRoot/macros/analysis/bfcread_hist_integrated_to_ps.C +++ b/StRoot/macros/analysis/bfcread_hist_integrated_to_ps.C @@ -204,7 +204,7 @@ void bfcread_hist_integrated_to_ps( cout << "bfcread_hist_integrated_to_ps.C, # histograms added with prefix " << HU->GetPrefix(prefixNum) << " = " << hCCount << endl; } // first set or not - delete dirList; // Only when using PrintList or Prefixes + HU->Clear(); } // found hists } // loop over prefixes diff --git a/StRoot/macros/analysis/bfcread_hist_prefixes_add.C b/StRoot/macros/analysis/bfcread_hist_prefixes_add.C index 4d5f5669c24..76c57db9e3b 100644 --- a/StRoot/macros/analysis/bfcread_hist_prefixes_add.C +++ b/StRoot/macros/analysis/bfcread_hist_prefixes_add.C @@ -163,6 +163,7 @@ void bfcread_hist_prefixes_add( HU[nbranch]->GetPrefix(prefixNum) << " = " << hCCount << endl; } // first set or not } // found hists + HU[nbranch]->Clear(); } // loop over prefixes diff --git a/StRoot/macros/analysis/bfcread_hist_prefixes_add_to_ps.C b/StRoot/macros/analysis/bfcread_hist_prefixes_add_to_ps.C index 2f0dbcf6ced..d8bfc8984fd 100644 --- a/StRoot/macros/analysis/bfcread_hist_prefixes_add_to_ps.C +++ b/StRoot/macros/analysis/bfcread_hist_prefixes_add_to_ps.C @@ -168,6 +168,7 @@ void bfcread_hist_prefixes_add_to_ps( HO->GetPrefix(prefixNum) << " = " << hCCount << endl; } // first set or not } // found hists + HO->Clear(); } // loop over prefixes From 0b6d598d86351fbc98e3360ea08a262f3a9d1002 Mon Sep 17 00:00:00 2001 From: Gene Van Buren <85305093+genevb@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:55:07 -0400 Subject: [PATCH 24/25] Proper dependencies for FCS Pi0 used in QA (#669) This resolves the issue brought in PR #437 : St_QA_Maker should not directly depend on MuDst (a solution proposed in #437 ), but instead should depend on the StFcsPi0FinderForEcal, which itself has a dependency on MuDst. --- StRoot/StBFChain/BigFullChain.h | 4 +++- StRoot/St_QA_Maker/StEventQAMaker.cxx | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/StRoot/StBFChain/BigFullChain.h b/StRoot/StBFChain/BigFullChain.h index ae8294bd260..57880357085 100644 --- a/StRoot/StBFChain/BigFullChain.h +++ b/StRoot/StBFChain/BigFullChain.h @@ -1648,6 +1648,7 @@ Bfc_st BFC[] = { // standard chains "StFcsClusterMaker","StFcsClusterMaker","Fill FCS clusters", kFALSE}, {"fcsPoint" ,"","fcsChain", "StEvent,fcsDb", "StFcsPointMaker","StFcsPointMaker,libMinuit","Fill FCS points", kFALSE}, + {"fcsPi0Libs","", "", "MuDst", "", "StFcsPi0FinderForEcal", "Libs for FCS Pi0 Finder", kFALSE}, // FTT {"ftt","fttChain","","FttDat,FttHitCalib,FttClu,FttPoint", "StMaker","StChain","FST chain" ,kFALSE}, {"FttDat","","fttChain","StEvent","StFttRawHitMaker","StFttRawHitMaker,StEvent", @@ -1931,7 +1932,8 @@ Bfc_st BFC[] = { // standard chains {"ppDAQfilter1","","","" ,"","",STAR_CHAIN_OBSOLETE,kFALSE}, {"ppLPeval1" ,"","","" ,"","",STAR_CHAIN_OBSOLETE,kFALSE}, {"QA" ,"","","" ,"","",STAR_CHAIN_OBSOLETE,kFALSE}, - {"EventQA","EventQA","","QUtils,Event","StEventQAMaker" ,"St_QA_Maker","Filling Y2/Y3 Qa histo",kFALSE}, + {"EventQA","EventQA","","QUtils,Event,fcsPi0Libs","StEventQAMaker" + ,"St_QA_Maker","Filling Y2/Y3 Qa histo",kFALSE}, {"QAC" ,"CosmicsQA","globT","" ,"StQACosmicMaker","StQACosmicMaker","",kFALSE}, {"QAalltrigs" ,"", "","", "","","Analyze all triggers in QA",kFALSE}, {"HitFilt" ,"", "","", "StHitFilterMaker","StHitFilterMaker","Hit filter Maker",kFALSE}, diff --git a/StRoot/St_QA_Maker/StEventQAMaker.cxx b/StRoot/St_QA_Maker/StEventQAMaker.cxx index e89040a8f3e..b25f8942723 100644 --- a/StRoot/St_QA_Maker/StEventQAMaker.cxx +++ b/StRoot/St_QA_Maker/StEventQAMaker.cxx @@ -46,9 +46,7 @@ #include "StEpdCollection.h" //fcs -#define SKIPDefImp -#include "StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.cxx" -#undef SKIPDefImp +#include "StFcsPi0FinderForEcal/StFcsPi0FinderForEcal.h" #include "StEvent/StTpcRawData.h" From 61338c568452f6a29b3ce7eff8606fa660d92bd5 Mon Sep 17 00:00:00 2001 From: Daniel Brandenburg Date: Mon, 15 Apr 2024 22:57:29 -0400 Subject: [PATCH 25/25] StFttDbMaker: Warning when DB not found (#682) Checks if databases are returned and issues a warning if not (instead of set faulting) Warning message provides helpful info about the name of the local file (debug only) to be used instead of the DB --- StRoot/StFttDbMaker/StFttDbMaker.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/StRoot/StFttDbMaker/StFttDbMaker.cxx b/StRoot/StFttDbMaker/StFttDbMaker.cxx index dc9a2a0fb2e..7a91ffe62d3 100644 --- a/StRoot/StFttDbMaker/StFttDbMaker.cxx +++ b/StRoot/StFttDbMaker/StFttDbMaker.cxx @@ -48,8 +48,12 @@ int StFttDbMaker::InitRun(int runNumber) { } else { // default TDataSet *mDbDataSet = GetDataBase("Geometry/ftt/fttHardwareMap"); - St_fttHardwareMap *dataset = (St_fttHardwareMap*) mDbDataSet->Find("fttHardwareMap"); - mFttDb->loadHardwareMapFromDb( dataset ); + if (mDbDataSet){ + St_fttHardwareMap *dataset = (St_fttHardwareMap*) mDbDataSet->Find("fttHardwareMap"); + mFttDb->loadHardwareMapFromDb( dataset ); + } else { + LOG_WARN << "Cannot access `Geometry/ftt/fttHardwareMap` and no local `vmm_map.dat` file provided. Cannot load ftt hardware mapping" << endm; + } } @@ -58,6 +62,8 @@ int StFttDbMaker::InitRun(int runNumber) { if ( mDbDataSetDW ) { St_fttDataWindows *dataset = (St_fttDataWindows*) mDbDataSetDW->Find("fttDataWindows"); mFttDb->loadDataWindowsFromDb( dataset ); + } else { + LOG_WARN << "Cannot access `Calibrations/ftt/fttDataWindows`" << endm; }