Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:12:52

0001 #include "DQMOffline/JetMET/interface/JetMETDQMDCSFilter.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "DataFormats/Common/interface/Handle.h"
0004 #include "DataFormats/Scalers/interface/DcsStatus.h"
0005 #include "FWCore/Utilities/interface/InputTag.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 
0008 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0009 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0010 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0011 
0012 #include <iostream>
0013 
0014 //using namespace edm;
0015 //using namespace std;
0016 //using namespace reco;
0017 
0018 //
0019 // -- Constructor
0020 //
0021 JetMETDQMDCSFilter::JetMETDQMDCSFilter(const edm::ParameterSet& pset, edm::ConsumesCollector& iC) {
0022   verbose_ = pset.getUntrackedParameter<bool>("DebugOn", false);
0023   detectorTypes_ = pset.getUntrackedParameter<std::string>("DetectorTypes", "ecal:hcal");
0024   filter_ = !pset.getUntrackedParameter<bool>("alwaysPass", false);
0025 
0026   detectorOn_ = false;
0027   if (verbose_)
0028     std::cout << "JetMETDQMDCSFilter constructor: " << detectorTypes_ << std::endl;
0029 
0030   passPIX = false, passSiStrip = false;
0031   passECAL = false, passES = false;
0032   passHBHE = false, passHF = false, passHO = false;
0033   passMuon = false;
0034   scalarsToken = iC.consumes<DcsStatusCollection>(std::string("scalersRawToDigi"));
0035 }
0036 JetMETDQMDCSFilter::JetMETDQMDCSFilter(const std::string& detectorTypes,
0037                                        edm::ConsumesCollector& iC,
0038                                        const bool verbose,
0039                                        const bool alwaysPass) {
0040   verbose_ = verbose;
0041   detectorTypes_ = detectorTypes;
0042   filter_ = !alwaysPass;
0043   scalarsToken = iC.consumes<DcsStatusCollection>(std::string("scalersRawToDigi"));
0044 
0045   detectorOn_ = false;
0046   if (verbose_)
0047     std::cout << "JetMETDQMDCSFilter constructor: " << detectorTypes_ << std::endl;
0048 
0049   passPIX = false, passSiStrip = false;
0050   passECAL = false, passES = false;
0051   passHBHE = false, passHF = false, passHO = false;
0052   passMuon = false;
0053 }
0054 
0055 //
0056 // -- Destructor
0057 //
0058 JetMETDQMDCSFilter::~JetMETDQMDCSFilter() {
0059   if (verbose_)
0060     std::cout << "JetMETDQMDCSFilter destructor: " << std::endl;
0061 }
0062 
0063 bool JetMETDQMDCSFilter::filter(const edm::Event& evt, const edm::EventSetup& es) {
0064   detectorOn_ = true;
0065 
0066   if (!evt.isRealData())
0067     return detectorOn_;
0068   if (!filter_)
0069     return detectorOn_;
0070 
0071   edm::Handle<DcsStatusCollection> dcsStatus;
0072   evt.getByToken(scalarsToken, dcsStatus);
0073 
0074   if (dcsStatus.isValid() && !dcsStatus->empty()) {
0075     if (detectorTypes_.find("pixel") != std::string::npos) {
0076       if ((*dcsStatus)[0].ready(DcsStatus::BPIX) && (*dcsStatus)[0].ready(DcsStatus::FPIX)) {
0077         if (verbose_)
0078           std::cout << "pixel on" << std::endl;
0079         passPIX = true;
0080       } else
0081         detectorOn_ = false;
0082     }
0083 
0084     if (detectorTypes_.find("sistrip") != std::string::npos) {
0085       if ((*dcsStatus)[0].ready(DcsStatus::TIBTID) && (*dcsStatus)[0].ready(DcsStatus::TOB) &&
0086           (*dcsStatus)[0].ready(DcsStatus::TECp) && (*dcsStatus)[0].ready(DcsStatus::TECm)) {
0087         if (verbose_)
0088           std::cout << "sistrip on" << std::endl;
0089         passSiStrip = true;
0090       } else
0091         detectorOn_ = false;
0092     }
0093 
0094     if (detectorTypes_.find("ecal") != std::string::npos) {
0095       if ((*dcsStatus)[0].ready(DcsStatus::EBp) && (*dcsStatus)[0].ready(DcsStatus::EBm) &&
0096           (*dcsStatus)[0].ready(DcsStatus::EEp) && (*dcsStatus)[0].ready(DcsStatus::EEm)) {
0097         if (verbose_)
0098           std::cout << "ecal on" << std::endl;
0099         passECAL = true;
0100       } else
0101         detectorOn_ = false;
0102     }
0103 
0104     if (detectorTypes_.find("hbhe") != std::string::npos) {
0105       if ((*dcsStatus)[0].ready(DcsStatus::HBHEa) && (*dcsStatus)[0].ready(DcsStatus::HBHEb) &&
0106           (*dcsStatus)[0].ready(DcsStatus::HBHEc)) {
0107         if (verbose_)
0108           std::cout << "hbhe on" << std::endl;
0109         passHBHE = true;
0110       } else
0111         detectorOn_ = false;
0112     }
0113 
0114     if (detectorTypes_.find("hf") != std::string::npos) {
0115       if ((*dcsStatus)[0].ready(DcsStatus::HF)) {
0116         if (verbose_)
0117           std::cout << "hf on" << std::endl;
0118         passHF = true;
0119       } else
0120         detectorOn_ = false;
0121     }
0122 
0123     if (detectorTypes_.find("ho") != std::string::npos) {
0124       if ((*dcsStatus)[0].ready(DcsStatus::HO)) {
0125         if (verbose_)
0126           std::cout << "ho on" << std::endl;
0127         passHO = true;
0128       } else
0129         detectorOn_ = false;
0130     }
0131 
0132     if (detectorTypes_.find("es") != std::string::npos) {
0133       if ((*dcsStatus)[0].ready(DcsStatus::ESp) && (*dcsStatus)[0].ready(DcsStatus::ESm)) {
0134         if (verbose_)
0135           std::cout << "es on" << std::endl;
0136         passES = true;
0137       } else
0138         detectorOn_ = false;
0139     }
0140 
0141     if (detectorTypes_.find("muon") != std::string::npos) {
0142       if ((*dcsStatus)[0].ready(DcsStatus::RPC) && (*dcsStatus)[0].ready(DcsStatus::DT0) &&
0143           (*dcsStatus)[0].ready(DcsStatus::DTp) && (*dcsStatus)[0].ready(DcsStatus::DTm) &&
0144           (*dcsStatus)[0].ready(DcsStatus::CSCp) && (*dcsStatus)[0].ready(DcsStatus::CSCm)) {
0145         if (verbose_)
0146           std::cout << "muon on" << std::endl;
0147         passMuon = true;
0148       } else
0149         detectorOn_ = false;
0150     }
0151   }
0152   return detectorOn_;
0153 }
0154 
0155 //#include "FWCore/Framework/interface/MakerMacros.h"
0156 //DEFINE_FWK_MODULE(JetMETDQMDCSFilter);