Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:43

0001 /** \class TriggerSummaryAnalyzerAOD
0002  *
0003  *  This class is an EDAnalyzer analyzing the HLT summary object for AOD
0004  *
0005  *
0006  *  \author Martin Grunewald
0007  *
0008  */
0009 
0010 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0015 #include "FWCore/Framework/interface/MakerMacros.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 
0018 //
0019 // class declaration
0020 //
0021 class TriggerSummaryAnalyzerAOD : public edm::global::EDAnalyzer<> {
0022 public:
0023   explicit TriggerSummaryAnalyzerAOD(const edm::ParameterSet&);
0024 
0025   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0026   void analyze(edm::StreamID, const edm::Event&, const edm::EventSetup&) const override;
0027 
0028 private:
0029   /// InputTag of TriggerEvent to analyze
0030   const edm::InputTag inputTag_;
0031   const edm::EDGetTokenT<trigger::TriggerEvent> inputToken_;
0032 };
0033 
0034 //
0035 // constructors and destructor
0036 //
0037 TriggerSummaryAnalyzerAOD::TriggerSummaryAnalyzerAOD(const edm::ParameterSet& ps)
0038     : inputTag_(ps.getParameter<edm::InputTag>("inputTag")), inputToken_(consumes<trigger::TriggerEvent>(inputTag_)) {}
0039 
0040 //
0041 // member functions
0042 //
0043 
0044 void TriggerSummaryAnalyzerAOD::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0045   edm::ParameterSetDescription desc;
0046   desc.add<edm::InputTag>("inputTag", edm::InputTag("hltTriggerSummaryAOD"));
0047   descriptions.add("triggerSummaryAnalyzerAOD", desc);
0048 }
0049 
0050 // ------------ method called to produce the data  ------------
0051 void TriggerSummaryAnalyzerAOD::analyze(edm::StreamID, const edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0052   using namespace std;
0053   using namespace edm;
0054   using namespace reco;
0055   using namespace trigger;
0056 
0057   LogVerbatim("TriggerSummaryAnalyzerAOD") << endl;
0058   LogVerbatim("TriggerSummaryAnalyzerAOD")
0059       << "TriggerSummaryAnalyzerAOD: content of TriggerEvent: " << inputTag_.encode() << endl;
0060 
0061   Handle<TriggerEvent> handle;
0062   iEvent.getByToken(inputToken_, handle);
0063   if (handle.isValid()) {
0064     LogVerbatim("TriggerSummaryAnalyzerAOD") << "Used Processname: " << handle->usedProcessName() << endl;
0065     const size_type nC(handle->sizeCollections());
0066     LogVerbatim("TriggerSummaryAnalyzerAOD") << "Number of packed Collections: " << nC << endl;
0067     LogVerbatim("TriggerSummaryAnalyzerAOD") << "The Collections: #, tag, 1-past-end index" << endl;
0068     for (size_type iC = 0; iC != nC; ++iC) {
0069       LogVerbatim("TriggerSummaryAnalyzerAOD")
0070           << iC << " " << handle->collectionTag(iC).encode() << " " << handle->collectionKey(iC) << endl;
0071     }
0072     const size_type nO(handle->sizeObjects());
0073     LogVerbatim("TriggerSummaryAnalyzerAOD") << "Number of TriggerObjects: " << nO << endl;
0074     LogVerbatim("TriggerSummaryAnalyzerAOD") << "The TriggerObjects: #, id, pt, eta, phi, mass" << endl;
0075     const TriggerObjectCollection& TOC(handle->getObjects());
0076     for (size_type iO = 0; iO != nO; ++iO) {
0077       const TriggerObject& TO(TOC[iO]);
0078       LogVerbatim("TriggerSummaryAnalyzerAOD")
0079           << iO << " " << TO.id() << " " << TO.pt() << " " << TO.eta() << " " << TO.phi() << " " << TO.mass() << endl;
0080     }
0081     const size_type nF(handle->sizeFilters());
0082     LogVerbatim("TriggerSummaryAnalyzerAOD") << "Number of TriggerFilters: " << nF << endl;
0083     LogVerbatim("TriggerSummaryAnalyzerAOD") << "The Filters: #, tag, #ids/#keys, the id/key pairs" << endl;
0084     for (size_type iF = 0; iF != nF; ++iF) {
0085       const Vids& VIDS(handle->filterIds(iF));
0086       const Keys& KEYS(handle->filterKeys(iF));
0087       const size_type nI(VIDS.size());
0088       const size_type nK(KEYS.size());
0089       LogVerbatim("TriggerSummaryAnalyzerAOD")
0090           << iF << " " << handle->filterTag(iF).encode() << " " << nI << "/" << nK << " the pairs: ";
0091       const size_type n(max(nI, nK));
0092       for (size_type i = 0; i != n; ++i) {
0093         LogVerbatim("TriggerSummaryAnalyzerAOD") << " " << VIDS[i] << "/" << KEYS[i];
0094       }
0095       LogVerbatim("TriggerSummaryAnalyzerAOD") << endl;
0096       assert(nI == nK);
0097     }
0098   } else {
0099     LogVerbatim("TriggerSummaryAnalyzerAOD") << "Handle invalid! Check InputTag provided." << endl;
0100   }
0101   LogVerbatim("TriggerSummaryAnalyzerAOD") << endl;
0102 
0103   return;
0104 }
0105 
0106 DEFINE_FWK_MODULE(TriggerSummaryAnalyzerAOD);