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