Skip to content

Commit

Permalink
Adding option to read from MuDst in StFcsRawHitMaker (#226)
Browse files Browse the repository at this point in the history
* Adding option to read from Mudst in StFcsRawHitMaker, and example macro to read from Mudst, re-create StFcsHit in StEvent on momery, and re-run FCS reconstruction makers.

* unsigned int -> int
  • Loading branch information
akioogawa authored and jml985 committed Dec 7, 2021
1 parent f01b3d6 commit cb7b57a
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
64 changes: 64 additions & 0 deletions StRoot/StFcsFastSimulatorMaker/macro/runMudst.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
void runMudst(char* file="st_cosmic_adc_22326042_raw_0000005.MuDst.root",
int ifile=-1, Int_t nevt=-1, char* outdir=".", int readMuDst=1){
gROOT->Macro("Load.C");
gROOT->Macro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
gSystem->Load("StEventMaker");
gSystem->Load("StFcsDbMaker");
gSystem->Load("StFcsRawHitMaker");
gSystem->Load("StFcsWaveformFitMaker");
gSystem->Load("StFcsClusterMaker");
gSystem->Load("libMinuit");
gSystem->Load("StFcsPointMaker");

StChain* chain = new StChain("StChain"); chain->SetDEBUG(0);
StMuDstMaker* muDstMaker = new StMuDstMaker(0, 0, "", file,".", 1000, "MuDst");
int n=muDstMaker->tree()->GetEntries();
printf("Found %d entries in Mudst\n",n);
int start=0, stop=n;
if(ifile>=0){
int start=ifile*nevt;
int stop=(ifile+1)*nevt-1;
if(n<start) {printf(" No event left. Exiting\n"); return;}
if(n<stop) {printf(" Overwriting end event# stop=%d\n",n); stop=n;}
}else if(nevt>=0 && nevt<n){
stop=nevt;
}else if(nevt==-2){
stop=2000000000;
}
printf("Doing Event=%d to %d\n",start,stop);

St_db_Maker* dbMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb");
if(dbMk){
dbMk->SetAttr("blacklist", "tpc");
dbMk->SetAttr("blacklist", "svt");
dbMk->SetAttr("blacklist", "ssd");
dbMk->SetAttr("blacklist", "ist");
dbMk->SetAttr("blacklist", "pxl");
dbMk->SetAttr("blacklist", "pp2pp");
dbMk->SetAttr("blacklist", "ftpc");
dbMk->SetAttr("blacklist", "emc");
dbMk->SetAttr("blacklist", "eemc");
dbMk->SetAttr("blacklist", "mtd");
dbMk->SetAttr("blacklist", "pmd");
dbMk->SetAttr("blacklist", "tof");
dbMk->SetAttr("blacklist", "etof");
dbMk->SetAttr("blacklist", "rhicf");
}

StFcsDbMaker *fcsDbMkr= new StFcsDbMaker();
StFcsDb* fcsDb = (StFcsDb*) chain->GetDataSet("fcsDb");
StEventMaker* eventMk = new StEventMaker();
StFcsRawHitMaker* hit = new StFcsRawHitMaker();
hit->setReadMuDst(readMuDst);
StFcsWaveformFitMaker *wff= new StFcsWaveformFitMaker();
StFcsClusterMaker *clu= new StFcsClusterMaker();
StFcsPointMaker *poi= new StFcsPointMaker();
wff->SetDebug();
clu->SetDebug();
poi->SetDebug();

chain->Init();
chain->EventLoop(start,stop);
chain->Finish();
delete chain;
}
16 changes: 16 additions & 0 deletions StRoot/StFcsRawHitMaker/StFcsRawHitMaker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "StRoot/StEvent/StFcsCollection.h"
#include "StRoot/StEvent/StFcsHit.h"
#include "StRoot/StFcsDbMaker/StFcsDb.h"
#include "StMuDSTMaker/COMMON/StMuTypes.hh"
#include "StMuDSTMaker/COMMON/StMuFcsUtil.h"

StFcsRawHitMaker::StFcsRawHitMaker( const char* name) :
StRTSBaseMaker("fcs",name){
Expand All @@ -37,6 +39,9 @@ int StFcsRawHitMaker::Make() {
AddData(mEvent);
LOG_INFO <<"Added StEvent"<<endm;
}

if(mReadMuDst>0) return readMuDst();

mFcsCollectionPtr=mEvent->fcsCollection();
if(!mFcsCollectionPtr) {
mFcsCollectionPtr=new StFcsCollection();
Expand All @@ -47,6 +52,7 @@ int StFcsRawHitMaker::Make() {
LOG_DEBUG <<"Found StFcsCollection"<<endm;
}


StRtsTable* dd=0;
int nData=0, nValidData=0;
const char* mode[2]={"adc","zs"};
Expand Down Expand Up @@ -91,6 +97,16 @@ int StFcsRawHitMaker::Make() {
return kStOK;
};

int StFcsRawHitMaker::readMuDst() {
StMuDst* mudst = (StMuDst*)GetInputDS("MuDst");
if(!mudst){LOG_ERROR<<"StFcsRawHitMaker::readMuDst() found no MuDst"<<endm; return kStErr;}
StMuFcsCollection* mufcsColl= mudst->muFcsCollection();
if(!mufcsColl){LOG_ERROR<<"StFcsRawHitMaker::readMuDst found no MuFcsCollection"<<endm; return kStErr;}
StMuFcsUtil util;
mFcsCollectionPtr = util.getFcs(mufcsColl);
mEvent->setFcsCollection(mFcsCollectionPtr);
}

void StFcsRawHitMaker::Clear( Option_t *opts ){};

ClassImp(StFcsRawHitMaker);
Expand Down
8 changes: 6 additions & 2 deletions StRoot/StFcsRawHitMaker/StFcsRawHitMaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class StFcsRawHitMaker : public StRTSBaseMaker {

void setReadMode(int v) {mReadMode=v;}
void setDebug(int v=1) {SetDebug(v);} //!backward compatubility

void setReadMuDst(int v=1) {mReadMuDst=v;} //!reading Mudst/StMuFcsHit into StEvent/StFcsHit

// Get CVS
virtual const char *GetCVS() const;

Expand All @@ -34,7 +35,10 @@ class StFcsRawHitMaker : public StRTSBaseMaker {
StFcsCollection *mFcsCollectionPtr;
unsigned int mRun=0;
StFcsDb* mFcsDb=0;
unsigned int mReadMode=1;
int mReadMode=1;
int mReadMuDst=0;

int readMuDst();

ClassDef(StFcsRawHitMaker,1);
};
Expand Down

0 comments on commit cb7b57a

Please # to comment.