Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-23 01:35:31

0001 #include "DQM/EcalMonitorTasks/interface/EcalDQMonitorTask.h"
0002 
0003 #include "DQM/EcalMonitorTasks/interface/DQWorkerTask.h"
0004 
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Utilities/interface/Exception.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include "DataFormats/Common/interface/Handle.h"
0010 #include "DataFormats/Common/interface/View.h"
0011 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0012 #include "DataFormats/EcalRawData/interface/EcalRawDataCollections.h"
0013 #include "DataFormats/EcalDetId/interface/EcalDetIdCollections.h"
0014 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0015 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0016 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
0017 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
0018 
0019 template <typename CollectionClass>
0020 void EcalDQMonitorTask::runOnCollection(edm::Event const& _evt,
0021                                         ecaldqm::Collections _col,
0022                                         std::set<ecaldqm::DQWorker*> const& _enabledTasks) {
0023   edm::Handle<CollectionClass> hndl;
0024   if (!_evt.getByToken(collectionTokens_[_col], hndl)) {
0025     if (!allowMissingCollections_)
0026       throw cms::Exception("ObjectNotFound")
0027           << moduleName_ << "::runOnCollection: " << ecaldqm::collectionName[_col] << " does not exist";
0028     edm::LogWarning("EcalDQM") << moduleName_ << "::runOnCollection: " << ecaldqm::collectionName[_col]
0029                                << " does not exist";
0030     return;
0031   }
0032 
0033   CollectionClass const* collection(hndl.product());
0034 
0035   executeOnWorkers_(
0036       [collection, _col, &_enabledTasks](ecaldqm::DQWorker* worker) {
0037         if (_enabledTasks.find(worker) != _enabledTasks.end())
0038           static_cast<ecaldqm::DQWorkerTask*>(worker)->analyze(collection, _col);
0039       },
0040       "analyze");
0041 
0042   if (verbosity_ > 1)
0043     edm::LogInfo("EcalDQM") << moduleName_ << "::runOn" << ecaldqm::collectionName[_col] << " returning";
0044 }
0045 
0046 void EcalDQMonitorTask::formSchedule(std::vector<ecaldqm::Collections> const& _preSchedule,
0047                                      edm::ParameterSet const& _tagPSet) {
0048   for (std::vector<ecaldqm::Collections>::const_iterator colItr(_preSchedule.begin()); colItr != _preSchedule.end();
0049        ++colItr) {
0050     std::pair<Processor, ecaldqm::Collections> sch;
0051 
0052     edm::InputTag tag(_tagPSet.getUntrackedParameter<edm::InputTag>(ecaldqm::collectionName[*colItr]));
0053 
0054     switch (*colItr) {
0055       case ecaldqm::kSource:
0056         collectionTokens_[*colItr] = edm::EDGetToken(consumes<FEDRawDataCollection>(tag));
0057         sch.first = &EcalDQMonitorTask::runOnCollection<FEDRawDataCollection>;
0058         break;
0059       case ecaldqm::kEcalRawData:
0060         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalRawDataCollection>(tag));
0061         sch.first = &EcalDQMonitorTask::runOnCollection<EcalRawDataCollection>;
0062         break;
0063       case ecaldqm::kEBGainErrors:
0064       case ecaldqm::kEBChIdErrors:
0065       case ecaldqm::kEBGainSwitchErrors:
0066         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EBDetIdCollection>(tag));
0067         sch.first = &EcalDQMonitorTask::runOnCollection<EBDetIdCollection>;
0068         break;
0069       case ecaldqm::kEEGainErrors:
0070       case ecaldqm::kEEChIdErrors:
0071       case ecaldqm::kEEGainSwitchErrors:
0072         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EEDetIdCollection>(tag));
0073         sch.first = &EcalDQMonitorTask::runOnCollection<EEDetIdCollection>;
0074         break;
0075       case ecaldqm::kTowerIdErrors:
0076       case ecaldqm::kBlockSizeErrors:
0077       case ecaldqm::kMEMTowerIdErrors:
0078       case ecaldqm::kMEMBlockSizeErrors:
0079       case ecaldqm::kMEMChIdErrors:
0080       case ecaldqm::kMEMGainErrors:
0081         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalElectronicsIdCollection>(tag));
0082         sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>;
0083         break;
0084       case ecaldqm::kEBSrFlag:
0085         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EBSrFlagCollection>(tag));
0086         sch.first = &EcalDQMonitorTask::runOnCollection<EBSrFlagCollection>;
0087         break;
0088       case ecaldqm::kEESrFlag:
0089         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EESrFlagCollection>(tag));
0090         sch.first = &EcalDQMonitorTask::runOnCollection<EESrFlagCollection>;
0091         break;
0092       case ecaldqm::kEBDigi:
0093       case ecaldqm::kEBCpuDigi:
0094       case ecaldqm::kEBGpuDigi:
0095         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EBDigiCollection>(tag));
0096         sch.first = &EcalDQMonitorTask::runOnCollection<EBDigiCollection>;
0097         break;
0098       case ecaldqm::kEEDigi:
0099       case ecaldqm::kEECpuDigi:
0100       case ecaldqm::kEEGpuDigi:
0101         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EEDigiCollection>(tag));
0102         sch.first = &EcalDQMonitorTask::runOnCollection<EEDigiCollection>;
0103         break;
0104       case ecaldqm::kPnDiodeDigi:
0105         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalPnDiodeDigiCollection>(tag));
0106         sch.first = &EcalDQMonitorTask::runOnCollection<EcalPnDiodeDigiCollection>;
0107         break;
0108       case ecaldqm::kTrigPrimDigi:
0109       case ecaldqm::kTrigPrimEmulDigi:
0110         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalTrigPrimDigiCollection>(tag));
0111         sch.first = &EcalDQMonitorTask::runOnCollection<EcalTrigPrimDigiCollection>;
0112         break;
0113       case ecaldqm::kEBUncalibRecHit:
0114       case ecaldqm::kEEUncalibRecHit:
0115       case ecaldqm::kEBLaserLedUncalibRecHit:
0116       case ecaldqm::kEELaserLedUncalibRecHit:
0117       case ecaldqm::kEBTestPulseUncalibRecHit:
0118       case ecaldqm::kEETestPulseUncalibRecHit:
0119       case ecaldqm::kEBCpuUncalibRecHit:
0120       case ecaldqm::kEECpuUncalibRecHit:
0121       case ecaldqm::kEBGpuUncalibRecHit:
0122       case ecaldqm::kEEGpuUncalibRecHit:
0123         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalUncalibratedRecHitCollection>(tag));
0124         sch.first = &EcalDQMonitorTask::runOnCollection<EcalUncalibratedRecHitCollection>;
0125         break;
0126       case ecaldqm::kEBRecHit:
0127       case ecaldqm::kEBReducedRecHit:
0128       case ecaldqm::kEERecHit:
0129       case ecaldqm::kEEReducedRecHit:
0130       case ecaldqm::kEBCpuRecHit:
0131       case ecaldqm::kEECpuRecHit:
0132       case ecaldqm::kEBGpuRecHit:
0133       case ecaldqm::kEEGpuRecHit:
0134         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalRecHitCollection>(tag));
0135         sch.first = &EcalDQMonitorTask::runOnCollection<EcalRecHitCollection>;
0136         break;
0137       case ecaldqm::kEBBasicCluster:
0138       case ecaldqm::kEEBasicCluster:
0139         collectionTokens_[*colItr] = edm::EDGetToken(consumes<edm::View<reco::CaloCluster> >(tag));
0140         sch.first = &EcalDQMonitorTask::runOnCollection<edm::View<reco::CaloCluster> >;
0141         break;
0142       case ecaldqm::kEBSuperCluster:
0143       case ecaldqm::kEESuperCluster:
0144         collectionTokens_[*colItr] = edm::EDGetToken(consumes<reco::SuperClusterCollection>(tag));
0145         sch.first = &EcalDQMonitorTask::runOnCollection<reco::SuperClusterCollection>;
0146         break;
0147       default:
0148         throw cms::Exception("InvalidConfiguration") << "Undefined collection " << *colItr;
0149     }
0150 
0151     sch.second = *colItr;
0152 
0153     schedule_.push_back(sch);
0154   }
0155 }