Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:46

0001 #ifndef CL_EcnaAnalyzer_H
0002 #define CL_EcnaAnalyzer_H
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:    EcalCorrelatedNoiseAnalysisModules
0007 // Class:      EcnaAnalyzer
0008 //
0009 /**\class EcnaAnalyzer EcnaAnalyzer.cc
0010  CalibCalorimetry/EcalCorrelatedNoiseAnalysisModules/src/EcnaAnalyzer.cc
0011 
0012  Description: <one line class summary>
0013 
0014  Implementation:
0015      <Notes on implementation>
0016 */
0017 //
0018 // Original Author:  Bernard Fabbro
0019 //         Created:  Fri Jun  2 10:27:01 CEST 2006
0020 // $Id: EcnaAnalyzer.h,v 1.3 2013/04/05 20:17:20 wmtan Exp $
0021 //
0022 //
0023 
0024 // system include files
0025 #include "Riostream.h"
0026 #include <ctime>
0027 #include <fstream>
0028 #include <iomanip>
0029 #include <iostream>
0030 #include <memory>
0031 #include <string>
0032 #include <vector>
0033 
0034 #include <csignal>
0035 #include <sys/time.h>
0036 
0037 // ROOT include files
0038 #include "TObject.h"
0039 #include "TString.h"
0040 #include "TSystem.h"
0041 #include "TTreeIndex.h"
0042 #include "TVectorD.h"
0043 
0044 // CMSSW include files
0045 #include "CondCore/CondDB/interface/Time.h"
0046 #include "DataFormats/Common/interface/Handle.h"
0047 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0048 #include "FWCore/Framework/interface/ESHandle.h"
0049 #include "FWCore/Framework/interface/Event.h"
0050 #include "FWCore/Framework/interface/EventSetup.h"
0051 #include "FWCore/Framework/interface/Frameworkfwd.h"
0052 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0053 
0054 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0055 
0056 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0057 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0058 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
0059 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0060 #include "DataFormats/EcalDigi/interface/EcalMGPASample.h"
0061 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0062 #include "DataFormats/Provenance/interface/EventID.h"
0063 
0064 #include "DataFormats/Provenance/interface/Timestamp.h"
0065 
0066 #include "DataFormats/EcalRawData/interface/EcalRawDataCollections.h"
0067 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0068 
0069 // user include files
0070 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaNumbering.h"
0071 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaObject.h"
0072 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaParEcal.h"
0073 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaParPaths.h"
0074 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaRun.h"
0075 
0076 ///-----------------------------------------------------------
0077 ///   EcnaAnalyzer.h
0078 ///   Update: 11/0'/2011
0079 ///   Authors:   B.Fabbro (bernard.fabbro@cea.fr)
0080 ///              DSM/IRFU/SPP CEA-Saclay
0081 ///   Copyright: Those valid for CEA sofware
0082 ///
0083 ///   ECNA web page:
0084 ///     http://cms-fabbro.web.cern.ch/cms-fabbro/
0085 ///     cna_new/Correlated_Noise_Analysis/ECNA_cna_1.htm
0086 ///-----------------------------------------------------------
0087 ///
0088 ///----------------------------------- Analysis name codes
0089 ///------------------------------------------
0090 ///
0091 ///      TString  AnalysisName: code for the analysis. According to this code,
0092 ///                             the analyzer selects the event type
0093 ///                             (PEDESTAL_STD, PEDESTAL_GAP, LASER_STD, etc...)
0094 ///                             and some other event characteristics
0095 ///                             (example: the gain in pedestal runs:
0096 ///                              AnalysisName = "Ped1" or "Ped6" or "Ped12")
0097 ///                             The string AnalysisName is automatically
0098 ///                             included in the name of the results files
0099 ///
0100 ///                  AnalysisName  RunType         Gain    DBLS (Dynamic
0101 ///                  BaseLine Substraction)
0102 ///                  ..........................................
0103 ///
0104 ///                  AdcAny        any run type       0    No
0105 ///
0106 ///                  AdcPed1       fPEDESTAL_STD      3    No
0107 ///                  AdcPed6       fPEDESTAL_STD      2    No
0108 ///                  AdcPed12      fPEDESTAL_STD      1    No
0109 ///
0110 ///                  AdcPeg12      fPEDESTAL_GAP      1    No
0111 ///
0112 ///                  AdcLaser      fLASER_STD         0    No
0113 ///                  AdcPes12      fPEDSIM            0    No
0114 ///
0115 ///                  AdcPhys       fPHYSICS_GLOBAL    0    No
0116 ///
0117 ///
0118 ///                  AdcSPed1      fPEDESTAL_STD      3    Yes
0119 ///                  AdcSPed6      fPEDESTAL_STD      2    Yes
0120 ///                  AdcSPed12     fPEDESTAL_STD      1    Yes
0121 ///
0122 ///                  AdcSPeg12     fPEDESTAL_GAP      1    Yes
0123 ///
0124 ///                  AdcSLaser     fLASER_STD         0    Yes
0125 ///                  AdcSPes12     fPEDSIM            0    Yes
0126 ///
0127 ///--------------------------------------------------------------------------------------------------
0128 
0129 //
0130 // class declaration
0131 //
0132 
0133 class EcnaAnalyzer : public edm::one::EDAnalyzer<> {
0134 public:
0135   enum { kChannels = 1700, kGains = 3, kFirstGainId = 1 };
0136 
0137   explicit EcnaAnalyzer(const edm::ParameterSet &);
0138   ~EcnaAnalyzer() override;
0139 
0140   void analyze(const edm::Event &, const edm::EventSetup &) override;
0141   TString runtype(const Int_t &);
0142   Int_t gainvalue(const Int_t &);
0143   void CheckMsg(const Int_t &, const Int_t &);
0144   void CheckMsg(const Int_t &);
0145   Bool_t AnalysisOutcome(const TString &);
0146 
0147 private:
0148   constexpr static Int_t fgMaxCar = 512;  // Max nb of caracters for char*
0149   TString fTTBELL;
0150 
0151   // ----------member data ---------------------------
0152   unsigned int verbosity_;
0153   Int_t nChannels_;
0154   Int_t iEvent_;  // should be removed when we can access class EventID
0155   std::string eventHeaderProducer_;
0156   std::string digiProducer_;
0157   std::string eventHeaderCollection_;
0158   std::string EBdigiCollection_;
0159   std::string EEdigiCollection_;
0160   edm::EDGetTokenT<EcalRawDataCollection> eventHeaderToken_;
0161   edm::EDGetTokenT<EBDigiCollection> EBdigiToken_;
0162   edm::EDGetTokenT<EEDigiCollection> EEdigiToken_;
0163 
0164   TString sAnalysisName_;
0165   TString sNbOfSamples_;
0166   TString sFirstReqEvent_;
0167   TString sLastReqEvent_;
0168   TString sReqNbOfEvts_;
0169   TString sStexName_;
0170   TString sStexNumber_;
0171 
0172   Bool_t fOutcomeError;
0173 
0174   Int_t fEvtNumber;
0175   Int_t fEvtNumberMemo;
0176   Int_t fRecNumber;
0177   Int_t fCurrentEventNumber;
0178   Int_t fNbOfSelectedEvents;
0179 
0180   std::vector<Int_t> fBuildEventDistribBad;
0181   std::vector<Int_t> fBuildEventDistribGood;
0182 
0183   TString fCfgAnalyzerParametersFilePath;  // absolute path for the analyzer
0184                                            // parameters files (/afs/etc...)
0185   TString fCfgAnalyzerParametersFileName;  // name of the analyzer parameters file
0186   std::ifstream fFcin_f;
0187 
0188   TString fAnalysisName;
0189   Int_t fChozenGainNumber;     // determined from fAnalysisName
0190   Int_t fChozenRunTypeNumber;  // determined from fAnalysisName
0191   TString fDynBaseLineSub;     // determined from fAnalysisName
0192 
0193   Int_t fNbOfSamples;
0194   Int_t fRunNumber;
0195   Int_t fRunTypeNumber;
0196   Int_t fFirstReqEvent;
0197   Int_t fLastReqEvent;
0198   TString fStexName;
0199   Int_t fStexNumber;
0200 
0201   Int_t fReqNbOfEvts;
0202   Int_t fMgpaGainNumber;
0203 
0204   Int_t fSMIndexBegin;
0205   Int_t fSMIndexStop;
0206   Int_t fDeeIndexBegin;
0207   Int_t fDeeIndexStop;
0208   Int_t fStexIndexBegin;
0209   Int_t fStexIndexStop;
0210 
0211   Int_t fFedTcc;
0212   std::vector<Int_t> fSMFromFedTcc;
0213   std::vector<Int_t> fESFromFedTcc;
0214   Int_t fTreatedFedOrder;
0215   std::vector<Int_t> fFedStatusOrder;
0216   Int_t fFedId;
0217   std::vector<std::string> fDeeNumberString;
0218 
0219   Int_t fMaxTreatedStexCounter = 0;
0220   Int_t fDeeDS5Memo1;
0221   Int_t fDeeDS5Memo2;
0222   std::vector<Int_t> fStexDigiOK;
0223   std::vector<Int_t> fStexNbOfTreatedEvents;
0224   std::vector<Int_t> fStexStatus;
0225 
0226   Int_t fMaxFedUnitCounter = 0;
0227   std::vector<Int_t> fFedStatus;
0228   std::vector<Int_t> fFedDigiOK;
0229   std::vector<Int_t> fFedNbOfTreatedEvents;
0230 
0231   Int_t fMemoCutOK;
0232   Int_t fNbOfTreatedStexs;
0233   std::vector<Int_t> fNbOfTreatedFedsInDee;
0234   std::vector<Int_t> fNbOfTreatedFedsInStex;
0235 
0236   Int_t fANY_RUN;
0237   Int_t fPEDESTAL_STD;
0238   Int_t fPEDESTAL_GAP;
0239   Int_t fLASER_STD;
0240   Int_t fPHYSICS_GLOBAL;
0241   Int_t fPEDSIM;
0242 
0243   std::vector<time_t> fTimeFirst;
0244   std::vector<time_t> fTimeLast;
0245   std::vector<TString> fDateFirst;
0246   std::vector<TString> fDateLast;
0247 
0248   std::vector<Int_t> fMemoDateFirstEvent;
0249 
0250   TEcnaObject fMyEcnaEBObjectManager;
0251   TEcnaObject fMyEcnaEEObjectManager;
0252 
0253   std::vector<std::unique_ptr<TEcnaRun>> fMyCnaEBSM;
0254   std::vector<std::unique_ptr<TEcnaRun>> fMyCnaEEDee;
0255 
0256   TEcnaNumbering fMyEBNumbering;
0257   TEcnaParEcal fMyEBEcal;
0258 
0259   TEcnaNumbering fMyEENumbering;
0260   TEcnaParEcal fMyEEEcal;
0261 
0262   //  Int_t** fT2d_LastEvt; // 2D array[channel][sample] max nb of evts read for
0263   //  a given (channel,sample) Int_t*  fT1d_LastEvt;
0264 
0265   constexpr static Int_t fMaxRunTypeCounter = 26;
0266   std::array<Int_t, fMaxRunTypeCounter> fRunTypeCounter;
0267 
0268   constexpr static Int_t fMaxMgpaGainCounter = 4;  // Because chozen gain = 0,1,2,3
0269   std::array<Int_t, fMaxMgpaGainCounter> fMgpaGainCounter;
0270 
0271   constexpr static Int_t fMaxFedIdCounter = 54;
0272   std::array<Int_t, fMaxFedIdCounter> fFedIdCounter;
0273 };
0274 
0275 #endif