/**@file CbmTbReceiver.h **@date 29.06.2009 **author V. Friese ** **Data receiver and event builder for testbeam AUG09 **Associates hit messages on the base of time stamps **Creates CbmTbEvent and fills digi trees **Setup: 3 STS + GEM (MUCH) + RICH, 2 beam counters **/ #ifndef CBMTBRECEIVER_H #define CBMTBRECEIVER_H 1 #include #include "CbmTbDaqMap.h" #include "TString.h" #include "FairTask.h" #include "CbmDetectorList.h" #include "roc/Message.h" #include "roc/Iterator.h" class TClonesArray; class CbmTbEvent; using namespace std; class CbmTbReceiver : public FairTask { public: /** Default constructor **/ CbmTbReceiver(); /** Standard constructor **@param inFile Name of input file **@param iVerbose Verbosity level **@param name Name of task **/ CbmTbReceiver(const char* inFile, Double_t timeWindow = 500., Int_t iVerbose = 1, const char* name = "CBM Testbeam Receiver"); /** Destructor **/ virtual ~CbmTbReceiver(); /** Execution **/ virtual void Exec(Option_t* opt); /** Add ROC with ID, detector type and FEB type **@param rocId ROC ID number **@param detType Detector type (STS, RICH, MUCH, ...) **@param febType FEB type (0=1nx, 1=4nx), default is 1nx **/ void AddRoc(Int_t rocId, DetectorId detType); /** Set the DAQ setup **@param tag Setup tag **/ void SetRun(Int_t iRun) { fDaqMap = new CbmTbDaqMap(iRun); } /** Set beam signal **@param iRoc ROC id for beam signal **@param iChn AUX channel for beam signal **/ void SetBeam(Int_t rocId, Int_t auxChn); /** Set persistency **@param persistence If kFALSE, data will not be written to output tree. **/ void SetPersistence(Bool_t persistence) { fPersistence = persistence; } private: // ----- Permanent members ----------------------------------------------- TString fInputFileName; /** Name of input LMD file **/ Double_t fTimeWindow; /** Time window for association of hit to event **/ Int_t fBeamRoc; /** ROC id for beam signal **/ Int_t fBeamAuxChn; /** AUX channel for beam signal **/ Bool_t fPersistence; /** Persistency of output data **/ Double_t fLastMsgTime; /** Time of previous message **/ Double_t fLastEventTime; /** Time of previous event **/ uint32_t fCurrentEpoch; /** Current epoch marker **/ Double_t fCurrentEpochTime; /** Time stamp of current epoch **/ Int_t fNofMessages; /** Number of processed ROC messages **/ Int_t fNofEpochs; /** Number of epoch messages **/ Int_t fNofEvents; /** Number of CbmTbEvents created **/ TClonesArray* fEvents; /** Output array of CbmTbEvent **/ TClonesArray* fStsDigis; /** Output array of CbmStsDigi **/ TClonesArray* fMuchDigis; /** Output array of CbmMuchDigi **/ TClonesArray* fRichDigis; /** Output array of RICH Digi **/ CbmTbDaqMap* fDaqMap; /** Class for DAQ channel mapping **/ // ----- Transient members --------------------------------------------- roc::Iterator* fRocIter; //! ROC iterator roc::Message* fCurrentMessage; //! Curent ROC message CbmTbEvent* fCurrentEvent; //! Current CBM event map fRocDetMap; //! map from ROC id to detector type // ---- Private methods ------------------------------------------------ /** Intialisation **/ virtual InitStatus Init(); /** Re-Initialisation **/ virtual InitStatus ReInit(); /** End of run action **/ virtual void Finish(); /** Add a STS digi **/ void AddStsDigi(Int_t iStation, Int_t iSide, Double_t channel, Double_t adc, Double_t time); /** Add a MUCH digi **/ void AddMuchDigi(Int_t iStation, Int_t iChannel, Double_t adc, Double_t time); /** Add a RICH digi **/ void AddRichDigi(Int_t channel, Int_t adc, Double_t time); /** Add beam signal **/ void AddBeam(Double_t time); /** Check time ordering of messages **/ void CheckMessage(Double_t time); ClassDef(CbmTbReceiver,1); }; #endif