CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCRecHit2DValidation.cc
Go to the documentation of this file.
4 
5 
6 
8 : CSCBaseValidation(dbe, inputTag),
9  theNPerEventPlot( dbe_->book1D("CSCRecHitsPerEvent", "Number of CSC Rec Hits per event", 100, 0, 500) )
10 {
11  rechits_Token_ = iC.consumes<CSCRecHit2DCollection>(inputTag);
12 
13  dbe_->setCurrentFolder("CSCRecHitsV/CSCRecHitTask");
14 
15  for(int i = 0; i < 10; ++i)
16  {
17  char title1[200], title2[200], title3[200], title4[200], title5[200], title6[200], title7[200], title8[200], title9[200];
18  sprintf(title1, "CSCRecHitResolution%d", i+1);
19  sprintf(title2, "CSCRecHitPull%d", i+1);
20  sprintf(title3, "CSCRecHitYResolution%d", i+1);
21  sprintf(title4, "CSCRecHitYPull%d", i+1);
22  sprintf(title5, "CSCRecHitPosInStrip%d", i+1);
23  sprintf(title6, "CSCSimHitPosInStrip%d", i+1);
24  sprintf(title7, "CSCRecHit%d", i+1);
25  sprintf(title8, "CSCSimHit%d", i+1);
26  sprintf(title9, "CSCTPeak%d", i+1);
27 
28 
29  theResolutionPlots[i] = dbe_->book1D(title1, title1, 100, -0.2, 0.2);
30  thePullPlots[i] = dbe_->book1D(title2, title2, 100, -3, 3);
31  theYResolutionPlots[i] = dbe_->book1D(title3, title3, 100, -5, 5);
32  theYPullPlots[i] = dbe_->book1D(title4, title4, 100, -3, 3);
33  theRecHitPosInStrip[i] = dbe_->book1D(title5, title5, 100, -2, 2);
34  theSimHitPosInStrip[i] = dbe_->book1D(title6, title6, 100, -2, 2);
35  theScatterPlots[i] = dbe->book2D(title7, title7, 200, -20, 20, 200, -250, 250);
36  theSimHitScatterPlots[i] = dbe->book2D(title8, title8, 200, -20, 20, 200, -250, 250);
37  theTPeaks[i] = dbe->book1D(title9, title9, 200, 0, 400);
38  }
39 
40 }
41 
43 {
44  for(int i = 0; i < 10; ++i)
45  {
46  edm::LogInfo("CSCRecHitValidation") << "Resolution of " << theResolutionPlots[i]->getName() << " is " << theResolutionPlots[i]->getRMS();
47  edm::LogInfo("CSCRecHitValidation") << "Peak Time is " << theTPeaks[i]->getMean();
48  }
49 }
50 
51 
53 {
54  // get the collection of CSCRecHrecHitItrD
56  e.getByToken(rechits_Token_, hRecHits);
57  const CSCRecHit2DCollection * cscRecHits = hRecHits.product();
58 
59  unsigned nPerEvent = 0;
60 
61  for(CSCRecHit2DCollection::const_iterator recHitItr = cscRecHits->begin();
62  recHitItr != cscRecHits->end(); recHitItr++)
63  {
64  ++nPerEvent;
65  int detId = (*recHitItr).cscDetId().rawId();
67  const CSCLayer * layer = findLayer(detId);
68  int chamberType = layer->chamber()->specs()->chamberType();
69  theTPeaks[chamberType-1]->Fill(recHitItr->tpeak());
70  if(simHits.size() == 1)
71  {
72  plotResolution(simHits[0], *recHitItr, layer, chamberType);
73  }
74  float localX = recHitItr->localPosition().x();
75  float localY = recHitItr->localPosition().y();
76  //theYPlots[chamberType-1]->Fill(localY);
77  // find a local phi
78  float globalR = layer->toGlobal(LocalPoint(0.,0.,0.)).perp();
79  GlobalPoint axisThruChamber(globalR+localY, localX, 0.);
80  float localPhi = axisThruChamber.phi().degrees();
81  //thePhiPlots[chamberType-1]->Fill(axisThruChamber.phi().degrees());
82  theScatterPlots[chamberType-1]->Fill( localPhi, localY);
83  }
84  theNPerEventPlot->Fill(nPerEvent);
85 return;
86  // fill sim hits
87  std::vector<int> layersWithSimHits = theSimHitMap->detsWithHits();
88  for(unsigned i = 0; i < layersWithSimHits.size(); ++i)
89  {
90  edm::PSimHitContainer simHits = theSimHitMap->hits(layersWithSimHits[i]);
91  for(edm::PSimHitContainer::const_iterator hitItr = simHits.begin(); hitItr != simHits.end(); ++hitItr)
92  {
93  const CSCLayer * layer = findLayer(layersWithSimHits[i]);
94  int chamberType = layer->chamber()->specs()->chamberType();
95  float localX = hitItr->localPosition().x();
96  float localY = hitItr->localPosition().y();
97  //theYPlots[chamberType-1]->Fill(localY);
98  // find a local phi
99  float globalR = layer->toGlobal(LocalPoint(0.,0.,0.)).perp();
100  GlobalPoint axisThruChamber(globalR+localY, localX, 0.);
101  float localPhi = axisThruChamber.phi().degrees();
102  //thePhiPlots[chamberType-1]->Fill(axisThruChamber.phi().degrees());
103  theSimHitScatterPlots[chamberType-1]->Fill( localPhi, localY);
104  }
105  }
106 
107 }
108 
109 
110 void CSCRecHit2DValidation::plotResolution(const PSimHit & simHit, const CSCRecHit2D & recHit,
111  const CSCLayer * layer, int chamberType)
112 {
113  GlobalPoint simHitPos = layer->toGlobal(simHit.localPosition());
114  GlobalPoint recHitPos = layer->toGlobal(recHit.localPosition());
115 
116  double dphi = recHitPos.phi() - simHitPos.phi();
117  double rdphi = recHitPos.perp() * dphi;
118  theResolutionPlots[chamberType-1]->Fill( rdphi );
119  thePullPlots[chamberType-1]->Fill( rdphi/ sqrt(recHit.localPositionError().xx()) );
120  double dy = recHit.localPosition().y() - simHit.localPosition().y();
121  theYResolutionPlots[chamberType-1]->Fill( dy );
122  theYPullPlots[chamberType-1]->Fill( dy/ sqrt(recHit.localPositionError().yy()) );
123 
124  const CSCLayerGeometry * layerGeometry = layer->geometry();
125  float recStrip = layerGeometry->strip(recHit.localPosition());
126  float simStrip = layerGeometry->strip(simHit.localPosition());
127  theRecHitPosInStrip[chamberType-1]->Fill( recStrip - int(recStrip) );
128  theSimHitPosInStrip[chamberType-1]->Fill( simStrip - int(simStrip) );
129 }
130 
MonitorElement * theSimHitScatterPlots[10]
MonitorElement * theYResolutionPlots[10]
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
float xx() const
Definition: LocalError.h:24
MonitorElement * theScatterPlots[10]
T perp() const
Definition: PV3DBase.h:72
void plotResolution(const PSimHit &simHit, const CSCRecHit2D &recHit, const CSCLayer *layer, int chamberType)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:954
edm::EDGetTokenT< CSCRecHit2DCollection > rechits_Token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
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)
void Fill(long long x)
MonitorElement * theSimHitPosInStrip[10]
MonitorElement * theYPullPlots[10]
const CSCChamberSpecs * specs() const
Definition: CSCChamber.h:42
LocalError localPositionError() const
Definition: CSCRecHit2D.h:51
float yy() const
Definition: LocalError.h:26
Local3DPoint localPosition() const
Definition: PSimHit.h:44
const PSimHitMap * theSimHitMap
T sqrt(T t)
Definition: SSEVec.h:48
const edm::PSimHitContainer & hits(int detId) const
Definition: PSimHitMap.cc:22
float strip(const LocalPoint &lp) const
DQMStore * dbe_
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< int > detsWithHits() const
Definition: PSimHitMap.cc:37
CSCRecHit2DValidation(DQMStore *dbe, const edm::InputTag &inputTag, edm::ConsumesCollector &&iC)
int chamberType() const
tuple simHits
Definition: trackerHits.py:16
MonitorElement * theNPerEventPlot
T const * product() const
Definition: Handle.h:81
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)
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
MonitorElement * theTPeaks[10]
std::vector< PSimHit > PSimHitContainer
T degrees() const
Definition: Phi.h:54
LocalPoint localPosition() const
Definition: CSCRecHit2D.h:50
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1082
const CSCChamber * chamber() const
Definition: CSCLayer.h:52
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:47
const CSCLayer * findLayer(int detId) const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667