Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-10 01:53:45

0001 ///
0002 /// \class l1t::GtInputDump.cc
0003 ///
0004 /// Description: Dump/Analyze Input Collections for GT.
0005 ///
0006 /// Implementation:
0007 ///    Based off of Michael Mulhearn's YellowParamTester
0008 ///
0009 /// \author: Brian Winer Ohio State
0010 ///
0011 
0012 //
0013 //  This simple module simply retreives the YellowParams object from the event
0014 //  setup, and sends its payload as an INFO message, for debugging purposes.
0015 //
0016 
0017 #include "FWCore/Framework/interface/MakerMacros.h"
0018 
0019 #include "FWCore/Framework/interface/EDAnalyzer.h"
0020 //#include "FWCore/ParameterSet/interface/InputTag.h"
0021 
0022 // system include files
0023 #include <iomanip>
0024 
0025 // user include files
0026 //   base class
0027 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0028 
0029 #include "FWCore/Framework/interface/Event.h"
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031 #include "FWCore/Utilities/interface/EDGetToken.h"
0032 #include "FWCore/Utilities/interface/InputTag.h"
0033 #include "FWCore/Framework/interface/EventSetup.h"
0034 #include "FWCore/Framework/interface/Frameworkfwd.h"
0035 
0036 #include "DataFormats/L1Trigger/interface/EGamma.h"
0037 #include "DataFormats/L1Trigger/interface/Muon.h"
0038 #include "DataFormats/L1Trigger/interface/Tau.h"
0039 #include "DataFormats/L1Trigger/interface/Jet.h"
0040 #include "DataFormats/L1Trigger/interface/EtSum.h"
0041 
0042 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0043 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0044 
0045 using namespace edm;
0046 using namespace std;
0047 
0048 namespace l1t {
0049 
0050   // class declaration
0051   class GtInputDump : public edm::one::EDAnalyzer<> {
0052   public:
0053     explicit GtInputDump(const edm::ParameterSet&);
0054     ~GtInputDump() override{};
0055     void analyze(const edm::Event&, const edm::EventSetup&) override;
0056 
0057     EDGetToken egToken;
0058     EDGetToken muToken;
0059     EDGetToken tauToken;
0060     EDGetToken jetToken;
0061     EDGetToken etsumToken;
0062 
0063     int m_minBx;
0064     int m_maxBx;
0065   };
0066 
0067   GtInputDump::GtInputDump(const edm::ParameterSet& iConfig) {
0068     egToken = consumes<BXVector<l1t::EGamma>>(iConfig.getParameter<InputTag>("egInputTag"));
0069     muToken = consumes<BXVector<l1t::Muon>>(iConfig.getParameter<InputTag>("muInputTag"));
0070     tauToken = consumes<BXVector<l1t::Tau>>(iConfig.getParameter<InputTag>("tauInputTag"));
0071     jetToken = consumes<BXVector<l1t::Jet>>(iConfig.getParameter<InputTag>("jetInputTag"));
0072     etsumToken = consumes<BXVector<l1t::EtSum>>(iConfig.getParameter<InputTag>("etsumInputTag"));
0073 
0074     m_minBx = iConfig.getParameter<int>("minBx");
0075     m_maxBx = iConfig.getParameter<int>("maxBx");
0076   }
0077 
0078   // loop over events
0079   void GtInputDump::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0080     //inputs
0081     Handle<BXVector<l1t::EGamma>> egammas;
0082     iEvent.getByToken(egToken, egammas);
0083 
0084     Handle<BXVector<l1t::Muon>> muons;
0085     iEvent.getByToken(muToken, muons);
0086 
0087     Handle<BXVector<l1t::Tau>> taus;
0088     iEvent.getByToken(tauToken, taus);
0089 
0090     Handle<BXVector<l1t::Jet>> jets;
0091     iEvent.getByToken(jetToken, jets);
0092 
0093     Handle<BXVector<l1t::EtSum>> etsums;
0094     iEvent.getByToken(etsumToken, etsums);
0095 
0096     printf("\n -------------------------------------- \n");
0097     printf(" ***********  New Event  ************** \n");
0098     printf(" -------------------------------------- \n");
0099     //Loop over BX
0100     //Loop over BX
0101     for (int i = m_minBx; i <= m_maxBx; ++i) {
0102       cout << " ========== BX = " << std::dec << i << " =============================" << endl;
0103 
0104       //Loop over EGamma
0105       int nObj = 0;
0106       cout << " ------ EGammas -------- " << endl;
0107       if (egammas.isValid()) {
0108         if (i >= egammas->getFirstBX() && i <= egammas->getLastBX()) {
0109           for (std::vector<l1t::EGamma>::const_iterator eg = egammas->begin(i); eg != egammas->end(i); ++eg) {
0110             cout << "  " << std::dec << std::setw(2) << std::setfill(' ') << nObj << std::setfill('0') << ")";
0111             cout << "   Pt " << std::dec << std::setw(3) << eg->hwPt() << " (0x" << std::hex << std::setw(3)
0112                  << std::setfill('0') << eg->hwPt() << ")";
0113             cout << "   Eta " << std::dec << std::setw(3) << eg->hwEta() << " (0x" << std::hex << std::setw(2)
0114                  << std::setfill('0') << (eg->hwEta() & 0xff) << ")";
0115             cout << "   Phi " << std::dec << std::setw(3) << eg->hwPhi() << " (0x" << std::hex << std::setw(2)
0116                  << std::setfill('0') << eg->hwPhi() << ")";
0117             cout << "   Iso " << std::dec << std::setw(1) << eg->hwIso();
0118             cout << "   Qual " << std::dec << std::setw(1) << eg->hwQual();
0119             cout << endl;
0120             nObj++;
0121           }
0122         } else {
0123           cout << "No EG stored for this bx " << i << endl;
0124         }
0125       } else {
0126         cout << "No EG Data in this event " << endl;
0127       }
0128 
0129       //Loop over Muons
0130       nObj = 0;
0131       cout << " ------ Muons --------" << endl;
0132       if (muons.isValid()) {
0133         if (i >= muons->getFirstBX() && i <= muons->getLastBX()) {
0134           for (std::vector<l1t::Muon>::const_iterator mu = muons->begin(i); mu != muons->end(i); ++mu) {
0135             cout << "  " << std::dec << std::setw(2) << std::setfill(' ') << nObj << std::setfill('0') << ")";
0136             cout << "   Pt " << std::dec << std::setw(3) << mu->hwPt() << " (0x" << std::hex << std::setw(3)
0137                  << std::setfill('0') << mu->hwPt() << ")";
0138             cout << "   EtaAtVtx " << std::dec << std::setw(3) << mu->hwEtaAtVtx() << " (0x" << std::hex << std::setw(3)
0139                  << std::setfill('0') << (mu->hwEtaAtVtx() & 0x1ff) << ")";
0140             cout << "   Eta " << std::dec << std::setw(3) << mu->hwEta() << " (0x" << std::hex << std::setw(3)
0141                  << std::setfill('0') << (mu->hwEta() & 0x1ff) << ")";
0142             cout << "   PhiAtVtx " << std::dec << std::setw(3) << mu->hwPhiAtVtx() << " (0x" << std::hex << std::setw(3)
0143                  << std::setfill('0') << mu->hwPhiAtVtx() << ")";
0144             cout << "   Phi " << std::dec << std::setw(3) << mu->hwPhi() << " (0x" << std::hex << std::setw(3)
0145                  << std::setfill('0') << mu->hwPhi() << ")";
0146             cout << "   Iso " << std::dec << std::setw(1) << mu->hwIso();
0147             cout << "   Qual " << std::dec << std::setw(1) << mu->hwQual();
0148             cout << endl;
0149             nObj++;
0150           }
0151         } else {
0152           cout << "No Muons stored for this bx " << i << endl;
0153         }
0154       } else {
0155         cout << "No Muon Data in this event " << endl;
0156       }
0157 
0158       //Loop over Taus
0159       nObj = 0;
0160       cout << " ------ Taus ----------" << endl;
0161       if (taus.isValid()) {
0162         if (i >= taus->getFirstBX() && i <= taus->getLastBX()) {
0163           for (std::vector<l1t::Tau>::const_iterator tau = taus->begin(i); tau != taus->end(i); ++tau) {
0164             cout << "  " << std::dec << std::setw(2) << std::setfill(' ') << nObj << std::setfill('0') << ")";
0165             cout << "   Pt " << std::dec << std::setw(3) << tau->hwPt() << " (0x" << std::hex << std::setw(3)
0166                  << std::setfill('0') << tau->hwPt() << ")";
0167             cout << "   Eta " << std::dec << std::setw(3) << tau->hwEta() << " (0x" << std::hex << std::setw(2)
0168                  << std::setfill('0') << (tau->hwEta() & 0xff) << ")";
0169             cout << "   Phi " << std::dec << std::setw(3) << tau->hwPhi() << " (0x" << std::hex << std::setw(2)
0170                  << std::setfill('0') << tau->hwPhi() << ")";
0171             cout << "   Iso " << std::dec << std::setw(1) << tau->hwIso();
0172             cout << "   Qual " << std::dec << std::setw(1) << tau->hwQual();
0173             cout << endl;
0174             nObj++;
0175           }
0176         } else {
0177           cout << "No Taus stored for this bx " << i << endl;
0178         }
0179       } else {
0180         cout << "No Tau Data in this event " << endl;
0181       }
0182 
0183       //Loop over Jets
0184       nObj = 0;
0185       cout << " ------ Jets ----------" << endl;
0186       if (jets.isValid()) {
0187         if (i >= jets->getFirstBX() && i <= jets->getLastBX()) {
0188           for (std::vector<l1t::Jet>::const_iterator jet = jets->begin(i); jet != jets->end(i); ++jet) {
0189             cout << "  " << std::dec << std::setw(2) << std::setfill(' ') << nObj << std::setfill('0') << ")";
0190             cout << "   Pt " << std::dec << std::setw(3) << jet->hwPt() << " (0x" << std::hex << std::setw(3)
0191                  << std::setfill('0') << jet->hwPt() << ")";
0192             cout << "   Eta " << std::dec << std::setw(3) << jet->hwEta() << " (0x" << std::hex << std::setw(2)
0193                  << std::setfill('0') << (jet->hwEta() & 0xff) << ")";
0194             cout << "   Phi " << std::dec << std::setw(3) << jet->hwPhi() << " (0x" << std::hex << std::setw(2)
0195                  << std::setfill('0') << jet->hwPhi() << ")";
0196             cout << "   Qual " << std::dec << std::setw(1) << jet->hwQual();
0197             cout << endl;
0198             nObj++;
0199           }
0200         } else {
0201           cout << "No Jets stored for this bx " << i << endl;
0202         }
0203       } else {
0204         cout << "No jet Data in this event " << endl;
0205       }
0206 
0207       //Dump Content
0208       cout << " ------ EtSums ----------" << endl;
0209       if (etsums.isValid()) {
0210         if (i >= etsums->getFirstBX() && i <= etsums->getLastBX()) {
0211           for (std::vector<l1t::EtSum>::const_iterator etsum = etsums->begin(i); etsum != etsums->end(i); ++etsum) {
0212             switch (etsum->getType()) {
0213               case l1t::EtSum::EtSumType::kMissingEt:
0214                 cout << " ETM: ";
0215                 break;
0216               case l1t::EtSum::EtSumType::kMissingHt:
0217                 cout << " HTM: ";
0218                 break;
0219               case l1t::EtSum::EtSumType::kTotalEt:
0220                 cout << " ETT: ";
0221                 break;
0222               case l1t::EtSum::EtSumType::kTotalHt:
0223                 cout << " HTT: ";
0224                 break;
0225               default:
0226                 cout << " Unknown: ";
0227                 break;
0228             }
0229             cout << " Et " << std::dec << std::setw(3) << etsum->hwPt() << " (0x" << std::hex << std::setw(3)
0230                  << std::setfill('0') << etsum->hwPt() << ")";
0231             if (etsum->getType() == l1t::EtSum::EtSumType::kMissingEt ||
0232                 etsum->getType() == l1t::EtSum::EtSumType::kMissingHt)
0233               cout << " Phi " << std::dec << std::setw(3) << etsum->hwPhi() << " (0x" << std::hex << std::setw(2)
0234                    << std::setfill('0') << etsum->hwPhi() << ")";
0235             cout << endl;
0236           }
0237         } else {
0238           cout << "No EtSums stored for this bx " << i << endl;
0239         }
0240       } else {
0241         cout << "No EtSum Data in this event " << endl;
0242       }
0243     }
0244     printf("\n");
0245   }
0246 
0247 }  // namespace l1t
0248 
0249 DEFINE_FWK_MODULE(l1t::GtInputDump);