00001 #ifndef TRPCPROC_H 00002 #define TRPCPROC_H 00003 00004 #include "TRocProc.h" 00005 #include "TRpcRec.h" 00006 #include "TRPCEvent.h" 00007 #include "TRPCParam.h" 00008 #include "TRocParam.h" 00009 #include "TBeamMonitorEvent.h" 00010 #include "TMbsCrateEvent.h" 00011 #include "TCBMBeamtimeProc.h" 00012 00013 //~ #include "TGet4MessageFull.h" 00014 #include "TFile.h" 00015 #include "TTree.h" 00016 00017 class TRocEvent; 00018 class TGet4MessageFull; 00019 class TGetHitUnpacked; 00020 00021 class TGo4EventElement; 00022 class TGo4MbsSubEvent; 00023 00024 namespace roc { 00025 class Message; 00026 } 00027 00028 00029 00030 00031 class TRPCProc : public TCBMBeamtimeProc { 00032 public: 00033 00034 TRPCProc(const char* name = 0); 00035 virtual ~TRPCProc(); 00036 00037 00038 virtual void InitEvent(TGo4EventElement*); 00039 00040 /* this is the main processing function here*/ 00041 virtual void FinalizeEvent(); 00042 00043 protected: 00044 Bool_t BuildHits( TRocData* rocEvent ); 00045 Bool_t TimeOrderBlock(UInt_t bBufferToSort); 00046 Bool_t FillCorrelationHistograms( UInt_t uIndexHisto, 00047 UInt_t uChipOne, Int_t iChanOne, UInt_t uChipSec, Int_t iChanSec); 00048 Bool_t FillCorrelationHistogramsInv( UInt_t uIndexHisto, 00049 UInt_t uChipOne, Int_t iChanOne, UInt_t uChipSec, Int_t iChanSec); 00050 00051 protected: 00052 00053 TRPCParam * fRpcPar; 00054 00055 TRocParam* fRocPar; 00056 00058 TRocEvent * fRocInputEvent; 00059 00060 TMbsCrateEvent * fCrateInputEvent; 00061 00062 TRPCEvent * fOutputEvent; 00063 00064 TBeamMonitorEvent* fBeamEvent; 00065 00066 std::vector<TRpcRec> FECHIP; 00067 00068 // Options readout from setup file or assigned from #define 00069 UInt_t fNumRocs; 00070 00071 // General counters 00072 UInt_t uNbEvents; 00073 UInt_t uFirstEventIndex; 00074 UInt_t uPrevEventIndex; 00075 00076 UInt_t uCurrentBlockBuffer; // unsigned integer giving which buffer to use when 00077 // sorting hits from a chip 00078 00079 UInt_t uEpochBufferStart; // Start of each message buffer 00080 UInt_t uCycleBufferStart; // Start of each message buffer 00081 TRocMessageExtended mLastFromBuffer; // Last read message 00082 00083 // Variables 00084 UInt_t uLastEpochMainClock; // Main 250MHz clock epoch counter 00085 UInt_t uMainEpochCycle; // Main 250MHz clock epoch counter cycle 00086 // Automatic GET4 chip failure detection 00087 UInt_t uRocEpochFirstSyncedChip; 00088 UInt_t uRocCycleFirstSyncedChip; 00089 00090 UInt_t uEpochLastBlock; 00091 UInt_t uLastEpochLastBlock; 00092 UInt_t uLastCycleLastBlock; 00093 UInt_t uCurrentEpoch2; // Last Epoch Nb from ROC message (global) 00094 UInt_t uCurrentCycle2; // Last Epoch Cycle Nb from ROC message (global) 00095 00096 // buffers used to sort in time ALL 00097 // hits from last 25 epochs (two to 00098 // cope with epoch mix between channels 00099 std::vector< std::vector< TGet4HitUnpacked > > v_HitUnpBlock; 00100 00101 TGet4HitUnpacked lastHit; 00102 00103 UInt_t uBlockIndexLast; 00104 UInt_t uBlockIndex; 00105 00106 // Tree outputs 00107 TString sOutputFilename; 00108 TDirectory* oldDir; 00109 TFile* fRootOut; 00110 TTree* cleanTree; 00111 TGet4HitUnpacked hitForTree; 00112 UInt_t uHitNumber; 00113 vector< UInt_t > *vuChannelId; 00114 vector< UInt_t > *vuTime; 00115 vector< UInt_t > *vuEpochTime; 00116 vector< Int_t > *viTot; 00117 00118 // Histograms 00119 00120 TH1 *fGet4EdgeMessagePerEvent; // Nb of accepted edge message per event 00121 TH1 *fGet4RisEdgesNb; // Nb of rising edges for each channel 00122 TH1 *fGet4FalEdgesNb; // Nb of falling edges for each channel 00123 TH1 *fGet4HitsNb; // Nb of matched hits for each channel 00124 TH2 *fGet4EdgesDiffEvol; // diff nb of rising & falling edges for each cycle/channel 00125 TH1 *fGet4RisEdgesEvol; // Total nb of rising edges for each cycle 00126 TH1 *fGet4FalEdgesEvol; // Total nb of falling edges for each cycle 00127 TH1 *fGet4HitsEvol; // Total nb of matched hits for each cycle 00128 TH1 *fGet4IncompletHitsEvol; // Total nb of incomplet hits for each cycle 00129 TH1 *fGet4BlocksEvol; // Total nb of blocks analysed for each cycle 00130 00131 TH1 *fReconErrLE; // Reconstruction Error: Leading Edge is already Set 00132 TH1 *fReconErrTE; // Reconstruction Error: Trailing Edge is already Set 00133 TH1 *fReconErrNegToT; // Reconstruction Error: Negative ToT 00134 TH1 *fReconErrTimeGate; // Reconstruction Error: ToT would be too big 00135 00136 TH2 *fMapOrderErrors; 00137 TH2 *fMapOrderErrorsChips; 00138 00139 TH2 *fBeamProfileHDRPC; // Attempt to get beam profile with Heidelberg RPC 00140 Int_t *iIsPadChannelX; // For each channel say if it is a pad: either -1 for no or PadIndexX 00141 Int_t *iIsPadChannelY; // For each channel say if it is a pad: either -1 for no or PadIndexX 00142 TH2 *fBeamProfilePRPC; // Attempt to get beam profile with Tsinghua Pad RPC 00143 00144 private: 00145 00146 ClassDef(TRPCProc,1) 00147 }; 00148 00149 #endif //TUNPACKPROCESSOR_H 00150