Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:24

0001 /** \file
0002  *
0003  *  \author A. Tumanov - Rice
0004  */
0005 
0006 #include <iostream>
0007 
0008 #include <FWCore/Framework/interface/ConsumesCollector.h>
0009 #include <FWCore/Utilities/interface/InputTag.h>
0010 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "DataFormats/Common/interface/Handle.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/Framework/interface/ESHandle.h"
0016 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
0017 
0018 class CSCDigiToPattern : public edm::one::EDAnalyzer<> {
0019 public:
0020   explicit CSCDigiToPattern(edm::ParameterSet const& conf);
0021   void analyze(edm::Event const& e, edm::EventSetup const& iSetup) override;
0022 
0023   //virtual void endJob();
0024 private:
0025   // variables persistent across events should be declared here.
0026   edm::EDGetTokenT<CSCCorrelatedLCTDigiCollection> d_token;
0027   //
0028 };
0029 
0030 CSCDigiToPattern::CSCDigiToPattern(edm::ParameterSet const& conf) {
0031   d_token = consumes<CSCCorrelatedLCTDigiCollection>(conf.getParameter<edm::InputTag>("corrlctDigiTag"));
0032 }
0033 
0034 void CSCDigiToPattern::analyze(edm::Event const& e, edm::EventSetup const& iSetup) {
0035   // These declarations create handles to the types of records that you want
0036   // to retrieve from event "e".
0037   //
0038   edm::Handle<CSCCorrelatedLCTDigiCollection> correlatedlcts;
0039   e.getByToken(d_token, correlatedlcts);
0040 
0041   for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator j = correlatedlcts->begin(); j != correlatedlcts->end(); j++) {
0042     CSCDetId id = (*j).first;
0043     std::cout << id << std::endl;
0044     std::vector<CSCCorrelatedLCTDigi>::const_iterator digiIt = (*j).second.first;
0045     std::vector<CSCCorrelatedLCTDigi>::const_iterator last = (*j).second.second;
0046     for (; digiIt != last; ++digiIt) {
0047       uint16_t wire = digiIt->getKeyWG();       // 7 bits
0048       uint16_t pattern = digiIt->getPattern();  // 4 bits
0049       uint16_t quality = digiIt->getQuality();  // 4 bits
0050       uint16_t valid = digiIt->isValid();       // 1 bit
0051       uint16_t strip = digiIt->getStrip();      // 8 bits
0052       uint16_t bend = digiIt->getBend();        // 1 bit
0053       uint16_t syncErr = digiIt->getSyncErr();  // 1 bit
0054       uint16_t bx = digiIt->getBX();            // 1 bit
0055       uint16_t bx0 = digiIt->getBX0();          // 1 bit
0056       uint16_t cscId = digiIt->getCSCID();      // 4 bits
0057       //                                             __
0058       //                                             32 bits in total
0059       long unsigned int mpc = ((cscId & 0xF) << 28) | ((bx0 & 0x1) << 27) | ((bx & 0x1) << 26) |
0060                               ((syncErr & 0x1) << 25) | ((bend & 0x1) << 24) | ((strip & 0xFF) << 16) |
0061                               ((valid & 0x1) << 15) | ((quality & 0xF) << 11) | ((pattern & 0xF) << 7) | (wire & 0x7F);
0062       std::cout << "MPC" << digiIt->getTrknmb() << " " << std::hex << mpc << std::dec << std::endl;
0063     }
0064   }
0065 }
0066 
0067 #include "FWCore/Framework/interface/MakerMacros.h"
0068 DEFINE_FWK_MODULE(CSCDigiToPattern);