CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CSCRecHit2DValidation.cc
Go to the documentation of this file.
4 
6  : CSCBaseValidation(ps), theNPerEventPlot(nullptr) {
7  const auto &pset = ps.getParameterSet("cscRecHit");
8  inputTag_ = pset.getParameter<edm::InputTag>("inputTag");
10 }
11 
13 
15  theNPerEventPlot = iBooker.book1D("CSCRecHitsPerEvent", "Number of CSC Rec Hits per event", 100, 0, 500);
16  // 10 chamber types, if you consider ME1/a and ME1/b separate
17  for (int i = 1; i <= 10; ++i) {
19  const std::string t1("CSCRecHitResolution_" + cn);
20  const std::string t2("CSCRecHitPull_" + cn);
21  const std::string t3("CSCRecHitYResolution_" + cn);
22 
23  const std::string t4("CSCRecHitYPull_" + cn);
24  const std::string t5("CSCRecHitPosInStrip_" + cn);
25  const std::string t6("CSCSimHitPosInStrip_" + cn);
26 
27  const std::string t7("CSCRecHit_" + cn);
28  const std::string t8("CSCSimHit_" + cn);
29  const std::string t9("CSCTPeak_" + cn);
30 
31  theResolutionPlots[i - 1] = iBooker.book1D(t1, t1 + ";R*dPhi Resolution [cm];Entries", 100, -0.2, 0.2);
32  thePullPlots[i - 1] = iBooker.book1D(t2, t2 + ";dPhi Pull;Entries", 100, -3, 3);
33  theYResolutionPlots[i - 1] = iBooker.book1D(t3, t3 + ";Local Y Resolution [cm];Entries", 100, -5, 5);
34  theYPullPlots[i - 1] = iBooker.book1D(t4, t4 + ";Local Y Pull;Entries", 100, -3, 3);
35  theRecHitPosInStrip[i - 1] = iBooker.book1D(t5, t5 + ";Position in Strip;Entries", 100, -2, 2);
36  theSimHitPosInStrip[i - 1] = iBooker.book1D(t6, t6 + ";Position in Strip;Entries", 100, -2, 2);
37 
38  theScatterPlots[i - 1] = iBooker.book2D(t7, t7 + ";Local Phi;Local Y [cm]", 200, -20, 20, 200, -250, 250);
39  theSimHitScatterPlots[i - 1] = iBooker.book2D(t8, t8 + ";Local Phi;Local Y [cm]", 200, -20, 20, 200, -250, 250);
40  theTPeaks[i - 1] = iBooker.book1D(t9, t9 + ";Peak Time [ns];Entries", 200, 0, 400);
41  }
42 }
43 
45  // get the collection of CSCRecHrecHitItrD
47  e.getByToken(rechits_Token_, hRecHits);
48  const CSCRecHit2DCollection *cscRecHits = hRecHits.product();
49 
50  unsigned nPerEvent = 0;
51 
52  for (auto recHitItr = cscRecHits->begin(); recHitItr != cscRecHits->end(); recHitItr++) {
53  ++nPerEvent;
54  int detId = (*recHitItr).cscDetId().rawId();
56  const CSCLayer *layer = findLayer(detId);
57  int chamberType = layer->chamber()->specs()->chamberType();
58  theTPeaks[chamberType - 1]->Fill(recHitItr->tpeak());
59  if (simHits.size() == 1) {
60  plotResolution(simHits[0], *recHitItr, layer, chamberType);
61  }
62  float localX = recHitItr->localPosition().x();
63  float localY = recHitItr->localPosition().y();
64  // find a local phi
65  float globalR = layer->toGlobal(LocalPoint(0., 0., 0.)).perp();
66  GlobalPoint axisThruChamber(globalR + localY, localX, 0.);
67  float localPhi = axisThruChamber.phi().degrees();
68  theScatterPlots[chamberType - 1]->Fill(localPhi, localY);
69  }
70  theNPerEventPlot->Fill(nPerEvent);
71 
72  if (doSim_) {
73  // fill sim hits
74  std::vector<int> layersWithSimHits = theSimHitMap->detsWithHits();
75  for (unsigned i = 0; i < layersWithSimHits.size(); ++i) {
76  edm::PSimHitContainer simHits = theSimHitMap->hits(layersWithSimHits[i]);
77  for (auto hitItr = simHits.begin(); hitItr != simHits.end(); ++hitItr) {
78  const CSCLayer *layer = findLayer(layersWithSimHits[i]);
79  int chamberType = layer->chamber()->specs()->chamberType();
80  float localX = hitItr->localPosition().x();
81  float localY = hitItr->localPosition().y();
82  // find a local phi
83  float globalR = layer->toGlobal(LocalPoint(0., 0., 0.)).perp();
84  GlobalPoint axisThruChamber(globalR + localY, localX, 0.);
85  float localPhi = axisThruChamber.phi().degrees();
86  theSimHitScatterPlots[chamberType - 1]->Fill(localPhi, localY);
87  }
88  }
89  }
90 }
91 
93  const CSCRecHit2D &recHit,
94  const CSCLayer *layer,
95  int chamberType) {
96  GlobalPoint simHitPos = layer->toGlobal(simHit.localPosition());
97  GlobalPoint recHitPos = layer->toGlobal(recHit.localPosition());
98 
99  double dphi = recHitPos.phi() - simHitPos.phi();
100  double rdphi = recHitPos.perp() * dphi;
101  theResolutionPlots[chamberType - 1]->Fill(rdphi);
102  thePullPlots[chamberType - 1]->Fill(rdphi / sqrt(recHit.localPositionError().xx()));
103  double dy = recHit.localPosition().y() - simHit.localPosition().y();
104  theYResolutionPlots[chamberType - 1]->Fill(dy);
105  theYPullPlots[chamberType - 1]->Fill(dy / sqrt(recHit.localPositionError().yy()));
106 
107  const CSCLayerGeometry *layerGeometry = layer->geometry();
108  float recStrip = layerGeometry->strip(recHit.localPosition());
109  float simStrip = layerGeometry->strip(simHit.localPosition());
110  theRecHitPosInStrip[chamberType - 1]->Fill(recStrip - int(recStrip));
111  theSimHitPosInStrip[chamberType - 1]->Fill(simStrip - int(simStrip));
112 }
MonitorElement * theSimHitScatterPlots[10]
MonitorElement * theYResolutionPlots[10]
float xx() const
Definition: LocalError.h:22
MonitorElement * theScatterPlots[10]
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
T perp() const
Definition: PV3DBase.h:69
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:539
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
CSCRecHit2DValidation(const edm::ParameterSet &ps, edm::ConsumesCollector &&iC)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T y() const
Definition: PV3DBase.h:60
void bookHistograms(DQMStore::IBooker &)
constexpr uint16_t localY(uint16_t py)
MonitorElement * theResolutionPlots[10]
constexpr std::array< uint8_t, layerIndexSize > layer
void Fill(long long x)
T1 degrees() const
Definition: Phi.h:107
MonitorElement * theSimHitPosInStrip[10]
MonitorElement * theYPullPlots[10]
const CSCChamberSpecs * specs() const
Definition: CSCChamber.h:39
float yy() const
Definition: LocalError.h:24
Local3DPoint localPosition() const
Definition: PSimHit.h:52
const PSimHitMap * theSimHitMap
T sqrt(T t)
Definition: SSEVec.h:19
const edm::PSimHitContainer & hits(int detId) const
Definition: PSimHitMap.cc:20
float strip(const LocalPoint &lp) const
LocalError localPositionError() const override
Definition: CSCRecHit2D.h:57
LocalPoint localPosition() const override
Definition: CSCRecHit2D.h:56
std::vector< int > detsWithHits() const
Definition: PSimHitMap.cc:29
std::string chamberName() const
Definition: CSCDetId.cc:92
T const * product() const
Definition: Handle.h:70
int chamberType() const
ParameterSet const & getParameterSet(std::string const &) const
constexpr uint16_t localX(uint16_t px)
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
tuple simHits
Definition: trackerHits.py:16
MonitorElement * theNPerEventPlot
MonitorElement * thePullPlots[10]
MonitorElement * theRecHitPosInStrip[10]
MonitorElement * theTPeaks[10]
std::vector< PSimHit > PSimHitContainer
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
const CSCChamber * chamber() const
Definition: CSCLayer.h:49
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:44
const CSCLayer * findLayer(int detId) const
void analyze(const edm::Event &, const edm::EventSetup &) override