CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelTrackResidualSource.cc
Go to the documentation of this file.
1 // Package: SiPixelMonitorTrack
2 // Class: SiPixelTrackResidualSource
3 //
4 // class SiPixelTrackResidualSource SiPixelTrackResidualSource.cc
5 // DQM/SiPixelMonitorTrack/src/SiPixelTrackResidualSource.cc
6 //
7 // Description: SiPixel hit-to-track residual data quality monitoring modules
8 // Implementation: prototype -> improved -> never final - end of the 1st step
9 //
10 // Original Author: Shan-Huei Chuang
11 // Created: Fri Mar 23 18:41:42 CET 2007
12 // Updated by Lukas Wehrli (plots for clusters on/off track added)
13 
14 
15 #include <iostream>
16 #include <map>
17 #include <string>
18 #include <vector>
19 #include <utility>
20 
23 
26 
30 
32 
35 
37 
43 
47 
48 //Claudia new libraries
58 
59 using namespace std;
60 using namespace edm;
61 
62 
64  pSet_(pSet),
65  modOn( pSet.getUntrackedParameter<bool>("modOn",true) ),
66  reducedSet( pSet.getUntrackedParameter<bool>("reducedSet",true) ),
67  ladOn( pSet.getUntrackedParameter<bool>("ladOn",false) ),
68  layOn( pSet.getUntrackedParameter<bool>("layOn",false) ),
69  phiOn( pSet.getUntrackedParameter<bool>("phiOn",false) ),
70  ringOn( pSet.getUntrackedParameter<bool>("ringOn",false) ),
71  bladeOn( pSet.getUntrackedParameter<bool>("bladeOn",false) ),
72  diskOn( pSet.getUntrackedParameter<bool>("diskOn",false) ),
73  isUpgrade( pSet.getUntrackedParameter<bool>("isUpgrade",false) )
74 {
75  pSet_ = pSet;
76  debug_ = pSet_.getUntrackedParameter<bool>("debug", false);
79  tracksrc_ = pSet_.getParameter<edm::InputTag>("trajectoryInput");
80  ttrhbuilder_ = pSet_.getParameter<std::string>("TTRHBuilder");
81  ptminres_= pSet.getUntrackedParameter<double>("PtMinRes",4.0) ;
82  beamSpotToken_ = consumes<reco::BeamSpot>(std::string("offlineBeamSpot"));
83  offlinePrimaryVerticesToken_ = consumes<reco::VertexCollection>(std::string("offlinePrimaryVertices"));
84  generalTracksToken_ = consumes<reco::TrackCollection>(std::string("generalTracks"));
85  tracksrcToken_ = consumes<std::vector<Trajectory> >(pSet_.getParameter<edm::InputTag>("trajectoryInput"));
86  trackToken_ = consumes<std::vector<reco::Track> >(pSet_.getParameter<edm::InputTag>("trajectoryInput"));
87  trackAssociationToken_ = consumes<TrajTrackAssociationCollection>(pSet_.getParameter<edm::InputTag>("trajectoryInput"));
88  clustersrcToken_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(pSet_.getParameter<edm::InputTag>("clustersrc"));
89 
90  LogInfo("PixelDQM") << "SiPixelTrackResidualSource constructor" << endl;
91  LogInfo ("PixelDQM") << "Mod/Lad/Lay/Phi " << modOn << "/" << ladOn << "/"
92  << layOn << "/" << phiOn << std::endl;
93  LogInfo ("PixelDQM") << "Blade/Disk/Ring" << bladeOn << "/" << diskOn << "/"
94  << ringOn << std::endl;
95 
96  firstRun = true;
97  NTotal=0;
98  NLowProb=0;
99 }
100 
101 
103  LogInfo("PixelDQM") << "SiPixelTrackResidualSource destructor" << endl;
104 
105  std::map<uint32_t,SiPixelTrackResidualModule*>::iterator struct_iter;
106  for (struct_iter = theSiPixelStructure.begin() ; struct_iter != theSiPixelStructure.end() ; struct_iter++){
107  delete struct_iter->second;
108  struct_iter->second = 0;
109  }
110 }
111 
112 
114  LogInfo("PixelDQM") << "SiPixelTrackResidualSource beginRun()" << endl;
115  // retrieve TrackerGeometry for pixel dets
117  iSetup.get<TrackerDigiGeometryRecord>().get(TG);
118  if (debug_) LogVerbatim("PixelDQM") << "TrackerGeometry "<< &(*TG) <<" size is "<< TG->dets().size() << endl;
119 
120  // build theSiPixelStructure with the pixel barrel and endcap dets from TrackerGeometry
121  for (TrackerGeometry::DetContainer::const_iterator pxb = TG->detsPXB().begin();
122  pxb!=TG->detsPXB().end(); pxb++) {
123  if (dynamic_cast<PixelGeomDetUnit const *>((*pxb))!=0) {
124  SiPixelTrackResidualModule* module = new SiPixelTrackResidualModule((*pxb)->geographicalId().rawId());
125  theSiPixelStructure.insert(pair<uint32_t, SiPixelTrackResidualModule*>((*pxb)->geographicalId().rawId(), module));
126  }
127  }
128  for (TrackerGeometry::DetContainer::const_iterator pxf = TG->detsPXF().begin();
129  pxf!=TG->detsPXF().end(); pxf++) {
130  if (dynamic_cast<PixelGeomDetUnit const *>((*pxf))!=0) {
131  SiPixelTrackResidualModule* module = new SiPixelTrackResidualModule((*pxf)->geographicalId().rawId());
132  theSiPixelStructure.insert(pair<uint32_t, SiPixelTrackResidualModule*>((*pxf)->geographicalId().rawId(), module));
133  }
134  }
135  LogInfo("PixelDQM") << "SiPixelStructure size is " << theSiPixelStructure.size() << endl;
136 }
137 
139 
140  // book residual histograms in theSiPixelFolder - one (x,y) pair of histograms per det
141  SiPixelFolderOrganizer theSiPixelFolder;
142  for (std::map<uint32_t, SiPixelTrackResidualModule*>::iterator pxd = theSiPixelStructure.begin();
143  pxd!=theSiPixelStructure.end(); pxd++) {
144 
145  if(modOn){
146  if (theSiPixelFolder.setModuleFolder((*pxd).first,0,isUpgrade)) (*pxd).second->book(pSet_,iBooker,reducedSet,0,isUpgrade);
147  else throw cms::Exception("LogicError") << "SiPixelTrackResidualSource Folder Creation Failed! ";
148  }
149  if(ladOn){
150  if (theSiPixelFolder.setModuleFolder((*pxd).first,1,isUpgrade)) {
151 
152  (*pxd).second->book(pSet_,iBooker,reducedSet,1,isUpgrade);
153  }
154  else throw cms::Exception("LogicError") << "SiPixelTrackResidualSource ladder Folder Creation Failed! ";
155  }
156  if(layOn){
157  if (theSiPixelFolder.setModuleFolder((*pxd).first,2,isUpgrade)) (*pxd).second->book(pSet_,iBooker,reducedSet,2,isUpgrade);
158  else throw cms::Exception("LogicError") << "SiPixelTrackResidualSource layer Folder Creation Failed! ";
159  }
160  if(phiOn){
161  if (theSiPixelFolder.setModuleFolder((*pxd).first,3,isUpgrade)) (*pxd).second->book(pSet_,iBooker,reducedSet,3,isUpgrade);
162  else throw cms::Exception("LogicError") << "SiPixelTrackResidualSource phi Folder Creation Failed! ";
163  }
164  if(bladeOn){
165  if (theSiPixelFolder.setModuleFolder((*pxd).first,4,isUpgrade)) (*pxd).second->book(pSet_,iBooker,reducedSet,4,isUpgrade);
166  else throw cms::Exception("LogicError") << "SiPixelTrackResidualSource Blade Folder Creation Failed! ";
167  }
168  if(diskOn){
169  if (theSiPixelFolder.setModuleFolder((*pxd).first,5,isUpgrade)) (*pxd).second->book(pSet_,iBooker,reducedSet,5,isUpgrade);
170  else throw cms::Exception("LogicError") << "SiPixelTrackResidualSource Disk Folder Creation Failed! ";
171  }
172  if(ringOn){
173  if (theSiPixelFolder.setModuleFolder((*pxd).first,6,isUpgrade)) (*pxd).second->book(pSet_,iBooker,reducedSet,6,isUpgrade);
174  else throw cms::Exception("LogicError") << "SiPixelTrackResidualSource Ring Folder Creation Failed! ";
175  }
176  }
177 
178 
179 // edm::InputTag tracksrc = pSet_.getParameter<edm::InputTag>("trajectoryInput");
180 // edm::InputTag clustersrc = pSet_.getParameter<edm::InputTag>("clustersrc");
181 
182  //number of tracks
183  iBooker.setCurrentFolder("Pixel/Tracks");
184  meNofTracks_ = iBooker.book1D("ntracks_" + tracksrc_.label(),"Number of Tracks",4,0,4);
185  meNofTracks_->setAxisTitle("Number of Tracks",1);
186  meNofTracks_->setBinLabel(1,"All");
187  meNofTracks_->setBinLabel(2,"Pixel");
188  meNofTracks_->setBinLabel(3,"BPix");
189  meNofTracks_->setBinLabel(4,"FPix");
190 
191  //number of tracks in pixel fiducial volume
192  iBooker.setCurrentFolder("Pixel/Tracks");
193  meNofTracksInPixVol_ = iBooker.book1D("ntracksInPixVol_" + tracksrc_.label(),"Number of Tracks crossing Pixel fiducial Volume",2,0,2);
194  meNofTracksInPixVol_->setAxisTitle("Number of Tracks",1);
195  meNofTracksInPixVol_->setBinLabel(1,"With Hits");
196  meNofTracksInPixVol_->setBinLabel(2,"Without Hits");
197 
198  //number of clusters (associated to track / not associated)
199  iBooker.setCurrentFolder("Pixel/Clusters/OnTrack");
200  meNofClustersOnTrack_ = iBooker.book1D("nclusters_" + clustersrc_.label() + "_tot","Number of Clusters (on track)",3,0,3);
201  meNofClustersOnTrack_->setAxisTitle("Number of Clusters on Track",1);
205  iBooker.setCurrentFolder("Pixel/Clusters/OffTrack");
206  meNofClustersNotOnTrack_ = iBooker.book1D("nclusters_" + clustersrc_.label() + "_tot","Number of Clusters (off track)",3,0,3);
207  meNofClustersNotOnTrack_->setAxisTitle("Number of Clusters off Track",1);
211 
212  //cluster charge and size
213  //charge
214  //on track
215  iBooker.setCurrentFolder("Pixel/Clusters/OnTrack");
216  meClChargeOnTrack_all = iBooker.book1D("charge_" + clustersrc_.label(),"Charge (on track)",500,0.,500.);
217  meClChargeOnTrack_all->setAxisTitle("Charge size (in ke)",1);
218  meClChargeOnTrack_bpix = iBooker.book1D("charge_" + clustersrc_.label() + "_Barrel","Charge (on track, barrel)",500,0.,500.);
219  meClChargeOnTrack_bpix->setAxisTitle("Charge size (in ke)",1);
220  meClChargeOnTrack_fpix = iBooker.book1D("charge_" + clustersrc_.label() + "_Endcap","Charge (on track, endcap)",500,0.,500.);
221  meClChargeOnTrack_fpix->setAxisTitle("Charge size (in ke)",1);
222  meClChargeOnTrack_layer1 = iBooker.book1D("charge_" + clustersrc_.label() + "_Layer_1","Charge (on track, layer1)",500,0.,500.);
223  meClChargeOnTrack_layer1->setAxisTitle("Charge size (in ke)",1);
224  meClChargeOnTrack_layer2 = iBooker.book1D("charge_" + clustersrc_.label() + "_Layer_2","Charge (on track, layer2)",500,0.,500.);
225  meClChargeOnTrack_layer2->setAxisTitle("Charge size (in ke)",1);
226  meClChargeOnTrack_layer3 = iBooker.book1D("charge_" + clustersrc_.label() + "_Layer_3","Charge (on track, layer3)",500,0.,500.);
227  meClChargeOnTrack_layer3->setAxisTitle("Charge size (in ke)",1);
228  if (isUpgrade) {
229  meClChargeOnTrack_layer4 = iBooker.book1D("charge_" + clustersrc_.label() + "_Layer_4","Charge (on track, layer4)",500,0.,500.);
230  meClChargeOnTrack_layer4->setAxisTitle("Charge size (in ke)",1);
231  }
232  meClChargeOnTrack_diskp1 = iBooker.book1D("charge_" + clustersrc_.label() + "_Disk_p1","Charge (on track, diskp1)",500,0.,500.);
233  meClChargeOnTrack_diskp1->setAxisTitle("Charge size (in ke)",1);
234  meClChargeOnTrack_diskp2 = iBooker.book1D("charge_" + clustersrc_.label() + "_Disk_p2","Charge (on track, diskp2)",500,0.,500.);
235  meClChargeOnTrack_diskp2->setAxisTitle("Charge size (in ke)",1);
236  if (isUpgrade) {
237  meClChargeOnTrack_diskp3 = iBooker.book1D("charge_" + clustersrc_.label() + "_Disk_p3","Charge (on track, diskp3)",500,0.,500.);
238  meClChargeOnTrack_diskp3->setAxisTitle("Charge size (in ke)",1);
239  }
240  meClChargeOnTrack_diskm1 = iBooker.book1D("charge_" + clustersrc_.label() + "_Disk_m1","Charge (on track, diskm1)",500,0.,500.);
241  meClChargeOnTrack_diskm1->setAxisTitle("Charge size (in ke)",1);
242  meClChargeOnTrack_diskm2 = iBooker.book1D("charge_" + clustersrc_.label() + "_Disk_m2","Charge (on track, diskm2)",500,0.,500.);
243  meClChargeOnTrack_diskm2->setAxisTitle("Charge size (in ke)",1);
244  if (isUpgrade) {
245  meClChargeOnTrack_diskm3 = iBooker.book1D("charge_" + clustersrc_.label() + "_Disk_m3","Charge (on track, diskm3)",500,0.,500.);
246  meClChargeOnTrack_diskm3->setAxisTitle("Charge size (in ke)",1);
247  }
248  //off track
249  iBooker.setCurrentFolder("Pixel/Clusters/OffTrack");
250  meClChargeNotOnTrack_all = iBooker.book1D("charge_" + clustersrc_.label(),"Charge (off track)",500,0.,500.);
251  meClChargeNotOnTrack_all->setAxisTitle("Charge size (in ke)",1);
252  meClChargeNotOnTrack_bpix = iBooker.book1D("charge_" + clustersrc_.label() + "_Barrel","Charge (off track, barrel)",500,0.,500.);
253  meClChargeNotOnTrack_bpix->setAxisTitle("Charge size (in ke)",1);
254  meClChargeNotOnTrack_fpix = iBooker.book1D("charge_" + clustersrc_.label() + "_Endcap","Charge (off track, endcap)",500,0.,500.);
255  meClChargeNotOnTrack_fpix->setAxisTitle("Charge size (in ke)",1);
256  meClChargeNotOnTrack_layer1 = iBooker.book1D("charge_" + clustersrc_.label() + "_Layer_1","Charge (off track, layer1)",500,0.,500.);
257  meClChargeNotOnTrack_layer1->setAxisTitle("Charge size (in ke)",1);
258  meClChargeNotOnTrack_layer2 = iBooker.book1D("charge_" + clustersrc_.label() + "_Layer_2","Charge (off track, layer2)",500,0.,500.);
259  meClChargeNotOnTrack_layer2->setAxisTitle("Charge size (in ke)",1);
260  meClChargeNotOnTrack_layer3 = iBooker.book1D("charge_" + clustersrc_.label() + "_Layer_3","Charge (off track, layer3)",500,0.,500.);
261  meClChargeNotOnTrack_layer3->setAxisTitle("Charge size (in ke)",1);
262  if (isUpgrade) {
263  meClChargeNotOnTrack_layer4 = iBooker.book1D("charge_" + clustersrc_.label() + "_Layer_4","Charge (off track, layer4)",500,0.,500.);
264  meClChargeNotOnTrack_layer4->setAxisTitle("Charge size (in ke)",1);
265  }
266  meClChargeNotOnTrack_diskp1 = iBooker.book1D("charge_" + clustersrc_.label() + "_Disk_p1","Charge (off track, diskp1)",500,0.,500.);
267  meClChargeNotOnTrack_diskp1->setAxisTitle("Charge size (in ke)",1);
268  meClChargeNotOnTrack_diskp2 = iBooker.book1D("charge_" + clustersrc_.label() + "_Disk_p2","Charge (off track, diskp2)",500,0.,500.);
269  meClChargeNotOnTrack_diskp2->setAxisTitle("Charge size (in ke)",1);
270  if (isUpgrade) {
271  meClChargeNotOnTrack_diskp3 = iBooker.book1D("charge_" + clustersrc_.label() + "_Disk_p3","Charge (off track, diskp3)",500,0.,500.);
272  meClChargeNotOnTrack_diskp3->setAxisTitle("Charge size (in ke)",1);
273  }
274  meClChargeNotOnTrack_diskm1 = iBooker.book1D("charge_" + clustersrc_.label() + "_Disk_m1","Charge (off track, diskm1)",500,0.,500.);
275  meClChargeNotOnTrack_diskm1->setAxisTitle("Charge size (in ke)",1);
276  meClChargeNotOnTrack_diskm2 = iBooker.book1D("charge_" + clustersrc_.label() + "_Disk_m2","Charge (off track, diskm2)",500,0.,500.);
277  meClChargeNotOnTrack_diskm2->setAxisTitle("Charge size (in ke)",1);
278  if (isUpgrade) {
279  meClChargeNotOnTrack_diskm3 = iBooker.book1D("charge_" + clustersrc_.label() + "_Disk_m3","Charge (off track, diskm3)",500,0.,500.);
280  meClChargeNotOnTrack_diskm3->setAxisTitle("Charge size (in ke)",1);
281  }
282 
283  //size
284  //on track
285  iBooker.setCurrentFolder("Pixel/Clusters/OnTrack");
286  meClSizeOnTrack_all = iBooker.book1D("size_" + clustersrc_.label(),"Size (on track)",100,0.,100.);
287  meClSizeOnTrack_all->setAxisTitle("Cluster size (in pixels)",1);
288  meClSizeOnTrack_bpix = iBooker.book1D("size_" + clustersrc_.label() + "_Barrel","Size (on track, barrel)",100,0.,100.);
289  meClSizeOnTrack_bpix->setAxisTitle("Cluster size (in pixels)",1);
290  meClSizeOnTrack_fpix = iBooker.book1D("size_" + clustersrc_.label() + "_Endcap","Size (on track, endcap)",100,0.,100.);
291  meClSizeOnTrack_fpix->setAxisTitle("Cluster size (in pixels)",1);
292  meClSizeOnTrack_layer1 = iBooker.book1D("size_" + clustersrc_.label() + "_Layer_1","Size (on track, layer1)",100,0.,100.);
293  meClSizeOnTrack_layer1->setAxisTitle("Cluster size (in pixels)",1);
294  meClSizeOnTrack_layer2 = iBooker.book1D("size_" + clustersrc_.label() + "_Layer_2","Size (on track, layer2)",100,0.,100.);
295  meClSizeOnTrack_layer2->setAxisTitle("Cluster size (in pixels)",1);
296  meClSizeOnTrack_layer3 = iBooker.book1D("size_" + clustersrc_.label() + "_Layer_3","Size (on track, layer3)",100,0.,100.);
297  meClSizeOnTrack_layer3->setAxisTitle("Cluster size (in pixels)",1);
298  if (isUpgrade) {
299  meClSizeOnTrack_layer4 = iBooker.book1D("size_" + clustersrc_.label() + "_Layer_4","Size (on track, layer4)",100,0.,100.);
300  meClSizeOnTrack_layer4->setAxisTitle("Cluster size (in pixels)",1);
301  }
302  meClSizeOnTrack_diskp1 = iBooker.book1D("size_" + clustersrc_.label() + "_Disk_p1","Size (on track, diskp1)",100,0.,100.);
303  meClSizeOnTrack_diskp1->setAxisTitle("Cluster size (in pixels)",1);
304  meClSizeOnTrack_diskp2 = iBooker.book1D("size_" + clustersrc_.label() + "_Disk_p2","Size (on track, diskp2)",100,0.,100.);
305  meClSizeOnTrack_diskp2->setAxisTitle("Cluster size (in pixels)",1);
306  if (isUpgrade) {
307  meClSizeOnTrack_diskp3 = iBooker.book1D("size_" + clustersrc_.label() + "_Disk_p3","Size (on track, diskp3)",100,0.,100.);
308  meClSizeOnTrack_diskp3->setAxisTitle("Cluster size (in pixels)",1);
309  }
310  meClSizeOnTrack_diskm1 = iBooker.book1D("size_" + clustersrc_.label() + "_Disk_m1","Size (on track, diskm1)",100,0.,100.);
311  meClSizeOnTrack_diskm1->setAxisTitle("Cluster size (in pixels)",1);
312  meClSizeOnTrack_diskm2 = iBooker.book1D("size_" + clustersrc_.label() + "_Disk_m2","Size (on track, diskm2)",100,0.,100.);
313  meClSizeOnTrack_diskm2->setAxisTitle("Cluster size (in pixels)",1);
314  if (isUpgrade) {
315  meClSizeOnTrack_diskm3 = iBooker.book1D("size_" + clustersrc_.label() + "_Disk_m3","Size (on track, diskm3)",100,0.,100.);
316  meClSizeOnTrack_diskm3->setAxisTitle("Cluster size (in pixels)",1);
317  }
318  meClSizeXOnTrack_all = iBooker.book1D("sizeX_" + clustersrc_.label(),"SizeX (on track)",100,0.,100.);
319  meClSizeXOnTrack_all->setAxisTitle("Cluster sizeX (in pixels)",1);
320  meClSizeXOnTrack_bpix = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Barrel","SizeX (on track, barrel)",100,0.,100.);
321  meClSizeXOnTrack_bpix->setAxisTitle("Cluster sizeX (in pixels)",1);
322  meClSizeXOnTrack_fpix = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Endcap","SizeX (on track, endcap)",100,0.,100.);
323  meClSizeXOnTrack_fpix->setAxisTitle("Cluster sizeX (in pixels)",1);
324  meClSizeXOnTrack_layer1 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Layer_1","SizeX (on track, layer1)",100,0.,100.);
325  meClSizeXOnTrack_layer1->setAxisTitle("Cluster size (in pixels)",1);
326  meClSizeXOnTrack_layer2 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Layer_2","SizeX (on track, layer2)",100,0.,100.);
327  meClSizeXOnTrack_layer2->setAxisTitle("Cluster size (in pixels)",1);
328  meClSizeXOnTrack_layer3 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Layer_3","SizeX (on track, layer3)",100,0.,100.);
329  meClSizeXOnTrack_layer3->setAxisTitle("Cluster size (in pixels)",1);
330  if (isUpgrade) {
331  meClSizeXOnTrack_layer4 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Layer_4","SizeX (on track, layer4)",100,0.,100.);
332  meClSizeXOnTrack_layer4->setAxisTitle("Cluster size (in pixels)",1);
333  }
334  meClSizeXOnTrack_diskp1 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Disk_p1","SizeX (on track, diskp1)",100,0.,100.);
335  meClSizeXOnTrack_diskp1->setAxisTitle("Cluster size (in pixels)",1);
336  meClSizeXOnTrack_diskp2 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Disk_p2","SizeX (on track, diskp2)",100,0.,100.);
337  meClSizeXOnTrack_diskp2->setAxisTitle("Cluster size (in pixels)",1);
338  if (isUpgrade) {
339  meClSizeXOnTrack_diskp3 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Disk_p3","SizeX (on track, diskp3)",100,0.,100.);
340  meClSizeXOnTrack_diskp3->setAxisTitle("Cluster size (in pixels)",1);
341  }
342  meClSizeXOnTrack_diskm1 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Disk_m1","SizeX (on track, diskm1)",100,0.,100.);
343  meClSizeXOnTrack_diskm1->setAxisTitle("Cluster size (in pixels)",1);
344  meClSizeXOnTrack_diskm2 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Disk_m2","SizeX (on track, diskm2)",100,0.,100.);
345  meClSizeXOnTrack_diskm2->setAxisTitle("Cluster size (in pixels)",1);
346  if (isUpgrade) {
347  meClSizeXOnTrack_diskm3 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Disk_m3","SizeX (on track, diskm3)",100,0.,100.);
348  meClSizeXOnTrack_diskm3->setAxisTitle("Cluster size (in pixels)",1);
349  }
350  meClSizeYOnTrack_all = iBooker.book1D("sizeY_" + clustersrc_.label(),"SizeY (on track)",100,0.,100.);
351  meClSizeYOnTrack_all->setAxisTitle("Cluster sizeY (in pixels)",1);
352  meClSizeYOnTrack_bpix = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Barrel","SizeY (on track, barrel)",100,0.,100.);
353  meClSizeYOnTrack_bpix->setAxisTitle("Cluster sizeY (in pixels)",1);
354  meClSizeYOnTrack_fpix = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Endcap","SizeY (on track, endcap)",100,0.,100.);
355  meClSizeYOnTrack_fpix->setAxisTitle("Cluster sizeY (in pixels)",1);
356  meClSizeYOnTrack_layer1 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Layer_1","SizeY (on track, layer1)",100,0.,100.);
357  meClSizeYOnTrack_layer1->setAxisTitle("Cluster size (in pixels)",1);
358  meClSizeYOnTrack_layer2 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Layer_2","SizeY (on track, layer2)",100,0.,100.);
359  meClSizeYOnTrack_layer2->setAxisTitle("Cluster size (in pixels)",1);
360  meClSizeYOnTrack_layer3 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Layer_3","SizeY (on track, layer3)",100,0.,100.);
361  meClSizeYOnTrack_layer3->setAxisTitle("Cluster size (in pixels)",1);
362  if (isUpgrade) {
363  meClSizeYOnTrack_layer4 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Layer_4","SizeY (on track, layer4)",100,0.,100.);
364  meClSizeYOnTrack_layer4->setAxisTitle("Cluster size (in pixels)",1);
365  }
366  meClSizeYOnTrack_diskp1 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Disk_p1","SizeY (on track, diskp1)",100,0.,100.);
367  meClSizeYOnTrack_diskp1->setAxisTitle("Cluster size (in pixels)",1);
368  meClSizeYOnTrack_diskp2 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Disk_p2","SizeY (on track, diskp2)",100,0.,100.);
369  meClSizeYOnTrack_diskp2->setAxisTitle("Cluster size (in pixels)",1);
370  if (isUpgrade) {
371  meClSizeYOnTrack_diskp3 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Disk_p3","SizeY (on track, diskp3)",100,0.,100.);
372  meClSizeYOnTrack_diskp3->setAxisTitle("Cluster size (in pixels)",1);
373  }
374  meClSizeYOnTrack_diskm1 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Disk_m1","SizeY (on track, diskm1)",100,0.,100.);
375  meClSizeYOnTrack_diskm1->setAxisTitle("Cluster size (in pixels)",1);
376  meClSizeYOnTrack_diskm2 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Disk_m2","SizeY (on track, diskm2)",100,0.,100.);
377  meClSizeYOnTrack_diskm2->setAxisTitle("Cluster size (in pixels)",1);
378  if (isUpgrade) {
379  meClSizeYOnTrack_diskm3 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Disk_m3","SizeY (on track, diskm3)",100,0.,100.);
380  meClSizeYOnTrack_diskm3->setAxisTitle("Cluster size (in pixels)",1);
381  }
382  //off track
383  iBooker.setCurrentFolder("Pixel/Clusters/OffTrack");
384  meClSizeNotOnTrack_all = iBooker.book1D("size_" + clustersrc_.label(),"Size (off track)",100,0.,100.);
385  meClSizeNotOnTrack_all->setAxisTitle("Cluster size (in pixels)",1);
386  meClSizeNotOnTrack_bpix = iBooker.book1D("size_" + clustersrc_.label() + "_Barrel","Size (off track, barrel)",100,0.,100.);
387  meClSizeNotOnTrack_bpix->setAxisTitle("Cluster size (in pixels)",1);
388  meClSizeNotOnTrack_fpix = iBooker.book1D("size_" + clustersrc_.label() + "_Endcap","Size (off track, endcap)",100,0.,100.);
389  meClSizeNotOnTrack_fpix->setAxisTitle("Cluster size (in pixels)",1);
390  meClSizeNotOnTrack_layer1 = iBooker.book1D("size_" + clustersrc_.label() + "_Layer_1","Size (off track, layer1)",100,0.,100.);
391  meClSizeNotOnTrack_layer1->setAxisTitle("Cluster size (in pixels)",1);
392  meClSizeNotOnTrack_layer2 = iBooker.book1D("size_" + clustersrc_.label() + "_Layer_2","Size (off track, layer2)",100,0.,100.);
393  meClSizeNotOnTrack_layer2->setAxisTitle("Cluster size (in pixels)",1);
394  meClSizeNotOnTrack_layer3 = iBooker.book1D("size_" + clustersrc_.label() + "_Layer_3","Size (off track, layer3)",100,0.,100.);
395  meClSizeNotOnTrack_layer3->setAxisTitle("Cluster size (in pixels)",1);
396  if (isUpgrade) {
397  meClSizeNotOnTrack_layer4 = iBooker.book1D("size_" + clustersrc_.label() + "_Layer_4","Size (off track, layer4)",100,0.,100.);
398  meClSizeNotOnTrack_layer4->setAxisTitle("Cluster size (in pixels)",1);
399  }
400  meClSizeNotOnTrack_diskp1 = iBooker.book1D("size_" + clustersrc_.label() + "_Disk_p1","Size (off track, diskp1)",100,0.,100.);
401  meClSizeNotOnTrack_diskp1->setAxisTitle("Cluster size (in pixels)",1);
402  meClSizeNotOnTrack_diskp2 = iBooker.book1D("size_" + clustersrc_.label() + "_Disk_p2","Size (off track, diskp2)",100,0.,100.);
403  meClSizeNotOnTrack_diskp2->setAxisTitle("Cluster size (in pixels)",1);
404  if (isUpgrade) {
405  meClSizeNotOnTrack_diskp3 = iBooker.book1D("size_" + clustersrc_.label() + "_Disk_p3","Size (off track, diskp3)",100,0.,100.);
406  meClSizeNotOnTrack_diskp3->setAxisTitle("Cluster size (in pixels)",1);
407  }
408  meClSizeNotOnTrack_diskm1 = iBooker.book1D("size_" + clustersrc_.label() + "_Disk_m1","Size (off track, diskm1)",100,0.,100.);
409  meClSizeNotOnTrack_diskm1->setAxisTitle("Cluster size (in pixels)",1);
410  meClSizeNotOnTrack_diskm2 = iBooker.book1D("size_" + clustersrc_.label() + "_Disk_m2","Size (off track, diskm2)",100,0.,100.);
411  meClSizeNotOnTrack_diskm2->setAxisTitle("Cluster size (in pixels)",1);
412  if (isUpgrade) {
413  meClSizeNotOnTrack_diskm3 = iBooker.book1D("size_" + clustersrc_.label() + "_Disk_m3","Size (off track, diskm3)",100,0.,100.);
414  meClSizeNotOnTrack_diskm3->setAxisTitle("Cluster size (in pixels)",1);
415  }
416  meClSizeXNotOnTrack_all = iBooker.book1D("sizeX_" + clustersrc_.label(),"SizeX (off track)",100,0.,100.);
417  meClSizeXNotOnTrack_all->setAxisTitle("Cluster sizeX (in pixels)",1);
418  meClSizeXNotOnTrack_bpix = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Barrel","SizeX (off track, barrel)",100,0.,100.);
419  meClSizeXNotOnTrack_bpix->setAxisTitle("Cluster sizeX (in pixels)",1);
420  meClSizeXNotOnTrack_fpix = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Endcap","SizeX (off track, endcap)",100,0.,100.);
421  meClSizeXNotOnTrack_fpix->setAxisTitle("Cluster sizeX (in pixels)",1);
422  meClSizeXNotOnTrack_layer1 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Layer_1","SizeX (off track, layer1)",100,0.,100.);
423  meClSizeXNotOnTrack_layer1->setAxisTitle("Cluster size (in pixels)",1);
424  meClSizeXNotOnTrack_layer2 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Layer_2","SizeX (off track, layer2)",100,0.,100.);
425  meClSizeXNotOnTrack_layer2->setAxisTitle("Cluster size (in pixels)",1);
426  meClSizeXNotOnTrack_layer3 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Layer_3","SizeX (off track, layer3)",100,0.,100.);
427  meClSizeXNotOnTrack_layer3->setAxisTitle("Cluster size (in pixels)",1);
428  if (isUpgrade) {
429  meClSizeXNotOnTrack_layer4 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Layer_4","SizeX (off track, layer4)",100,0.,100.);
430  meClSizeXNotOnTrack_layer4->setAxisTitle("Cluster size (in pixels)",1);
431  }
432  meClSizeXNotOnTrack_diskp1 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Disk_p1","SizeX (off track, diskp1)",100,0.,100.);
433  meClSizeXNotOnTrack_diskp1->setAxisTitle("Cluster size (in pixels)",1);
434  meClSizeXNotOnTrack_diskp2 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Disk_p2","SizeX (off track, diskp2)",100,0.,100.);
435  meClSizeXNotOnTrack_diskp2->setAxisTitle("Cluster size (in pixels)",1);
436  if (isUpgrade) {
437  meClSizeXNotOnTrack_diskp3 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Disk_p3","SizeX (off track, diskp3)",100,0.,100.);
438  meClSizeXNotOnTrack_diskp3->setAxisTitle("Cluster size (in pixels)",1);
439  }
440  meClSizeXNotOnTrack_diskm1 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Disk_m1","SizeX (off track, diskm1)",100,0.,100.);
441  meClSizeXNotOnTrack_diskm1->setAxisTitle("Cluster size (in pixels)",1);
442  meClSizeXNotOnTrack_diskm2 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Disk_m2","SizeX (off track, diskm2)",100,0.,100.);
443  meClSizeXNotOnTrack_diskm2->setAxisTitle("Cluster size (in pixels)",1);
444  if (isUpgrade) {
445  meClSizeXNotOnTrack_diskm3 = iBooker.book1D("sizeX_" + clustersrc_.label() + "_Disk_m3","SizeX (off track, diskm3)",100,0.,100.);
446  meClSizeXNotOnTrack_diskm3->setAxisTitle("Cluster size (in pixels)",1);
447  }
448  meClSizeYNotOnTrack_all = iBooker.book1D("sizeY_" + clustersrc_.label(),"SizeY (off track)",100,0.,100.);
449  meClSizeYNotOnTrack_all->setAxisTitle("Cluster sizeY (in pixels)",1);
450  meClSizeYNotOnTrack_bpix = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Barrel","SizeY (off track, barrel)",100,0.,100.);
451  meClSizeYNotOnTrack_bpix->setAxisTitle("Cluster sizeY (in pixels)",1);
452  meClSizeYNotOnTrack_fpix = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Endcap","SizeY (off track, endcap)",100,0.,100.);
453  meClSizeYNotOnTrack_fpix->setAxisTitle("Cluster sizeY (in pixels)",1);
454  meClSizeYNotOnTrack_layer1 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Layer_1","SizeY (off track, layer1)",100,0.,100.);
455  meClSizeYNotOnTrack_layer1->setAxisTitle("Cluster size (in pixels)",1);
456  meClSizeYNotOnTrack_layer2 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Layer_2","SizeY (off track, layer2)",100,0.,100.);
457  meClSizeYNotOnTrack_layer2->setAxisTitle("Cluster size (in pixels)",1);
458  meClSizeYNotOnTrack_layer3 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Layer_3","SizeY (off track, layer3)",100,0.,100.);
459  meClSizeYNotOnTrack_layer3->setAxisTitle("Cluster size (in pixels)",1);
460  if (isUpgrade) {
461  meClSizeYNotOnTrack_layer4 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Layer_4","SizeY (off track, layer4)",100,0.,100.);
462  meClSizeYNotOnTrack_layer4->setAxisTitle("Cluster size (in pixels)",1);
463  }
464  meClSizeYNotOnTrack_diskp1 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Disk_p1","SizeY (off track, diskp1)",100,0.,100.);
465  meClSizeYNotOnTrack_diskp1->setAxisTitle("Cluster size (in pixels)",1);
466  meClSizeYNotOnTrack_diskp2 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Disk_p2","SizeY (off track, diskp2)",100,0.,100.);
467  meClSizeYNotOnTrack_diskp2->setAxisTitle("Cluster size (in pixels)",1);
468  if (isUpgrade) {
469  meClSizeYNotOnTrack_diskp3 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Disk_p3","SizeY (off track, diskp3)",100,0.,100.);
470  meClSizeYNotOnTrack_diskp3->setAxisTitle("Cluster size (in pixels)",1);
471  }
472  meClSizeYNotOnTrack_diskm1 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Disk_m1","SizeY (off track, diskm1)",100,0.,100.);
473  meClSizeYNotOnTrack_diskm1->setAxisTitle("Cluster size (in pixels)",1);
474  meClSizeYNotOnTrack_diskm2 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Disk_m2","SizeY (off track, diskm2)",100,0.,100.);
475  meClSizeYNotOnTrack_diskm2->setAxisTitle("Cluster size (in pixels)",1);
476  if (isUpgrade) {
477  meClSizeYNotOnTrack_diskm3 = iBooker.book1D("sizeY_" + clustersrc_.label() + "_Disk_m3","SizeY (off track, diskm3)",100,0.,100.);
478  meClSizeYNotOnTrack_diskm3->setAxisTitle("Cluster size (in pixels)",1);
479  }
480 
481  //cluster global position
482  //on track
483  iBooker.setCurrentFolder("Pixel/Clusters/OnTrack");
484  //bpix
485  meClPosLayer1OnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_Layer_1","Clusters Layer1 (on track)",200,-30.,30.,128,-3.2,3.2);
486  meClPosLayer1OnTrack->setAxisTitle("Global Z (cm)",1);
487  meClPosLayer1OnTrack->setAxisTitle("Global #phi",2);
488  meClPosLayer2OnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_Layer_2","Clusters Layer2 (on track)",200,-30.,30.,128,-3.2,3.2);
489  meClPosLayer2OnTrack->setAxisTitle("Global Z (cm)",1);
490  meClPosLayer2OnTrack->setAxisTitle("Global #phi",2);
491  meClPosLayer3OnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_Layer_3","Clusters Layer3 (on track)",200,-30.,30.,128,-3.2,3.2);
492  meClPosLayer3OnTrack->setAxisTitle("Global Z (cm)",1);
493  meClPosLayer3OnTrack->setAxisTitle("Global #phi",2);
494  if (isUpgrade) {
495  meClPosLayer4OnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_Layer_4","Clusters Layer4 (on track)",200,-30.,30.,128,-3.2,3.2);
496  meClPosLayer4OnTrack->setAxisTitle("Global Z (cm)",1);
497  meClPosLayer4OnTrack->setAxisTitle("Global #phi",2);
498  }
499  //fpix
500  meClPosDisk1pzOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_pz_Disk_1","Clusters +Z Disk1 (on track)",80,-20.,20.,80,-20.,20.);
501  meClPosDisk1pzOnTrack->setAxisTitle("Global X (cm)",1);
502  meClPosDisk1pzOnTrack->setAxisTitle("Global Y (cm)",2);
503  meClPosDisk2pzOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_pz_Disk_2","Clusters +Z Disk2 (on track)",80,-20.,20.,80,-20.,20.);
504  meClPosDisk2pzOnTrack->setAxisTitle("Global X (cm)",1);
505  meClPosDisk2pzOnTrack->setAxisTitle("Global Y (cm)",2);
506  if (isUpgrade) {
507  meClPosDisk3pzOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_pz_Disk_3","Clusters +Z Disk3 (on track)",80,-20.,20.,80,-20.,20.);
508  meClPosDisk3pzOnTrack->setAxisTitle("Global X (cm)",1);
509  meClPosDisk3pzOnTrack->setAxisTitle("Global Y (cm)",2);
510  }
511  meClPosDisk1mzOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_mz_Disk_1","Clusters -Z Disk1 (on track)",80,-20.,20.,80,-20.,20.);
512  meClPosDisk1mzOnTrack->setAxisTitle("Global X (cm)",1);
513  meClPosDisk1mzOnTrack->setAxisTitle("Global Y (cm)",2);
514  meClPosDisk2mzOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_mz_Disk_2","Clusters -Z Disk2 (on track)",80,-20.,20.,80,-20.,20.);
515  meClPosDisk2mzOnTrack->setAxisTitle("Global X (cm)",1);
516  meClPosDisk2mzOnTrack->setAxisTitle("Global Y (cm)",2);
517  if (isUpgrade) {
518  meClPosDisk3mzOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_mz_Disk_3","Clusters -Z Disk3 (on track)",80,-20.,20.,80,-20.,20.);
519  meClPosDisk3mzOnTrack->setAxisTitle("Global X (cm)",1);
520  meClPosDisk3mzOnTrack->setAxisTitle("Global Y (cm)",2);
521  }
522  meNClustersOnTrack_all = iBooker.book1D("nclusters_" + clustersrc_.label(),"Number of Clusters (on Track)",50,0.,50.);
523  meNClustersOnTrack_all->setAxisTitle("Number of Clusters",1);
524  meNClustersOnTrack_bpix = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Barrel","Number of Clusters (on track, barrel)",50,0.,50.);
525  meNClustersOnTrack_bpix->setAxisTitle("Number of Clusters",1);
526  meNClustersOnTrack_fpix = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Endcap","Number of Clusters (on track, endcap)",50,0.,50.);
527  meNClustersOnTrack_fpix->setAxisTitle("Number of Clusters",1);
528  meNClustersOnTrack_layer1 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Layer_1","Number of Clusters (on track, layer1)",50,0.,50.);
529  meNClustersOnTrack_layer1->setAxisTitle("Number of Clusters",1);
530  meNClustersOnTrack_layer2 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Layer_2","Number of Clusters (on track, layer2)",50,0.,50.);
531  meNClustersOnTrack_layer2->setAxisTitle("Number of Clusters",1);
532  meNClustersOnTrack_layer3 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Layer_3","Number of Clusters (on track, layer3)",50,0.,50.);
533  meNClustersOnTrack_layer3->setAxisTitle("Number of Clusters",1);
534  if (isUpgrade) {
535  meNClustersOnTrack_layer4 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Layer_4","Number of Clusters (on track, layer4)",50,0.,50.);
536  meNClustersOnTrack_layer4->setAxisTitle("Number of Clusters",1);
537  }
538  meNClustersOnTrack_diskp1 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Disk_p1","Number of Clusters (on track, diskp1)",50,0.,50.);
539  meNClustersOnTrack_diskp1->setAxisTitle("Number of Clusters",1);
540  meNClustersOnTrack_diskp2 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Disk_p2","Number of Clusters (on track, diskp2)",50,0.,50.);
541  meNClustersOnTrack_diskp2->setAxisTitle("Number of Clusters",1);
542  if (isUpgrade) {
543  meNClustersOnTrack_diskp3 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Disk_p3","Number of Clusters (on track, diskp3)",50,0.,50.);
544  meNClustersOnTrack_diskp3->setAxisTitle("Number of Clusters",1);
545  }
546  meNClustersOnTrack_diskm1 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Disk_m1","Number of Clusters (on track, diskm1)",50,0.,50.);
547  meNClustersOnTrack_diskm1->setAxisTitle("Number of Clusters",1);
548  meNClustersOnTrack_diskm2 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Disk_m2","Number of Clusters (on track, diskm2)",50,0.,50.);
549  meNClustersOnTrack_diskm2->setAxisTitle("Number of Clusters",1);
550  if (isUpgrade) {
551  meNClustersOnTrack_diskm3 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Disk_m3","Number of Clusters (on track, diskm3)",50,0.,50.);
552  meNClustersOnTrack_diskm3->setAxisTitle("Number of Clusters",1);
553  }
554 
555  //not on track
556  iBooker.setCurrentFolder("Pixel/Clusters/OffTrack");
557  //bpix
558  meClPosLayer1NotOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_Layer_1","Clusters Layer1 (off track)",200,-30.,30.,128,-3.2,3.2);
559  meClPosLayer1NotOnTrack->setAxisTitle("Global Z (cm)",1);
560  meClPosLayer1NotOnTrack->setAxisTitle("Global #phi",2);
561  meClPosLayer2NotOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_Layer_2","Clusters Layer2 (off track)",200,-30.,30.,128,-3.2,3.2);
562  meClPosLayer2NotOnTrack->setAxisTitle("Global Z (cm)",1);
563  meClPosLayer2NotOnTrack->setAxisTitle("Global #phi",2);
564  meClPosLayer3NotOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_Layer_3","Clusters Layer3 (off track)",200,-30.,30.,128,-3.2,3.2);
565  meClPosLayer3NotOnTrack->setAxisTitle("Global Z (cm)",1);
566  meClPosLayer3NotOnTrack->setAxisTitle("Global #phi",2);
567  if (isUpgrade) {
568  meClPosLayer4NotOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_Layer_4","Clusters Layer4 (off track)",200,-30.,30.,128,-3.2,3.2);
569  meClPosLayer4NotOnTrack->setAxisTitle("Global Z (cm)",1);
570  meClPosLayer4NotOnTrack->setAxisTitle("Global #phi",2);
571  }
572  //fpix
573  meClPosDisk1pzNotOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_pz_Disk_1","Clusters +Z Disk1 (off track)",80,-20.,20.,80,-20.,20.);
574  meClPosDisk1pzNotOnTrack->setAxisTitle("Global X (cm)",1);
575  meClPosDisk1pzNotOnTrack->setAxisTitle("Global Y (cm)",2);
576  meClPosDisk2pzNotOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_pz_Disk_2","Clusters +Z Disk2 (off track)",80,-20.,20.,80,-20.,20.);
577  meClPosDisk2pzNotOnTrack->setAxisTitle("Global X (cm)",1);
578  meClPosDisk2pzNotOnTrack->setAxisTitle("Global Y (cm)",2);
579  if (isUpgrade) {
580  meClPosDisk3pzNotOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_pz_Disk_3","Clusters +Z Disk3 (off track)",80,-20.,20.,80,-20.,20.);
581  meClPosDisk3pzNotOnTrack->setAxisTitle("Global X (cm)",1);
582  meClPosDisk3pzNotOnTrack->setAxisTitle("Global Y (cm)",2);
583  }
584  meClPosDisk1mzNotOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_mz_Disk_1","Clusters -Z Disk1 (off track)",80,-20.,20.,80,-20.,20.);
585  meClPosDisk1mzNotOnTrack->setAxisTitle("Global X (cm)",1);
586  meClPosDisk1mzNotOnTrack->setAxisTitle("Global Y (cm)",2);
587  meClPosDisk2mzNotOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_mz_Disk_2","Clusters -Z Disk2 (off track)",80,-20.,20.,80,-20.,20.);
588  meClPosDisk2mzNotOnTrack->setAxisTitle("Global X (cm)",1);
589  meClPosDisk2mzNotOnTrack->setAxisTitle("Global Y (cm)",2);
590  if (isUpgrade) {
591  meClPosDisk3mzNotOnTrack = iBooker.book2D("position_" + clustersrc_.label() + "_mz_Disk_3","Clusters -Z Disk3 (off track)",80,-20.,20.,80,-20.,20.);
592  meClPosDisk3mzNotOnTrack->setAxisTitle("Global X (cm)",1);
593  meClPosDisk3mzNotOnTrack->setAxisTitle("Global Y (cm)",2);
594  }
595  meNClustersNotOnTrack_all = iBooker.book1D("nclusters_" + clustersrc_.label(),"Number of Clusters (off Track)",50,0.,50.);
596  meNClustersNotOnTrack_all->setAxisTitle("Number of Clusters",1);
597  meNClustersNotOnTrack_bpix = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Barrel","Number of Clusters (off track, barrel)",50,0.,50.);
598  meNClustersNotOnTrack_bpix->setAxisTitle("Number of Clusters",1);
599  meNClustersNotOnTrack_fpix = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Endcap","Number of Clusters (off track, endcap)",50,0.,50.);
600  meNClustersNotOnTrack_fpix->setAxisTitle("Number of Clusters",1);
601  meNClustersNotOnTrack_layer1 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Layer_1","Number of Clusters (off track, layer1)",50,0.,50.);
602  meNClustersNotOnTrack_layer1->setAxisTitle("Number of Clusters",1);
603  meNClustersNotOnTrack_layer2 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Layer_2","Number of Clusters (off track, layer2)",50,0.,50.);
604  meNClustersNotOnTrack_layer2->setAxisTitle("Number of Clusters",1);
605  meNClustersNotOnTrack_layer3 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Layer_3","Number of Clusters (off track, layer3)",50,0.,50.);
606  meNClustersNotOnTrack_layer3->setAxisTitle("Number of Clusters",1);
607  if (isUpgrade) {
608  meNClustersNotOnTrack_layer4 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Layer_4","Number of Clusters (off track, layer4)",50,0.,50.);
609  meNClustersNotOnTrack_layer4->setAxisTitle("Number of Clusters",1);
610  }
611  meNClustersNotOnTrack_diskp1 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Disk_p1","Number of Clusters (off track, diskp1)",50,0.,50.);
612  meNClustersNotOnTrack_diskp1->setAxisTitle("Number of Clusters",1);
613  meNClustersNotOnTrack_diskp2 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Disk_p2","Number of Clusters (off track, diskp2)",50,0.,50.);
614  meNClustersNotOnTrack_diskp2->setAxisTitle("Number of Clusters",1);
615  if (isUpgrade) {
616  meNClustersNotOnTrack_diskp3 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Disk_p3","Number of Clusters (off track, diskp3)",50,0.,50.);
617  meNClustersNotOnTrack_diskp3->setAxisTitle("Number of Clusters",1);
618  }
619  meNClustersNotOnTrack_diskm1 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Disk_m1","Number of Clusters (off track, diskm1)",50,0.,50.);
620  meNClustersNotOnTrack_diskm1->setAxisTitle("Number of Clusters",1);
621  meNClustersNotOnTrack_diskm2 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Disk_m2","Number of Clusters (off track, diskm2)",50,0.,50.);
622  meNClustersNotOnTrack_diskm2->setAxisTitle("Number of Clusters",1);
623  if (isUpgrade) {
624  meNClustersNotOnTrack_diskm3 = iBooker.book1D("nclusters_" + clustersrc_.label() + "_Disk_m3","Number of Clusters (off track, diskm3)",50,0.,50.);
625  meNClustersNotOnTrack_diskm3->setAxisTitle("Number of Clusters",1);
626  }
627 
628  //HitProbability
629  //on track
630  iBooker.setCurrentFolder("Pixel/Clusters/OnTrack");
631  meHitProbability = iBooker.book1D("FractionLowProb","Fraction of hits with low probability;FractionLowProb;#HitsOnTrack",100,0.,1.);
632 
633  if (debug_) {
634  // book summary residual histograms in a debugging folder - one (x,y) pair of histograms per subdetector
635  iBooker.setCurrentFolder("debugging");
636  char hisID[80];
637  for (int s=0; s<3; s++) {
638  sprintf(hisID,"residual_x_subdet_%i",s);
639  meSubdetResidualX[s] = iBooker.book1D(hisID,"Pixel Hit-to-Track Residual in X",500,-5.,5.);
640 
641  sprintf(hisID,"residual_y_subdet_%i",s);
642  meSubdetResidualY[s] = iBooker.book1D(hisID,"Pixel Hit-to-Track Residual in Y",500,-5.,5.);
643  }
644  }
645 
646  firstRun = false;
647 }
648 
649 
651  //Retrieve tracker topology from geometry
652  edm::ESHandle<TrackerTopology> tTopoHandle;
653  iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
654  const TrackerTopology* const tTopo = tTopoHandle.product();
655 
656 
657 
658  // retrieve TrackerGeometry again and MagneticField for use in transforming
659  // a TrackCandidate's P(ersistent)TrajectoryStateoOnDet (PTSoD) to a TrajectoryStateOnSurface (TSoS)
661  iSetup.get<TrackerDigiGeometryRecord>().get(TG);
662  const TrackerGeometry* theTrackerGeometry = TG.product();
663 
664  //analytic triplet method to calculate the track residuals in the pixe barrel detector
665 
666  //--------------------------------------------------------------------
667  // beam spot:
668  //
670  //iEvent.getByLabel( "offlineBeamSpot", rbs );
671  iEvent.getByToken( beamSpotToken_, rbs );
672  math::XYZPoint bsP = math::XYZPoint(0,0,0);
673  if( !rbs.failedToGet() && rbs.isValid() )
674  {
675  bsP = math::XYZPoint( rbs->x0(), rbs->y0(), rbs->z0() );
676  }
677 
678  //--------------------------------------------------------------------
679  // primary vertices:
680  //
682  //iEvent.getByLabel("offlinePrimaryVertices", vertices );
683  iEvent.getByToken( offlinePrimaryVerticesToken_, vertices );
684 
685  if( vertices.failedToGet() ) return;
686  if( !vertices.isValid() ) return;
687 
688  math::XYZPoint vtxN = math::XYZPoint(0,0,0);
689  math::XYZPoint vtxP = math::XYZPoint(0,0,0);
690 
691  double bestNdof = 0;
692  double maxSumPt = 0;
693  reco::Vertex bestPvx;
694  for(reco::VertexCollection::const_iterator iVertex = vertices->begin();
695  iVertex != vertices->end(); ++iVertex ) {
696  if( iVertex->ndof() > bestNdof ) {
697  bestNdof = iVertex->ndof();
698  vtxN = math::XYZPoint( iVertex->x(), iVertex->y(), iVertex->z() );
699  }//ndof
700  if( iVertex->p4().pt() > maxSumPt ) {
701  maxSumPt = iVertex->p4().pt();
702  vtxP = math::XYZPoint( iVertex->x(), iVertex->y(), iVertex->z() );
703  bestPvx = *iVertex;
704  }//sumpt
705 
706  }//vertex
707 
708  if( maxSumPt < 1 ) return;
709 
710  if( maxSumPt < 1 ) vtxP = vtxN;
711 
712  //---------------------------------------------
713  //get Tracks
714  //
716  //iEvent.getByLabel( "generalTracks", TracksForRes );
717  iEvent.getByToken( generalTracksToken_, TracksForRes );
718 
719  //
720  // transient track builder, needs B-field from data base (global tag in .py)
721  //
723  iSetup.get<TransientTrackRecord>().get( "TransientTrackBuilder", theB );
724 
725  //get the TransienTrackingRecHitBuilder needed for extracting the global position of the hits in the pixel
726  edm::ESHandle<TransientTrackingRecHitBuilder> theTrackerRecHitBuilder;
727  iSetup.get<TransientRecHitRecord>().get(ttrhbuilder_,theTrackerRecHitBuilder);
728 
729  //check that tracks are valid
730  if( TracksForRes.failedToGet() ) return;
731  if( !TracksForRes.isValid() ) return;
732 
733  //get tracker geometry
735  iSetup.get<TrackerDigiGeometryRecord>().get(pDD);
736 
737  if( !pDD.isValid() ) {
738  cout << "Unable to find TrackerDigiGeometry. Return\n";
739  return;
740  }
741 
742  int kk = -1;
743  //----------------------------------------------------------------------------
744  // Residuals:
745  //
746  for( reco::TrackCollection::const_iterator iTrack = TracksForRes->begin();
747  iTrack != TracksForRes->end(); ++iTrack ) {
748  //count
749  kk++;
750  //Calculate minimal track pt before curling
751  // cpt = cqRB = 0.3*R[m]*B[T] = 1.14*R[m] for B=3.8T
752  // D = 2R = 2*pt/1.14
753  // calo: D = 1.3 m => pt = 0.74 GeV/c
754  double pt = iTrack->pt();
755  if( pt < 0.75 ) continue;// curls up
756  if( abs( iTrack->dxy(vtxP) ) > 5*iTrack->dxyError() ) continue; // not prompt
757 
758  double charge = iTrack->charge();
759 
760  reco::TransientTrack tTrack = theB->build(*iTrack);
761  //get curvature of the track, needed for the residuals
762  double kap = tTrack.initialFreeState().transverseCurvature();
763  //needed for the TransienTrackingRecHitBuilder
765  if( iTrack->extra().isNonnull() &&iTrack->extra().isAvailable() ){
766 
767  double x1 = 0;
768  double y1 = 0;
769  double z1 = 0;
770  double x2 = 0;
771  double y2 = 0;
772  double z2 = 0;
773  double x3 = 0;
774  double y3 = 0;
775  double z3 = 0;
776  int n1 = 0;
777  int n2 = 0;
778  int n3 = 0;
779 
780  //for saving the pixel barrel hits
781  vector<TransientTrackingRecHit::RecHitPointer> GoodPixBarrelHits;
782  //looping through the RecHits of the track
783  for( trackingRecHit_iterator irecHit = iTrack->recHitsBegin();
784  irecHit != iTrack->recHitsEnd(); ++irecHit){
785 
786  if( (*irecHit)->isValid() ){
787  DetId detId = (*irecHit)->geographicalId();
788  // enum Detector { Tracker=1, Muon=2, Ecal=3, Hcal=4, Calo=5 };
789  if( detId.det() != 1 ){
790  if(debug_){
791  cout << "rec hit ID = " << detId.det() << " not in tracker!?!?\n";
792  }
793  continue;
794  }
795  uint32_t subDet = detId.subdetId();
796 
797  // enum SubDetector{ PixelBarrel=1, PixelEndcap=2 };
798  // enum SubDetector{ TIB=3, TID=4, TOB=5, TEC=6 };
799 
800  TransientTrackingRecHit::RecHitPointer trecHit = theTrackerRecHitBuilder->build( &*(*irecHit), initialTSOS);
801 
802 
803  double gX = trecHit->globalPosition().x();
804  double gY = trecHit->globalPosition().y();
805  double gZ = trecHit->globalPosition().z();
806 
807 
808  if( subDet == PixelSubdetector::PixelBarrel ) {
809 
810  int ilay = tTopo->pxbLayer(detId);
811 
812  if( ilay == 1 ){
813  n1++;
814  x1 = gX;
815  y1 = gY;
816  z1 = gZ;
817 
818  GoodPixBarrelHits.push_back((trecHit));
819  }//PXB1
820  if( ilay == 2 ){
821 
822  n2++;
823  x2 = gX;
824  y2 = gY;
825  z2 = gZ;
826 
827  GoodPixBarrelHits.push_back((trecHit));
828 
829  }//PXB2
830  if( ilay == 3 ){
831 
832  n3++;
833  x3 = gX;
834  y3 = gY;
835  z3 = gZ;
836  GoodPixBarrelHits.push_back((trecHit));
837  }
838  }//PXB
839 
840 
841  }//valid
842  }//loop rechits
843 
844  //CS extra plots
845 
846 
847  if( n1+n2+n3 == 3 && n1*n2*n3 > 0) {
848  for( unsigned int i = 0; i < GoodPixBarrelHits.size(); i++){
849 
850  if( GoodPixBarrelHits[i]->isValid() ){
851  DetId detId = GoodPixBarrelHits[i]->geographicalId().rawId();
852  int ilay = tTopo->pxbLayer(detId);
853  if(pt > ptminres_){
854 
855  double dca2 = 0.0, dz2=0.0;
856  double ptsig = pt;
857  if(charge<0.) ptsig = -pt;
858  //Filling the histograms in modules
859 
860  MeasurementPoint Test;
861  MeasurementPoint Test2;
862  Test=MeasurementPoint(0,0);
863  Test2=MeasurementPoint(0,0);
864  Measurement2DVector residual;
865 
866  if( ilay == 1 ){
867 
868  triplets(x2,y2,z2,x1,y1,z1,x3,y3,z3,ptsig,dca2,dz2, kap);
869 
870  Test=MeasurementPoint(dca2*1E4,dz2*1E4);
871  residual=Test-Test2;
872  }
873 
874  if( ilay == 2 ){
875 
876  triplets(x1,y1,z1,x2,y2,z2,x3,y3,z3,ptsig,dca2,dz2, kap);
877 
878  Test=MeasurementPoint(dca2*1E4,dz2*1E4);
879  residual=Test-Test2;
880 
881  }
882 
883  if( ilay == 3 ){
884 
885  triplets(x1,y1,z1,x3,y3,z3,x2,y2,z2,ptsig,dca2,dz2, kap);
886 
887  Test=MeasurementPoint(dca2*1E4,dz2*1E4);
888  residual=Test-Test2;
889  }
890  // fill the residual histograms
891 
892  std::map<uint32_t, SiPixelTrackResidualModule*>::iterator pxd = theSiPixelStructure.find(detId);
893  if (pxd!=theSiPixelStructure.end()) (*pxd).second->fill(residual, reducedSet, modOn, ladOn, layOn, phiOn, bladeOn, diskOn, ringOn);
894  }//three hits
895  }//is valid
896  }//rechits loop
897  }//pt 4
898  }
899 
900 
901  }//-----Tracks
903  //get trajectories
904  edm::Handle<std::vector<Trajectory> > trajCollectionHandle;
905  //iEvent.getByLabel(tracksrc_,trajCollectionHandle);
906  iEvent.getByToken ( tracksrcToken_, trajCollectionHandle );
907  const std::vector<Trajectory> trajColl = *(trajCollectionHandle.product());
908 
909  //get tracks
910  edm::Handle<std::vector<reco::Track> > trackCollectionHandle;
911  //iEvent.getByLabel(tracksrc_,trackCollectionHandle);
912  iEvent.getByToken( trackToken_, trackCollectionHandle );
913 
914  const std::vector<reco::Track> trackColl = *(trackCollectionHandle.product());
915 
916  //get the map
918  //iEvent.getByLabel(tracksrc_,match);
919  iEvent.getByToken( trackAssociationToken_, match);
920  const TrajTrackAssociationCollection ttac = *(match.product());
921 
922  // get clusters
924  //iEvent.getByLabel( clustersrc_, clusterColl );
925  iEvent.getByToken( clustersrcToken_, clusterColl );
926  const edmNew::DetSetVector<SiPixelCluster> clustColl = *(clusterColl.product());
927 
928  if(debug_){
929  std::cout << "Trajectories\t : " << trajColl.size() << std::endl;
930  std::cout << "recoTracks \t : " << trackColl.size() << std::endl;
931  std::cout << "Map entries \t : " << ttac.size() << std::endl;
932  }
933 
934  std::set<SiPixelCluster> clusterSet;
935  TrajectoryStateCombiner tsoscomb;
936  int tracks=0, pixeltracks=0, bpixtracks=0, fpixtracks=0;
937  int trackclusters=0, barreltrackclusters=0, endcaptrackclusters=0;
938  int otherclusters=0, barrelotherclusters=0, endcapotherclusters=0;
939 
940  //Loop over map entries
941  for(TrajTrackAssociationCollection::const_iterator it = ttac.begin();it != ttac.end(); ++it){
942  const edm::Ref<std::vector<Trajectory> > traj_iterator = it->key;
943  // Trajectory Map, extract Trajectory for this track
944  reco::TrackRef trackref = it->val;
945  tracks++;
946 
947  bool isBpixtrack = false, isFpixtrack = false, crossesPixVol=false;
948 
949  //find out whether track crosses pixel fiducial volume (for cosmic tracks)
950 
951  double d0 = (*trackref).d0(), dz = (*trackref).dz();
952 
953  if(abs(d0)<15 && abs(dz)<50) crossesPixVol = true;
954 
955  std::vector<TrajectoryMeasurement> tmeasColl =traj_iterator->measurements();
956  std::vector<TrajectoryMeasurement>::const_iterator tmeasIt;
957  //loop on measurements to find out whether there are bpix and/or fpix hits
958  for(tmeasIt = tmeasColl.begin();tmeasIt!=tmeasColl.end();tmeasIt++){
959  if(! tmeasIt->updatedState().isValid()) continue;
960  TransientTrackingRecHit::ConstRecHitPointer testhit = tmeasIt->recHit();
961  if(! testhit->isValid() || testhit->geographicalId().det() != DetId::Tracker) continue;
962  uint testSubDetID = (testhit->geographicalId().subdetId());
963  if(testSubDetID==PixelSubdetector::PixelBarrel) isBpixtrack = true;
964  if(testSubDetID==PixelSubdetector::PixelEndcap) isFpixtrack = true;
965  }//end loop on measurements
966  if(isBpixtrack) {
967  bpixtracks++;
968  if(debug_) std::cout << "bpixtrack\n";
969  }
970  if(isFpixtrack) {
971  fpixtracks++;
972  if(debug_) std::cout << "fpixtrack\n";
973  }
974  if(isBpixtrack || isFpixtrack){
975  pixeltracks++;
976 
977  if(crossesPixVol) meNofTracksInPixVol_->Fill(0,1);
978 
979  std::vector<TrajectoryMeasurement> tmeasColl = traj_iterator->measurements();
980  for(std::vector<TrajectoryMeasurement>::const_iterator tmeasIt = tmeasColl.begin(); tmeasIt!=tmeasColl.end(); tmeasIt++){
981  if(! tmeasIt->updatedState().isValid()) continue;
982 
983  TrajectoryStateOnSurface tsos = tsoscomb( tmeasIt->forwardPredictedState(), tmeasIt->backwardPredictedState() );
985  if(! hit->isValid() || hit->geographicalId().det() != DetId::Tracker ) {
986  continue;
987  } else {
988 
989 // //residual
990  const DetId & hit_detId = hit->geographicalId();
991  //uint IntRawDetID = (hit_detId.rawId());
992  uint IntSubDetID = (hit_detId.subdetId());
993 
994  if(IntSubDetID == 0 ) continue; // don't look at SiStrip hits!
995 
996  // get the enclosed persistent hit
997  const TrackingRecHit *persistentHit = hit->hit();
998  // check if it's not null, and if it's a valid pixel hit
999  if ((persistentHit != 0) && (typeid(*persistentHit) == typeid(SiPixelRecHit))) {
1000  // tell the C++ compiler that the hit is a pixel hit
1001  const SiPixelRecHit* pixhit = static_cast<const SiPixelRecHit*>( hit->hit() );
1002  //Hit probability:
1003  float hit_prob = -1.;
1004  if(pixhit->hasFilledProb()){
1005  hit_prob = pixhit->clusterProbability(0);
1006  //std::cout<<"HITPROB= "<<hit_prob<<std::endl;
1007  if(hit_prob<pow(10.,-15.)) NLowProb++;
1008  NTotal++;
1009  if(NTotal>0) meHitProbability->Fill(float(NLowProb/NTotal));
1010  }
1011 
1012  // get the edm::Ref to the cluster
1013  edm::Ref<edmNew::DetSetVector<SiPixelCluster>, SiPixelCluster> const& clust = (*pixhit).cluster();
1014  // check if the ref is not null
1015  if (clust.isNonnull()) {
1016 
1017  //define tracker and pixel geometry and topology
1018  const TrackerGeometry& theTracker(*theTrackerGeometry);
1019  const PixelGeomDetUnit* theGeomDet = static_cast<const PixelGeomDetUnit*> (theTracker.idToDet(hit_detId) );
1020  //test if PixelGeomDetUnit exists
1021  if(theGeomDet == 0) {
1022  if(debug_) std::cout << "NO THEGEOMDET\n";
1023  continue;
1024  }
1025 
1026  const PixelTopology * topol = &(theGeomDet->specificTopology());
1027  //fill histograms for clusters on tracks
1028  //correct SiPixelTrackResidualModule
1029  std::map<uint32_t, SiPixelTrackResidualModule*>::iterator pxd = theSiPixelStructure.find((*hit).geographicalId().rawId());
1030 
1031  //CHARGE CORRECTION (for track impact angle)
1032  // calculate alpha and beta from cluster position
1034  LocalVector localDir = ltp.momentum()/ltp.momentum().mag();
1035 
1036  float clust_alpha = atan2(localDir.z(), localDir.x());
1037  float clust_beta = atan2(localDir.z(), localDir.y());
1038  double corrCharge = clust->charge() * sqrt( 1.0 / ( 1.0/pow( tan(clust_alpha), 2 ) +
1039  1.0/pow( tan(clust_beta ), 2 ) +
1040  1.0 )
1041  )/1000.;
1042 
1043  if (pxd!=theSiPixelStructure.end()) (*pxd).second->fill((*clust), true, corrCharge, reducedSet, modOn, ladOn, layOn, phiOn, bladeOn, diskOn, ringOn);
1044 
1045 
1046  trackclusters++;
1047  //CORR CHARGE
1048  meClChargeOnTrack_all->Fill(corrCharge);
1049  meClSizeOnTrack_all->Fill((*clust).size());
1050  meClSizeXOnTrack_all->Fill((*clust).sizeX());
1051  meClSizeYOnTrack_all->Fill((*clust).sizeY());
1052  clusterSet.insert(*clust);
1053 
1054  //find cluster global position (rphi, z)
1055  // get cluster center of gravity (of charge)
1056  float xcenter = clust->x();
1057  float ycenter = clust->y();
1058  // get the cluster position in local coordinates (cm)
1059  LocalPoint clustlp = topol->localPosition( MeasurementPoint(xcenter, ycenter) );
1060  // get the cluster position in global coordinates (cm)
1061  GlobalPoint clustgp = theGeomDet->surface().toGlobal( clustlp );
1062 
1063  //find location of hit (barrel or endcap, same for cluster)
1064  bool barrel = DetId((*hit).geographicalId()).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
1065  bool endcap = DetId((*hit).geographicalId()).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
1066  if(barrel) {
1067  barreltrackclusters++;
1068  //CORR CHARGE
1069  meClChargeOnTrack_bpix->Fill(corrCharge);
1070  meClSizeOnTrack_bpix->Fill((*clust).size());
1071  meClSizeXOnTrack_bpix->Fill((*clust).sizeX());
1072  meClSizeYOnTrack_bpix->Fill((*clust).sizeY());
1073  uint32_t DBlayer;
1074  if (!isUpgrade) { DBlayer = PixelBarrelName(DetId((*hit).geographicalId())).layerName(); }
1075  else { DBlayer = PixelBarrelNameUpgrade(DetId((*hit).geographicalId())).layerName(); }
1076  float phi = clustgp.phi();
1077  float z = clustgp.z();
1078  switch(DBlayer){
1079  case 1: {
1080  meClPosLayer1OnTrack->Fill(z,phi);
1081  meClChargeOnTrack_layer1->Fill(corrCharge);
1082  meClSizeOnTrack_layer1->Fill((*clust).size());
1083  meClSizeXOnTrack_layer1->Fill((*clust).sizeX());
1084  meClSizeYOnTrack_layer1->Fill((*clust).sizeY());
1085  break;
1086  }
1087  case 2: {
1088  meClPosLayer2OnTrack->Fill(z,phi);
1089  meClChargeOnTrack_layer2->Fill(corrCharge);
1090  meClSizeOnTrack_layer2->Fill((*clust).size());
1091  meClSizeXOnTrack_layer2->Fill((*clust).sizeX());
1092  meClSizeYOnTrack_layer2->Fill((*clust).sizeY());
1093  break;
1094  }
1095  case 3: {
1096  meClPosLayer3OnTrack->Fill(z,phi);
1097  meClChargeOnTrack_layer3->Fill(corrCharge);
1098  meClSizeOnTrack_layer3->Fill((*clust).size());
1099  meClSizeXOnTrack_layer3->Fill((*clust).sizeX());
1100  meClSizeYOnTrack_layer3->Fill((*clust).sizeY());
1101  break;
1102  }
1103  case 4: {
1104  if (isUpgrade) {
1105  meClPosLayer4OnTrack->Fill(z,phi);
1106  meClChargeOnTrack_layer4->Fill(corrCharge);
1107  meClSizeOnTrack_layer4->Fill((*clust).size());
1108  meClSizeXOnTrack_layer4->Fill((*clust).sizeX());
1109  meClSizeYOnTrack_layer4->Fill((*clust).sizeY());
1110  }
1111  break;
1112  }
1113 
1114  }
1115 
1116  }
1117  if(endcap) {
1118  endcaptrackclusters++;
1119  //CORR CHARGE
1120  meClChargeOnTrack_fpix->Fill(corrCharge);
1121  meClSizeOnTrack_fpix->Fill((*clust).size());
1122  meClSizeXOnTrack_fpix->Fill((*clust).sizeX());
1123  meClSizeYOnTrack_fpix->Fill((*clust).sizeY());
1124  uint32_t DBdisk;
1125  if (!isUpgrade) { DBdisk = PixelEndcapName(DetId((*hit).geographicalId())).diskName(); }
1126  else if (isUpgrade) { DBdisk = PixelEndcapNameUpgrade(DetId((*hit).geographicalId())).diskName(); }
1127  float x = clustgp.x();
1128  float y = clustgp.y();
1129  float z = clustgp.z();
1130  if(z>0){
1131  if(DBdisk==1) {
1133  meClChargeOnTrack_diskp1->Fill(corrCharge);
1134  meClSizeOnTrack_diskp1->Fill((*clust).size());
1135  meClSizeXOnTrack_diskp1->Fill((*clust).sizeX());
1136  meClSizeYOnTrack_diskp1->Fill((*clust).sizeY());
1137  }
1138  if(DBdisk==2) {
1139  meClPosDisk2pzOnTrack->Fill(x,y);
1140  meClChargeOnTrack_diskp2->Fill(corrCharge);
1141  meClSizeOnTrack_diskp2->Fill((*clust).size());
1142  meClSizeXOnTrack_diskp2->Fill((*clust).sizeX());
1143  meClSizeYOnTrack_diskp2->Fill((*clust).sizeY());
1144  }
1145  if(DBdisk==3 && isUpgrade) {
1147  meClChargeOnTrack_diskp3->Fill(corrCharge);
1148  meClSizeOnTrack_diskp3->Fill((*clust).size());
1149  meClSizeXOnTrack_diskp3->Fill((*clust).sizeX());
1150  meClSizeYOnTrack_diskp3->Fill((*clust).sizeY());
1151  }
1152  }
1153  else{
1154  if(DBdisk==1) {
1156  meClChargeOnTrack_diskm1->Fill(corrCharge);
1157  meClSizeOnTrack_diskm1->Fill((*clust).size());
1158  meClSizeXOnTrack_diskm1->Fill((*clust).sizeX());
1159  meClSizeYOnTrack_diskm1->Fill((*clust).sizeY());
1160  }
1161  if(DBdisk==2) {
1162  meClPosDisk2mzOnTrack->Fill(x,y);
1163  meClChargeOnTrack_diskm2->Fill(corrCharge);
1164  meClSizeOnTrack_diskm2->Fill((*clust).size());
1165  meClSizeXOnTrack_diskm2->Fill((*clust).sizeX());
1166  meClSizeYOnTrack_diskm2->Fill((*clust).sizeY());
1167  }
1168  if(DBdisk==3 && isUpgrade) {
1170  meClChargeOnTrack_diskm3->Fill(corrCharge);
1171  meClSizeOnTrack_diskm3->Fill((*clust).size());
1172  meClSizeXOnTrack_diskm3->Fill((*clust).sizeX());
1173  meClSizeYOnTrack_diskm3->Fill((*clust).sizeY());
1174  }
1175  }
1176  }
1177 
1178  }//end if (cluster exists)
1179 
1180  }//end if (persistent hit exists and is pixel hit)
1181 
1182  }//end of else
1183 
1184 
1185  }//end for (all traj measurements of pixeltrack)
1186  }//end if (is pixeltrack)
1187  else {
1188  if(debug_) std::cout << "no pixeltrack:\n";
1189  if(crossesPixVol) meNofTracksInPixVol_->Fill(1,1);
1190  }
1191 
1192  }//end loop on map entries
1193 
1194  //find clusters that are NOT on track
1195  //edmNew::DetSet<SiPixelCluster>::const_iterator di;
1196  if(debug_) std::cout << "clusters not on track: (size " << clustColl.size() << ") ";
1197 
1198  for(TrackerGeometry::DetContainer::const_iterator it = TG->dets().begin(); it != TG->dets().end(); it++){
1199  //if(dynamic_cast<PixelGeomDetUnit const *>((*it))!=0){
1200  DetId detId = (*it)->geographicalId();
1201  if(detId>=302055684 && detId<=352477708){ // make sure it's a Pixel module WITHOUT using dynamic_cast!
1202  int nofclOnTrack = 0, nofclOffTrack=0;
1203  uint32_t DBlayer=10, DBdisk=10;
1204  float z=0.;
1205  //set layer/disk
1206  if(DetId(detId).subdetId() == 1) { // Barrel module
1207  if (!isUpgrade) {
1208  DBlayer = PixelBarrelName(DetId(detId)).layerName();
1209  } else if (isUpgrade) {
1210  DBlayer = PixelBarrelNameUpgrade(DetId(detId)).layerName();
1211  }
1212  }
1213  if(DetId(detId).subdetId() == 2){ // Endcap module
1214  if (!isUpgrade) { DBdisk = PixelEndcapName(DetId(detId )).diskName(); }
1215  else if (isUpgrade) { DBdisk = PixelEndcapNameUpgrade(DetId(detId )).diskName(); }
1216  }
1218  if( isearch != clustColl.end() ) { // Not an empty iterator
1220  for(di=isearch->begin(); di!=isearch->end(); di++){
1221  unsigned int temp = clusterSet.size();
1222  clusterSet.insert(*di);
1223  //check if cluster is off track
1224  if(clusterSet.size()>temp) {
1225  otherclusters++;
1226  nofclOffTrack++;
1227  //fill histograms for clusters off tracks
1228  //correct SiPixelTrackResidualModule
1229  std::map<uint32_t, SiPixelTrackResidualModule*>::iterator pxd = theSiPixelStructure.find((*it)->geographicalId().rawId());
1230 
1231  if (pxd!=theSiPixelStructure.end()) (*pxd).second->fill((*di), false, -1., reducedSet, modOn, ladOn, layOn, phiOn, bladeOn, diskOn, ringOn);
1232 
1233 
1234 
1235  meClSizeNotOnTrack_all->Fill((*di).size());
1236  meClSizeXNotOnTrack_all->Fill((*di).sizeX());
1237  meClSizeYNotOnTrack_all->Fill((*di).sizeY());
1238  meClChargeNotOnTrack_all->Fill((*di).charge()/1000);
1239 
1241  //find cluster global position (rphi, z) get cluster
1242  //define tracker and pixel geometry and topology
1243  const TrackerGeometry& theTracker(*theTrackerGeometry);
1244  const PixelGeomDetUnit* theGeomDet = static_cast<const PixelGeomDetUnit*> (theTracker.idToDet(detId) );
1245  //test if PixelGeomDetUnit exists
1246  if(theGeomDet == 0) {
1247  if(debug_) std::cout << "NO THEGEOMDET\n";
1248  continue;
1249  }
1250  const PixelTopology * topol = &(theGeomDet->specificTopology());
1251 
1252  //center of gravity (of charge)
1253  float xcenter = di->x();
1254  float ycenter = di->y();
1255  // get the cluster position in local coordinates (cm)
1256  LocalPoint clustlp = topol->localPosition( MeasurementPoint(xcenter, ycenter) );
1257  // get the cluster position in global coordinates (cm)
1258  GlobalPoint clustgp = theGeomDet->surface().toGlobal( clustlp );
1259 
1261 
1262  //barrel
1263  if(DetId(detId).subdetId() == 1) {
1264  meClSizeNotOnTrack_bpix->Fill((*di).size());
1265  meClSizeXNotOnTrack_bpix->Fill((*di).sizeX());
1266  meClSizeYNotOnTrack_bpix->Fill((*di).sizeY());
1267  meClChargeNotOnTrack_bpix->Fill((*di).charge()/1000);
1268  barrelotherclusters++;
1269  //DBlayer = PixelBarrelName(DetId(detId)).layerName();
1270  float phi = clustgp.phi();
1271  //float r = clustgp.perp();
1272  z = clustgp.z();
1273  switch(DBlayer){
1274  case 1: {
1275  meClPosLayer1NotOnTrack->Fill(z,phi);
1276  meClSizeNotOnTrack_layer1->Fill((*di).size());
1277  meClSizeXNotOnTrack_layer1->Fill((*di).sizeX());
1278  meClSizeYNotOnTrack_layer1->Fill((*di).sizeY());
1279  meClChargeNotOnTrack_layer1->Fill((*di).charge()/1000);
1280  break;
1281  }
1282  case 2: {
1283  meClPosLayer2NotOnTrack->Fill(z,phi);
1284  meClSizeNotOnTrack_layer2->Fill((*di).size());
1285  meClSizeXNotOnTrack_layer2->Fill((*di).sizeX());
1286  meClSizeYNotOnTrack_layer2->Fill((*di).sizeY());
1287  meClChargeNotOnTrack_layer2->Fill((*di).charge()/1000);
1288  break;
1289  }
1290  case 3: {
1291  meClPosLayer3NotOnTrack->Fill(z,phi);
1292  meClSizeNotOnTrack_layer3->Fill((*di).size());
1293  meClSizeXNotOnTrack_layer3->Fill((*di).sizeX());
1294  meClSizeYNotOnTrack_layer3->Fill((*di).sizeY());
1295  meClChargeNotOnTrack_layer3->Fill((*di).charge()/1000);
1296  break;
1297  }
1298  case 4: {
1299  if (isUpgrade) {
1300  meClPosLayer4NotOnTrack->Fill(z,phi);
1301  meClSizeNotOnTrack_layer4->Fill((*di).size());
1302  meClSizeXNotOnTrack_layer4->Fill((*di).sizeX());
1303  meClSizeYNotOnTrack_layer4->Fill((*di).sizeY());
1304  meClChargeNotOnTrack_layer4->Fill((*di).charge()/1000);
1305  }
1306  break;
1307  }
1308 
1309  }
1310  }
1311  //endcap
1312  if(DetId(detId).subdetId() == 2) {
1313  meClSizeNotOnTrack_fpix->Fill((*di).size());
1314  meClSizeXNotOnTrack_fpix->Fill((*di).sizeX());
1315  meClSizeYNotOnTrack_fpix->Fill((*di).sizeY());
1316  meClChargeNotOnTrack_fpix->Fill((*di).charge()/1000);
1317  endcapotherclusters++;
1318  //DBdisk = PixelEndcapName(DetId(detId )).diskName();
1319  float x = clustgp.x();
1320  float y = clustgp.y();
1321  z = clustgp.z();
1322  if(z>0){
1323  if(DBdisk==1) {
1325  meClSizeNotOnTrack_diskp1->Fill((*di).size());
1326  meClSizeXNotOnTrack_diskp1->Fill((*di).sizeX());
1327  meClSizeYNotOnTrack_diskp1->Fill((*di).sizeY());
1328  meClChargeNotOnTrack_diskp1->Fill((*di).charge()/1000);
1329  }
1330  if(DBdisk==2) {
1332  meClSizeNotOnTrack_diskp2->Fill((*di).size());
1333  meClSizeXNotOnTrack_diskp2->Fill((*di).sizeX());
1334  meClSizeYNotOnTrack_diskp2->Fill((*di).sizeY());
1335  meClChargeNotOnTrack_diskp2->Fill((*di).charge()/1000);
1336  }
1337  if(DBdisk==3 && isUpgrade) {
1339  meClSizeNotOnTrack_diskp3->Fill((*di).size());
1340  meClSizeXNotOnTrack_diskp3->Fill((*di).sizeX());
1341  meClSizeYNotOnTrack_diskp3->Fill((*di).sizeY());
1342  meClChargeNotOnTrack_diskp3->Fill((*di).charge()/1000);
1343  }
1344  }
1345  else{
1346  if(DBdisk==1) {
1348  meClSizeNotOnTrack_diskm1->Fill((*di).size());
1349  meClSizeXNotOnTrack_diskm1->Fill((*di).sizeX());
1350  meClSizeYNotOnTrack_diskm1->Fill((*di).sizeY());
1351  meClChargeNotOnTrack_diskm1->Fill((*di).charge()/1000);
1352  }
1353  if(DBdisk==2) {
1355  meClSizeNotOnTrack_diskm2->Fill((*di).size());
1356  meClSizeXNotOnTrack_diskm2->Fill((*di).sizeX());
1357  meClSizeYNotOnTrack_diskm2->Fill((*di).sizeY());
1358  meClChargeNotOnTrack_diskm2->Fill((*di).charge()/1000);
1359  }
1360  if(DBdisk==3 && isUpgrade) {
1362  meClSizeNotOnTrack_diskm3->Fill((*di).size());
1363  meClSizeXNotOnTrack_diskm3->Fill((*di).sizeX());
1364  meClSizeYNotOnTrack_diskm3->Fill((*di).sizeY());
1365  meClChargeNotOnTrack_diskm3->Fill((*di).charge()/1000);
1366  }
1367  }
1368 
1369  }
1370  }// end "if cluster off track"
1371  else {
1372  nofclOnTrack++;
1373  if(z == 0 && DBdisk != 10){
1374  //find cluster global position (rphi, z) get cluster
1375  //define tracker and pixel geometry and topology
1376  const TrackerGeometry& theTracker(*theTrackerGeometry);
1377  const PixelGeomDetUnit* theGeomDet = static_cast<const PixelGeomDetUnit*> (theTracker.idToDet(detId) );
1378  //test if PixelGeomDetUnit exists
1379  if(theGeomDet == 0) {
1380  if(debug_) std::cout << "NO THEGEOMDET\n";
1381  continue;
1382  }
1383  const PixelTopology * topol = &(theGeomDet->specificTopology());
1384  //center of gravity (of charge)
1385  float xcenter = di->x();
1386  float ycenter = di->y();
1387  // get the cluster position in local coordinates (cm)
1388  LocalPoint clustlp = topol->localPosition( MeasurementPoint(xcenter, ycenter) );
1389  // get the cluster position in global coordinates (cm)
1390  GlobalPoint clustgp = theGeomDet->surface().toGlobal( clustlp );
1391  z = clustgp.z();
1392  }
1393  }
1394  }
1395  }
1396  //++ fill the number of clusters on a module
1397  std::map<uint32_t, SiPixelTrackResidualModule*>::iterator pxd = theSiPixelStructure.find((*it)->geographicalId().rawId());
1398  if (pxd!=theSiPixelStructure.end()) (*pxd).second->nfill(nofclOnTrack, nofclOffTrack, reducedSet, modOn, ladOn, layOn, phiOn, bladeOn, diskOn, ringOn);
1399  if(nofclOnTrack!=0) meNClustersOnTrack_all->Fill(nofclOnTrack);
1400  if(nofclOffTrack!=0) meNClustersNotOnTrack_all->Fill(nofclOffTrack);
1401  //barrel
1402  if(DetId(detId).subdetId() == 1){
1403  if(nofclOnTrack!=0) meNClustersOnTrack_bpix->Fill(nofclOnTrack);
1404  if(nofclOffTrack!=0) meNClustersNotOnTrack_bpix->Fill(nofclOffTrack);
1405  //DBlayer = PixelBarrelName(DetId(detId)).layerName();
1406  switch(DBlayer){
1407  case 1: {
1408  if(nofclOnTrack!=0) meNClustersOnTrack_layer1->Fill(nofclOnTrack);
1409  if(nofclOffTrack!=0) meNClustersNotOnTrack_layer1->Fill(nofclOffTrack); break;
1410  }
1411  case 2: {
1412  if(nofclOnTrack!=0) meNClustersOnTrack_layer2->Fill(nofclOnTrack);
1413  if(nofclOffTrack!=0) meNClustersNotOnTrack_layer2->Fill(nofclOffTrack); break;
1414  }
1415  case 3: {
1416  if(nofclOnTrack!=0) meNClustersOnTrack_layer3->Fill(nofclOnTrack);
1417  if(nofclOffTrack!=0) meNClustersNotOnTrack_layer3->Fill(nofclOffTrack); break;
1418  }
1419  case 4: {
1420  if(nofclOnTrack!=0 && isUpgrade) meNClustersOnTrack_layer4->Fill(nofclOnTrack);
1421  if(nofclOffTrack!=0 && isUpgrade) meNClustersNotOnTrack_layer4->Fill(nofclOffTrack); break;
1422  }
1423  }
1424  }//end barrel
1425  //endcap
1426  if(DetId(detId).subdetId() == 2) {
1427  //DBdisk = PixelEndcapName(DetId(detId )).diskName();
1428  //z = clustgp.z();
1429  if(nofclOnTrack!=0) meNClustersOnTrack_fpix->Fill(nofclOnTrack);
1430  if(nofclOffTrack!=0) meNClustersNotOnTrack_fpix->Fill(nofclOffTrack);
1431  if(z>0){
1432  if(DBdisk==1) {
1433  if(nofclOnTrack!=0) meNClustersOnTrack_diskp1->Fill(nofclOnTrack);
1434  if(nofclOffTrack!=0) meNClustersNotOnTrack_diskp1->Fill(nofclOffTrack);
1435  }
1436  if(DBdisk==2) {
1437  if(nofclOnTrack!=0) meNClustersOnTrack_diskp2->Fill(nofclOnTrack);
1438  if(nofclOffTrack!=0) meNClustersNotOnTrack_diskp2->Fill(nofclOffTrack);
1439  }
1440  if(DBdisk==3) {
1441  if(nofclOnTrack!=0 && isUpgrade) meNClustersOnTrack_diskp3->Fill(nofclOnTrack);
1442  if(nofclOffTrack!=0) meNClustersNotOnTrack_diskp3->Fill(nofclOffTrack);
1443  }
1444  }
1445  if(z<0){
1446  if(DBdisk==1) {
1447  if(nofclOnTrack!=0) meNClustersOnTrack_diskm1->Fill(nofclOnTrack);
1448  if(nofclOffTrack!=0) meNClustersNotOnTrack_diskm1->Fill(nofclOffTrack);
1449  }
1450  if(DBdisk==2) {
1451  if(nofclOnTrack!=0) meNClustersOnTrack_diskm2->Fill(nofclOnTrack);
1452  if(nofclOffTrack!=0) meNClustersNotOnTrack_diskm2->Fill(nofclOffTrack);
1453  }
1454  if(DBdisk==3) {
1455  if(nofclOnTrack!=0 && isUpgrade) meNClustersOnTrack_diskm3->Fill(nofclOnTrack);
1456  if(nofclOffTrack!=0 && isUpgrade) meNClustersNotOnTrack_diskm3->Fill(nofclOffTrack);
1457  }
1458  }
1459  }
1460 
1461  }//end if it's a Pixel module
1462  }//end for loop over tracker detector geometry modules
1463 
1464 
1465  if(trackclusters>0) (meNofClustersOnTrack_)->Fill(0,trackclusters);
1466  if(barreltrackclusters>0)(meNofClustersOnTrack_)->Fill(1,barreltrackclusters);
1467  if(endcaptrackclusters>0)(meNofClustersOnTrack_)->Fill(2,endcaptrackclusters);
1468  if(otherclusters>0)(meNofClustersNotOnTrack_)->Fill(0,otherclusters);
1469  if(barrelotherclusters>0)(meNofClustersNotOnTrack_)->Fill(1,barrelotherclusters);
1470  if(endcapotherclusters>0)(meNofClustersNotOnTrack_)->Fill(2,endcapotherclusters);
1471  if(tracks>0)(meNofTracks_)->Fill(0,tracks);
1472  if(pixeltracks>0)(meNofTracks_)->Fill(1,pixeltracks);
1473  if(bpixtracks>0)(meNofTracks_)->Fill(2,bpixtracks);
1474  if(fpixtracks>0)(meNofTracks_)->Fill(3,fpixtracks);
1475 }
1476 void SiPixelTrackResidualSource::triplets(double x1,double y1,double z1,double x2,double y2,double z2,double x3,double y3,double z3,
1477  double ptsig, double & dca2,double & dz2, double kap) {
1478 
1479  //Define some constants
1480  using namespace std;
1481 
1482  //Curvature kap from global Track
1483 
1484  //inverse of the curvature is the radius in the transverse plane
1485  double rho = 1/kap;
1486  //Check that the hits are in the correct layers
1487  double r1 = sqrt( x1*x1 + y1*y1 );
1488  double r3 = sqrt( x3*x3 + y3*y3 );
1489 
1490  if( r3-r1 < 2.0 ) cout << "warn r1 = " << r1 << ", r3 = " << r3 << endl;
1491 
1492  // Calculate the centre of the helix in xy-projection with radius rho from the track.
1493  //start with a line (sekante) connecting the two points (x1,y1) and (x3,y3) vec_L = vec_x3-vec_x1
1494  //with L being the length of that vector.
1495  double L=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
1496  //lam is the line from the middel point of vec_q towards the center of the circle X0,Y0
1497  // we already have kap and rho = 1/kap
1498  double lam = sqrt(rho*rho - L*L/4);
1499 
1500  // There are two solutions, the sign of kap gives the information
1501  // which of them is correct.
1502  //
1503  if( kap > 0 ) lam = -lam;
1504 
1505  //
1506  // ( X0, Y0 ) is the centre of the circle that describes the helix in xy-projection.
1507  //
1508  double x0 = 0.5*( x1 + x3 ) + lam/L * ( -y1 + y3 );
1509  double y0 = 0.5*( y1 + y3 ) + lam/L * ( x1 - x3 );
1510 
1511  // Calculate the dipangle in z direction (needed later for z residual) :
1512  //Starting from the heliz equation whihc has to hold for both points z1,z3
1513  double num = ( y3 - y0 ) * ( x1 - x0 ) - ( x3 - x0 ) * ( y1 - y0 );
1514  double den = ( x1 - x0 ) * ( x3 - x0 ) + ( y1 - y0 ) * ( y3 - y0 );
1515  double tandip = kap * ( z3 - z1 ) / atan( num / den );
1516 
1517 
1518  // angle from first hit to dca point:
1519  //
1520  double dphi = atan( ( ( x1 - x0 ) * y0 - ( y1 - y0 ) * x0 )
1521  / ( ( x1 - x0 ) * x0 + ( y1 - y0 ) * y0 ) );
1522  //z position of the track based on the middle of the circle
1523  //track equation for the z component
1524  double uz0 = z1 + tandip * dphi * rho;
1525 
1527  //RESIDUAL IN R-PHI
1529  //Calculate distance dca2 from point (x2,y2) to the circle which is given by
1530  //the distance of the point to the middlepoint dcM = sqrt((x0-x2)^2+(y0-y2)) and rho
1531  //dca = rho +- dcM
1532  if(kap>0) dca2=rho-sqrt((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2));
1533  else dca2=rho+sqrt((-x0+x2)*(-x0+x2)+(-y0+y2)*(-y0+y2));
1534 
1536  //RESIDUAL IN Z
1538  double xx =0 ;
1539  double yy =0 ;
1540  //sign of kappa determines the calculation
1541  //xx and yy are the new coordinates starting from x2, y2 that are on the track itself
1542  //vec_X2+-dca2*vec(X0-X2)/|(X0-X2)|
1543  if(kap<0){
1544  xx = x2+(dca2*((x0-x2))/sqrt((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2)));
1545  yy = y2+(dca2*((y0-y2))/sqrt((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2)));
1546  }
1547  else if(kap>=0){
1548  xx = x2-(dca2*((x0-x2))/sqrt((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2)));
1549  yy = y2-(dca2*((y0-y2))/sqrt((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2)));
1550  }
1551 
1552  //to get residual in z start with calculating the new uz2 position if one has moved to xx, yy
1553  //on the track. First calculate the change in phi2 with respect to the center X0, Y0
1554  double dphi2 = atan( ( ( xx - x0 ) * y0 - ( yy - y0 ) * x0 )
1555  / ( ( xx - x0 ) * x0 + ( yy - y0 ) * y0 ) );
1556  //Solve track equation for this new z depending on the dip angle of the track (see above
1557  //calculated based on X1, X3 and X0, use uz0 as reference point again.
1558  double uz2= uz0 - dphi2*tandip*rho;
1559 
1560  //subtract new z position from the old one
1561  dz2=z2-uz2;
1562 
1563  //if we are interested in the arclength this is unsigned though
1564  // double cosphi2 = (x2*xx+y2*yy)/(sqrt(x2*x2+y2*y2)*sqrt(xx*xx+yy*yy));
1565  //double arcdca2=sqrt(x2*x2+y2*y2)*acos(cosphi2);
1566 
1567 }
1568 
1569 
1570 DEFINE_FWK_MODULE(SiPixelTrackResidualSource); // define this as a plug-in
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:114
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > generalTracksToken_
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
edm::EDGetTokenT< std::vector< Trajectory > > tracksrcToken_
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
const LocalTrajectoryParameters & localParameters() const
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual void dqmBeginRun(const edm::Run &r, edm::EventSetup const &iSetup)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: DDAxes.h:10
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
data_type const * const_iterator
Definition: DetSetNew.h:30
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
SiPixelTrackResidualSource(const edm::ParameterSet &)
double charge(const std::vector< uint8_t > &Ampls)
float float float z
tuple gX
Definition: corrVsCorr.py:109
TrajectoryStateOnSurface innermostMeasurementState() const
void Fill(long long x)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
int iEvent
Definition: GenABIO.cc:230
T mag() const
Definition: PV3DBase.h:67
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
T sqrt(T t)
Definition: SSEVec.h:48
bool setModuleFolder(const uint32_t &rawdetid=0, int type=0, bool isUpgrade=false)
Set folder name for a module or plaquette.
T z() const
Definition: PV3DBase.h:64
void triplets(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, double ptsig, double &dc, double &dz, double kap)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:113
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
LocalVector momentum() const
Momentum vector in the local frame.
edm::EDGetTokenT< std::vector< reco::Track > > trackToken_
bool isValid() const
Definition: HandleBase.h:76
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > clustersrcToken_
virtual const GeomDet * idToDet(DetId) const
std::shared_ptr< TrackingRecHit const > RecHitPointer
double ndof() const
Definition: Vertex.h:102
int diskName() const
disk id
unsigned int pxbLayer(const DetId &id) const
FreeTrajectoryState initialFreeState() const
bool failedToGet() const
Definition: HandleBase.h:80
Definition: DetId.h:18
virtual TrackingRecHit const * hit() const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
std::map< uint32_t, SiPixelTrackResidualModule * > theSiPixelStructure
size_type size() const
map size
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:131
tuple tracks
Definition: testEve_cfg.py:39
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const T & get() const
Definition: EventSetup.h:55
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
key_type key() const
Accessor for product key.
Definition: Ref.h:266
int layerName() const
layer id
T const * product() const
Definition: ESHandle.h:62
edm::EDGetTokenT< reco::VertexCollection > offlinePrimaryVerticesToken_
T const * product() const
Definition: Handle.h:81
tuple gY
Definition: corrVsCorr.py:110
double transverseCurvature() const
std::string const & label() const
Definition: InputTag.h:42
const_iterator find(id_type i, bool update=false) const
size_type size() const
Pixel cluster – collection of neighboring pixels above threshold.
tuple cout
Definition: gather_cfg.py:121
int diskName() const
disk id
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
const_iterator begin() const
first iterator over the map (read only)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
volatile std::atomic< bool > shutdown_flag false
Definition: DDAxes.h:10
bool isValid() const
Definition: ESHandle.h:37
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
T x() const
Definition: PV3DBase.h:62
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: vlib.h:208
edm::EDGetTokenT< TrajTrackAssociationCollection > trackAssociationToken_
int layerName() const
layer id
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
const_iterator begin(bool update=false) const
Definition: Run.h:41
Pixel Reconstructed Hit.
Definition: DDAxes.h:10