1 #include "StEmcMicroDstMaker.h"
3 #include "StEventTypes.h"
4 #include "StEmcMicroEvent.h"
5 #include "StIOMaker/StIOMaker.h"
6 #include "StEmcUtil/filters/StEmcFilter.h"
7 #include "StEmcMicroUtil.h"
8 #include "StChain/StEvtHddr.h"
9 #include "StTreeMaker/StTreeMaker.h"
44 mMicroEventChain=NULL;
46 mDoCreateStEvent=kTRUE;
48 mDoSavePrimaries = kTRUE;
49 mDoSaveGlobals = kTRUE;
59 StEmcMicroDstMaker::~StEmcMicroDstMaker()
61 if(mMicroUtil)
delete mMicroUtil;
62 if(mGFilter)
delete mGFilter;
63 if(mPFilter)
delete mPFilter;
70 mAcc=
new TH1F(
"macc",
"Events accepted and rejected",2,-0.5,1.5);
72 mMicroUtil->setPrimaryFilter(mPFilter);
73 mMicroUtil->setGlobalFilter(mGFilter);
84 return StMaker::Init();
91 cout <<
"***** StEmcMicroDstMaker::Make() *******************************\n";
92 if(mMicroEvent)
delete mMicroEvent;
99 mStEvent = (
StEvent*) GetInputDS(
"StEvent");
104 if(summary) BF = summary->magneticField()/10.;
110 if (!mPFilter->
accept(mStEvent))
112 cout <<
"StEmcMicroDstMaker::Make(): event not accepted." << endl;
123 const char* chp = strrchr(IO->GetFile(),
'/');
124 if(chp) mEventFile = strrchr(IO->GetFile(),
'/')+1;
125 else mEventFile = IO->GetFile();
137 StTree *t = tree->GetTree();;
138 mEventFile=t->GetBaseName();
142 if(mAccEv%100==0) mFileCounter++;
144 sprintf(f,
"EmcEvent.file%04d",mFileCounter);
152 if(mEventFile!=mEventFileOld)
154 if(mMicroDstFile)
if(mMicroDstFile->IsOpen())
156 mMicroDstFile->Write(0,TObject::kOverwrite);
157 mMicroDstFile->Close();
159 if (mMicroEvent)
delete mMicroEvent;
160 if (mMicroDstFile)
delete mMicroDstFile;
164 mEventFileOld=mEventFile;
166 else cout <<
"Filename being written: "<<mEventFile.Data()<<endl;
172 mMicroEvent->setCTB(old->
getCTB());
173 mMicroEvent->setZDCe(old->
getZDCe());
174 mMicroEvent->setZDCw(old->
getZDCw());
176 mMicroEvent->setBBCe(old->
getBBCe());
177 mMicroEvent->setBBCw(old->
getBBCw());
196 mMicroEvent->setFpd(fpd);
199 cout <<
"before Fill()" << endl;
201 cout <<
"after Fill()" << endl;
209 if(mCurMicroEvent<mNMicroEvents)
213 mMicroEventChain->SetBranchAddress(
"MicroEvent",&mMicroEvent);
214 mMicroEventChain->GetEntry(mStart+mCurMicroEvent++);
219 hd->SetGMTime(GMTTime);
220 mEventFile = strrchr(mMicroEventChain->GetFile()->GetName(),
'/')+1;
221 if(mEventFile.EndsWith(
".emcEvent.root"))
223 Int_t size=mEventFile.Sizeof();
224 mEventFile.Remove(size-15,14);
228 mStEvent = mMicroUtil->
getStEvent(mMicroEvent);
249 if(mMicroDstFile->IsOpen())
251 mMicroDstFile->Write(0,TObject::kOverwrite);
252 mMicroDstFile->Close();
265 Int_t bufsize = 256000;
266 if (split) bufsize /= 16;
270 cout <<
"Input file = "<<mEventFile.Data()<<endl;
271 TString* filestring =
new TString(mEventDir);
272 filestring->Append(mEventFile);
274 if(filestring->EndsWith(
".event.root"))
276 Int_t size=filestring->Sizeof();
277 filestring->Remove(size-12,11);
280 filestring->Append(
".emcEvent.root");
281 cout <<
"Output file = "<<filestring->Data()<<endl;
283 mMicroDstFile =
new TFile(filestring->Data(),
"RECREATE",
"EMC Micro DST file");
286 cout <<
"##### EmcMicroEventMaker: Warning: no MicroEvents file = " << filestring->Data() << endl;
289 mMicroDstFile->SetCompressionLevel(comp);
290 mEmcTree =
new TTree(
"EmcTree",
"EMC Micro Tree");
293 cout <<
"##### EmcMicroEventMaker: Warning: No EmcMicroTree" << endl;
296 mEmcTree->SetAutoSave(1000000);
297 mEmcTree->Branch(
"MicroEvent",
"StEmcMicroEvent", &mMicroEvent,bufsize,split);
307 if(!mMicroEventChain)
309 mMicroEventChain =
new TChain(
"EmcTree",
"EMC Micro chain");
314 mMicroEventChain->Add(file);
315 mNMicroEvents=(Int_t)mMicroEventChain->GetEntries();
316 cout <<
"Total number of events in the chain = "<<mNMicroEvents<<endl;
void setSavePrimaries(Bool_t a)
Save or don't primary tracks. Default is kTRUE. Track selection is done by PrimaryFilter.
Int_t initMicroEventFile()
Int_t getZDCe() const
Return ZDC east.
void setMinMult(Float_t a)
minimum multiplicity. Default is 0.
Int_t getBBCe() const
Return BBC east.
Int_t getSumAdcPreShower1() const
Return FPD Sum ADC Pre Shower 1.
void setSaveEmc(Bool_t a)
Save or don't EMC data. Default is kTRUE.
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
void setPrintLog(Bool_t a)
Print log if event is rejected.
Int_t getSumAdcSouth() const
Return FPD Sum ADC South.
StEmcMicroDstMaker(const Char_t *name="EmcMicroDst")
Int_t getEventTime() const
Return event time (unix time)
Int_t getSumAdcSmdX() const
Return FPD Sum ADC Shower Max X.
StEmcMicroEvent * getMicroEvent()
Return current StEmcMicroEvent.
void setEmcPresent(Bool_t a)
requires EMC data on event (kTRUE, kFALSE). Default value is kTRUE.
StFpdMicroCollection * getFpd() const
Return FPD Information.
void setHavePrimaries(Bool_t a)
requires at least one primary track (kTRUE, kFALSE). Default is kTRUE.
const char * getCurrentFile()
Return currect .event.root file.
void setFitPointsCut(Int_t a)
number of fit points in the track. Default is 0.
Float_t getZVertexZDC() const
Return Z vertex from ZDC.
Int_t getZDCw() const
Return ZDC west.
void setSaveV0(Bool_t a)
Save or don't V0 data. Default is kFALSE.
void setHaveVertex(Bool_t a)
requires a valid vertex (kTRUE, kFALSE). Default is kTRUE.
void setMustProjectEmc(Bool_t a)
requires that the track is projected on a valid EMC tower (kTRUE, kFALSE). Default is kTRUE...
StEvent * getStEvent(StEmcMicroEvent *)
Returns StEvent.
Int_t getSumAdcNorth() const
Return FPD Sum ADC North.
void setSaveGlobals(Bool_t a)
Save or don't global tracks. Default is kTRUE. Track selection is done by GlobalFilter.
Int_t getSpinBits() const
Return Spin bits.
Int_t getBBCNHits() const
Return BBC number of hits.
void setBField(Float_t a)
just set the BField value for track projection in tesla. Default is 0.5 tesla.
void setPtCut(Float_t a)
transverse momentm cut (GeV/c). Default is 0.
Int_t getBBCw() const
Return BBC west.
Int_t getSumAdcPreShower2() const
Return FPD Sum ADC Pre Shower 2.
Bool_t accept(StEvent *)
Returns kTRUE/kFALSE if StEvent is accepted.
Int_t getSumAdcBottom() const
Return FPD Sum ADC Bottom.
Int_t getSumAdcTop() const
Return FPD Sum ADC Top.
void setDCACut(Float_t a)
DCA cut on track in cm. Default is 300000.
void setZVertexCut(Float_t a)
Z Vertex threshold in cm. Default is 20 cm.
void setSaveFpd(Bool_t a)
Save or don't FPD data. Default is kFALSE.
void setEtaMin(Float_t a)
minimum eta of the track (momentum). Default is -10000.
UInt_t getBunchCrossing7bit() const
Return Bunch Crossing Id 7 bits.
void setEtaMax(Float_t a)
maximum eta of the track (momentum). Default is +10000.
StEmcMicroEvent * getMicroEvent(StEvent *)
Returns StEmcMicroEvent.
void setMaxMult(Float_t a)
maximum multiplicity. Default is 100000.
Int_t getSumAdcSmdY() const
Return FPD Sum ADC Shower Max Y.
Float_t getZVertexBBC() const
Return BBC Z Vertex.
void addMicroEventFile(char *)
Add EMC micro DST file to read.
UInt_t getBunchCrossing() const
Return Bunch Crossing.
Int_t getCTB() const
Return CTB sum.
Int_t getToken() const
Return FPD token.