CMS 3D CMS Logo

GEMPadDigiReader.cc
Go to the documentation of this file.
1 
16 
17 #include <map>
18 #include <vector>
19 #include <iostream>
20 #include <iterator>
21 #include <algorithm>
22 
23 using namespace std;
24 
26 public:
27  explicit GEMPadDigiReader(const edm::ParameterSet& pset);
28 
29  ~GEMPadDigiReader() override {}
30 
31  void analyze(const edm::Event&, const edm::EventSetup&) override;
32 
33 private:
36 };
37 
39  : gemDigiToken_(consumes<GEMDigiCollection>(pset.getParameter<edm::InputTag>("gemDigiToken"))),
40  gemPadToken_(consumes<GEMPadDigiCollection>(pset.getParameter<edm::InputTag>("gemPadToken"))) {}
41 
42 void GEMPadDigiReader::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) {
43  //cout << "--- Run: " << event.id().run() << " Event: " << event.id().event() << endl;
44 
46  eventSetup.get<MuonGeometryRecord>().get(geometry);
47 
49  event.getByToken(gemDigiToken_, digis);
50 
52  event.getByToken(gemPadToken_, pads);
53 
54  if (pads->begin() == pads->end())
55  return; // no pads in event
56 
57  for (auto pad_range_it = pads->begin(); pad_range_it != pads->end(); ++pad_range_it) {
58  const auto& id = (*pad_range_it).first;
59  const auto& roll = geometry->etaPartition(id);
60 
61  // GEMDetId print-out
62  cout << "--------------" << endl;
63  //cout<<"id: "<<id.rawId()<<" #strips "<<roll->nstrips()<<" #pads "<<roll->npads()<<endl;
64 
65  // retrieve this DetUnit's digis
66  std::map<std::pair<int, int>, // #pad (starting from 1), BX
67  std::vector<int> // digi strip numbers (starting from 1)
68  >
69  digi_map;
70  auto digis_in_det = digis->get(id);
71  cout << "strip digis in detid: ";
72  for (auto d = digis_in_det.first; d != digis_in_det.second; ++d) {
73  int pad_num = 1 + static_cast<int>(roll->padOfStrip(d->strip())); // d->strip() is int
74  digi_map[{pad_num, d->bx()}].push_back(d->strip());
75  cout << " (" << d->strip() << "," << d->bx() << ") -> " << pad_num;
76  }
77  cout << endl;
78 
79  // loop over pads of this DetUnit and print stuff
80  auto pads_range = (*pad_range_it).second;
81  for (auto p = pads_range.first; p != pads_range.second; ++p) {
82  int first_strip = roll->firstStripInPad(p->pad()); // p->pad() is int, firstStripInPad returns int
83  int last_strip = roll->lastStripInPad(p->pad());
84 
85  if (p->pad() < 1 || p->pad() > roll->npads()) {
86  cout << " XXXXXXXXXXXXX Problem! " << id << " has pad digi with too large pad# = " << p->pad() << endl;
87  }
88 
89  auto& strips = digi_map[{p->pad(), p->bx()}];
90  std::vector<int> pads_strips;
91  remove_copy_if(
92  strips.begin(), strips.end(), inserter(pads_strips, pads_strips.end()), [first_strip, last_strip](int s) {
93  return s < first_strip || s > last_strip;
94  });
95  cout << id << " paddigi(pad,bx) " << *p << " has " << pads_strips.size() << " strip digis strips in range ["
96  << first_strip << "," << last_strip << "]: ";
97  copy(pads_strips.begin(), pads_strips.end(), ostream_iterator<int>(cout, " "));
98  cout << endl;
99  }
100 
101  } // for (detids with pads)
102 }
103 
void analyze(const edm::Event &, const edm::EventSetup &) override
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
Definition: GEMGeometry.cc:77
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< GEMPadDigiCollection > gemPadToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
GEMPadDigiReader(const edm::ParameterSet &pset)
edm::EDGetTokenT< GEMDigiCollection > gemDigiToken_
d
Definition: ztail.py:151
~GEMPadDigiReader() override
ESHandle< TrackerGeometry > geometry
HLT enums.
T get() const
Definition: EventSetup.h:73
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers.hcal.doNoise = False simEcalUnsuppressedDigis.doNoise = False mix.digitizers.ecal.doNoise = False simEcalUnsuppressedDigis.doESNoise = False simSiPixelDigis.AddNoise = False mix.digitizers.pixel.AddNoise = False simSiStripDigis.Noise = False mix.digitizers.strip.AddNoise = False
Definition: DigiDM_cff.py:32
Definition: event.py:1