CMS 3D CMS Logo

CSCSegmentValidation.cc
Go to the documentation of this file.
3 #include <algorithm>
4 
6  : CSCBaseValidation(inputTag), theLayerHitsPerChamber(), theChamberSegmentMap(), theShowerThreshold(10) {
8 }
9 
11 
13  theNPerEventPlot = iBooker.book1D("CSCSegmentsPerEvent", "Number of CSC segments per event", 100, 0, 50);
14  theNRecHitsPlot = iBooker.book1D("CSCRecHitsPerSegment", "Number of CSC rec hits per segment", 8, 0, 7);
16  iBooker.book1D("CSCSegmentsPerChamberType", "Number of CSC segments per chamber type", 11, 0, 10);
17  theTypePlot4HitsNoShower = iBooker.book1D("CSCSegments4HitsNoShower", "", 100, 0, 10);
18  theTypePlot4HitsNoShowerSeg = iBooker.book1D("CSCSegments4HitsNoShowerSeg", "", 100, 0, 10);
19  theTypePlot4HitsShower = iBooker.book1D("CSCSegments4HitsShower", "", 100, 0, 10);
20  theTypePlot4HitsShowerSeg = iBooker.book1D("CSCSegments4HitsShowerSeg", "", 100, 0, 10);
21  theTypePlot5HitsNoShower = iBooker.book1D("CSCSegments5HitsNoShower", "", 100, 0, 10);
22  theTypePlot5HitsNoShowerSeg = iBooker.book1D("CSCSegments5HitsNoShowerSeg", "", 100, 0, 10);
23  theTypePlot5HitsShower = iBooker.book1D("CSCSegments5HitsShower", "", 100, 0, 10);
24  theTypePlot5HitsShowerSeg = iBooker.book1D("CSCSegments5HitsShowerSeg", "", 100, 0, 10);
25  theTypePlot6HitsNoShower = iBooker.book1D("CSCSegments6HitsNoShower", "", 100, 0, 10);
26  theTypePlot6HitsNoShowerSeg = iBooker.book1D("CSCSegments6HitsNoShowerSeg", "", 100, 0, 10);
27  theTypePlot6HitsShower = iBooker.book1D("CSCSegments6HitsShower", "", 100, 0, 10);
28  theTypePlot6HitsShowerSeg = iBooker.book1D("CSCSegments6HitsShowerSeg", "", 100, 0, 10);
29  for (int i = 0; i < 10; ++i) {
30  char title1[200], title2[200], title3[200], title4[200], title5[200], title6[200], title7[200], title8[200];
31  sprintf(title1, "CSCSegmentRdPhiResolution%d", i + 1);
32  sprintf(title2, "CSCSegmentRdPhiPull%d", i + 1);
33  sprintf(title3, "CSCSegmentThetaResolution%d", i + 1);
34  sprintf(title4, "CSCSegmentThetaPull%d", i + 1);
35  sprintf(title5, "CSCSegmentdXdZResolution%d", i + 1);
36  sprintf(title6, "CSCSegmentdXdZPull%d", i + 1);
37  sprintf(title7, "CSCSegmentdYdZResolution%d", i + 1);
38  sprintf(title8, "CSCSegmentdYdZPull%d", i + 1);
39 
40  theRdPhiResolutionPlots[i] = iBooker.book1D(title1, title1, 100, -0.4, 0.4);
41  theRdPhiPullPlots[i] = iBooker.book1D(title2, title2, 100, -5, 5);
42  theThetaResolutionPlots[i] = iBooker.book1D(title3, title3, 100, -1, 1);
43  theThetaPullPlots[i] = iBooker.book1D(title4, title4, 100, -5, 5);
44  thedXdZResolutionPlots[i] = iBooker.book1D(title5, title5, 100, -1, 1);
45  thedXdZPullPlots[i] = iBooker.book1D(title6, title6, 100, -5, 5);
46  thedYdZResolutionPlots[i] = iBooker.book1D(title7, title7, 100, -1, 1);
47  thedYdZPullPlots[i] = iBooker.book1D(title8, title8, 100, -5, 5);
48  }
49 }
50 
51 void CSCSegmentValidation::analyze(const edm::Event &e, const edm::EventSetup &eventSetup) {
52  // get the collection of CSCRecHsegmentItrD
54  e.getByToken(segments_Token_, hRecHits);
55  const CSCSegmentCollection *cscRecHits = hRecHits.product();
56 
57  theChamberSegmentMap.clear();
58  unsigned nPerEvent = 0;
59  for (CSCSegmentCollection::const_iterator segmentItr = cscRecHits->begin(); segmentItr != cscRecHits->end();
60  segmentItr++) {
61  ++nPerEvent;
62  int detId = segmentItr->geographicalId().rawId();
63  int chamberType = whatChamberType(detId);
64 
65  theNRecHitsPlot->Fill(segmentItr->nRecHits());
66  theNPerChamberTypePlot->Fill(chamberType);
67  theChamberSegmentMap[detId].push_back(*segmentItr);
68 
69  // do the resolution plots
70  const PSimHit *hit = keyHit(detId);
71  if (hit != nullptr) {
72  const CSCLayer *layer = findLayer(hit->detUnitId());
73  plotResolution(*hit, *segmentItr, layer, chamberType);
74  }
75  }
76 
77  theNPerEventPlot->Fill(nPerEvent);
78 
81 }
82 
84  // now plot efficiency by looping over all chambers with hits
85  for (ChamberHitMap::const_iterator mapItr = theLayerHitsPerChamber.begin(), mapEnd = theLayerHitsPerChamber.end();
86  mapItr != mapEnd;
87  ++mapItr) {
88  int chamberId = mapItr->first;
89  int nHitsInChamber = mapItr->second.size();
90  bool isShower = (nHitsInChamber > theShowerThreshold);
91  bool hasSeg = hasSegment(chamberId);
92  int chamberType = whatChamberType(chamberId);
93  // find how many layers were hit in this chamber
94  std::vector<int> v = mapItr->second;
95  std::sort(v.begin(), v.end());
96  // maybe can just count
97  v.erase(std::unique(v.begin(), v.end()), v.end());
98  int nLayersHit = v.size();
99 
100  if (nLayersHit == 4) {
101  if (isShower)
102  theTypePlot4HitsShower->Fill(chamberType);
103  else
104  theTypePlot4HitsNoShower->Fill(chamberType);
105 
106  if (hasSeg) {
107  if (isShower)
108  theTypePlot4HitsShowerSeg->Fill(chamberType);
109  else
110  theTypePlot4HitsNoShowerSeg->Fill(chamberType);
111  }
112  }
113 
114  if (nLayersHit == 5) {
115  if (isShower)
116  theTypePlot5HitsShower->Fill(chamberType);
117  else
118  theTypePlot5HitsNoShower->Fill(chamberType);
119 
120  if (hasSeg) {
121  if (isShower)
122  theTypePlot5HitsShowerSeg->Fill(chamberType);
123  else
124  theTypePlot5HitsNoShowerSeg->Fill(chamberType);
125  }
126  }
127 
128  if (nLayersHit == 6) {
129  if (isShower)
130  theTypePlot6HitsShower->Fill(chamberType);
131  else
132  theTypePlot6HitsNoShower->Fill(chamberType);
133 
134  if (hasSeg) {
135  if (isShower)
136  theTypePlot6HitsShowerSeg->Fill(chamberType);
137  else
138  theTypePlot6HitsNoShowerSeg->Fill(chamberType);
139  }
140  }
141  }
142 }
143 
144 bool CSCSegmentValidation::hasSegment(int chamberId) const {
145  return (theChamberSegmentMap.find(chamberId) != theChamberSegmentMap.end());
146 }
147 
149  CSCDetId cscDetId(detId);
150  return CSCChamberSpecs::whatChamberType(cscDetId.station(), cscDetId.ring());
151 }
152 
154  const CSCSegment &segment,
155  const CSCLayer *layer,
156  int chamberType) {
157  GlobalPoint simHitPos = layer->toGlobal(simHit.localPosition());
158  GlobalPoint segmentPos = layer->toGlobal(segment.localPosition());
159  LocalVector simHitDir = simHit.localDirection();
160  LocalVector segmentDir = segment.localDirection();
161 
162  double dphi = segmentPos.phi() - simHitPos.phi();
163  double rdphi = segmentPos.perp() * dphi;
164  double dtheta = segmentPos.theta() - simHitPos.theta();
165 
166  double sigmax = sqrt(segment.localPositionError().xx());
167  // double sigmay = sqrt(segment.localPositionError().yy());
168 
169  double ddxdz = segmentDir.x() / segmentDir.z() - simHitDir.x() / simHitDir.z();
170  double ddydz = segmentDir.y() / segmentDir.z() - simHitDir.y() / simHitDir.z();
171  double sigmadxdz = sqrt(segment.localDirectionError().xx());
172  double sigmadydz = sqrt(segment.localDirectionError().yy());
173 
174  theRdPhiResolutionPlots[chamberType - 1]->Fill(rdphi);
175  theRdPhiPullPlots[chamberType - 1]->Fill(rdphi / sigmax);
176  theThetaResolutionPlots[chamberType - 1]->Fill(dtheta);
177  // theThetaPullPlots[chamberType-1]->Fill( dy/sigmay );
178 
179  thedXdZResolutionPlots[chamberType - 1]->Fill(ddxdz);
180  thedXdZPullPlots[chamberType - 1]->Fill(ddxdz / sigmadxdz);
181  thedYdZResolutionPlots[chamberType - 1]->Fill(ddydz);
182  thedYdZPullPlots[chamberType - 1]->Fill(ddydz / sigmadydz);
183 }
184 
186  theLayerHitsPerChamber.clear();
187  std::vector<int> layersHit = theSimHitMap->detsWithHits();
188  for (std::vector<int>::const_iterator layerItr = layersHit.begin(), layersHitEnd = layersHit.end();
189  layerItr != layersHitEnd;
190  ++layerItr) {
191  CSCDetId layerId(*layerItr);
192  CSCDetId chamberId = layerId.chamberId();
193  int nhits = theSimHitMap->hits(*layerItr).size();
194  // multiple entries, so we can see showers
195  for (int i = 0; i < nhits; ++i) {
196  theLayerHitsPerChamber[chamberId.rawId()].push_back(*layerItr);
197  }
198  }
199 }
200 
202  bool SimHitPabsLessThan(const PSimHit &p1, const PSimHit &p2) { return p1.pabs() < p2.pabs(); }
203 } // namespace CSCSegmentValidationUtils
204 
205 const PSimHit *CSCSegmentValidation::keyHit(int chamberId) const {
206  const PSimHit *result = nullptr;
207  int layerId = chamberId + 3;
208  const edm::PSimHitContainer &layerHits = theSimHitMap->hits(layerId);
209 
210  if (!layerHits.empty()) {
211  // pick the hit with maximum energy
212  edm::PSimHitContainer::const_iterator hitItr =
213  std::max_element(layerHits.begin(), layerHits.end(), CSCSegmentValidationUtils::SimHitPabsLessThan);
214  result = &(*hitItr);
215  }
216  return result;
217 }
Vector3DBase< float, LocalTag >
CSCSegmentValidation::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: CSCSegmentValidation.cc:51
CSCSegmentValidation::theTypePlot5HitsNoShowerSeg
MonitorElement * theTypePlot5HitsNoShowerSeg
Definition: CSCSegmentValidation.h:57
CSCSegmentValidation.h
CSCSegmentValidation::fillEfficiencyPlots
void fillEfficiencyPlots()
Definition: CSCSegmentValidation.cc:83
mps_fire.i
i
Definition: mps_fire.py:428
edm::Handle::product
T const * product() const
Definition: Handle.h:70
CSCSegmentValidation::plotResolution
void plotResolution(const PSimHit &simHit, const CSCSegment &recHit, const CSCLayer *layer, int chamberType)
Definition: CSCSegmentValidation.cc:153
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
CSCSegmentValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &)
Definition: CSCSegmentValidation.cc:12
CSCSegmentValidation::theTypePlot6HitsNoShowerSeg
MonitorElement * theTypePlot6HitsNoShowerSeg
Definition: CSCSegmentValidation.h:61
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
PV3DBase::theta
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
CSCSegmentValidation::keyHit
const PSimHit * keyHit(int chamberId) const
Definition: CSCSegmentValidation.cc:205
CSCSegmentValidation::theTypePlot5HitsShower
MonitorElement * theTypePlot5HitsShower
Definition: CSCSegmentValidation.h:58
CSCSegmentValidation::thedYdZResolutionPlots
MonitorElement * thedYdZResolutionPlots[10]
Definition: CSCSegmentValidation.h:49
CSCSegmentValidation::theRdPhiPullPlots
MonitorElement * theRdPhiPullPlots[10]
Definition: CSCSegmentValidation.h:44
CSCSegmentValidation::theNPerChamberTypePlot
MonitorElement * theNPerChamberTypePlot
Definition: CSCSegmentValidation.h:42
CSCSegmentValidation::~CSCSegmentValidation
~CSCSegmentValidation() override
Definition: CSCSegmentValidation.cc:10
CSCSegmentValidation::segments_Token_
edm::EDGetTokenT< CSCSegmentCollection > segments_Token_
Definition: CSCSegmentValidation.h:24
DQMStore.h
CSCLayer
Definition: CSCLayer.h:24
CSCSegmentValidation::theRdPhiResolutionPlots
MonitorElement * theRdPhiResolutionPlots[10]
Definition: CSCSegmentValidation.h:43
CSCSegmentValidation::theLayerHitsPerChamber
ChamberHitMap theLayerHitsPerChamber
Definition: CSCSegmentValidation.h:29
CSCSegmentCollection
findQualityFiles.v
v
Definition: findQualityFiles.py:179
edm::Handle< CSCSegmentCollection >
CSCSegmentValidationUtils
Definition: CSCSegmentValidation.cc:201
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
CSCSegmentValidation::theShowerThreshold
int theShowerThreshold
Definition: CSCSegmentValidation.h:38
CSCSegmentValidation::CSCSegmentValidation
CSCSegmentValidation(const edm::InputTag &inputTag, edm::ConsumesCollector &&iC)
Definition: CSCSegmentValidation.cc:5
LocalError::xx
float xx() const
Definition: LocalError.h:22
rpcPointValidation_cfi.simHit
simHit
Definition: rpcPointValidation_cfi.py:24
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
p2
double p2[4]
Definition: TauolaWrapper.h:90
CSCSegmentValidation::theTypePlot5HitsNoShower
MonitorElement * theTypePlot5HitsNoShower
Definition: CSCSegmentValidation.h:56
CSCSegmentValidation::hasSegment
bool hasSegment(int chamberId) const
Definition: CSCSegmentValidation.cc:144
CSCSegmentValidation::theTypePlot4HitsShower
MonitorElement * theTypePlot4HitsShower
Definition: CSCSegmentValidation.h:54
CSCBaseValidation::findLayer
const CSCLayer * findLayer(int detId) const
Definition: CSCBaseValidation.cc:7
CSCSegmentValidation::theNPerEventPlot
MonitorElement * theNPerEventPlot
Definition: CSCSegmentValidation.h:40
Point3DBase< float, GlobalTag >
nhits
Definition: HIMultiTrackSelector.h:42
CSCSegmentValidation::theNRecHitsPlot
MonitorElement * theNRecHitsPlot
Definition: CSCSegmentValidation.h:41
CSCSegment
Definition: CSCSegment.h:21
CSCSegmentValidation::theTypePlot4HitsNoShower
MonitorElement * theTypePlot4HitsNoShower
Definition: CSCSegmentValidation.h:52
CSCBaseValidation::theSimHitMap
const PSimHitMap * theSimHitMap
Definition: CSCBaseValidation.h:28
CSCSegmentValidation::theTypePlot6HitsNoShower
MonitorElement * theTypePlot6HitsNoShower
Definition: CSCSegmentValidation.h:60
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
PSimHitMap::detsWithHits
std::vector< int > detsWithHits() const
Definition: PSimHitMap.cc:28
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
CSCDetId
Definition: CSCDetId.h:26
CSCSegmentValidation::theThetaPullPlots
MonitorElement * theThetaPullPlots[10]
Definition: CSCSegmentValidation.h:46
CSCSegment::localDirection
LocalVector localDirection() const override
Local direction.
Definition: CSCSegment.h:42
CSCSegment::localDirectionError
LocalError localDirectionError() const override
Error on the local direction.
Definition: CSCSegment.cc:52
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
CSCSegmentValidation::whatChamberType
static int whatChamberType(int detId)
Definition: CSCSegmentValidation.cc:148
CSCSegmentValidation::theTypePlot6HitsShower
MonitorElement * theTypePlot6HitsShower
Definition: CSCSegmentValidation.h:62
CSCSegmentValidation::fillLayerHitsPerChamber
void fillLayerHitsPerChamber()
Definition: CSCSegmentValidation.cc:185
CSCSegmentValidation::thedXdZPullPlots
MonitorElement * thedXdZPullPlots[10]
Definition: CSCSegmentValidation.h:48
CSCDetId::chamberId
CSCDetId chamberId() const
Definition: CSCDetId.h:47
p1
double p1[4]
Definition: TauolaWrapper.h:89
edm::EventSetup
Definition: EventSetup.h:57
CSCSegmentValidation::theTypePlot4HitsNoShowerSeg
MonitorElement * theTypePlot4HitsNoShowerSeg
Definition: CSCSegmentValidation.h:53
CSCChamberSpecs::whatChamberType
static int whatChamberType(int istation, int iring)
Definition: CSCChamberSpecs.cc:164
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
CSCSegmentValidation::theTypePlot5HitsShowerSeg
MonitorElement * theTypePlot5HitsShowerSeg
Definition: CSCSegmentValidation.h:59
tier0.unique
def unique(seq, keepstr=True)
Definition: tier0.py:24
CSCSegmentValidation::theChamberSegmentMap
ChamberSegmentMap theChamberSegmentMap
Definition: CSCSegmentValidation.h:36
PSimHitMap::hits
const edm::PSimHitContainer & hits(int detId) const
Definition: PSimHitMap.cc:19
CSCSegmentValidationUtils::SimHitPabsLessThan
bool SimHitPabsLessThan(const PSimHit &p1, const PSimHit &p2)
Definition: CSCSegmentValidation.cc:202
dqm::implementation::IBooker
Definition: DQMStore.h:43
mps_fire.result
result
Definition: mps_fire.py:311
CSCBaseValidation
Definition: CSCBaseValidation.h:14
edm::PSimHitContainer
std::vector< PSimHit > PSimHitContainer
Definition: PSimHitContainer.h:11
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
PSimHit
Definition: PSimHit.h:15
SimL1EmulatorRepack_Full_cff.inputTag
inputTag
Definition: SimL1EmulatorRepack_Full_cff.py:56
edm::Event
Definition: Event.h:73
CSCSegmentValidation::thedXdZResolutionPlots
MonitorElement * thedXdZResolutionPlots[10]
Definition: CSCSegmentValidation.h:47
CSCSegmentValidation::thedYdZPullPlots
MonitorElement * thedYdZPullPlots[10]
Definition: CSCSegmentValidation.h:50
CSCSegmentValidation::theTypePlot4HitsShowerSeg
MonitorElement * theTypePlot4HitsShowerSeg
Definition: CSCSegmentValidation.h:55
CSCSegment::localPosition
LocalPoint localPosition() const override
Definition: CSCSegment.h:39
CSCSegmentValidation::theThetaResolutionPlots
MonitorElement * theThetaResolutionPlots[10]
Definition: CSCSegmentValidation.h:45
LocalError::yy
float yy() const
Definition: LocalError.h:24
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
hit
Definition: SiStripHitEffFromCalibTree.cc:88
CSCSegment::localPositionError
LocalError localPositionError() const override
Definition: CSCSegment.cc:48
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
CSCSegmentValidation::theTypePlot6HitsShowerSeg
MonitorElement * theTypePlot6HitsShowerSeg
Definition: CSCSegmentValidation.h:63
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37