// -*- mode: c++ -*- // // $Id: BrRawDataInput.h,v 1.14 2002/03/04 15:05:51 videbaek Exp $ // /////////////////////////////////////////////////////////////////////// // // // BRAHMS raw data class // // // // BrRawDataInput read raw data with BrRawEvent // // // // the class is derived from the BrIOModule class // // // // Author : K. Hagel // // Created : April 99 // // Version : 1.0 // // Changed : // // // // June 23,1999 FV - the fGlobalOn was set as default // // in the SetGlobal member function // // // // August 6, 1999 Fv - Start adding Trigger TDC // // // /////////////////////////////////////////////////////////////////////// #ifndef BRAT_BrRawDataInput #define BRAT_BrRawDataInput #ifndef BRAT_BrIOModule #include "BrIOModule.h" #endif #ifndef ROOT_TObject #include "TObject.h" #endif #ifndef BRAT_BrRawEvent #include "BrRawEvent.h" #endif #ifndef BrRawIOH #include "BrRawIO.h" #endif #ifndef NODISPATCH #ifndef DisIOH #include "DisIO.h" #endif #endif #ifndef BRAT_BrEventNode #include "BrEventNode.h" #endif #ifndef BRAT_BrDetectorList_h #include "BrDetectorList.h" #endif #define BR_IO_RAW_BIT 7 #define BR_IO_EVB_BIT 8 class BrRichDig; class BrTileDig; class BrSiDig; class BrZdcDig; class BrTrigScaler; class BrDvDig; #include enum ESpecID { kGlobal = 10, kMRS = 11, kFS = 12 }; //Definitions for fReadMode const Int_t kNULLMode = 0; const Int_t kDiskFile = 1; const Int_t kEventBuilder = 2; class BrRawDataInput : public BrIOModule { public: static const UInt_t kBrRawDiskFile; //! For read-only raw files static const UInt_t kBrEventBuilderStream; //! For read-only EVB streams BrRawDataInput(); BrRawDataInput(Char_t *filename, Char_t *title=""); virtual ~BrRawDataInput(); virtual Int_t Test(); virtual Bool_t Open(const Char_t *fname, const Option_t *option=""); virtual Bool_t Close(); virtual void Event(BrEvent* event); virtual void SkipEvent(Int_t numevt); virtual void SetDataState(Bool_t state) {fDataState = state;} virtual Bool_t GetDataState() const {return fDataState;} //Methods to control which parts of the event are unpacked // The new detector list based methods void SetOn (EBrDetectorBit b) { fDetectors.SetDetectorOn(b); } void SetOn (EBrSectorBit m) { fDetectors.AddToDetectorMask(m); } void SetOn (EBrDetectorBit b, Bool_t v) { if (v) SetOn(b); else SetOff(b); } void SetOn (EBrSectorBit m, Bool_t v) { if (v) SetOn(m); else SetOff(m); } void SetOff(EBrDetectorBit b) { fDetectors.SetDetectorOff(b); } void SetOff(EBrSectorBit m) { fDetectors.StripDetectorMask(m); } Bool_t IsOn (EBrDetectorBit b) const { return fDetectors.IsOn(b); } Bool_t IsOn (EBrSectorBit m) const { return (fDetectors.GetDetectorMask() & m) != 0; } // The old methods implemented using the new methods // Kept for backward compatibility virtual void SetOn(const Char_t* part, Bool_t val=kTRUE); virtual void SetOff(const Char_t* part){SetOn(part, kFALSE);} //Unpack everything virtual void SetAllOn(Bool_t val=kTRUE){ SetFSOn(val); SetMRSOn(val); SetGlobalOn(val); } //Unpack nothing (except header) virtual void SetAllOff() {SetAllOn(kFALSE);} //Unpack FS virtual void SetFSOn(Bool_t val=kTRUE){ SetFFSOn(val); SetBFSOn(val); } //Don't unpack FS virtual void SetFSOff(){SetFSOn(kFALSE);} //Unpack FFS virtual void SetFFSOn(Bool_t val=kTRUE) { SetT1On(val); SetT2On(val); SetC1On(val); SetH1On(val); } virtual void SetT1On(Bool_t val=kTRUE) {SetOn(kBrT1,val);} virtual void SetT2On(Bool_t val=kTRUE) {SetOn(kBrT2,val);} virtual void SetC1On(Bool_t val=kTRUE) {SetOn(kBrC1,val);} virtual void SetH1On(Bool_t val=kTRUE) {SetOn(kBrTOF1,val);} //Don't unpack FFS virtual void SetFFSOff() {SetFFSOn(kFALSE);} virtual void SetT1Off() {SetT1On(kFALSE);} virtual void SetT2Off() {SetT2On(kFALSE);} virtual void SetC1Off() {SetC1On(kFALSE);} virtual void SetH1Off() {SetH1On(kFALSE);} //Unpack BFS virtual void SetBFSOn( Bool_t val=kTRUE) { SetT3On(val); SetT4On(val); SetT5On(val); SetH2On(val); SetRICHOn(val); } virtual void SetT3On(Bool_t val=kTRUE) {SetOn(kBrT3,val);} virtual void SetT4On(Bool_t val=kTRUE) {SetOn(kBrT4,val);} virtual void SetT5On(Bool_t val=kTRUE) {SetOn(kBrT5,val);} virtual void SetH2On(Bool_t val=kTRUE) {SetOn(kBrTOF2,val);} virtual void SetRICHOn(Bool_t val=kTRUE) {SetOn(kBrRICH,val);} //Don't unpack BFS virtual void SetBFSOff(){SetBFSOn(kFALSE);} virtual void SetT3Off() {SetT3On(kFALSE);} virtual void SetT4Off() {SetT4On(kFALSE);} virtual void SetT5Off() {SetT5On(kFALSE);} virtual void SetH2Off() {SetH2On(kFALSE);} virtual void SetRICHOff(){SetRICHOn(kFALSE);} //Unpack MRS virtual void SetMRSOn(Bool_t val=kTRUE){ SetMTP1On(val); SetMTP2On(val); SetTOFWOn(val); } virtual void SetMTP1On(Bool_t val=kTRUE) {SetOn(kBrTPM1,val);} virtual void SetMTP2On(Bool_t val=kTRUE) {SetOn(kBrTPM2,val);} virtual void SetTOFWOn(Bool_t val=kTRUE) {SetOn(kBrTOFW,val);} //Don't unpack MRS virtual void SetMRSOff(){SetMRSOn(kFALSE);} virtual void SetMTP1Off() {SetMTP1On(kFALSE);} virtual void SetMTP2Off() {SetMTP2On(kFALSE);} virtual void SetTOFWOff() {SetTOFWOn(kFALSE);} //Unpack Global virtual void SetGlobalOn(Bool_t val=kTRUE) { SetMultOn(val); SetBBOn(val); SetZDCOn(val); } virtual void SetMultOn(Bool_t val=kTRUE) { SetOn(kBrTile,val); SetOn(kBrSi,val); } virtual void SetBBOn( Bool_t val=kTRUE) {SetOn(kBrBB,val);} virtual void SetZDCOn( Bool_t val=kTRUE) {SetOn(kBrZDC,val);} //Don't unpack Global virtual void SetGlobalOff(){SetGlobalOn(kFALSE);} virtual void SetMultOff() {SetMultOn(kFALSE);} virtual void SetBBOff() {SetBBOn(kFALSE);} virtual void SetZDCOff() {SetZDCOn(kFALSE);} enum ERawMagic { kEventHeader = 1, kEventTrigger = 3, kEventScaler = 4, kZDCLeft = 10010, kZDCRight = 10011, kBBCLeft = 10012, kBBCRight = 10013, kMultSi = 10014, kMultTiles = 10015, kTriggerBBL = 10018, kTriggerBBR = 10019, kZDC = 10020, kZDCLo = 10021, kDriftVelTPC = 10022, kTriggerStart = 10023, kClock = 10024, kInelRing = 10025, kInelAll = 10026, kTOFW = 11301, kTOFWBottom = 11302, kTOFWTop = 11303, kTOFWCal = 11304, kTpm2BFib = 11305, kTpm2FFib = 11306, kTMRS = 11307, kH1 = 12612, kH1Cal = 12616, kH2 = 12613, kC1 = 12614, kRICH = 12615, kTPM1B = 11715, kTPM1 = 11716, kTPM2B = 11725, kTPM2 = 11726, kT1B = 12735, kT1 = 12736, kT2B = 12745, kT2 = 12746, kT2FFib = 12617, kT1BFib = 12618, kTD1 = 12619, //T3 kT31X1 = 12301, kT31X2 = 12302, kT31X3 = 12303, kT31Y1 = 12304, kT31Y2 = 12305, kT31Y3 = 12306, kT31U1 = 12307, kT31U2 = 12308, kT31V1 = 12309, kT31V2 = 12310, kT32X1 = 12311, kT32X2 = 12312, kT32X3 = 12313, kT32Y1 = 12314, kT32Y2 = 12315, kT32Y3 = 12316, kT32U1 = 12317, kT32U2 = 12318, kT32V1 = 12319, kT32V2 = 12320, kT33X1 = 12321, kT33X2 = 12322, kT33X3 = 12323, kT33Y1 = 12324, kT33Y2 = 12325, kT33Y3 = 12326, kT33U1 = 12327, kT33U2 = 12328, kT33V1 = 12329, kT33V2 = 12330, //T4 kT41X1 = 12401, kT41X2 = 12402, kT41Y1 = 12404, kT41Y2 = 12405, kT41U1 = 12407, kT41U2 = 12408, kT41V1 = 12409, kT41V2 = 12410, kT42X1 = 12411, kT42X2 = 12412, kT42Y1 = 12414, kT42Y2 = 12415, kT42U1 = 12417, kT42U2 = 12418, kT42V1 = 12419, kT42V2 = 12420, kT43X1 = 12421, kT43X2 = 12422, kT43Y1 = 12424, kT43Y2 = 12425, kT43U1 = 12427, kT43U2 = 12428, kT43V1 = 12429, kT43V2 = 12430, //T5 kT51X1 = 12501, kT51X2 = 12502, kT51Y1 = 12504, kT51Y2 = 12505, kT51U1 = 12507, kT51U2 = 12508, kT51V1 = 12509, kT51V2 = 12510, kT52X1 = 12511, kT52X2 = 12512, kT52Y1 = 12514, kT52Y2 = 12515, kT52U1 = 12517, kT52U2 = 12518, kT52V1 = 12519, kT52V2 = 12520, kT53X1 = 12521, kT53X2 = 12522, kT53Y1 = 12524, kT53Y2 = 12525, kT53U1 = 12527, kT53U2 = 12528, kT53V1 = 12529, kT53V2 = 12530, }; protected: virtual void OpenNext(); // Actual method to open next file private: Int_t fRunNumber; //! runNumber Int_t fEventCounter; //! Event counter BrRawIO *fFileDescriptor; //! File descriptor #ifndef NODISPATCH //BrDisIOProxy *fDispatcher; //! pointer to dispatcher changed 9-Feb-00 DisIO *fDispatcher; //! pointer to dispatcher #endif BrRawEvent *fRawEvent; //! Pointer to raw BRAHMS event Int_t fRecordFormat; //! Record format, used internally Int_t fReadMode; //! Read mode; disk file, or event builder Int_t fReqBatch; //! Number of events requested at a time Int_t fBatchNumber; //! Counter to keep track of where it is Bool_t fDataState; //! Flag to tell if we got event from EVB //Event Nodes BrEventNode *fGlobalNode; //!Global node BrEventNode *fMRSNode; //!MRS node BrEventNode *fFSNode; //!FS node BrEventNode *fFFSNode; //!FFS node BrEventNode *fBFSNode; //!BFS node //Scalers BrTrigScaler *fTriggerScalers; //Trigger Scalers data object //Data objects and Tables BrZdcDig *fZDCObject; //!ZDC data object BrZdcDig *fZDCLoObject; //!ZDC data object (attenuated ADCs) BrDataTable *fBBLeftTable; //!BB Left BrDataTable *fBBRightTable; //!BB Right BrDataTable *fBBLeftTriggerTable; //!BB Left (Trigger TDC) BrDataTable *fBBRightTriggerTable;//!BB Right (Trigger TDC) BrDataTable *fMultTilesTable; //!Mult Tiles BrDataTable *fMultSiTable; //!MultSi BrTileDig *fTiles; //!Mult tiles BrSiDig *fSi; //!Mult si BrDataTable *fH1Table; //!H1 table BrDataTable *fH1CalTable; //!H1CAL table BrDataTable *fH2Table; //!H2 table BrDataTable *fC1Table; //!C1 table BrRichDig *fRICHObject; //!RICH data object BrDataTable *fT1Table; //!T1 table BrDataTable *fT2Table; //!T2 table BrDataTable *fT3Table; //!T3 table BrDataTable *fT4Table; //!T4 table BrDataTable *fT5Table; //!T5 table BrDataTable *fTOFWTable; //!TOFW table BrDataTable *fTOFWCalTable; //!TOFWCAL table BrDvDig *fDvObject; //!DriftVel Object //Switches to turn on/off unpacking of different elements BrDetectorList fDetectors; // virtual void Init(); virtual Bool_t OpenDiskFile(const Char_t *fname); virtual Bool_t OpenEventBuilder(const Char_t *fname); virtual void ZeroNodesAndTables(); virtual void BuildEvent(BrEvent *event); virtual void BuildEventHeader(const Int_t recordId,BrEvent *event); virtual void AddTriggerWord(BrEvent *event); virtual void AddScalerRecord(BrEvent *event); virtual void DecodeFS(const Int_t recordId,BrEvent *event); virtual void DecodeBFS(const Int_t recordId); virtual void DecodeFFS(const Int_t recordId); virtual void DecodeMRS(const Int_t recordId,BrEvent *event); virtual void DecodeGlobal(const Int_t recordId,BrEvent *event); Bool_t UnpackBeamBeam(const Int_t recordId); Bool_t UnpackT3(const Int_t recordId); Bool_t UnpackT4(const Int_t recordId); Bool_t UnpackT5(const Int_t recordId); Bool_t UnpackTOFW(const Int_t recordId); Bool_t UnpackTOFWCal(const Int_t recordId); Bool_t UnpackH1Cal(const Int_t recordId); Bool_t UnpackDriftVel(const Int_t recordId); Bool_t UnpackTpcFib(const Int_t recordId); Bool_t UnpackTrigStart(const Int_t recordId); Bool_t UnpackTriggerBB(const Int_t recordId); Bool_t UnpackTriggerD1(const Int_t recordId); Bool_t UnpackTrigClock(const Int_t recordId); Bool_t UnpackTriggerMrs(const Int_t recordId); Bool_t UnpackTrigZdc(const Int_t recordId); Bool_t UnpackInelRing(const Int_t recordId); Bool_t UnpackInel(const Int_t recordId); public: ClassDef(BrRawDataInput,0) // Interface to Raw Event files }; #endif // $Log: BrRawDataInput.h,v $ // Revision 1.14 2002/03/04 15:05:51 videbaek // Changed the decoding of Inel counters from the pp running to appear in // 2 different tables INR and INL. // This make the Inel counters behave much more like the BB counters. This // is also utilized in the calibrations routines etc. // // Revision 1.13 2001/12/29 03:54:57 operator // Added new records for Inel counters // // Revision 1.12 2001/12/13 21:51:51 videbaek // Re-mapping of Bema Beam right tdc for module 20 and 23 for runs less than 6061 // (today). Some additional cleanup of unpack modules to make better modularity // ie. usage of Unpack methods rather than in-line. // // Revision 1.11 2001/12/12 20:51:35 operator // Added data structure for Mrs Trigger counters. The Name is // TMRS and of type BrTofDig (Left/right slat though) // // Revision 1.10 2001/12/06 21:51:14 operator // Unpack the inelastic counters so far 4 rings each side. // The data are stored as a Bbdig (has timing but no ADC - maybe it will // who knows. // // Revision 1.9 2001/11/28 21:44:49 operator // Added TD1 trigger record // // Revision 1.8 2001/11/26 18:07:50 videbaek // Added creation of Datatables for Sync Clock and ZDC timing. // Corrected several typos in warning messages. // // Revision 1.7 2001/11/22 21:37:32 operator // Added records 10024 // // Revision 1.6 2001/10/02 22:28:24 videbaek // Modified to handle BrTpcFibDig.:wq // // Revision 1.5 2001/09/18 13:49:40 operator // Unpack BrTrigStart data records added. // // Revision 1.4 2001/08/30 19:45:55 jakobsen // // Added H1Cal // // Revision 1.3 2001/07/17 17:58:49 videbaek // Added BrTpmfib data objects. // Unpack these as part of MRS datatable. // // Revision 1.2 2001/06/22 17:40:42 cholm // Changes t odo with data classes renaming. // // Revision 1.1.1.1 2001/06/21 14:55:09 hagel // Initial revision of brat2 // // Revision 1.44 2001/06/15 23:56:40 operator // Added the TOFWCal 6 stave detectors with a format as BrTofDig // just a different name. // // Revision 1.43 2001/06/04 18:14:21 videbaek // Complete implementation of DriftVelocity Monitor dataobjects // The data are stored in the BrDvDig dataobjects // // Revision 1.42 2001/05/01 00:33:22 videbaek // Changed BrTriggerScalewr -> BrTrigScaler .. // // Revision 1.41 2001/04/30 19:02:48 hagel // Added routine to unpack Drift velocity monitors although it does not build the object yet // // Revision 1.40 2001/03/12 18:46:44 cholm // Fixed a few mistakes. Added a hack to histogram module, to make // sure it's file is closed as the very last thing in Finish. // // Revision 1.39 2001/03/07 12:22:23 cholm // * Changed BrRawDataInput to use signals Stop, Failure, Abort, and // added specialised method OpenNext. // // Revision 1.38 2001/01/29 20:37:29 cholm // Updated to use the new data objects for the multiplicity array. See the // relevant classes (BrTileDig, BrTileRdo, BrSiDig, BrSiRdo) for more details. // // Revision 1.37 2000/08/31 21:25:39 hagel // Add unpacking for T5 (and unpacking guess for T4) // // Revision 1.36 2000/08/12 23:38:08 hagel // Changed unpacking of TOFW for splitting top and bottom data records // // Revision 1.35 2000/08/12 22:12:41 videbaek // Modified TOFW readout // // Revision 1.34 2000/07/29 23:42:25 hagel // Implement first version of unpacking T3 // // Revision 1.33 2000/07/28 20:46:31 alv // Replaced the Bool_t fXXXOn detector flags by a BrDetectorList fDetectors member. // Added methods // void SetOn (EBrDetectorBit b) // void SetOn (EBrSectorBit m) // void SetOn (EBrDetectorBit b, Bool_t v) // void SetOn (EBrSectorBit m, Bool_t v) // void SetOff(EBrDetectorBit b) // void SetOff(EBrSectorBit m) // Bool_t IsOn (EBrDetectorBit b) const // Bool_t IsOn (EBrSectorBit m) const // Changed the old SetXXXOn methods to use the new SetOn method. // Made GetDataState method const. // // Revision 1.32 2000/07/28 03:23:32 hagel // add trigger scaler object to unpacking // // Revision 1.31 2000/07/25 09:06:00 krakow // Added ; to allow compile // // Revision 1.30 2000/07/24 19:37:01 ouerdane // Added minor changes in SetxxxOn methods. // You can now do a SetOffAll and then a e.g. SetH2On() only, thing that was impossible before since a SetOffAll influences everything. The trick was to add fAllOn = kTRUE in each SetxxxOn. Thus the decoding of the data is faster since you can select a single detector at initialization of your BrRawDataInput object. // // Revision 1.29 2000/07/22 19:51:07 ouerdane // Added SetOn and SetOff methods to the set of SetxxxOn and SetxxxOff methods for a better flexibility, arguments are: name of the detector, boolean value. These methods are internally based on the other existing methods, so that there's no need to modify anything that already exists. // // Revision 1.28 2000/07/15 10:56:50 alv // Added decoding and extraction of data record 10021: ZDC attenuated ADC // Symbolic record id (in enum ERawMagic): kZDCLo // Name of data object (in BrTableNames.h): kDigZDCLo ("DigZDCLo") // Name of N-tuple object: "ZDCLo" // // Revision 1.27 2000/06/28 09:21:55 hagel // Added const's to Open Args in BrRawDataInput // // Revision 1.26 2000/06/13 17:14:45 alv // Updated record ids kTPM1 and kTPM1B // // Revision 1.25 2000/06/03 22:21:51 videbaek // compare revisions // // Revision 1.24 2000/05/20 18:18:33 hito // I (Hiro) added the Silicon strip detector. // // Revision 1.23 2000/05/04 03:02:52 hagel // Changes to have detector monitors inherit from BrDetectorMonitor // // Revision 1.22 2000/04/04 18:02:45 videbaek // Updates or TPC recordID (MRS) // // Revision 1.21 2000/03/27 22:29:39 videbaek // Adding proper code for reading MTP2 // // Revision 1.20 2000/03/09 22:37:40 hagel // Implemented constants from BrTableNames.h for data table names // // Revision 1.19 2000/02/16 22:24:11 brahmlib // All code changes to implement the BrDigTiles raw data structure. // // Revision 1.18 2000/02/16 20:53:17 hagel // 1. Changed BrZdcDig to inherit from BrDataObject // 2. Changed code in BrRawDataInput to reflect that change // 3. Changed BrMonitorZDC::Event to reflect that change // 4. Removed Draw methods from BrMonitorZDC, BrMonitorC1, BrMonitorMult because // they are obsolete. BrBaseMonitor now handles that function automatically // // Revision 1.17 2000/02/15 20:31:57 videbaek // // :q // // Revision 1.16 2000/02/11 00:14:05 hagel // 1. Updated to the latest version of all of Konstantin's online routines // 2. Changed ZDC to use updated recordId's which return 8 adc values in // one recordId. // 3. Added an alpha-alpha version of unpacking for RICH. It is mostly // placeholder, but will serve as ground work to quickly get unpacking // once I understand what needs to be unpacked and what the raw structure is // // Revision 1.15 2000/02/08 22:40:07 videbaek // Setup for MTP1,MTP2, added enmu types for TPCs // Add DebugLevel condition for some output. // // Revision 1.14 2000/02/04 15:51:49 videbaek // tarted added new detectors :wq // // Revision 1.13 1999/11/30 22:22:41 videbaek // Be able to dela with TPC data from raw data. // // Revision 1.12 1999/08/14 17:01:57 videbaek // Updates for // a) RawData adding the Trigger TDCs' // b) Implied new data objects BrTrigBB // c) Clean up of TPC code // d) Test MyMonitor and scripts // // Revision 1.11 1999/07/28 14:59:04 hagel // Added functionality to BrBaseMonitor // // Revision 1.10 1999/07/18 21:25:07 videbaek // Added code to deal with trigger words. This applies to raw data, as well as the // EventHeader. // // Revision 1.9 1999/07/02 16:50:50 hagel // Added C1 unpacking // // Revision 1.8 1999/06/29 14:55:23 videbaek // fix simple mistake in setting status variable // // Revision 1.7 1999/06/22 00:08:59 hagel // Impement beginning of C1 // // Revision 1.6 1999/06/20 20:56:03 hagel // Remove bottleneck with reading from Event Builder // // Revision 1.5 1999/06/19 22:25:29 hagel // Add support for MULT // // Revision 1.4 1999/06/18 22:37:13 hagel // Various modifications to make read raw data // // Revision 1.3 1999/06/16 14:00:48 hagel // Intermediate step for simple reason to save and have backup. // Works with ZDC. // Started implementation of reading from event builder // // Revision 1.2 1999/06/11 23:32:38 hagel // Closer to real thing // // Revision 1.1 1999/06/02 15:00:23 hagel // First version. This doesn't work; only put in to get into repository for backup. // Many things will change; perhaps even the philosophy //