CMS 3D CMS Logo

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