Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-07 05:50:19

0001 /**
0002  * Demo analyzer for reading digis
0003  * author A.Tumanov 2/22/06
0004  * Updated 10.09.2013 but untested - Tim Cox
0005  *
0006  */
0007 
0008 #include <iostream>
0009 
0010 #include "FWCore/Framework/interface/ConsumesCollector.h"
0011 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "DataFormats/Common/interface/Handle.h"
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/Framework/interface/ESHandle.h"
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018 
0019 #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
0020 #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
0021 #include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h"
0022 #include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h"
0023 #include "DataFormats/CSCDigi/interface/CSCDDUStatusDigiCollection.h"
0024 #include "DataFormats/CSCDigi/interface/CSCCLCTDigiCollection.h"
0025 #include "DataFormats/CSCDigi/interface/CSCRPCDigiCollection.h"
0026 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
0027 #include "DataFormats/CSCDigi/interface/CSCDCCFormatStatusDigiCollection.h"
0028 
0029 #include "EventFilter/CSCRawToDigi/interface/CSCDDUHeader.h"
0030 #include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
0031 #include "DataFormats/CSCDigi/interface/CSCStripDigi.h"
0032 
0033 class CSCDigiAnalyzer : public edm::one::EDAnalyzer<> {
0034 public:
0035   explicit CSCDigiAnalyzer(edm::ParameterSet const& conf);
0036   void analyze(edm::Event const& e, edm::EventSetup const& iSetup) override;
0037 
0038 private:
0039   int eventNumber;
0040 
0041   edm::EDGetTokenT<CSCWireDigiCollection> wd_token;
0042   edm::EDGetTokenT<CSCStripDigiCollection> sd_token;
0043   edm::EDGetTokenT<CSCComparatorDigiCollection> cd_token;
0044   edm::EDGetTokenT<CSCALCTDigiCollection> al_token;
0045   edm::EDGetTokenT<CSCCLCTDigiCollection> cl_token;
0046   edm::EDGetTokenT<CSCRPCDigiCollection> rd_token;
0047   edm::EDGetTokenT<CSCCorrelatedLCTDigiCollection> co_token;
0048   edm::EDGetTokenT<CSCDDUStatusDigiCollection> dd_token;
0049   edm::EDGetTokenT<CSCDCCFormatStatusDigiCollection> dc_token;
0050 };
0051 
0052 CSCDigiAnalyzer::CSCDigiAnalyzer(edm::ParameterSet const& conf) {
0053   eventNumber = 0;
0054 
0055   wd_token = consumes<CSCWireDigiCollection>(conf.getParameter<edm::InputTag>("wireDigiTag"));
0056   sd_token = consumes<CSCStripDigiCollection>(conf.getParameter<edm::InputTag>("stripDigiTag"));
0057   cd_token = consumes<CSCComparatorDigiCollection>(conf.getParameter<edm::InputTag>("compDigiTag"));
0058   al_token = consumes<CSCALCTDigiCollection>(conf.getParameter<edm::InputTag>("alctDigiTag"));
0059   cl_token = consumes<CSCCLCTDigiCollection>(conf.getParameter<edm::InputTag>("clctDigiTag"));
0060   rd_token = consumes<CSCRPCDigiCollection>(conf.getParameter<edm::InputTag>("rpcDigiTag"));
0061   co_token = consumes<CSCCorrelatedLCTDigiCollection>(conf.getParameter<edm::InputTag>("corrlctDigiTag"));
0062   dd_token = consumes<CSCDDUStatusDigiCollection>(conf.getParameter<edm::InputTag>("ddusDigiTag"));
0063   dc_token = consumes<CSCDCCFormatStatusDigiCollection>(conf.getParameter<edm::InputTag>("dccfDigiTag"));
0064 }
0065 
0066 void CSCDigiAnalyzer::analyze(edm::Event const& e, edm::EventSetup const& iSetup) {
0067   edm::Handle<CSCWireDigiCollection> wires;
0068   edm::Handle<CSCStripDigiCollection> strips;
0069   edm::Handle<CSCComparatorDigiCollection> comparators;
0070   edm::Handle<CSCALCTDigiCollection> alcts;
0071   edm::Handle<CSCCLCTDigiCollection> clcts;
0072   edm::Handle<CSCRPCDigiCollection> rpcs;
0073   edm::Handle<CSCCorrelatedLCTDigiCollection> correlatedlcts;
0074   edm::Handle<CSCDDUStatusDigiCollection> dduStatusDigi;
0075   edm::Handle<CSCDCCFormatStatusDigiCollection> formatStatusDigi;
0076 
0077   e.getByToken(dd_token, dduStatusDigi);
0078   e.getByToken(wd_token, wires);
0079   e.getByToken(sd_token, strips);
0080   e.getByToken(cd_token, comparators);
0081   e.getByToken(al_token, alcts);
0082   e.getByToken(cl_token, clcts);
0083   e.getByToken(rd_token, rpcs);
0084   e.getByToken(co_token, correlatedlcts);
0085   e.getByToken(dc_token, formatStatusDigi);
0086 
0087   for (CSCDCCFormatStatusDigiCollection::DigiRangeIterator j = formatStatusDigi->begin(); j != formatStatusDigi->end();
0088        j++) {
0089     std::vector<CSCDCCFormatStatusDigi>::const_iterator digiItr = (*j).second.first;
0090     std::vector<CSCDCCFormatStatusDigi>::const_iterator last = (*j).second.second;
0091     for (; digiItr != last; ++digiItr) {
0092       digiItr->print();
0093     }
0094   }
0095 
0096   for (CSCDDUStatusDigiCollection::DigiRangeIterator j = dduStatusDigi->begin(); j != dduStatusDigi->end(); j++) {
0097     std::vector<CSCDDUStatusDigi>::const_iterator digiItr = (*j).second.first;
0098     std::vector<CSCDDUStatusDigi>::const_iterator last = (*j).second.second;
0099     for (; digiItr != last; ++digiItr) {
0100       CSCDDUHeader header(*digiItr);
0101       std::cout << "L1 number = " << header.lvl1num() << std::endl;
0102       std::cout << "DDU number = " << header.source_id() << std::endl;
0103     }
0104   }
0105 
0106   for (CSCStripDigiCollection::DigiRangeIterator j = strips->begin(); j != strips->end(); j++) {
0107     std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
0108     CSCDetId const cscDetId = (*j).first;
0109     std::cout << cscDetId << std::endl;
0110     std::vector<CSCStripDigi>::const_iterator last = (*j).second.second;
0111     for (; digiItr != last; ++digiItr) {
0112       digiItr->print();
0113     }
0114   }
0115 
0116   for (CSCWireDigiCollection::DigiRangeIterator j = wires->begin(); j != wires->end(); j++) {
0117     CSCDetId const cscDetId = (*j).first;
0118     std::cout << cscDetId << std::endl;
0119     std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
0120     std::vector<CSCWireDigi>::const_iterator last = (*j).second.second;
0121     for (; digiItr != last; ++digiItr) {
0122       digiItr->print();
0123     }
0124   }
0125 
0126   for (CSCComparatorDigiCollection::DigiRangeIterator j = comparators->begin(); j != comparators->end(); j++) {
0127     std::vector<CSCComparatorDigi>::const_iterator digiItr = (*j).second.first;
0128     std::vector<CSCComparatorDigi>::const_iterator last = (*j).second.second;
0129     for (; digiItr != last; ++digiItr) {
0130       digiItr->print();
0131     }
0132   }
0133 
0134   for (CSCALCTDigiCollection::DigiRangeIterator j = alcts->begin(); j != alcts->end(); j++) {
0135     std::vector<CSCALCTDigi>::const_iterator digiItr = (*j).second.first;
0136     std::vector<CSCALCTDigi>::const_iterator last = (*j).second.second;
0137     for (; digiItr != last; ++digiItr) {
0138       digiItr->print();
0139     }
0140   }
0141 
0142   for (CSCCLCTDigiCollection::DigiRangeIterator j = clcts->begin(); j != clcts->end(); j++) {
0143     std::vector<CSCCLCTDigi>::const_iterator digiItr = (*j).second.first;
0144     std::vector<CSCCLCTDigi>::const_iterator last = (*j).second.second;
0145     for (; digiItr != last; ++digiItr) {
0146       digiItr->print();
0147     }
0148   }
0149 
0150   for (CSCRPCDigiCollection::DigiRangeIterator j = rpcs->begin(); j != rpcs->end(); j++) {
0151     std::vector<CSCRPCDigi>::const_iterator digiItr = (*j).second.first;
0152     std::vector<CSCRPCDigi>::const_iterator last = (*j).second.second;
0153     for (; digiItr != last; ++digiItr) {
0154       digiItr->print();
0155     }
0156   }
0157 
0158   for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator j = correlatedlcts->begin(); j != correlatedlcts->end(); j++) {
0159     std::vector<CSCCorrelatedLCTDigi>::const_iterator digiItr = (*j).second.first;
0160     std::vector<CSCCorrelatedLCTDigi>::const_iterator last = (*j).second.second;
0161     for (; digiItr != last; ++digiItr) {
0162       digiItr->print();
0163     }
0164   }
0165 
0166   eventNumber++;
0167   edm::LogInfo("CSCDigiAnalyzer") << "end of event number " << eventNumber;
0168 }
0169 
0170 #include "FWCore/Framework/interface/MakerMacros.h"
0171 DEFINE_FWK_MODULE(CSCDigiAnalyzer);