Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:14:50

0001 /*
0002  *
0003  * Author: Ph Gras. CEA/IRFU - Saclay
0004  */
0005 
0006 #ifndef ECALDUMPRAW_H
0007 #define ECALDUMPRAW_H
0008 
0009 #include <vector>
0010 #include <iostream>
0011 #include <fstream>
0012 #include <sstream>
0013 #include <string>
0014 #include <cinttypes>
0015 //#include "pgras/PGUtilities/interface/PGHisto.h"
0016 
0017 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0018 #include "DataFormats/Scalers/interface/L1AcceptBunchCrossing.h"
0019 #include "FWCore/Framework/interface/Frameworkfwd.h"
0020 #include "FWCore/Framework/interface/stream/EDAnalyzer.h"
0021 #include "FWCore/Utilities/interface/InputTag.h"
0022 
0023 /**
0024  * Utility to dump ECAL Raw data. Hexadecimal dump is accompagned with a side by
0025  * data interpretention.
0026  *
0027  * The script test/dumpRaw can be used to run this module. E. g.:
0028  *  dumpRaw /store/..../data_file.root
0029  * Run dumpRaw -h to get help on this script.
0030  *
0031  * Author: Ph. Gras CEA/IRFU Saclay
0032  *
0033  */
0034 class EcalDumpRaw : public edm::stream::EDAnalyzer<> {
0035   //ctors
0036 public:
0037   explicit EcalDumpRaw(const edm::ParameterSet&);
0038   ~EcalDumpRaw() override;
0039 
0040   void analyze(const edm::Event&, const edm::EventSetup&) override;
0041 
0042   void analyzeEB(const edm::Event&, const edm::EventSetup&) const;
0043   void analyzeEE(const edm::Event&, const edm::EventSetup&) const;
0044   void endJob();
0045   //methods
0046 public:
0047 private:
0048   void analyzeFed(int fedId);
0049   void analyzeApd();
0050   std::string toNth(int n);
0051   bool decode(const uint32_t* data, int iWord32, std::ostream& out);
0052   double max(const std::vector<double>& a, unsigned& pos) {
0053     pos = 0;
0054     double m = a[pos];
0055     for (unsigned i = 1; i < a.size(); ++i) {
0056       if (a[i] > m) {
0057         m = a[i];
0058         pos = i;
0059       }
0060     }
0061     return m;
0062   }
0063   double min(const std::vector<double>& a) {
0064     double m = a[0];
0065     for (unsigned i = 1; i < a.size(); ++i) {
0066       if (a[i] < m)
0067         m = a[i];
0068     }
0069     return m;
0070   }
0071   //static int lme(int dccId1, int side);
0072 
0073   template <class T>
0074   std::string toString(T val) {
0075     std::stringstream s;
0076     s << val;
0077     return s.str();
0078   }
0079 
0080   static int sideOfRu(int ru1);
0081 
0082   static int modOfRu(int ru1);
0083 
0084   static int lmodOfRu(int ru1);
0085 
0086   std::string srRange(int offset) const;
0087 
0088   std::string ttfTag(int tccType, unsigned iSeq) const;
0089 
0090   std::string tpgTag(int tccType, unsigned iSeq) const;
0091 
0092   //fields
0093 private:
0094   int verbosity_;
0095   bool writeDcc_;
0096   int beg_fed_id_;
0097   int end_fed_id_;
0098   int first_event_;
0099   int last_event_;
0100   std::string filename_;
0101   int iEvent_;
0102 
0103   unsigned iTowerWord64_;
0104   unsigned iSrWord64_;
0105   unsigned iTccWord64_;
0106   enum { inDaqHeader, inDccHeader, inTccBlock, inSrBlock, inTowerBlock } decodeState_;
0107   size_t towerBlockLength_;
0108 
0109   std::vector<double> adc_;
0110 
0111   static const int nSamples = 10;
0112   double amplCut_;
0113   bool dump_;
0114   bool dumpAdc_;
0115   bool l1aHistory_;
0116   //  bool doHisto_;
0117   int maxEvt_;
0118   int profileFedId_;
0119   int profileRuId_;
0120   int l1aMinX_;
0121   int l1aMaxX_;
0122   int dccCh_;
0123   std::vector<uint32_t> lastOrbit_;
0124   static const unsigned nDccs_ = 54;
0125   static const unsigned fedStart_ = 601;
0126   static const int maxTpgsPerTcc_ = 68;
0127   static const int maxTccsPerDcc_ = 4;
0128 
0129   //@{
0130   /** TCC types
0131    */
0132   static const int ebmTcc_ = 0;
0133   static const int ebpTcc_ = 1;
0134   static const int eeInnerTcc_ = 2;
0135   static const int eeOuterTcc_ = 3;
0136   static const int nTccTypes_ = 4;
0137   //@}
0138 
0139   /** TT ID in the order the TPG appears in the data
0140    */
0141   static const int ttId_[nTccTypes_][maxTpgsPerTcc_];
0142 
0143   unsigned fedId_;
0144   unsigned dccId_;
0145   unsigned side_;
0146   unsigned eventId_;
0147   std::vector<unsigned> eventList_;
0148   unsigned minEventId_;
0149   unsigned maxEventId_;
0150   unsigned orbit0_;
0151   uint32_t orbit_;
0152   bool orbit0Set_;
0153   int bx_;
0154   int l1a_;
0155   int simpleTrigType_;
0156   int detailedTrigType_;
0157   //  PGHisto histo_;
0158   std::vector<std::vector<uint32_t> > l1as_;
0159   std::vector<std::vector<uint32_t> > orbits_;
0160   std::vector<std::vector<int> > tpg_;
0161   std::vector<int> nTpgs_;
0162   std::vector<int> dccChStatus_;
0163   int iRu_;
0164   int srpL1a_;
0165   int tccL1a_;
0166   //Number of TPGs in TCC block currently parsed:
0167   int nTts_;
0168   //Length of TCC block currently parsed:
0169   int tccBlockLen64_;
0170   static const int nRu_ = 70;
0171   std::vector<int> feL1a_;
0172   int srpBx_;
0173   int tccBx_;
0174   ///type of TCC currently parsed
0175   int tccType_;
0176   std::vector<int> feBx_;
0177   std::vector<int> feRuId_;
0178   int iTow_;
0179   std::ofstream dumpFile_;
0180   bool pulsePerRu_;
0181   bool pulsePerLmod_;
0182   bool pulsePerLme_;
0183   int tccId_;
0184   //tcc sequence number of currenlty parsed tower block of one DCC
0185   int iTcc_;
0186   edm::InputTag fedRawDataCollectionTag_;
0187   edm::InputTag l1AcceptBunchCrossingCollectionTag_;
0188   edm::EDGetTokenT<FEDRawDataCollection> fedRawDataCollectionToken_;
0189   edm::EDGetTokenT<L1AcceptBunchCrossingCollection> l1AcceptBunchCrossingCollectionToken_;
0190 };
0191 
0192 #endif  //ECALDUMPRAW_H not defined