CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PrimaryVertexMonitor.cc
Go to the documentation of this file.
4 
7 
9 
10 using namespace reco;
11 using namespace edm;
12 
14 {
15  moduleLabel = pSet.getParameter<InputTag>("vertexLabel");
16  beamSpotLabel = pSet.getParameter<InputTag>("beamSpotLabel");
17 
18  //
19  // Book all histograms.
20  //
21 
22  // get the store
23  dqmStore_ = edm::Service<DQMStore>().operator->();
24  dqmLabel = "OfflinePV/"+moduleLabel.label();
25  dqmStore_->setCurrentFolder(dqmLabel);
26 
27 // xPos = dqmStore_->book1D ("xPos","x Coordinate" ,100, -0.1, 0.1);
28 
29  nbvtx = dqmStore_->book1D("vtxNbr","Reconstructed Vertices in Event",50,-0.5,49.5);
30 
31  nbtksinvtx[0] = dqmStore_->book1D("otherVtxTrksNbr","Reconstructed Tracks in Vertex (other Vtx)",40,-0.5,99.5);
32  trksWeight[0] = dqmStore_->book1D("otherVtxTrksWeight","Total weight of Tracks in Vertex (other Vtx)",40,0,100.);
33  vtxchi2[0] = dqmStore_->book1D("otherVtxChi2","#chi^{2} (other Vtx)",100,0.,200.);
34  vtxndf[0] = dqmStore_->book1D("otherVtxNdf","ndof (other Vtx)",100,0.,200.);
35  vtxprob[0] = dqmStore_->book1D("otherVtxProb","#chi^{2} probability (other Vtx)",100,0.,1.);
36  nans[0] = dqmStore_->book1D("otherVtxNans","Illegal values for x,y,z,xx,xy,xz,yy,yz,zz (other Vtx)",9,0.5,9.5);
37 
38  nbtksinvtx[1] = dqmStore_->book1D("tagVtxTrksNbr","Reconstructed Tracks in Vertex (tagged Vtx)",100,-0.5,99.5);
39  trksWeight[1] = dqmStore_->book1D("tagVtxTrksWeight","Total weight of Tracks in Vertex (tagged Vtx)",100,0,100.);
40  vtxchi2[1] = dqmStore_->book1D("tagVtxChi2","#chi^{2} (tagged Vtx)",100,0.,200.);
41  vtxndf[1] = dqmStore_->book1D("tagVtxNdf","ndof (tagged Vtx)",100,0.,200.);
42  vtxprob[1] = dqmStore_->book1D("tagVtxProb","#chi^{2} probability (tagged Vtx)",100,0.,1.);
43  nans[1] = dqmStore_->book1D("tagVtxNans","Illegal values for x,y,z,xx,xy,xz,yy,yz,zz (tagged Vtx)",9,0.5,9.5);
44 
45  xrec[0] = dqmStore_->book1D("otherPosX","Position x Coordinate (other Vtx)",100,-0.1,0.1);
46  yrec[0] = dqmStore_->book1D("otherPosY","Position y Coordinate (other Vtx)",100,-0.1,0.1);
47  zrec[0] = dqmStore_->book1D("otherPosZ","Position z Coordinate (other Vtx)",100,-20.,20.);
48  xDiff[0] = dqmStore_->book1D("otherDiffX","X distance from BeamSpot (other Vtx)",100,-500,500);
49  yDiff[0] = dqmStore_->book1D("otherDiffY","Y distance from BeamSpot (other Vtx)",100,-500,500);
50  xerr[0] = dqmStore_->book1D("otherErrX","Uncertainty x Coordinate (other Vtx)",100,-0.1,0.1);
51  yerr[0] = dqmStore_->book1D("otherErrY","Uncertainty y Coordinate (other Vtx)",100,-0.1,0.1);
52  zerr[0] = dqmStore_->book1D("otherErrZ","Uncertainty z Coordinate (other Vtx)",100,-20.,20.);
53  xerrVsTrks[0] = dqmStore_->book2D("otherErrVsWeightX","Uncertainty x Coordinate vs. track weight (other Vtx)",100,0,100.,100,-0.1,0.1);
54  yerrVsTrks[0] = dqmStore_->book2D("otherErrVsWeightY","Uncertainty y Coordinate vs. track weight (other Vtx)",100,0,100.,100,-0.1,0.1);
55  zerrVsTrks[0] = dqmStore_->book2D("otherErrVsWeightZ","Uncertainty z Coordinate vs. track weight (other Vtx)",100,0,100.,100,-0.1,0.1);
56 
57 
58  xrec[1] = dqmStore_->book1D("tagPosX","Position x Coordinate (tagged Vtx)",100,-0.1,0.1);
59  yrec[1] = dqmStore_->book1D("tagPosY","Position y Coordinate (tagged Vtx)",100,-0.1,0.1);
60  zrec[1] = dqmStore_->book1D("tagPosZ","Position z Coordinate (tagged Vtx)",100,-20.,20.);
61  xDiff[1] = dqmStore_->book1D("tagDiffX","X distance from BeamSpot (tagged Vtx)",100,-500, 500);
62  yDiff[1] = dqmStore_->book1D("tagDiffY","Y distance from BeamSpot (tagged Vtx)",100,-500, 500);
63  xerr[1] = dqmStore_->book1D("tagErrX","Uncertainty x Coordinate (tagged Vtx)",100,0.,100);
64  yerr[1] = dqmStore_->book1D("tagErrY","Uncertainty y Coordinate (tagged Vtx)",100,0.,100);
65  zerr[1] = dqmStore_->book1D("tagErrZ","Uncertainty z Coordinate (tagged Vtx)",100,0.,100);
66  xerrVsTrks[1] = dqmStore_->book2D("tagErrVsWeightX","Uncertainty x Coordinate vs. track weight (tagged Vtx)",100,0,100.,100,0.,100);
67  yerrVsTrks[1] = dqmStore_->book2D("tagErrVsWeightY","Uncertainty y Coordinate vs. track weight (tagged Vtx)",100,0,100.,100,0.,100);
68  zerrVsTrks[1] = dqmStore_->book2D("tagErrVsWeightZ","Uncertainty z Coordinate vs. track weight (tagged Vtx)",100,0,100.,100,0.,100);
69 
70  type[0] = dqmStore_->book1D("otherType","Vertex type (other Vtx)",3,-0.5,2.5);
71  type[1] = dqmStore_->book1D("tagType","Vertex type (tagged Vtx)",3,-0.5,2.5);
72  for (int i=0;i<2;++i){
73  type[i]->getTH1F()->GetXaxis()->SetBinLabel(1,"Valid, real");
74  type[i]->getTH1F()->GetXaxis()->SetBinLabel(2,"Valid, fake");
75  type[i]->getTH1F()->GetXaxis()->SetBinLabel(3,"Invalid");
76  }
77 
78  bsX = dqmStore_->book1D("bsX", "BeamSpot x0", 100,-0.1,0.1);
79  bsY = dqmStore_->book1D("bsY", "BeamSpot y0", 100,-0.1,0.1);
80  bsZ = dqmStore_->book1D("bsZ", "BeamSpot z0", 100,-2.,2.);
81  bsSigmaZ = dqmStore_->book1D("bsSigmaZ", "BeamSpot sigmaZ", 100, 0., 10. );
82  bsDxdz = dqmStore_->book1D("bsDxdz", "BeamSpot dxdz", 100, -0.0003, 0.0003);
83  bsDydz = dqmStore_->book1D("bsDydz", "BeamSpot dydz", 100, -0.0003, 0.0003);
84  bsBeamWidthX = dqmStore_->book1D("bsBeamWidthX", "BeamSpot BeamWidthX", 100, 0., 100.);
85  bsBeamWidthY = dqmStore_->book1D("bsBeamWidthY", "BeamSpot BeamWidthY", 100, 0., 100.);
86  bsType = dqmStore_->book1D("bsType", "BeamSpot type", 4, -1.5, 2.5);
87  bsType->getTH1F()->GetXaxis()->SetBinLabel(1,"Unknown");
88  bsType->getTH1F()->GetXaxis()->SetBinLabel(2,"Fake");
89  bsType->getTH1F()->GetXaxis()->SetBinLabel(3,"LHC");
90  bsType->getTH1F()->GetXaxis()->SetBinLabel(4,"Tracker");
91 }
92 
93 
95 {}
96 
98 {
100  iEvent.getByLabel(moduleLabel, recVtxs);
101 
102  edm::Handle<reco::BeamSpot> beamSpotHandle;
103  iEvent.getByLabel(beamSpotLabel,beamSpotHandle);
104 
105  //
106  // check for absent products and simply "return" in that case
107  //
108  if (recVtxs.isValid() == false || beamSpotHandle.isValid()== false){
109  edm::LogWarning("PrimaryVertexMonitor")
110  <<" Some products not available in the event: VertexCollection "
111  <<moduleLabel<<" "
112  <<recVtxs.isValid() <<" BeamSpot "
113  <<beamSpotLabel<<" "
114  <<beamSpotHandle.isValid()<<". Skipping plots for this event";
115  return;
116  }
117 
118  BeamSpot beamSpot = *beamSpotHandle;
119 
120  nbvtx->Fill(recVtxs->size()*1.);
121 
122  vertexPlots(recVtxs->front(), beamSpot, 1);
123 
124  for(reco::VertexCollection::const_iterator v=recVtxs->begin()+1;
125  v!=recVtxs->end(); ++v){
126  vertexPlots(*v, beamSpot, 0);
127  }
128  // Beamline plots:
129  bsX->Fill(beamSpot.x0());
130  bsY->Fill(beamSpot.y0());
131  bsZ->Fill(beamSpot.z0());
132  bsSigmaZ->Fill(beamSpot.sigmaZ());
133  bsDxdz->Fill(beamSpot.dxdz());
134  bsDydz->Fill(beamSpot.dydz());
135  bsBeamWidthX->Fill(beamSpot.BeamWidthX()*10000);
136  bsBeamWidthY->Fill(beamSpot.BeamWidthY()*10000);
137  // bsType->Fill(beamSpot.type());
138 
139 }
140 
142 {
143 
144  if (!v.isValid()) type[i]->Fill(2.);
145  else if (v.isFake()) type[i]->Fill(1.);
146  else type[i]->Fill(0.);
147 
148  if (v.isValid() && !v.isFake()) {
149  float weight = 0;
151  t!=v.tracks_end(); t++) weight+= v.trackWeight(*t);
152  trksWeight[i]->Fill(weight);
153  nbtksinvtx[i]->Fill(v.tracksSize());
154 
155  vtxchi2[i]->Fill(v.chi2());
156  vtxndf[i]->Fill(v.ndof());
157  vtxprob[i]->Fill(ChiSquaredProbability(v.chi2() ,v.ndof()));
158 
159  xrec[i]->Fill(v.position().x());
160  yrec[i]->Fill(v.position().y());
161  zrec[i]->Fill(v.position().z());
162 
163  float xb = beamSpot.x0() + beamSpot.dxdz() * (v.position().z() - beamSpot.z0());
164  float yb = beamSpot.y0() + beamSpot.dydz() * (v.position().z() - beamSpot.z0());
165  xDiff[i]->Fill((v.position().x() - xb)*10000);
166  yDiff[i]->Fill((v.position().y() - yb)*10000);
167 
168  xerr[i]->Fill(v.xError()*10000);
169  yerr[i]->Fill(v.yError()*10000);
170  zerr[i]->Fill(v.zError()*10000);
171  xerrVsTrks[i]->Fill(weight, v.xError()*10000);
172  yerrVsTrks[i]->Fill(weight, v.yError()*10000);
173  zerrVsTrks[i]->Fill(weight, v.zError()*10000);
174 
175  nans[i]->Fill(1.,std::isnan(v.position().x())*1.);
176  nans[i]->Fill(2.,std::isnan(v.position().y())*1.);
177  nans[i]->Fill(3.,std::isnan(v.position().z())*1.);
178 
179  int index = 3;
180  for (int i = 0; i != 3; i++) {
181  for (int j = i; j != 3; j++) {
182  index++;
183  nans[i]->Fill(index*1., std::isnan(v.covariance(i, j))*1.);
184  // in addition, diagonal element must be positive
185  if (j == i && v.covariance(i, j) < 0) {
186  nans[i]->Fill(index*1., 1.);
187  }
188  }
189  }
190  }
191 }
192 
193 
195 {
196 }
197 
198 
199 //define this as a plug-in
type
Definition: HCALResponse.h:22
T getParameter(std::string const &) const
double z0() const
z coordinate
Definition: BeamSpot.h:69
int i
Definition: DBlmapReader.cc:9
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:45
void vertexPlots(const reco::Vertex &v, const reco::BeamSpot &beamSpot, int i)
double zError() const
error on z
Definition: Vertex.h:105
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void zerr(int)
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:61
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
Definition: Vertex.h:110
const Point & position() const
position
Definition: Vertex.h:93
double dydz() const
dydz slope
Definition: BeamSpot.h:85
int iEvent
Definition: GenABIO.cc:243
bool isnan(float x)
Definition: math.h:13
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
float trackWeight(const TrackBaseRef &r) const
returns the weight with which a Track has contributed to the vertex-fit.
double chi2() const
chi-squares
Definition: Vertex.h:82
int j
Definition: DBlmapReader.cc:9
float ChiSquaredProbability(double chiSquared, double nrDOF)
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:87
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double dxdz() const
dxdz slope
Definition: BeamSpot.h:83
double ndof() const
Definition: Vertex.h:89
double xError() const
error on x
Definition: Vertex.h:101
bool isFake() const
Definition: Vertex.h:65
double sigmaZ() const
sigma z
Definition: BeamSpot.h:81
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:89
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:38
double y0() const
y coordinate
Definition: BeamSpot.h:67
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:40
mathSSE::Vec4< T > v
double yError() const
error on y
Definition: Vertex.h:103
virtual void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup)
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:35
PrimaryVertexMonitor(const edm::ParameterSet &pSet)
double x0() const
x coordinate
Definition: BeamSpot.h:65