CMS 3D CMS Logo

RPCDigiValid.cc
Go to the documentation of this file.
4 
10 
11 #include <cmath>
12 
13 using namespace std;
14 using namespace edm;
15 
17  // Init the tokens for run data retrieval - stanislav
18  // ps.getUntackedParameter<InputTag> retrieves a InputTag from the
19  // configuration. The second param is default value module, instance and
20  // process labels may be passed in a single string if separated by colon ':'
21  // (@see the edm::InputTag constructor documentation)
22  simHitToken = consumes<PSimHitContainer>(
23  ps.getUntrackedParameter<edm::InputTag>("simHitTag", edm::InputTag("g4SimHits:MuonRPCHits")));
24  rpcDigiToken = consumes<RPCDigiCollection>(
25  ps.getUntrackedParameter<edm::InputTag>("rpcDigiTag", edm::InputTag("simMuonRPCDigis")));
26 
27  outputFile_ = ps.getUntrackedParameter<string>("outputFile", "rpcDigiValidPlots.root");
28 
29  rpcGeomToken_ = esConsumes();
30 }
31 
33 
34 void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) {
35  // Get the RPC Geometry
36  auto rpcGeom = eventSetup.getHandle(rpcGeomToken_);
37 
40  event.getByToken(simHitToken, simHit);
41  event.getByToken(rpcDigiToken, rpcDigis);
42 
43  // Loop on simhits
44  PSimHitContainer::const_iterator simIt;
45 
46  // loop over Simhit
47  std::map<RPCDetId, std::vector<double>> allsims;
48 
49  for (simIt = simHit->begin(); simIt != simHit->end(); simIt++) {
50  RPCDetId Rsid = (RPCDetId)(*simIt).detUnitId();
51  const RPCRoll *soll = dynamic_cast<const RPCRoll *>(rpcGeom->roll(Rsid));
52  int ptype = simIt->particleType();
53 
54  if (ptype == 13 || ptype == -13) {
55  std::vector<double> buff;
56  if (allsims.find(Rsid) != allsims.end()) {
57  buff = allsims[Rsid];
58  }
59 
60  buff.push_back(simIt->localPosition().x());
61 
62  allsims[Rsid] = buff;
63  }
64  GlobalPoint p = soll->toGlobal(simIt->localPosition());
65 
66  double sim_x = p.x();
67  double sim_y = p.y();
68 
69  xyview->Fill(sim_x, sim_y);
70 
71  if (Rsid.region() == (+1)) {
72  if (Rsid.station() == 4) {
73  xyvDplu4->Fill(sim_x, sim_y);
74  }
75  } else if (Rsid.region() == (-1)) {
76  if (Rsid.station() == 4) {
77  xyvDmin4->Fill(sim_x, sim_y);
78  }
79  }
80  rzview->Fill(p.z(), p.perp());
81  }
82  // loop over Digis
84  for (detUnitIt = rpcDigis->begin(); detUnitIt != rpcDigis->end(); ++detUnitIt) {
85  const RPCDetId Rsid = (*detUnitIt).first;
86  const RPCRoll *roll = dynamic_cast<const RPCRoll *>(rpcGeom->roll(Rsid));
87 
88  const RPCDigiCollection::Range &range = (*detUnitIt).second;
89  std::vector<double> sims;
90  if (allsims.find(Rsid) != allsims.end()) {
91  sims = allsims[Rsid];
92  }
93 
94  int ndigi = 0;
95  for (RPCDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
96  StripProf->Fill(digiIt->strip());
97  BxDist->Fill(digiIt->bx());
98  // bx for 4 endcaps
99  if (Rsid.region() == (+1)) {
100  if (Rsid.station() == 4)
101  BxDisc_4Plus->Fill(digiIt->bx());
102  } else if (Rsid.region() == (-1)) {
103  if (Rsid.station() == 4)
104  BxDisc_4Min->Fill(digiIt->bx());
105  }
106 
107  // Fill timing information
108  const double digiTime = digiIt->hasTime() ? digiIt->time() : digiIt->bx() * 25;
109  hDigiTimeAll->Fill(digiTime);
110  if (digiIt->hasTime()) {
111  hDigiTime->Fill(digiTime);
112  if (roll->isIRPC())
113  hDigiTimeIRPC->Fill(digiTime);
114  else
115  hDigiTimeNoIRPC->Fill(digiTime);
116  }
117  }
118 
119  if (sims.size() == 1 && ndigi == 1) {
120  double dis = roll->centreOfStrip(range.first->strip()).x() - sims[0];
121  Res->Fill(dis);
122 
123  if (Rsid.region() == 0) {
124  if (Rsid.ring() == -2)
125  ResWmin2->Fill(dis);
126  else if (Rsid.ring() == -1)
127  ResWmin1->Fill(dis);
128  else if (Rsid.ring() == 0)
129  ResWzer0->Fill(dis);
130  else if (Rsid.ring() == 1)
131  ResWplu1->Fill(dis);
132  else if (Rsid.ring() == 2)
133  ResWplu2->Fill(dis);
134  // barrel layers
135  if (Rsid.station() == 1 && Rsid.layer() == 1)
136  ResLayer1_barrel->Fill(dis);
137  if (Rsid.station() == 1 && Rsid.layer() == 2)
138  ResLayer2_barrel->Fill(dis);
139  if (Rsid.station() == 2 && Rsid.layer() == 1)
140  ResLayer3_barrel->Fill(dis);
141  if (Rsid.station() == 2 && Rsid.layer() == 2)
142  ResLayer4_barrel->Fill(dis);
143  if (Rsid.station() == 3)
144  ResLayer5_barrel->Fill(dis);
145  if (Rsid.station() == 4)
146  ResLayer6_barrel->Fill(dis);
147  }
148  // endcap layers residuals
149  if (Rsid.region() != 0) {
150  if (Rsid.ring() == 2) {
151  if (abs(Rsid.station()) == 1) {
152  if (Rsid.roll() == 1)
153  Res_Endcap1_Ring2_A->Fill(dis);
154  if (Rsid.roll() == 2)
155  Res_Endcap1_Ring2_B->Fill(dis);
156  if (Rsid.roll() == 3)
157  Res_Endcap1_Ring2_C->Fill(dis);
158  }
159  if (abs(Rsid.station()) == 2 || abs(Rsid.station()) == 3) {
160  if (Rsid.roll() == 1)
161  Res_Endcap23_Ring2_A->Fill(dis);
162  if (Rsid.roll() == 2)
163  Res_Endcap23_Ring2_B->Fill(dis);
164  if (Rsid.roll() == 3)
165  Res_Endcap23_Ring2_C->Fill(dis);
166  }
167  }
168  if (Rsid.ring() == 3) {
169  if (Rsid.roll() == 1)
170  Res_Endcap123_Ring3_A->Fill(dis);
171  if (Rsid.roll() == 2)
172  Res_Endcap123_Ring3_B->Fill(dis);
173  if (Rsid.roll() == 3)
174  Res_Endcap123_Ring3_C->Fill(dis);
175  }
176  }
177 
178  if (Rsid.region() == (+1)) {
179  if (Rsid.station() == 1)
180  ResDplu1->Fill(dis);
181  else if (Rsid.station() == 2)
182  ResDplu2->Fill(dis);
183  else if (Rsid.station() == 3)
184  ResDplu3->Fill(dis);
185  else if (Rsid.station() == 4)
186  ResDplu4->Fill(dis);
187  }
188  if (Rsid.region() == (-1)) {
189  if (Rsid.station() == 1)
190  ResDmin1->Fill(dis);
191  else if (Rsid.station() == 2)
192  ResDmin2->Fill(dis);
193  else if (Rsid.station() == 3)
194  ResDmin3->Fill(dis);
195  else if (Rsid.station() == 4)
196  ResDmin4->Fill(dis);
197  }
198  }
199  }
200 }
201 
203  booker.setCurrentFolder("RPCDigisV/RPCDigis");
204 
205  xyview = booker.book2D("X_Vs_Y_View", "X_Vs_Y_View", 155, -775., 775., 155, -775., 775.);
206 
207  xyvDplu4 = booker.book2D("Dplu4_XvsY", "Dplu4_XvsY", 155, -775., 775., 155, -775., 775.);
208  xyvDmin4 = booker.book2D("Dmin4_XvsY", "Dmin4_XvsY", 155, -775., 775., 155, -775., 775.);
209 
210  rzview = booker.book2D("R_Vs_Z_View", "R_Vs_Z_View", 216, -1080., 1080., 52, 260., 780.);
211  Res = booker.book1D("Digi_SimHit_difference", "Digi_SimHit_difference", 300, -8, 8);
212  ResWmin2 = booker.book1D("W_Min2_Residuals", "W_Min2_Residuals", 400, -8, 8);
213  ResWmin1 = booker.book1D("W_Min1_Residuals", "W_Min1_Residuals", 400, -8, 8);
214  ResWzer0 = booker.book1D("W_Zer0_Residuals", "W_Zer0_Residuals", 400, -8, 8);
215  ResWplu1 = booker.book1D("W_Plu1_Residuals", "W_Plu1_Residuals", 400, -8, 8);
216  ResWplu2 = booker.book1D("W_Plu2_Residuals", "W_Plu2_Residuals", 400, -8, 8);
217 
218  ResLayer1_barrel = booker.book1D("ResLayer1_barrel", "ResLayer1_barrel", 400, -8, 8);
219  ResLayer2_barrel = booker.book1D("ResLayer2_barrel", "ResLayer2_barrel", 400, -8, 8);
220  ResLayer3_barrel = booker.book1D("ResLayer3_barrel", "ResLayer3_barrel", 400, -8, 8);
221  ResLayer4_barrel = booker.book1D("ResLayer4_barrel", "ResLayer4_barrel", 400, -8, 8);
222  ResLayer5_barrel = booker.book1D("ResLayer5_barrel", "ResLayer5_barrel", 400, -8, 8);
223  ResLayer6_barrel = booker.book1D("ResLayer6_barrel", "ResLayer6_barrel", 400, -8, 8);
224 
225  BxDist = booker.book1D("Bunch_Crossing", "Bunch_Crossing", 20, -10., 10.);
226  StripProf = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100);
227 
228  BxDisc_4Plus = booker.book1D("BxDisc_4Plus", "BxDisc_4Plus", 20, -10., 10.);
229  BxDisc_4Min = booker.book1D("BxDisc_4Min", "BxDisc_4Min", 20, -10., 10.);
230 
231  // endcap residuals
232  ResDmin1 = booker.book1D("Disk_Min1_Residuals", "Disk_Min1_Residuals", 400, -8, 8);
233  ResDmin2 = booker.book1D("Disk_Min2_Residuals", "Disk_Min2_Residuals", 400, -8, 8);
234  ResDmin3 = booker.book1D("Disk_Min3_Residuals", "Disk_Min3_Residuals", 400, -8, 8);
235  ResDplu1 = booker.book1D("Disk_Plu1_Residuals", "Disk_Plu1_Residuals", 400, -8, 8);
236  ResDplu2 = booker.book1D("Disk_Plu2_Residuals", "Disk_Plu2_Residuals", 400, -8, 8);
237  ResDplu3 = booker.book1D("Disk_Plu3_Residuals", "Disk_Plu3_Residuals", 400, -8, 8);
238 
239  ResDmin4 = booker.book1D("Disk_Min4_Residuals", "Disk_Min4_Residuals", 400, -8, 8);
240  ResDplu4 = booker.book1D("Disk_Plu4_Residuals", "Disk_Plu4_Residuals", 400, -8, 8);
241 
242  Res_Endcap1_Ring2_A = booker.book1D("Res_Endcap1_Ring2_A", "Res_Endcap1_Ring2_A", 400, -8, 8);
243  Res_Endcap1_Ring2_B = booker.book1D("Res_Endcap1_Ring2_B", "Res_Endcap1_Ring2_B", 400, -8, 8);
244  Res_Endcap1_Ring2_C = booker.book1D("Res_Endcap1_Ring2_C", "Res_Endcap1_Ring2_C", 400, -8, 8);
245 
246  Res_Endcap23_Ring2_A = booker.book1D("Res_Endcap23_Ring2_A", "Res_Endcap23_Ring2_A", 400, -8, 8);
247  Res_Endcap23_Ring2_B = booker.book1D("Res_Endcap23_Ring2_B", "Res_Endcap23_Ring2_B", 400, -8, 8);
248  Res_Endcap23_Ring2_C = booker.book1D("Res_Endcap23_Ring2_C", "Res_Endcap23_Ring2_C", 400, -8, 8);
249 
250  Res_Endcap123_Ring3_A = booker.book1D("Res_Endcap123_Ring3_A", "Res_Endcap123_Ring3_A", 400, -8, 8);
251  Res_Endcap123_Ring3_B = booker.book1D("Res_Endcap123_Ring3_B", "Res_Endcap123_Ring3_B", 400, -8, 8);
252  Res_Endcap123_Ring3_C = booker.book1D("Res_Endcap123_Ring3_C", "Res_Endcap123_Ring3_C", 400, -8, 8);
253 
254  // Timing informations
255  hDigiTimeAll =
256  booker.book1D("DigiTimeAll", "Digi time including present electronics;Digi time (ns)", 100, -12.5, 12.5);
257  hDigiTime = booker.book1D("DigiTime", "Digi time only with timing information;Digi time (ns)", 100, -12.5, 12.5);
258  hDigiTimeIRPC = booker.book1D("DigiTimeIRPC", "IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5);
259  hDigiTimeNoIRPC = booker.book1D("DigiTimeNoIRPC", "non-IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5);
260 }
RPCRoll
Definition: RPCRoll.h:12
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
RPCDetId::station
int station() const
Definition: RPCDetId.h:78
RPCDetId::region
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
SiPixelPhase1TrackingParticleV_cfi.simHitToken
simHitToken
Definition: SiPixelPhase1TrackingParticleV_cfi.py:122
RPCDigiValid::~RPCDigiValid
~RPCDigiValid() override
Definition: RPCDigiValid.cc:32
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
RPCDetId
Definition: RPCDetId.h:16
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
RPCDigiValid::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: RPCDigiValid.cc:34
OfflineHarvestingSequence_cosmic.ptype
ptype
Definition: OfflineHarvestingSequence_cosmic.py:7
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle
Definition: AssociativeIterator.h:50
RectangularStripTopology.h
MuonDigiCollection< RPCDetId, RPCDigi >::const_iterator
std::vector< RPCDigi >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
MixCollection.h
rpcPointValidation_cfi.simHit
simHit
Definition: rpcPointValidation_cfi.py:24
RPCDigiValid::RPCDigiValid
RPCDigiValid(const edm::ParameterSet &ps)
Definition: RPCDigiValid.cc:16
Point3DBase< float, GlobalTag >
RPCDetId.h
RPCRoll::centreOfStrip
LocalPoint centreOfStrip(int strip) const
Definition: RPCRoll.cc:26
RPCDetId::roll
int roll() const
Definition: RPCDetId.h:92
GeomDet::toGlobal
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
RPCDigiValid.h
RPCDigiValid::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: RPCDigiValid.cc:202
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
edm::EventSetup
Definition: EventSetup.h:58
InputTag.h
RPCDetId::ring
int ring() const
Definition: RPCDetId.h:59
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
TrapezoidalStripTopology.h
LocalPoint.h
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
MuonDigiCollection< RPCDetId, RPCDigi >::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
dqm::implementation::IBooker
Definition: DQMStore.h:43
RPCRoll::isIRPC
bool isIRPC() const
Definition: RPCRoll.h:36
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
event
Definition: event.py:1
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
DigiContainerIterator
Definition: MuonDigiCollection.h:30
edm::Event
Definition: Event.h:73
RPCDetId::layer
int layer() const
Definition: RPCDetId.h:85
GlobalPoint.h
edm::InputTag
Definition: InputTag.h:15
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98