#include "SasyTime.h" #include "TChain.h" #include "TBranch.h" #include #include "TList.h" #include "TSystem.h" #include "TFile.h" #include #include #include #include #include #include #include #include #include "TRandom.h" #include #include "definitions.h" #include "LegsTagHit.h" #ifndef LegsEvent_h #define LegsEvent_h class LegsHit; class LegsPart; class LegsPid; class LegsEvent : public TObject { private: static LegsEvent* fInstance; protected: Int_t fCount; UChar_t fDet[kMaxDetHitPerEvent]; UChar_t fFace[kMaxDetHitPerEvent]; UChar_t fRow[kMaxDetHitPerEvent]; UChar_t fCol[kMaxDetHitPerEvent]; UShort_t fAdc1[kMaxDetHitPerEvent]; UShort_t fTdc1[kMaxDetHitPerEvent]; UShort_t fAdc2[kMaxDetHitPerEvent]; UShort_t fTdc2[kMaxDetHitPerEvent]; Float_t fLgt[kMaxDetHitPerEvent]; Float_t fTof[kMaxDetHitPerEvent]; UChar_t fClump[kMaxDetHitPerEvent]; Int_t fTagCount; UChar_t fTagID[64]; Float_t fTagEgy[64]; UShort_t fTagTdc[64]; Int_t fStCount; UChar_t fStID[30]; UShort_t fStTdc[30]; Int_t tagck_count; UChar_t tagck_id[64]; // planning to use 121604 UShort_t tagck_tdc[64]; UChar_t fRegPol; UInt_t fRegIO; UInt_t fTime; UInt_t fFeraReg; Int_t fSlrCount; UInt_t fRawSlr[24]; UInt_t fLivSlr[24]; // The following variables are not used at the moment Feb 29, 00 Int_t fPCount; Float_t fPLgt[40]; Float_t fPEgy[40]; Float_t fPR[40]; Float_t fPTheta[40]; Float_t fPPhi[40]; Float_t fPTof[40]; Float_t fPDlgt[40]; Float_t fPDegy[40]; Float_t fPMom[40]; UChar_t fPId[40]; UChar_t fPNhits[40]; Int_t fMcCount; UChar_t fMcID[10]; Float_t fMcPX[10]; Float_t fMcPY[10]; Float_t fMcPZ[10]; Float_t fMcEgy[10]; Int_t fMcTrue; Float_t fMcX[1]; Float_t fMcY[1]; Float_t fMcZ[1]; UChar_t fMcPol[1]; Float_t fMcPhotEgy[1]; bool fSkipMultipleTagHitsEvents; // if this flag is set then program will skip multiple tag hit events, default value is set in LegsEvent::LegsEvent() (use function LegsRun::SetSkipMultipleTagHitsEvents() to change value) bool fLoopOverMultipleTagHits; // if this flag is set then program will automatically loop over multiple tag hits in an event, default value is set in LegsEvent::LegsEvent() (use function LegsRun::SetLoopOverMultipleTagHits() to change value) bool fIsGeantSimulation; TList* fListOfSelectors; TList* fListOfStandardMakers; TList* fListOfUserMakers; TIter* fSelectorIter; TIter* fStandardMakerIter; TIter* fUserMakerIter; TFile* fOutFile; string fPrefix; Int_t fNumberOfFilesInRun; Int_t fCurrent; Int_t fStart; // index of entry from which to start processing tree Int_t fEntries; // total number of entries in a tree Int_t fFinish; // index of entry up to which to process the tree bool fTmpBool; Int_t fFluxMonitor; bool fDetON; TTree* fSubsetTree; TFile* fSubsetTreeFile; bool fTargetEmpty; bool ConvertInput(); bool ConvertInputVetos(); void DataOK(UShort_t data); vector > fFluxPolTagBin; vector > fFluxPolTagGroup; vector > fFluxErrPolTagGroup; UChar_t GetTagIdFromTagEgy() const; UShort_t fDefaultPart; // default particle ID set by user bool fNotToProcess[kNumDetGroups]; Int_t fMyRank; // rank of this process Int_t fNtasks; // number of nodes string fHostName; #ifdef PARALLEL Int_t fNeventsPerNodePerCycle; // specify how many events each slave node will process before reporting(communicating) to master node if number too small - a lot of network traffic will occur but load distribution between nodes will be better. If number too large - slow node may make you wait for a long time when all others already finished. #endif public: static LegsEvent* Instance() { #ifndef NDEBUG if(fInstance == 0) { cout << " You tried to use LegsEvent before creating an instance of the class."<< endl; exit(1); } #endif return fInstance; } LegsEvent(){;} LegsEvent(const char* run, const char* suffix = NULL, Int_t simRunNumber = 4341); virtual ~LegsEvent() { if(fTree) delete fTree; if(fGeo) delete fGeo; if(fDB) delete fDB; if(fListOfStandardMakers) delete fListOfStandardMakers; if(fListOfUserMakers) delete fListOfUserMakers; if(fStandardMakerIter) delete fStandardMakerIter; if(fUserMakerIter) delete fUserMakerIter; } void NotToProcess(UChar_t det); bool GetNotToProcess(UChar_t det) { return fNotToProcess[det];} TChain* fTree;//! pointer to the analyzed TChain void CdOutFile(){fOutFile->cd();} //Declaration of leaves types Int_t GetCount() const{ return fCount;} UChar_t GetDet(UShort_t i) const { assert(iGetBranch("adc2") == NULL) return 0; // in subsets I might have adc2 branch deleted for XTC or PB return fAdc2[i]; } UShort_t GetTdc2(UShort_t i) const { assert(iGetBranch("tdc2") == NULL) return 0; // in subsets I might have tdc2 branch deleted for XTC or PB return fTdc2[i]; } Double_t GetLgt(UShort_t i) const { assert(i= 0); assert(i < fTagCount); assert(fTagID[i] >= 1); assert(fTagID[i] <= kNumTagBins); return fTagID[i]; } UChar_t GetTagID(UInt_t i=1000) const { // in simulation I always have only one "tagger hit" which has // energy of incoming beam photon energy if(GeantSimulation()) { assert(fTagHitVec.size() == 1); return fTagHitVec[0].GetId(); } // in data I may have acidental hits as well as real one coming from tagged electron if(fTagCount == 0) { assert("tag_count is ZERO"=="!!!"); } assert(fTagHit != NULL); if(i==1000) return fTagHit->GetId(); // by default take current tag hit (if NOT doing one hit analysis this will always default to 0) assert(iGetEgy(); // by default take current tag hit (if NOT doing one hit analysis this will always default to 0) // I should check if index of the hit is not larger than number of tagger hits is. assert(iGetTdc(); // by default take current tag hit (if NOT doing one hit analysis this will always default to 0) assert(i 255 if(GeantSimulation()) { assert(i > fClumpVec; // vector of clumps for an event vector fHitVec; // vector of CALORIMETER hits for an event vector fVetoVec; // vector of VETO hits for an event vector fOtherVec; // vector of "other" hits for an event vector fPartVec; // vector of simple clusters-particles for an event vector fPidVec; // vector of physical 4-momentum particles for an event vector fTagHitVec; // vector of tagger hits for an event LegsTagHit* fTagHit; // tagger hit Stat_t fEntrySize; LegsDB* fDB; // calibration files handling LegsGeo* fGeo; // geometry vector fTagBinBoundary; TargetMaterial_t fTargetMaterial; // functions Int_t GetStart() const { return fStart;} Int_t GetFinish() const {return fFinish;} Int_t GetCurrent() const { return fCurrent;} UInt_t GetRunNumber(UInt_t data=0) const; bool IsDet(UShort_t detId, Short_t num=1) const; // returns TRUE if at least [data] of detectors are hit with threshold of thresh. bool IsXv(Short_t num=1,const Double_t& thresh = 0.0) const; bool IsXt(Short_t num=1) const { return IsDet(2,num);} bool IsXc(Short_t num=1) const { return IsDet(3,num);} bool IsPv(Short_t num=1) const { return IsDet(4,num);} bool IsPn(Short_t num=1) const { return IsDet(5,num);} bool IsPb(Short_t num=1) const { return IsDet(6,num); } bool IsPf() const { return IsDet(7);} bool IsCv() const { return IsDet(8);} bool IsCG3() const { return IsDet(9);} bool IsNb(Short_t num=1) const { return IsDet(10,num); } bool IsNv(Short_t num=1) const { return IsDet(11,num); } bool IsPbp() const { // returns TRUE if 40 of blocks in Pb-wall are hit. // returns FALSE otherwise if(rpb_count >=40) return true; return false; } bool IsXvFace(Short_t face, const Double_t& thresh = 0.0) const; bool IsXtFace(Short_t face, const Double_t& thresh = 0.0) const; bool AreTwoNeutralsInXT() const; bool GeantSimulation() const { return fIsGeantSimulation;} void Show(UInt_t event = 0); void AddToListOfSelectors(TObject* data); void AddToListOfStandardMakers(TObject* data); void AddToListOfUserMakers(TObject* data); void IncrementRawDetectorHitsCounters(); Double_t GetFluxPolTagBin(UChar_t pol,UChar_t tagbin) const { // tagbin =0 gives sum of fluxes of all bins for given pol #ifndef NDEBUG if(! (pol < kNumPolStates)) cout << "pol=" << (UShort_t)pol << endl; assert(pol < kNumPolStates); assert(tagbin <=kNumTagBins); #endif return fFluxPolTagBin[pol][tagbin]; } Double_t GetFluxPolTagGroup(UChar_t pol,UChar_t tagGroup) const { // tagbin =0 gives sum of fluxes of all groups for given pol #ifdef DEBUG_CRASH cout << " Double_t GetFluxPolTagGroup(UChar_t pol,UChar_t tagGroup) const " << (Int_t)pol << " " << (Int_t)tagGroup << endl; #endif #ifndef NDEBUG if(! (pol < kNumPolStates)) cout << "pol=" << (UShort_t)pol << " kNumPolStates= " << kNumPolStates << endl; assert(pol < kNumPolStates); assert(tagGroup <=kNumTagGroups); #endif assert(pol < fFluxPolTagGroup.size()); assert(tagGroup < fFluxPolTagGroup[pol].size()); return fFluxPolTagGroup[pol][tagGroup]; } void SubsetTreeFill(string& newPrefix); void InitSubsetTree(string newPrefix = "subset_"); bool IsDetON() { // returns true if I am using SASY reconstructed event, false if generator data from MC ; the variable is set in LegsRun during initialization return fDetON; } bool IsDetOFF() { return !IsDetON();} bool IsDetOff() { return !IsDetON();} bool IsDetOn() { return fDetON;} bool GetLoopOverMultipleTagHits(){ return fLoopOverMultipleTagHits;} bool GetSkipMultipleTagHitsEvents(){ return fSkipMultipleTagHitsEvents;} Int_t GetSimulatedRunNumber() { return fSimulatedDataRunNumber;} TargetMaterial_t GetTargetMaterial() { return fTargetMaterial;} bool IsTargetEmpty() { return fTargetEmpty; } Int_t GetFluxMonitor() {return fFluxMonitor;} void SetFluxMonitor(Int_t ID) { fFluxMonitor = ID;} Int_t MyRank() {return fMyRank;} // rank of this process Int_t Ntasks() {return fNtasks;} // number of nodes #ifdef PARALLEL Int_t NeventsPerNodePerCycle() {return fNeventsPerNodePerCycle;} // specify how many events each slave node will process before reporting(communicating) to master node if number too small - a lot of network traffic will occur but load distribution between nodes will be better. If number too large - slow node may make you wait for a long time when all others already finished. #endif ClassDef(LegsEvent,0) // all information about an event is here through global pointer "it" . $Date: 2004/07/30 02:20:17 $ }; #include #include #include #endif