CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/EventFilter/CSCRawToDigi/interface/CSCALCTHeader.h

Go to the documentation of this file.
00001 #ifndef CSCALCTHeader_h
00002 #define CSCALCTHeader_h
00003 
00007 #include <bitset>
00008 #include <vector>
00009 #include <iosfwd>
00010 #include "DataFormats/CSCDigi/interface/CSCALCTDigi.h"
00011 #include "DataFormats/CSCDigi/interface/CSCALCTStatusDigi.h"
00012 #include "EventFilter/CSCRawToDigi/interface/CSCALCTHeader2006.h"
00013 #include "EventFilter/CSCRawToDigi/interface/CSCALCTHeader2007.h"
00014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00015 #include "FWCore/Utilities/interface/Exception.h"
00016 #include <boost/dynamic_bitset.hpp>
00017 
00018 class CSCALCTHeader {
00019  public:
00020   explicit CSCALCTHeader(int chamberType); 
00021 
00022   explicit CSCALCTHeader(const unsigned short * buf);
00023 
00024   CSCALCTHeader(const CSCALCTStatusDigi & digi);
00025 
00027   static void setDebug(bool value){debug = value;};
00028 
00029   void setEventInformation(const CSCDMBHeader &);
00030   unsigned short int nLCTChipRead()   const;
00031   
00032   std::vector<CSCALCTDigi> ALCTDigis() const;
00033   
00036 
00037   enum FIFO_MODE {NO_DUMP, FULL_DUMP, LOCAL_DUMP};
00038   unsigned short int FIFOMode()       const {return header2006.fifoMode;} 
00039   unsigned short int NTBins()         const {
00040     switch (firmwareVersion)
00041       {
00042       case 2006:
00043         return header2006.nTBins;
00044       case 2007:
00045         return header2007.rawBins;
00046       default:
00047         edm::LogError("CSCALCTHeader|CSCRawToDigi")
00048           <<"trying to access NTBINs: ALCT firmware version is bad/not defined!";
00049         return 0;
00050       }
00051   }
00052   unsigned short int BoardID()        const {return header2006.boardID;}
00053   unsigned short int ExtTrig()        const {return header2006.extTrig;}
00054   unsigned short int CSCID()          const {return header2006.cscID;}
00055   unsigned short int BXNCount()       const {
00056     switch (firmwareVersion)
00057       {
00058       case 2006:
00059         return header2006.bxnCount;
00060       case 2007:
00061         return header2007.bxnCount;
00062       default:
00063         edm::LogError("CSCALCTHeader|CSCRawToDigi")
00064           <<"trying to access BXNcount: ALCT firmware version is bad/not defined!";
00065         return 0;
00066       }
00067   }
00068   unsigned short int L1Acc()          const {
00069     switch (firmwareVersion)
00070       {
00071       case 2006:
00072         return header2006.l1Acc;
00073       case 2007:
00074         return header2007.l1aCounter;
00075       default:
00076         edm::LogError("CSCALCTHeader|CSCRawToDigi")
00077           <<"trying to access L1Acc: ALCT firmware version is bad/not defined!";
00078         return 0;
00079       }
00080   }
00081   unsigned short int L1AMatch()        const {return header2006.l1aMatch;}
00082   unsigned short int ActiveFEBs()      const {return header2006.activeFEBs;}
00083   unsigned short int Promote1()        const {return header2006.promote1;}
00084   unsigned short int Promote2()        const {return header2006.promote2;}
00085   unsigned short int LCTChipRead()     const {return header2006.lctChipRead;}
00086   unsigned short int alctFirmwareVersion() const {return firmwareVersion;}
00087   void setDAVForChannel(int wireGroup) {
00088      if(firmwareVersion == 2006) {
00089        header2006.setDAV((wireGroup-1)/16);
00090      }
00091   }
00092   CSCALCTHeader2007 alctHeader2007()   const {return header2007;}
00093   CSCALCTHeader2006 alctHeader2006()   const {return header2006;}
00094 
00095   unsigned short int * data() {return theOriginalBuffer;}
00096  
00098   int sizeInWords() {
00099     switch (firmwareVersion)
00100       {
00101       case 2006:
00102         return 8;
00103       case 2007:
00104         return sizeInWords2007_;
00105       default:
00106         edm::LogError("CSCALCTHeader|CSCRawToDigi")
00107           <<"SizeInWords(): ALCT firmware version is bad/not defined!";
00108         return 0;
00109       }
00110   }
00111   
00112   bool check() const {
00113     switch (firmwareVersion)
00114       {
00115       case 2006:
00116         return header2006.flag_0 == 0xC;
00117       case 2007:
00118         return header2007.flag1 == 0xDB0A;
00119       default:
00120         edm::LogError("CSCALCTHeader|CSCRawToDigi")
00121           <<"check(): ALCT firmware version is bad/not defined!";
00122         return 0;
00123       }
00124   }
00125  
00126   void add(const std::vector<CSCALCTDigi> & digis);
00127 
00128   boost::dynamic_bitset<> pack();
00129 
00131   static void selfTest(int firmware);  
00132 
00133  private:
00134   CSCALCTHeader2006 header2006;
00135   CSCALCTHeader2007 header2007;
00136   std::vector<CSCALCT> theALCTs;   
00137   CSCALCTs2006 alcts2006;
00138   CSCVirtexID virtexID;
00139   CSCConfigurationRegister configRegister;
00140   std::vector<CSCCollisionMask> collisionMasks;
00141   std::vector<CSCHotChannelMask> hotChannelMasks;
00142   
00143   //raw data also stored in this buffer
00144   //maximum header size is 116 words
00145   unsigned short int theOriginalBuffer[116];
00146   
00147   static bool debug;
00148   static unsigned short int firmwareVersion;
00149 
00151   unsigned short int sizeInWords2007_, bxn0, bxn1;
00152 };
00153 
00154 std::ostream & operator<<(std::ostream & os, const CSCALCTHeader & header);
00155 
00156 #endif
00157