EcalChannelStatusHandler

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
#ifndef ECAL_CHANNELSTATUS_HANDLER_H
#define ECAL_CHANNELSTATUS_HANDLER_H

#include <typeinfo>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <iostream>
#include <fstream>
#include <cmath>
#include <ctime>
#include "TTree.h"
#include "TFile.h"

#include "CondCore/PopCon/interface/PopConSourceHandler.h"
#include "FWCore/ParameterSet/interface/ParameterSetfwd.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/EventSetupRecordKey.h"

#include "CondTools/Ecal/interface/EcalErrorMask.h"
#include "CondTools/Ecal/interface/EcalErrorDictionary.h"

#include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
#include "CondFormats/EcalObjects/interface/EcalPedestals.h"
#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
#include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"

#include "OnlineDB/EcalCondDB/interface/MonLaserBlueDat.h"
#include "OnlineDB/EcalCondDB/interface/MonPNBlueDat.h"
#include "OnlineDB/EcalCondDB/interface/MonTimingLaserBlueCrystalDat.h"
#include "OnlineDB/EcalCondDB/interface/RunCrystalErrorsDat.h"
#include "OnlineDB/EcalCondDB/interface/RunTTErrorsDat.h"
#include "OnlineDB/EcalCondDB/interface/all_od_types.h"
#include "OnlineDB/EcalCondDB/interface/all_fe_config_types.h"
#include "OnlineDB/EcalCondDB/interface/all_monitoring_types.h"

#include "OnlineDB/EcalCondDB/interface/all_monitoring_types.h"
#include "OnlineDB/Oracle/interface/Oracle.h"
#include "OnlineDB/EcalCondDB/interface/EcalCondDBInterface.h"

#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "DataFormats/Provenance/interface/Timestamp.h"

#include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
#include "Geometry/EcalMapping/interface/EcalMappingRcd.h"

#include "TProfile2D.h"

namespace edm {
  class ParameterSet;
  class Event;
  class EventSetup;
}  // namespace edm

namespace popcon {

  class EcalChannelStatusHandler : public popcon::PopConSourceHandler<EcalChannelStatus> {
  public:
    EcalChannelStatusHandler(edm::ParameterSet const &);
    ~EcalChannelStatusHandler() override;

    void getNewObjects() override;
    void setElectronicsMap(const EcalElectronicsMapping *);

    std::string id() const override { return m_name; }
    EcalCondDBInterface *econn;

    // checks on pedestals
    float checkPedestalValueGain12(EcalPedestals::Item *item);
    float checkPedestalValueGain6(EcalPedestals::Item *item);
    float checkPedestalValueGain1(EcalPedestals::Item *item);
    float checkPedestalRMSGain12(EcalPedestals::Item *item);
    float checkPedestalRMSGain6(EcalPedestals::Item *item);
    float checkPedestalRMSGain1(EcalPedestals::Item *item);

    // check which laser sectors are on
    void nBadLaserModules(std::map<EcalLogicID, MonLaserBlueDat> dataset_mon);

    // to mask channels reading from pedestal
    void pedOnlineMasking();
    void pedMasking();
    void laserMasking();
    void physicsMasking();

    // to read the daq configuration
    void daqOut(const RunIOV &myRun);

    // real analysis
    void pedAnalysis(std::map<EcalLogicID, MonPedestalsDat> dataset_mon,
                     std::map<EcalLogicID, MonCrystalConsistencyDat> wrongGain_mon);
    void laserAnalysis(std::map<EcalLogicID, MonLaserBlueDat> dataset_mon);
    void cosmicsAnalysis(std::map<EcalLogicID, MonPedestalsOnlineDat> pedestalO_mon,
                         std::map<EcalLogicID, MonCrystalConsistencyDat> wrongGain_mon,
                         std::map<EcalLogicID, MonLaserBlueDat> laser_mon,
                         std::map<EcalLogicID, MonOccupancyDat> occupancy_mon);

  private:
    unsigned int m_firstRun;
    unsigned int m_lastRun;

    std::string m_location;
    std::string m_gentag;
    std::string m_runtype;
    std::string m_sid;
    std::string m_user;
    std::string m_pass;
    std::string m_locationsource;
    std::string m_name;

    bool isGoodLaserEBSm[36][2];
    bool isGoodLaserEESm[18][2];
    bool isEBRef1[36][2];
    bool isEBRef2[36][2];
    bool isEERef1[18][2];
    bool isEERef2[18][2];

    EcalErrorMask ecalErrorMask_;
    EcalElectronicsMapping ecalElectronicsMap_;

    std::ofstream *ResFileEB;
    std::ofstream *ResFileEE;
    std::ofstream *ResFileNewEB;
    std::ofstream *ResFileNewEE;
    std::ofstream *daqFile;
    std::ofstream *daqFile2;

    std::map<DetId, float> maskedOnlinePedEB, maskedOnlinePedEE;
    std::map<DetId, float> maskedPedEB, maskedPedEE;
    std::map<DetId, float> maskedLaserEB, maskedLaserEE;
    std::map<DetId, float> maskedPhysicsEB, maskedPhysicsEE;

    TProfile2D *newBadEB_;
    TProfile2D *newBadEEP_;
    TProfile2D *newBadEEM_;
  };
}  // namespace popcon
#endif