CMS 3D CMS Logo

CSCRecHit2DValidation.cc
Go to the documentation of this file.
4 
6  : CSCBaseValidation(inputTag), theNPerEventPlot(nullptr) {
8 }
9 
11  for (int i = 0; i < 10; ++i) {
12  edm::LogInfo("CSCRecHitValidation") << "Resolution of " << theResolutionPlots[i]->getName() << " is "
14  edm::LogInfo("CSCRecHitValidation") << "Peak Time is " << theTPeaks[i]->getMean();
15  }
16 }
17 
19  theNPerEventPlot = iBooker.book1D("CSCRecHitsPerEvent", "Number of CSC Rec Hits per event", 100, 0, 500);
20  for (int i = 0; i < 10; ++i) {
21  char title1[200], title2[200], title3[200], title4[200], title5[200], title6[200], title7[200], title8[200],
22  title9[200];
23  sprintf(title1, "CSCRecHitResolution%d", i + 1);
24  sprintf(title2, "CSCRecHitPull%d", i + 1);
25  sprintf(title3, "CSCRecHitYResolution%d", i + 1);
26  sprintf(title4, "CSCRecHitYPull%d", i + 1);
27  sprintf(title5, "CSCRecHitPosInStrip%d", i + 1);
28  sprintf(title6, "CSCSimHitPosInStrip%d", i + 1);
29  sprintf(title7, "CSCRecHit%d", i + 1);
30  sprintf(title8, "CSCSimHit%d", i + 1);
31  sprintf(title9, "CSCTPeak%d", i + 1);
32 
33  theResolutionPlots[i] = iBooker.book1D(title1, title1, 100, -0.2, 0.2);
34  thePullPlots[i] = iBooker.book1D(title2, title2, 100, -3, 3);
35  theYResolutionPlots[i] = iBooker.book1D(title3, title3, 100, -5, 5);
36  theYPullPlots[i] = iBooker.book1D(title4, title4, 100, -3, 3);
37  theRecHitPosInStrip[i] = iBooker.book1D(title5, title5, 100, -2, 2);
38  theSimHitPosInStrip[i] = iBooker.book1D(title6, title6, 100, -2, 2);
39  theScatterPlots[i] = iBooker.book2D(title7, title7, 200, -20, 20, 200, -250, 250);
40  theSimHitScatterPlots[i] = iBooker.book2D(title8, title8, 200, -20, 20, 200, -250, 250);
41  theTPeaks[i] = iBooker.book1D(title9, title9, 200, 0, 400);
42  }
43 }
44 
46  // get the collection of CSCRecHrecHitItrD
48  e.getByToken(rechits_Token_, hRecHits);
49  const CSCRecHit2DCollection *cscRecHits = hRecHits.product();
50 
51  unsigned nPerEvent = 0;
52 
53  for (CSCRecHit2DCollection::const_iterator recHitItr = cscRecHits->begin(); recHitItr != cscRecHits->end();
54  recHitItr++) {
55  ++nPerEvent;
56  int detId = (*recHitItr).cscDetId().rawId();
58  const CSCLayer *layer = findLayer(detId);
59  int chamberType = layer->chamber()->specs()->chamberType();
60  theTPeaks[chamberType - 1]->Fill(recHitItr->tpeak());
61  if (simHits.size() == 1) {
62  plotResolution(simHits[0], *recHitItr, layer, chamberType);
63  }
64  float localX = recHitItr->localPosition().x();
65  float localY = recHitItr->localPosition().y();
66  // theYPlots[chamberType-1]->Fill(localY);
67  // find a local phi
68  float globalR = layer->toGlobal(LocalPoint(0., 0., 0.)).perp();
69  GlobalPoint axisThruChamber(globalR + localY, localX, 0.);
70  float localPhi = axisThruChamber.phi().degrees();
71  // thePhiPlots[chamberType-1]->Fill(axisThruChamber.phi().degrees());
72  theScatterPlots[chamberType - 1]->Fill(localPhi, localY);
73  }
74  theNPerEventPlot->Fill(nPerEvent);
75  return;
76  // fill sim hits
77  std::vector<int> layersWithSimHits = theSimHitMap->detsWithHits();
78  for (unsigned i = 0; i < layersWithSimHits.size(); ++i) {
79  edm::PSimHitContainer simHits = theSimHitMap->hits(layersWithSimHits[i]);
80  for (edm::PSimHitContainer::const_iterator hitItr = simHits.begin(); hitItr != simHits.end(); ++hitItr) {
81  const CSCLayer *layer = findLayer(layersWithSimHits[i]);
82  int chamberType = layer->chamber()->specs()->chamberType();
83  float localX = hitItr->localPosition().x();
84  float localY = hitItr->localPosition().y();
85  // theYPlots[chamberType-1]->Fill(localY);
86  // find a local phi
87  float globalR = layer->toGlobal(LocalPoint(0., 0., 0.)).perp();
88  GlobalPoint axisThruChamber(globalR + localY, localX, 0.);
89  float localPhi = axisThruChamber.phi().degrees();
90  // thePhiPlots[chamberType-1]->Fill(axisThruChamber.phi().degrees());
91  theSimHitScatterPlots[chamberType - 1]->Fill(localPhi, localY);
92  }
93  }
94 }
95 
97  const CSCRecHit2D &recHit,
98  const CSCLayer *layer,
99  int chamberType) {
100  GlobalPoint simHitPos = layer->toGlobal(simHit.localPosition());
101  GlobalPoint recHitPos = layer->toGlobal(recHit.localPosition());
102 
103  double dphi = recHitPos.phi() - simHitPos.phi();
104  double rdphi = recHitPos.perp() * dphi;
105  theResolutionPlots[chamberType - 1]->Fill(rdphi);
106  thePullPlots[chamberType - 1]->Fill(rdphi / sqrt(recHit.localPositionError().xx()));
107  double dy = recHit.localPosition().y() - simHit.localPosition().y();
108  theYResolutionPlots[chamberType - 1]->Fill(dy);
109  theYPullPlots[chamberType - 1]->Fill(dy / sqrt(recHit.localPositionError().yy()));
110 
111  const CSCLayerGeometry *layerGeometry = layer->geometry();
112  float recStrip = layerGeometry->strip(recHit.localPosition());
113  float simStrip = layerGeometry->strip(simHit.localPosition());
114  theRecHitPosInStrip[chamberType - 1]->Fill(recStrip - int(recStrip));
115  theSimHitPosInStrip[chamberType - 1]->Fill(simStrip - int(simStrip));
116 }
MonitorElement * theSimHitScatterPlots[10]
MonitorElement * theYResolutionPlots[10]
float xx() const
Definition: LocalError.h:24
MonitorElement * theScatterPlots[10]
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
T perp() const
Definition: PV3DBase.h:72
void plotResolution(const PSimHit &simHit, const CSCRecHit2D &recHit, const CSCLayer *layer, int chamberType)
edm::EDGetTokenT< CSCRecHit2DCollection > rechits_Token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
#define nullptr
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
void bookHistograms(DQMStore::IBooker &)
const std::string & getName() const
get name of ME
constexpr uint16_t localY(uint16_t py)
LocalPoint localPosition() const override
Definition: CSCRecHit2D.h:50
MonitorElement * theResolutionPlots[10]
double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
CSCRecHit2DValidation(const edm::InputTag &inputTag, edm::ConsumesCollector &&iC)
void Fill(long long x)
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
MonitorElement * theSimHitPosInStrip[10]
MonitorElement * theYPullPlots[10]
const CSCChamberSpecs * specs() const
Definition: CSCChamber.h:42
float yy() const
Definition: LocalError.h:26
Local3DPoint localPosition() const
Definition: PSimHit.h:52
const PSimHitMap * theSimHitMap
T sqrt(T t)
Definition: SSEVec.h:18
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
const edm::PSimHitContainer & hits(int detId) const
Definition: PSimHitMap.cc:19
float strip(const LocalPoint &lp) const
std::vector< int > detsWithHits() const
Definition: PSimHitMap.cc:28
T const * product() const
Definition: Handle.h:74
int chamberType() const
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
constexpr uint16_t localX(uint16_t px)
LocalError localPositionError() const override
Definition: CSCRecHit2D.h:51
MonitorElement * theNPerEventPlot
MonitorElement * thePullPlots[10]
MonitorElement * theRecHitPosInStrip[10]
double getRMS(int axis=1) const
get RMS of histogram along x, y or z axis (axis=1, 2, 3 respectively)
MonitorElement * theTPeaks[10]
std::vector< PSimHit > PSimHitContainer
const CSCChamber * chamber() const
Definition: CSCLayer.h:52
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:47
const CSCLayer * findLayer(int detId) const
void analyze(const edm::Event &, const edm::EventSetup &) override