Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-02 03:39:00

0001 #ifndef ECAL_CHANNELSTATUS_HANDLER_H
0002 #define ECAL_CHANNELSTATUS_HANDLER_H
0003 
0004 #include <typeinfo>
0005 #include <vector>
0006 #include <string>
0007 #include <map>
0008 #include <sstream>
0009 #include <iostream>
0010 #include <fstream>
0011 #include <cmath>
0012 #include <ctime>
0013 #include "TTree.h"
0014 #include "TFile.h"
0015 
0016 #include "CondCore/PopCon/interface/PopConSourceHandler.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0018 
0019 #include "FWCore/ServiceRegistry/interface/Service.h"
0020 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0021 #include "FWCore/Framework/interface/ESHandle.h"
0022 #include "FWCore/Framework/interface/Event.h"
0023 #include "FWCore/Framework/interface/MakerMacros.h"
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0026 #include "DataFormats/Common/interface/Handle.h"
0027 #include "FWCore/Framework/interface/EventSetup.h"
0028 #include "FWCore/Framework/interface/EventSetupRecordKey.h"
0029 
0030 #include "CondTools/Ecal/interface/EcalErrorMask.h"
0031 #include "CondTools/Ecal/interface/EcalErrorDictionary.h"
0032 
0033 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
0034 #include "CondFormats/EcalObjects/interface/EcalPedestals.h"
0035 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
0036 #include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
0037 
0038 #include "OnlineDB/EcalCondDB/interface/MonLaserBlueDat.h"
0039 #include "OnlineDB/EcalCondDB/interface/MonPNBlueDat.h"
0040 #include "OnlineDB/EcalCondDB/interface/MonTimingLaserBlueCrystalDat.h"
0041 #include "OnlineDB/EcalCondDB/interface/RunCrystalErrorsDat.h"
0042 #include "OnlineDB/EcalCondDB/interface/RunTTErrorsDat.h"
0043 #include "OnlineDB/EcalCondDB/interface/all_od_types.h"
0044 #include "OnlineDB/EcalCondDB/interface/all_fe_config_types.h"
0045 #include "OnlineDB/EcalCondDB/interface/all_monitoring_types.h"
0046 
0047 #include "OnlineDB/EcalCondDB/interface/all_monitoring_types.h"
0048 #include "OnlineDB/Oracle/interface/Oracle.h"
0049 #include "OnlineDB/EcalCondDB/interface/EcalCondDBInterface.h"
0050 
0051 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0052 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0053 #include "DataFormats/Provenance/interface/Timestamp.h"
0054 
0055 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
0056 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
0057 
0058 #include "TProfile2D.h"
0059 
0060 namespace edm {
0061   class ParameterSet;
0062   class Event;
0063   class EventSetup;
0064 }  // namespace edm
0065 
0066 namespace popcon {
0067 
0068   class EcalChannelStatusHandler : public popcon::PopConSourceHandler<EcalChannelStatus> {
0069   public:
0070     EcalChannelStatusHandler(edm::ParameterSet const &);
0071     ~EcalChannelStatusHandler() override;
0072 
0073     void getNewObjects() override;
0074     void setElectronicsMap(const EcalElectronicsMapping *);
0075 
0076     std::string id() const override { return m_name; }
0077     EcalCondDBInterface *econn;
0078 
0079     // checks on pedestals
0080     float checkPedestalValueGain12(EcalPedestals::Item *item);
0081     float checkPedestalValueGain6(EcalPedestals::Item *item);
0082     float checkPedestalValueGain1(EcalPedestals::Item *item);
0083     float checkPedestalRMSGain12(EcalPedestals::Item *item);
0084     float checkPedestalRMSGain6(EcalPedestals::Item *item);
0085     float checkPedestalRMSGain1(EcalPedestals::Item *item);
0086 
0087     // check which laser sectors are on
0088     void nBadLaserModules(std::map<EcalLogicID, MonLaserBlueDat> dataset_mon);
0089 
0090     // to mask channels reading from pedestal
0091     void pedOnlineMasking();
0092     void pedMasking();
0093     void laserMasking();
0094     void physicsMasking();
0095 
0096     // to read the daq configuration
0097     void daqOut(const RunIOV &myRun);
0098 
0099     // real analysis
0100     void pedAnalysis(std::map<EcalLogicID, MonPedestalsDat> dataset_mon,
0101                      std::map<EcalLogicID, MonCrystalConsistencyDat> wrongGain_mon);
0102     void laserAnalysis(std::map<EcalLogicID, MonLaserBlueDat> dataset_mon);
0103     void cosmicsAnalysis(std::map<EcalLogicID, MonPedestalsOnlineDat> pedestalO_mon,
0104                          std::map<EcalLogicID, MonCrystalConsistencyDat> wrongGain_mon,
0105                          std::map<EcalLogicID, MonLaserBlueDat> laser_mon,
0106                          std::map<EcalLogicID, MonOccupancyDat> occupancy_mon);
0107 
0108   private:
0109     unsigned int m_firstRun;
0110     unsigned int m_lastRun;
0111 
0112     std::string m_location;
0113     std::string m_gentag;
0114     std::string m_runtype;
0115     std::string m_sid;
0116     std::string m_user;
0117     std::string m_pass;
0118     std::string m_locationsource;
0119     std::string m_name;
0120 
0121     bool isGoodLaserEBSm[36][2];
0122     bool isGoodLaserEESm[18][2];
0123     bool isEBRef1[36][2];
0124     bool isEBRef2[36][2];
0125     bool isEERef1[18][2];
0126     bool isEERef2[18][2];
0127 
0128     EcalErrorMask ecalErrorMask_;
0129     EcalElectronicsMapping ecalElectronicsMap_;
0130 
0131     std::ofstream *ResFileEB;
0132     std::ofstream *ResFileEE;
0133     std::ofstream *ResFileNewEB;
0134     std::ofstream *ResFileNewEE;
0135     std::ofstream *daqFile;
0136     std::ofstream *daqFile2;
0137 
0138     std::map<DetId, float> maskedOnlinePedEB, maskedOnlinePedEE;
0139     std::map<DetId, float> maskedPedEB, maskedPedEE;
0140     std::map<DetId, float> maskedLaserEB, maskedLaserEE;
0141     std::map<DetId, float> maskedPhysicsEB, maskedPhysicsEE;
0142 
0143     TProfile2D *newBadEB_;
0144     TProfile2D *newBadEEP_;
0145     TProfile2D *newBadEEM_;
0146   };
0147 }  // namespace popcon
0148 #endif