CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DQM/CastorMonitor/interface/CastorMonitorModule.h

Go to the documentation of this file.
00001 #ifndef CastorMonitorModule_H
00002 #define CastorMonitorModule_H
00003 
00004 #include "FWCore/Framework/interface/Frameworkfwd.h"
00005 #include "FWCore/Framework/interface/EDAnalyzer.h"
00006 #include "FWCore/Framework/interface/Event.h"
00007 #include "FWCore/Framework/interface/MakerMacros.h"
00008 #include "FWCore/Framework/interface/ESHandle.h"
00009 #include "FWCore/Framework/interface/Run.h"
00010 #include "FWCore/ServiceRegistry/interface/Service.h"
00011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00012 
00013 #include "DQMServices/Core/interface/DQMStore.h"
00014 #include "DQMServices/Core/interface/MonitorElement.h"
00015 
00016 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00017 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00018 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00019 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00020 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00021 
00022 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00023 #include "SimG4CMS/Calo/interface/CaloHit.h"
00024 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
00025 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
00026 
00027 #include "FWCore/Utilities/interface/CPUTimer.h"
00028 #include "DataFormats/Provenance/interface/EventID.h"  
00029 
00030 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00031 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00032 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00033 
00034 
00035 #include "DataFormats/CastorReco/interface/CastorTower.h"
00036 #include "DataFormats/CastorReco/interface/CastorCluster.h"
00037 #include "DataFormats/CastorReco/interface/CastorJet.h"
00038 #include "DataFormats/JetReco/interface/CastorJetID.h"
00039 #include "RecoJets/JetProducers/interface/CastorJetIDHelper.h"
00040 #include "RecoJets/JetProducers/plugins/CastorJetIDProducer.h"
00041 #include "DataFormats/JetReco/interface/BasicJet.h"
00042 #include "DataFormats/JetReco/interface/BasicJetCollection.h"
00043 #include "DataFormats/JetReco/interface/Jet.h"
00044 
00045 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00046 #include "DataFormats/DetId/interface/DetId.h"
00047 #include "DataFormats/HcalDigi/interface/HcalUnpackerReport.h" //-- no CastorUnpackerReport at the moment !
00048 #include "DataFormats/HcalDetId/interface/HcalCastorDetId.h" //-- HcalCastorDetId
00049 
00050 #include "DQM/CastorMonitor/interface/CastorMonitorSelector.h"
00051 #include "DQM/CastorMonitor/interface/CastorDigiMonitor.h"
00052 #include "DQM/CastorMonitor/interface/CastorRecHitMonitor.h"
00053 #include "DQM/CastorMonitor/interface/CastorChannelQualityMonitor.h"
00054 #include "DQM/CastorMonitor/interface/CastorLEDMonitor.h"
00055 #include "DQM/CastorMonitor/interface/CastorPSMonitor.h"
00056 #include "DQM/CastorMonitor/interface/CastorEventDisplay.h"
00057 #include "DQM/CastorMonitor/interface/CastorHIMonitor.h"
00058 #include "DQM/CastorMonitor/interface/CastorDataIntegrityMonitor.h"
00059 #include "DQM/CastorMonitor/interface/CastorTowerJetMonitor.h"
00060 
00061 #include "CalibCalorimetry/CastorCalib/interface/CastorDbASCIIIO.h" //-- use to get/dump Calib to DB 
00062 #include "CondFormats/CastorObjects/interface/CastorChannelQuality.h" //-- use to get/hold channel status
00063 #include "CondFormats/DataRecord/interface/CastorChannelQualityRcd.h"
00064 
00065 
00067 
00068 #include <memory>
00069 #include <iostream>
00070 #include <fstream>
00071 #include <vector>
00072 #include <string>
00073 #include <sys/time.h>
00074 
00075 
00076 
00077 
00078 class CastorMonitorModule : public edm::EDAnalyzer{
00079 
00080 public:
00081   
00083   CastorMonitorModule(const edm::ParameterSet& ps);
00084 
00086   ~CastorMonitorModule();
00087   
00088  protected:
00089   
00091   void analyze(const edm::Event& iEvent, const edm::EventSetup& eventSetup);
00092   
00094   void beginJob();
00095   
00097   void beginRun(const edm::Run& iRun, const edm::EventSetup& eventSetup);
00098 
00100   void beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00101                             const edm::EventSetup& eventSetup) ;
00102 
00104   void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00105                           const edm::EventSetup& eventSetup);
00106 
00108   void endJob(void);
00109   
00111   void endRun(const edm::Run& run, const edm::EventSetup& eventSetup);
00112 
00114   void reset(void);
00115 
00117   bool prescale();
00118 
00120   void CheckCastorStatus     (const FEDRawDataCollection& rawraw, 
00121                               const HcalUnpackerReport& report, 
00122                               const CastorElectronicsMap& emap,
00123                               const CastorDigiCollection& castordigi
00124                               );
00125     
00126  private:
00127  
00135   int prescaleEvt_;    //-- units of events
00136   int prescaleLS_;     //-- units of lumi sections
00137   int prescaleTime_;   //-- units of minutes
00138   int prescaleUpdate_; //-- units of "updates", TBD
00139 
00142   std::string monitorName_;
00143 
00145   int fVerbosity;  
00146 
00148   int nevt_;
00149   int nlumisecs_;
00150   bool saved_;
00151 
00153   bool rawOK_    ;
00154   bool reportOK_ ;
00155   bool digiOK_   ;
00156   bool rechitOK_ ;
00157   bool towerOK_  ;
00158   bool jetOK_    ;
00159   bool jetIdOK_  ;
00160   
00161   int nRaw;
00162   int nDigi;
00163   int nRechit;
00164   int nTower;
00165   int nJet;
00166   int nJetId;
00167    
00168   
00170   bool showTiming_; 
00171   edm::CPUTimer cpu_timer; 
00172 
00174   struct{
00175     timeval startTV,updateTV;
00176     double elapsedTime; 
00177     double vetoTime; 
00178     double updateTime;
00179   } psTime_;    
00180 
00181 
00183   DQMStore* dbe_;  
00184   
00186   int irun_,ilumisec_,ievent_,itime_,ibunch_;
00187   bool actonLS_ ;
00188   std::string rootFolder_;
00189 
00190   int ievt_;
00191   int ievt_pre_; //-- copy of counter used for prescale purposes
00192   bool fedsListed_;
00193   
00194   //edm::InputTag inputLabelGT_;
00195   edm::InputTag inputLabelRaw_;
00196   edm::InputTag inputLabelReport_;
00197   edm::InputTag inputLabelDigi_;
00198   edm::InputTag inputLabelRecHitCASTOR_;
00199   edm::InputTag inputLabelTowerCASTOR_;  
00200   edm::InputTag inputLabelBasicJetCASTOR_;  
00201   edm::InputTag inputLabelJetIdCASTOR_ ;
00202   edm::InputTag inputLabelCastorTowers_    ; 
00203   edm::InputTag inputLabelCastorBasicJets_ ; 
00204   edm::InputTag inputLabelCastorJetIDs_ ; 
00205 
00206 
00207 
00209   // typedef std::vector<reco::CastorTower> CastorTowerCollection;
00210 
00211   //edm::InputTag inputLabelCaloTower_;
00212   //edm::InputTag inputLabelLaser_;
00213 
00215   std::map<uint32_t, std::vector<HcalCastorDetId> > DCCtoCell;
00216   std::map<uint32_t, std::vector<HcalCastorDetId> > ::iterator thisDCC;
00217   std::map<std::pair <int,int> , std::vector<HcalCastorDetId> > HTRtoCell;
00218   std::map<std::pair <int,int> , std::vector<HcalCastorDetId> > ::iterator thisHTR;
00219 
00221   MonitorElement* meFEDS_;
00222   MonitorElement* meStatus_;
00223   MonitorElement* meRunType_;
00224   MonitorElement* meEvtMask_;
00225   MonitorElement* meTrigger_;
00226   MonitorElement* meLatency_;
00227   MonitorElement* meQuality_;
00228   MonitorElement* CastorEventProduct;
00229   
00230 
00232   CastorMonitorSelector*    evtSel_;
00233   CastorRecHitMonitor*      RecHitMon_;
00234   CastorChannelQualityMonitor*  CQMon_;
00235   CastorDigiMonitor*        DigiMon_;
00236   CastorLEDMonitor*         LedMon_;
00237   CastorPSMonitor*          PSMon_;
00238   CastorEventDisplay*       EDMon_;
00239   CastorHIMonitor*          HIMon_;
00240   CastorDataIntegrityMonitor* DataIntMon_;
00241   CastorTowerJetMonitor*     TowerJetMon_;
00242 
00243   MonitorElement* meEVT_;
00244 
00245   edm::ESHandle<CastorDbService> conditions_;
00246   const CastorElectronicsMap*     CastorReadoutMap_;
00247 
00249   edm::ESHandle<CastorPedestals> dbPedestals;
00250 
00251   // pedestal width averaged over capIDs, calculated in beginRun
00252   // aware of the difference between index[0..15][0..13] 
00253   // and sector/module numeration[1..16][1..14]
00254   float        fPedestalNSigmaAverage[14][16];
00255 
00256   std::vector<HcalGenericDetId> listEMap; //electronics Emap
00257 
00258 
00259   ofstream m_logFile;
00260 
00262   bool checkCASTOR_;
00263 
00267   MonitorElement* meCASTOR_;
00268    
00270   bool EDMonOn_;
00271 
00273   bool dump2database_;
00274   std::map<HcalCastorDetId, unsigned int> myquality_;
00275   CastorChannelQuality* chanquality_;
00276 };
00277 
00278 #endif