Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:19

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   std::vector<ecaldqm::Collections> collectionsToSkip;
0049   for (const auto& skipColName : skipCollections_) {
0050     for (unsigned iCol = 0; iCol <= ecaldqm::nCollections; iCol++) {
0051       if (iCol == ecaldqm::nCollections)
0052         throw cms::Exception("InvalidConfiguration")
0053             << moduleName_ << "::formSchedule: Collection name " << skipColName << " in skipCollections does not exist";
0054       if (skipColName == ecaldqm::collectionName[iCol]) {
0055         collectionsToSkip.push_back(ecaldqm::Collections(iCol));
0056         break;
0057       }
0058     }
0059   }
0060 
0061   for (std::vector<ecaldqm::Collections>::const_iterator colItr(_preSchedule.begin()); colItr != _preSchedule.end();
0062        ++colItr) {
0063     std::pair<Processor, ecaldqm::Collections> sch;
0064 
0065     edm::InputTag tag(_tagPSet.getUntrackedParameter<edm::InputTag>(ecaldqm::collectionName[*colItr]));
0066 
0067     auto skipItr = std::find(collectionsToSkip.begin(), collectionsToSkip.end(), *colItr);
0068     if (skipItr != collectionsToSkip.end()) {
0069       if (verbosity_ > 0)
0070         edm::LogInfo("EcalDQM") << moduleName_ << ": Skipping collection " << ecaldqm::collectionName[*colItr]
0071                                 << " and removing from schedule";
0072       collectionsToSkip.erase(skipItr);
0073       continue;
0074     }
0075 
0076     switch (*colItr) {
0077       case ecaldqm::kSource:
0078         collectionTokens_[*colItr] = edm::EDGetToken(consumes<FEDRawDataCollection>(tag));
0079         sch.first = &EcalDQMonitorTask::runOnCollection<FEDRawDataCollection>;
0080         break;
0081       case ecaldqm::kEcalRawData:
0082         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalRawDataCollection>(tag));
0083         sch.first = &EcalDQMonitorTask::runOnCollection<EcalRawDataCollection>;
0084         break;
0085       case ecaldqm::kEBGainErrors:
0086       case ecaldqm::kEBChIdErrors:
0087       case ecaldqm::kEBGainSwitchErrors:
0088         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EBDetIdCollection>(tag));
0089         sch.first = &EcalDQMonitorTask::runOnCollection<EBDetIdCollection>;
0090         break;
0091       case ecaldqm::kEEGainErrors:
0092       case ecaldqm::kEEChIdErrors:
0093       case ecaldqm::kEEGainSwitchErrors:
0094         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EEDetIdCollection>(tag));
0095         sch.first = &EcalDQMonitorTask::runOnCollection<EEDetIdCollection>;
0096         break;
0097       case ecaldqm::kTowerIdErrors:
0098       case ecaldqm::kBlockSizeErrors:
0099       case ecaldqm::kMEMTowerIdErrors:
0100       case ecaldqm::kMEMBlockSizeErrors:
0101       case ecaldqm::kMEMChIdErrors:
0102       case ecaldqm::kMEMGainErrors:
0103         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalElectronicsIdCollection>(tag));
0104         sch.first = &EcalDQMonitorTask::runOnCollection<EcalElectronicsIdCollection>;
0105         break;
0106       case ecaldqm::kEBSrFlag:
0107         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EBSrFlagCollection>(tag));
0108         sch.first = &EcalDQMonitorTask::runOnCollection<EBSrFlagCollection>;
0109         break;
0110       case ecaldqm::kEESrFlag:
0111         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EESrFlagCollection>(tag));
0112         sch.first = &EcalDQMonitorTask::runOnCollection<EESrFlagCollection>;
0113         break;
0114       case ecaldqm::kEBDigi:
0115       case ecaldqm::kEBCpuDigi:
0116       case ecaldqm::kEBGpuDigi:
0117         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EBDigiCollection>(tag));
0118         sch.first = &EcalDQMonitorTask::runOnCollection<EBDigiCollection>;
0119         break;
0120       case ecaldqm::kEEDigi:
0121       case ecaldqm::kEECpuDigi:
0122       case ecaldqm::kEEGpuDigi:
0123         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EEDigiCollection>(tag));
0124         sch.first = &EcalDQMonitorTask::runOnCollection<EEDigiCollection>;
0125         break;
0126       case ecaldqm::kPnDiodeDigi:
0127         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalPnDiodeDigiCollection>(tag));
0128         sch.first = &EcalDQMonitorTask::runOnCollection<EcalPnDiodeDigiCollection>;
0129         break;
0130       case ecaldqm::kTrigPrimDigi:
0131       case ecaldqm::kTrigPrimEmulDigi:
0132         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalTrigPrimDigiCollection>(tag));
0133         sch.first = &EcalDQMonitorTask::runOnCollection<EcalTrigPrimDigiCollection>;
0134         break;
0135       case ecaldqm::kEBUncalibRecHit:
0136       case ecaldqm::kEEUncalibRecHit:
0137       case ecaldqm::kEBLaserLedUncalibRecHit:
0138       case ecaldqm::kEELaserLedUncalibRecHit:
0139       case ecaldqm::kEBTestPulseUncalibRecHit:
0140       case ecaldqm::kEETestPulseUncalibRecHit:
0141       case ecaldqm::kEBCpuUncalibRecHit:
0142       case ecaldqm::kEECpuUncalibRecHit:
0143       case ecaldqm::kEBGpuUncalibRecHit:
0144       case ecaldqm::kEEGpuUncalibRecHit:
0145         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalUncalibratedRecHitCollection>(tag));
0146         sch.first = &EcalDQMonitorTask::runOnCollection<EcalUncalibratedRecHitCollection>;
0147         break;
0148       case ecaldqm::kEBRecHit:
0149       case ecaldqm::kEBReducedRecHit:
0150       case ecaldqm::kEERecHit:
0151       case ecaldqm::kEEReducedRecHit:
0152       case ecaldqm::kEBCpuRecHit:
0153       case ecaldqm::kEECpuRecHit:
0154       case ecaldqm::kEBGpuRecHit:
0155       case ecaldqm::kEEGpuRecHit:
0156         collectionTokens_[*colItr] = edm::EDGetToken(consumes<EcalRecHitCollection>(tag));
0157         sch.first = &EcalDQMonitorTask::runOnCollection<EcalRecHitCollection>;
0158         break;
0159       case ecaldqm::kEBBasicCluster:
0160       case ecaldqm::kEEBasicCluster:
0161         collectionTokens_[*colItr] = edm::EDGetToken(consumes<edm::View<reco::CaloCluster> >(tag));
0162         sch.first = &EcalDQMonitorTask::runOnCollection<edm::View<reco::CaloCluster> >;
0163         break;
0164       case ecaldqm::kEBSuperCluster:
0165       case ecaldqm::kEESuperCluster:
0166         collectionTokens_[*colItr] = edm::EDGetToken(consumes<reco::SuperClusterCollection>(tag));
0167         sch.first = &EcalDQMonitorTask::runOnCollection<reco::SuperClusterCollection>;
0168         break;
0169       default:
0170         throw cms::Exception("InvalidConfiguration") << "Undefined collection " << *colItr;
0171     }
0172 
0173     sch.second = *colItr;
0174 
0175     schedule_.push_back(sch);
0176   }
0177   for (const auto& colNotSkipped : collectionsToSkip)
0178     edm::LogWarning("EcalDQM") << moduleName_
0179                                << "::formSchedule: Collection: " << ecaldqm::collectionName[colNotSkipped]
0180                                << " is not in the schedule but was listed to be skipped";
0181 }