CMS 3D CMS Logo

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