CMS 3D CMS Logo

GEMPackingTester.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <iostream>
3 #include <TTree.h>
4 
9 
12 
19 
20 using namespace std;
21 class GEMPackingTester : public edm::one::EDAnalyzer<edm::one::SharedResources> {
22 public:
23  explicit GEMPackingTester(const edm::ParameterSet&);
24  ~GEMPackingTester() override;
25 
26  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
27 
28 private:
29  void beginJob() override;
30  void analyze(const edm::Event&, const edm::EventSetup&) override;
31  void endJob() override;
32 
37 
38  TTree* tree_;
39  int b_ge0, b_ge1, b_ge2;
40 };
41 
43  : fedToken_(consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("fed"))),
44  gemDigiToken_(consumes<GEMDigiCollection>(iConfig.getParameter<edm::InputTag>("gemDigi"))),
45  gemSimDigiToken_(consumes<GEMDigiCollection>(iConfig.getParameter<edm::InputTag>("gemSimDigi"))),
46  readMultiBX_(iConfig.getParameter<bool>("readMultiBX")) {
47  usesResource("TFileService");
49  tree_ = fs->make<TTree>("fed", "fed");
50  tree_->Branch("ge0", &b_ge0, "ge0/I");
51  tree_->Branch("ge1", &b_ge1, "ge1/I");
52  tree_->Branch("ge2", &b_ge2, "ge2/I");
53 }
54 
56 
58  using namespace edm;
59 
60  b_ge0 = 0;
61  b_ge1 = 0;
62  b_ge2 = 0;
63 
64  auto const& fed_buffers = iEvent.get(fedToken_);
65 
67  const FEDRawData& fedData = fed_buffers.FEDData(fedId);
68 
69  if (fedId == 1473 or fedId == 1474)
70  b_ge0 += fedData.size();
71  if (fedId == 1467 or fedId == 1468)
72  b_ge1 += fedData.size();
73  if (fedId == 1469 or fedId == 1470)
74  b_ge2 += fedData.size();
75  }
76 
77  auto const& gemDigis = iEvent.get(gemDigiToken_);
78  auto const& gemSimDigis = iEvent.get(gemSimDigiToken_);
79 
80  for (auto const& simDigi : gemSimDigis) {
81  const GEMDetId& gemId = simDigi.first;
82  const GEMDigiCollection::Range& sim = simDigi.second;
83  const GEMDigiCollection::Range& packed = gemDigis.get(gemId);
84 
85  for (auto digi = sim.first; digi != sim.second; ++digi) {
86  if (!readMultiBX_ && digi->bx() != 0)
87  continue;
88 
89  bool foundDigi = false;
90  for (auto unpackeddigi = packed.first; unpackeddigi != packed.second; ++unpackeddigi) {
91  if ((digi->strip() == unpackeddigi->strip()) && (digi->bx() == unpackeddigi->bx()))
92  foundDigi = true;
93  }
94  if (!foundDigi) {
95  edm::LogInfo("GEMPackingTester") << "simMuonGEMDigi NOT found " << gemId << " " << digi->strip() << " "
96  << digi->bx();
97  for (auto unpackeddigi = packed.first; unpackeddigi != packed.second; ++unpackeddigi) {
98  edm::LogInfo("GEMPackingTester") << "rec " << unpackeddigi->strip() << " " << unpackeddigi->bx();
99  }
100  }
101  }
102  }
103 
104  tree_->Fill();
105 }
106 
108 
110 
113  desc.add<edm::InputTag>("fed", edm::InputTag("rawDataCollector"));
114  desc.add<edm::InputTag>("gemDigi", edm::InputTag("muonGEMDigis"));
115  desc.add<edm::InputTag>("gemSimDigi", edm::InputTag("simMuonGEMDigis"));
116  desc.add<bool>("readMultiBX", false);
117  descriptions.add("GEMPackingTester", desc);
118 }
119 
GEMPackingTester(const edm::ParameterSet &)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:48
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
void beginJob()
Definition: Breakpoints.cc:14
edm::EDGetTokenT< GEMDigiCollection > gemDigiToken_
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< FEDRawDataCollection > fedToken_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
~GEMPackingTester() override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< GEMDigiCollection > gemSimDigiToken_
Log< level::Info, false > LogInfo
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::pair< const_iterator, const_iterator > Range
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void endJob() override
HLT enums.
void beginJob() override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void analyze(const edm::Event &, const edm::EventSetup &) override