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>(pSet_.getParameter<edm::InputTag>("tracksrc"));
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(false);
142  for (std::map<uint32_t, SiPixelTrackResidualModule*>::iterator pxd = theSiPixelStructure.begin();
143  pxd!=theSiPixelStructure.end(); pxd++) {
144 
145  if(modOn){
146  if (theSiPixelFolder.setModuleFolder(iBooker,(*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(iBooker,(*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(iBooker,(*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(iBooker,(*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(iBooker,(*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(iBooker,(*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(iBooker,(*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.0;
692  double maxSumPt = 0.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.0 ) vtxP = vtxN;
709 
710  //---------------------------------------------
711  //get Tracks
712  //
714  //iEvent.getByLabel( "generalTracks", TracksForRes );
715  iEvent.getByToken( generalTracksToken_, TracksForRes );
716 
717  //
718  // transient track builder, needs B-field from data base (global tag in .py)
719  //
721  iSetup.get<TransientTrackRecord>().get( "TransientTrackBuilder", theB );
722 
723  //get the TransienTrackingRecHitBuilder needed for extracting the global position of the hits in the pixel
724  edm::ESHandle<TransientTrackingRecHitBuilder> theTrackerRecHitBuilder;
725  iSetup.get<TransientRecHitRecord>().get(ttrhbuilder_,theTrackerRecHitBuilder);
726 
727  //check that tracks are valid
728  if( TracksForRes.failedToGet() ) return;
729  if( !TracksForRes.isValid() ) return;
730 
731  //get tracker geometry
733  iSetup.get<TrackerDigiGeometryRecord>().get(pDD);
734 
735  if( !pDD.isValid() ) {
736  cout << "Unable to find TrackerDigiGeometry. Return\n";
737  return;
738  }
739 
740  int kk = -1;
741  //----------------------------------------------------------------------------
742  // Residuals:
743  //
744  for( reco::TrackCollection::const_iterator iTrack = TracksForRes->begin();
745  iTrack != TracksForRes->end(); ++iTrack ) {
746  //count
747  kk++;
748  //Calculate minimal track pt before curling
749  // cpt = cqRB = 0.3*R[m]*B[T] = 1.14*R[m] for B=3.8T
750  // D = 2R = 2*pt/1.14
751  // calo: D = 1.3 m => pt = 0.74 GeV/c
752  double pt = iTrack->pt();
753  if( pt < 0.75 ) continue;// curls up
754  if( abs( iTrack->dxy(vtxP) ) > 5*iTrack->dxyError() ) continue; // not prompt
755 
756  double charge = iTrack->charge();
757 
758  reco::TransientTrack tTrack = theB->build(*iTrack);
759  //get curvature of the track, needed for the residuals
760  double kap = tTrack.initialFreeState().transverseCurvature();
761  //needed for the TransienTrackingRecHitBuilder
763  if( iTrack->extra().isNonnull() &&iTrack->extra().isAvailable() ){
764 
765  double x1 = 0;
766  double y1 = 0;
767  double z1 = 0;
768  double x2 = 0;
769  double y2 = 0;
770  double z2 = 0;
771  double x3 = 0;
772  double y3 = 0;
773  double z3 = 0;
774  int n1 = 0;
775  int n2 = 0;
776  int n3 = 0;
777 
778  //for saving the pixel barrel hits
779  vector<TransientTrackingRecHit::RecHitPointer> GoodPixBarrelHits;
780  //looping through the RecHits of the track
781  for( trackingRecHit_iterator irecHit = iTrack->recHitsBegin();
782  irecHit != iTrack->recHitsEnd(); ++irecHit){
783 
784  if( (*irecHit)->isValid() ){
785  DetId detId = (*irecHit)->geographicalId();
786  // enum Detector { Tracker=1, Muon=2, Ecal=3, Hcal=4, Calo=5 };
787  if( detId.det() != 1 ){
788  if(debug_){
789  cout << "rec hit ID = " << detId.det() << " not in tracker!?!?\n";
790  }
791  continue;
792  }
793  uint32_t subDet = detId.subdetId();
794 
795  // enum SubDetector{ PixelBarrel=1, PixelEndcap=2 };
796  // enum SubDetector{ TIB=3, TID=4, TOB=5, TEC=6 };
797 
798  TransientTrackingRecHit::RecHitPointer trecHit = theTrackerRecHitBuilder->build( &*(*irecHit), initialTSOS);
799 
800 
801  double gX = trecHit->globalPosition().x();
802  double gY = trecHit->globalPosition().y();
803  double gZ = trecHit->globalPosition().z();
804 
805 
806  if( subDet == PixelSubdetector::PixelBarrel ) {
807 
808  int ilay = tTopo->pxbLayer(detId);
809 
810  if( ilay == 1 ){
811  n1++;
812  x1 = gX;
813  y1 = gY;
814  z1 = gZ;
815 
816  GoodPixBarrelHits.push_back((trecHit));
817  }//PXB1
818  if( ilay == 2 ){
819 
820  n2++;
821  x2 = gX;
822  y2 = gY;
823  z2 = gZ;
824 
825  GoodPixBarrelHits.push_back((trecHit));
826 
827  }//PXB2
828  if( ilay == 3 ){
829 
830  n3++;
831  x3 = gX;
832  y3 = gY;
833  z3 = gZ;
834  GoodPixBarrelHits.push_back((trecHit));
835  }
836  }//PXB
837 
838 
839  }//valid
840  }//loop rechits
841 
842  //CS extra plots
843 
844 
845  if( n1+n2+n3 == 3 && n1*n2*n3 > 0) {
846  for( unsigned int i = 0; i < GoodPixBarrelHits.size(); i++){
847 
848  if( GoodPixBarrelHits[i]->isValid() ){
849  DetId detId = GoodPixBarrelHits[i]->geographicalId().rawId();
850  int ilay = tTopo->pxbLayer(detId);
851  if(pt > ptminres_){
852 
853  double dca2 = 0.0, dz2=0.0;
854  double ptsig = pt;
855  if(charge<0.) ptsig = -pt;
856  //Filling the histograms in modules
857 
858  MeasurementPoint Test;
859  MeasurementPoint Test2;
860  Test=MeasurementPoint(0,0);
861  Test2=MeasurementPoint(0,0);
862  Measurement2DVector residual;
863 
864  if( ilay == 1 ){
865 
866  triplets(x2,y2,z2,x1,y1,z1,x3,y3,z3,ptsig,dca2,dz2, kap);
867 
868  Test=MeasurementPoint(dca2*1E4,dz2*1E4);
869  residual=Test-Test2;
870  }
871 
872  if( ilay == 2 ){
873 
874  triplets(x1,y1,z1,x2,y2,z2,x3,y3,z3,ptsig,dca2,dz2, kap);
875 
876  Test=MeasurementPoint(dca2*1E4,dz2*1E4);
877  residual=Test-Test2;
878 
879  }
880 
881  if( ilay == 3 ){
882 
883  triplets(x1,y1,z1,x3,y3,z3,x2,y2,z2,ptsig,dca2,dz2, kap);
884 
885  Test=MeasurementPoint(dca2*1E4,dz2*1E4);
886  residual=Test-Test2;
887  }
888  // fill the residual histograms
889 
890  std::map<uint32_t, SiPixelTrackResidualModule*>::iterator pxd = theSiPixelStructure.find(detId);
891  if (pxd!=theSiPixelStructure.end()) (*pxd).second->fill(residual, reducedSet, modOn, ladOn, layOn, phiOn, bladeOn, diskOn, ringOn);
892  }//three hits
893  }//is valid
894  }//rechits loop
895  }//pt 4
896  }
897 
898 
899  }//-----Tracks
901  //get trajectories
902  edm::Handle<std::vector<Trajectory> > trajCollectionHandle;
903  //iEvent.getByLabel(tracksrc_,trajCollectionHandle);
904  iEvent.getByToken ( tracksrcToken_, trajCollectionHandle );
905  const std::vector<Trajectory> trajColl = *(trajCollectionHandle.product());
906 
907  //get tracks
908  edm::Handle<std::vector<reco::Track> > trackCollectionHandle;
909  //iEvent.getByLabel(tracksrc_,trackCollectionHandle);
910  iEvent.getByToken( trackToken_, trackCollectionHandle );
911 
912  const std::vector<reco::Track> trackColl = *(trackCollectionHandle.product());
913 
914  //get the map
916  //iEvent.getByLabel(tracksrc_,match);
917  iEvent.getByToken( trackAssociationToken_, match);
918  const TrajTrackAssociationCollection ttac = *(match.product());
919 
920  // get clusters
922  //iEvent.getByLabel( clustersrc_, clusterColl );
923  iEvent.getByToken( clustersrcToken_, clusterColl );
924  const edmNew::DetSetVector<SiPixelCluster> clustColl = *(clusterColl.product());
925 
926  if(debug_){
927  std::cout << "Trajectories\t : " << trajColl.size() << std::endl;
928  std::cout << "recoTracks \t : " << trackColl.size() << std::endl;
929  std::cout << "Map entries \t : " << ttac.size() << std::endl;
930  }
931 
932  std::set<SiPixelCluster> clusterSet;
933  TrajectoryStateCombiner tsoscomb;
934  int tracks=0, pixeltracks=0, bpixtracks=0, fpixtracks=0;
935  int trackclusters=0, barreltrackclusters=0, endcaptrackclusters=0;
936  int otherclusters=0, barrelotherclusters=0, endcapotherclusters=0;
937 
938  //Loop over map entries
939  for(TrajTrackAssociationCollection::const_iterator it = ttac.begin();it != ttac.end(); ++it){
940  const edm::Ref<std::vector<Trajectory> > traj_iterator = it->key;
941  // Trajectory Map, extract Trajectory for this track
942  reco::TrackRef trackref = it->val;
943  tracks++;
944 
945  bool isBpixtrack = false, isFpixtrack = false, crossesPixVol=false;
946 
947  //find out whether track crosses pixel fiducial volume (for cosmic tracks)
948 
949  double d0 = (*trackref).d0(), dz = (*trackref).dz();
950 
951  if(abs(d0)<15 && abs(dz)<50) crossesPixVol = true;
952 
953  std::vector<TrajectoryMeasurement> tmeasColl =traj_iterator->measurements();
954  std::vector<TrajectoryMeasurement>::const_iterator tmeasIt;
955  //loop on measurements to find out whether there are bpix and/or fpix hits
956  for(tmeasIt = tmeasColl.begin();tmeasIt!=tmeasColl.end();tmeasIt++){
957  if(! tmeasIt->updatedState().isValid()) continue;
958  TransientTrackingRecHit::ConstRecHitPointer testhit = tmeasIt->recHit();
959  if(! testhit->isValid() || testhit->geographicalId().det() != DetId::Tracker) continue;
960  uint testSubDetID = (testhit->geographicalId().subdetId());
961  if(testSubDetID==PixelSubdetector::PixelBarrel) isBpixtrack = true;
962  if(testSubDetID==PixelSubdetector::PixelEndcap) isFpixtrack = true;
963  }//end loop on measurements
964  if(isBpixtrack) {
965  bpixtracks++;
966  if(debug_) std::cout << "bpixtrack\n";
967  }
968  if(isFpixtrack) {
969  fpixtracks++;
970  if(debug_) std::cout << "fpixtrack\n";
971  }
972  if(isBpixtrack || isFpixtrack){
973  pixeltracks++;
974 
975  if(crossesPixVol) meNofTracksInPixVol_->Fill(0,1);
976 
977  std::vector<TrajectoryMeasurement> tmeasColl = traj_iterator->measurements();
978  for(std::vector<TrajectoryMeasurement>::const_iterator tmeasIt = tmeasColl.begin(); tmeasIt!=tmeasColl.end(); tmeasIt++){
979  if(! tmeasIt->updatedState().isValid()) continue;
980 
981  TrajectoryStateOnSurface tsos = tsoscomb( tmeasIt->forwardPredictedState(), tmeasIt->backwardPredictedState() );
983  if(! hit->isValid() || hit->geographicalId().det() != DetId::Tracker ) {
984  continue;
985  } else {
986 
987 // //residual
988  const DetId & hit_detId = hit->geographicalId();
989  //uint IntRawDetID = (hit_detId.rawId());
990  uint IntSubDetID = (hit_detId.subdetId());
991 
992  if(IntSubDetID == 0 ) continue; // don't look at SiStrip hits!
993 
994  // get the enclosed persistent hit
995  const TrackingRecHit *persistentHit = hit->hit();
996  // check if it's not null, and if it's a valid pixel hit
997  if ((persistentHit != 0) && (typeid(*persistentHit) == typeid(SiPixelRecHit))) {
998  // tell the C++ compiler that the hit is a pixel hit
999  const SiPixelRecHit* pixhit = static_cast<const SiPixelRecHit*>( hit->hit() );
1000  //Hit probability:
1001  float hit_prob = -1.;
1002  if(pixhit->hasFilledProb()){
1003  hit_prob = pixhit->clusterProbability(0);
1004  //std::cout<<"HITPROB= "<<hit_prob<<std::endl;
1005  if(hit_prob<pow(10.,-15.)) NLowProb++;
1006  NTotal++;
1007  if(NTotal>0) meHitProbability->Fill(float(NLowProb/NTotal));
1008  }
1009 
1010  // get the edm::Ref to the cluster
1011  edm::Ref<edmNew::DetSetVector<SiPixelCluster>, SiPixelCluster> const& clust = (*pixhit).cluster();
1012  // check if the ref is not null
1013  if (clust.isNonnull()) {
1014 
1015  //define tracker and pixel geometry and topology
1016  const TrackerGeometry& theTracker(*theTrackerGeometry);
1017  const PixelGeomDetUnit* theGeomDet = static_cast<const PixelGeomDetUnit*> (theTracker.idToDet(hit_detId) );
1018  //test if PixelGeomDetUnit exists
1019  if(theGeomDet == 0) {
1020  if(debug_) std::cout << "NO THEGEOMDET\n";
1021  continue;
1022  }
1023 
1024  const PixelTopology * topol = &(theGeomDet->specificTopology());
1025  //fill histograms for clusters on tracks
1026  //correct SiPixelTrackResidualModule
1027  std::map<uint32_t, SiPixelTrackResidualModule*>::iterator pxd = theSiPixelStructure.find((*hit).geographicalId().rawId());
1028 
1029  //CHARGE CORRECTION (for track impact angle)
1030  // calculate alpha and beta from cluster position
1032  LocalVector localDir = ltp.momentum()/ltp.momentum().mag();
1033 
1034  float clust_alpha = atan2(localDir.z(), localDir.x());
1035  float clust_beta = atan2(localDir.z(), localDir.y());
1036  double corrCharge = clust->charge() * sqrt( 1.0 / ( 1.0/pow( tan(clust_alpha), 2 ) +
1037  1.0/pow( tan(clust_beta ), 2 ) +
1038  1.0 )
1039  )/1000.;
1040 
1041  if (pxd!=theSiPixelStructure.end()) (*pxd).second->fill((*clust), true, corrCharge, reducedSet, modOn, ladOn, layOn, phiOn, bladeOn, diskOn, ringOn);
1042 
1043 
1044  trackclusters++;
1045  //CORR CHARGE
1046  meClChargeOnTrack_all->Fill(corrCharge);
1047  meClSizeOnTrack_all->Fill((*clust).size());
1048  meClSizeXOnTrack_all->Fill((*clust).sizeX());
1049  meClSizeYOnTrack_all->Fill((*clust).sizeY());
1050  clusterSet.insert(*clust);
1051 
1052  //find cluster global position (rphi, z)
1053  // get cluster center of gravity (of charge)
1054  float xcenter = clust->x();
1055  float ycenter = clust->y();
1056  // get the cluster position in local coordinates (cm)
1057  LocalPoint clustlp = topol->localPosition( MeasurementPoint(xcenter, ycenter) );
1058  // get the cluster position in global coordinates (cm)
1059  GlobalPoint clustgp = theGeomDet->surface().toGlobal( clustlp );
1060 
1061  //find location of hit (barrel or endcap, same for cluster)
1062  bool barrel = DetId((*hit).geographicalId()).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
1063  bool endcap = DetId((*hit).geographicalId()).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
1064  if(barrel) {
1065  barreltrackclusters++;
1066  //CORR CHARGE
1067  meClChargeOnTrack_bpix->Fill(corrCharge);
1068  meClSizeOnTrack_bpix->Fill((*clust).size());
1069  meClSizeXOnTrack_bpix->Fill((*clust).sizeX());
1070  meClSizeYOnTrack_bpix->Fill((*clust).sizeY());
1071  uint32_t DBlayer;
1072  if (!isUpgrade) { DBlayer = PixelBarrelName(DetId((*hit).geographicalId())).layerName(); }
1073  else { DBlayer = PixelBarrelNameUpgrade(DetId((*hit).geographicalId())).layerName(); }
1074  float phi = clustgp.phi();
1075  float z = clustgp.z();
1076  switch(DBlayer){
1077  case 1: {
1078  meClPosLayer1OnTrack->Fill(z,phi);
1079  meClChargeOnTrack_layer1->Fill(corrCharge);
1080  meClSizeOnTrack_layer1->Fill((*clust).size());
1081  meClSizeXOnTrack_layer1->Fill((*clust).sizeX());
1082  meClSizeYOnTrack_layer1->Fill((*clust).sizeY());
1083  break;
1084  }
1085  case 2: {
1086  meClPosLayer2OnTrack->Fill(z,phi);
1087  meClChargeOnTrack_layer2->Fill(corrCharge);
1088  meClSizeOnTrack_layer2->Fill((*clust).size());
1089  meClSizeXOnTrack_layer2->Fill((*clust).sizeX());
1090  meClSizeYOnTrack_layer2->Fill((*clust).sizeY());
1091  break;
1092  }
1093  case 3: {
1094  meClPosLayer3OnTrack->Fill(z,phi);
1095  meClChargeOnTrack_layer3->Fill(corrCharge);
1096  meClSizeOnTrack_layer3->Fill((*clust).size());
1097  meClSizeXOnTrack_layer3->Fill((*clust).sizeX());
1098  meClSizeYOnTrack_layer3->Fill((*clust).sizeY());
1099  break;
1100  }
1101  case 4: {
1102  if (isUpgrade) {
1103  meClPosLayer4OnTrack->Fill(z,phi);
1104  meClChargeOnTrack_layer4->Fill(corrCharge);
1105  meClSizeOnTrack_layer4->Fill((*clust).size());
1106  meClSizeXOnTrack_layer4->Fill((*clust).sizeX());
1107  meClSizeYOnTrack_layer4->Fill((*clust).sizeY());
1108  }
1109  break;
1110  }
1111 
1112  }
1113 
1114  }
1115  if(endcap) {
1116  endcaptrackclusters++;
1117  //CORR CHARGE
1118  meClChargeOnTrack_fpix->Fill(corrCharge);
1119  meClSizeOnTrack_fpix->Fill((*clust).size());
1120  meClSizeXOnTrack_fpix->Fill((*clust).sizeX());
1121  meClSizeYOnTrack_fpix->Fill((*clust).sizeY());
1122  uint32_t DBdisk = 0;
1123  if (!isUpgrade) { DBdisk = PixelEndcapName(DetId((*hit).geographicalId())).diskName(); }
1124  else { DBdisk = PixelEndcapNameUpgrade(DetId((*hit).geographicalId())).diskName(); }
1125  float x = clustgp.x();
1126  float y = clustgp.y();
1127  float z = clustgp.z();
1128  if(z>0){
1129  if(DBdisk==1) {
1131  meClChargeOnTrack_diskp1->Fill(corrCharge);
1132  meClSizeOnTrack_diskp1->Fill((*clust).size());
1133  meClSizeXOnTrack_diskp1->Fill((*clust).sizeX());
1134  meClSizeYOnTrack_diskp1->Fill((*clust).sizeY());
1135  }
1136  if(DBdisk==2) {
1137  meClPosDisk2pzOnTrack->Fill(x,y);
1138  meClChargeOnTrack_diskp2->Fill(corrCharge);
1139  meClSizeOnTrack_diskp2->Fill((*clust).size());
1140  meClSizeXOnTrack_diskp2->Fill((*clust).sizeX());
1141  meClSizeYOnTrack_diskp2->Fill((*clust).sizeY());
1142  }
1143  if(DBdisk==3 && isUpgrade) {
1145  meClChargeOnTrack_diskp3->Fill(corrCharge);
1146  meClSizeOnTrack_diskp3->Fill((*clust).size());
1147  meClSizeXOnTrack_diskp3->Fill((*clust).sizeX());
1148  meClSizeYOnTrack_diskp3->Fill((*clust).sizeY());
1149  }
1150  }
1151  else{
1152  if(DBdisk==1) {
1154  meClChargeOnTrack_diskm1->Fill(corrCharge);
1155  meClSizeOnTrack_diskm1->Fill((*clust).size());
1156  meClSizeXOnTrack_diskm1->Fill((*clust).sizeX());
1157  meClSizeYOnTrack_diskm1->Fill((*clust).sizeY());
1158  }
1159  if(DBdisk==2) {
1160  meClPosDisk2mzOnTrack->Fill(x,y);
1161  meClChargeOnTrack_diskm2->Fill(corrCharge);
1162  meClSizeOnTrack_diskm2->Fill((*clust).size());
1163  meClSizeXOnTrack_diskm2->Fill((*clust).sizeX());
1164  meClSizeYOnTrack_diskm2->Fill((*clust).sizeY());
1165  }
1166  if(DBdisk==3 && isUpgrade) {
1168  meClChargeOnTrack_diskm3->Fill(corrCharge);
1169  meClSizeOnTrack_diskm3->Fill((*clust).size());
1170  meClSizeXOnTrack_diskm3->Fill((*clust).sizeX());
1171  meClSizeYOnTrack_diskm3->Fill((*clust).sizeY());
1172  }
1173  }
1174  }
1175 
1176  }//end if (cluster exists)
1177 
1178  }//end if (persistent hit exists and is pixel hit)
1179 
1180  }//end of else
1181 
1182 
1183  }//end for (all traj measurements of pixeltrack)
1184  }//end if (is pixeltrack)
1185  else {
1186  if(debug_) std::cout << "no pixeltrack:\n";
1187  if(crossesPixVol) meNofTracksInPixVol_->Fill(1,1);
1188  }
1189 
1190  }//end loop on map entries
1191 
1192  //find clusters that are NOT on track
1193  //edmNew::DetSet<SiPixelCluster>::const_iterator di;
1194  if(debug_) std::cout << "clusters not on track: (size " << clustColl.size() << ") ";
1195 
1196  for(TrackerGeometry::DetContainer::const_iterator it = TG->dets().begin(); it != TG->dets().end(); it++){
1197  //if(dynamic_cast<PixelGeomDetUnit const *>((*it))!=0){
1198  DetId detId = (*it)->geographicalId();
1199  if(detId>=302055684 && detId<=352477708){ // make sure it's a Pixel module WITHOUT using dynamic_cast!
1200  int nofclOnTrack = 0, nofclOffTrack=0;
1201  uint32_t DBlayer=10, DBdisk=10;
1202  float z=0.;
1203  //set layer/disk
1204  if(DetId(detId).subdetId() == 1) { // Barrel module
1205  if (!isUpgrade) {
1206  DBlayer = PixelBarrelName(DetId(detId)).layerName();
1207  } else if (isUpgrade) {
1208  DBlayer = PixelBarrelNameUpgrade(DetId(detId)).layerName();
1209  }
1210  }
1211  if(DetId(detId).subdetId() == 2){ // Endcap module
1212  if (!isUpgrade) { DBdisk = PixelEndcapName(DetId(detId )).diskName(); }
1213  else if (isUpgrade) { DBdisk = PixelEndcapNameUpgrade(DetId(detId )).diskName(); }
1214  }
1216  if( isearch != clustColl.end() ) { // Not an empty iterator
1218  for(di=isearch->begin(); di!=isearch->end(); di++){
1219  unsigned int temp = clusterSet.size();
1220  clusterSet.insert(*di);
1221  //check if cluster is off track
1222  if(clusterSet.size()>temp) {
1223  otherclusters++;
1224  nofclOffTrack++;
1225  //fill histograms for clusters off tracks
1226  //correct SiPixelTrackResidualModule
1227  std::map<uint32_t, SiPixelTrackResidualModule*>::iterator pxd = theSiPixelStructure.find((*it)->geographicalId().rawId());
1228 
1229  if (pxd!=theSiPixelStructure.end()) (*pxd).second->fill((*di), false, -1., reducedSet, modOn, ladOn, layOn, phiOn, bladeOn, diskOn, ringOn);
1230 
1231 
1232 
1233  meClSizeNotOnTrack_all->Fill((*di).size());
1234  meClSizeXNotOnTrack_all->Fill((*di).sizeX());
1235  meClSizeYNotOnTrack_all->Fill((*di).sizeY());
1236  meClChargeNotOnTrack_all->Fill((*di).charge()/1000);
1237 
1239  //find cluster global position (rphi, z) get cluster
1240  //define tracker and pixel geometry and topology
1241  const TrackerGeometry& theTracker(*theTrackerGeometry);
1242  const PixelGeomDetUnit* theGeomDet = static_cast<const PixelGeomDetUnit*> (theTracker.idToDet(detId) );
1243  //test if PixelGeomDetUnit exists
1244  if(theGeomDet == 0) {
1245  if(debug_) std::cout << "NO THEGEOMDET\n";
1246  continue;
1247  }
1248  const PixelTopology * topol = &(theGeomDet->specificTopology());
1249 
1250  //center of gravity (of charge)
1251  float xcenter = di->x();
1252  float ycenter = di->y();
1253  // get the cluster position in local coordinates (cm)
1254  LocalPoint clustlp = topol->localPosition( MeasurementPoint(xcenter, ycenter) );
1255  // get the cluster position in global coordinates (cm)
1256  GlobalPoint clustgp = theGeomDet->surface().toGlobal( clustlp );
1257 
1259 
1260  //barrel
1261  if(DetId(detId).subdetId() == 1) {
1262  meClSizeNotOnTrack_bpix->Fill((*di).size());
1263  meClSizeXNotOnTrack_bpix->Fill((*di).sizeX());
1264  meClSizeYNotOnTrack_bpix->Fill((*di).sizeY());
1265  meClChargeNotOnTrack_bpix->Fill((*di).charge()/1000);
1266  barrelotherclusters++;
1267  //DBlayer = PixelBarrelName(DetId(detId)).layerName();
1268  float phi = clustgp.phi();
1269  //float r = clustgp.perp();
1270  z = clustgp.z();
1271  switch(DBlayer){
1272  case 1: {
1273  meClPosLayer1NotOnTrack->Fill(z,phi);
1274  meClSizeNotOnTrack_layer1->Fill((*di).size());
1275  meClSizeXNotOnTrack_layer1->Fill((*di).sizeX());
1276  meClSizeYNotOnTrack_layer1->Fill((*di).sizeY());
1277  meClChargeNotOnTrack_layer1->Fill((*di).charge()/1000);
1278  break;
1279  }
1280  case 2: {
1281  meClPosLayer2NotOnTrack->Fill(z,phi);
1282  meClSizeNotOnTrack_layer2->Fill((*di).size());
1283  meClSizeXNotOnTrack_layer2->Fill((*di).sizeX());
1284  meClSizeYNotOnTrack_layer2->Fill((*di).sizeY());
1285  meClChargeNotOnTrack_layer2->Fill((*di).charge()/1000);
1286  break;
1287  }
1288  case 3: {
1289  meClPosLayer3NotOnTrack->Fill(z,phi);
1290  meClSizeNotOnTrack_layer3->Fill((*di).size());
1291  meClSizeXNotOnTrack_layer3->Fill((*di).sizeX());
1292  meClSizeYNotOnTrack_layer3->Fill((*di).sizeY());
1293  meClChargeNotOnTrack_layer3->Fill((*di).charge()/1000);
1294  break;
1295  }
1296  case 4: {
1297  if (isUpgrade) {
1298  meClPosLayer4NotOnTrack->Fill(z,phi);
1299  meClSizeNotOnTrack_layer4->Fill((*di).size());
1300  meClSizeXNotOnTrack_layer4->Fill((*di).sizeX());
1301  meClSizeYNotOnTrack_layer4->Fill((*di).sizeY());
1302  meClChargeNotOnTrack_layer4->Fill((*di).charge()/1000);
1303  }
1304  break;
1305  }
1306 
1307  }
1308  }
1309  //endcap
1310  if(DetId(detId).subdetId() == 2) {
1311  meClSizeNotOnTrack_fpix->Fill((*di).size());
1312  meClSizeXNotOnTrack_fpix->Fill((*di).sizeX());
1313  meClSizeYNotOnTrack_fpix->Fill((*di).sizeY());
1314  meClChargeNotOnTrack_fpix->Fill((*di).charge()/1000);
1315  endcapotherclusters++;
1316  //DBdisk = PixelEndcapName(DetId(detId )).diskName();
1317  float x = clustgp.x();
1318  float y = clustgp.y();
1319  z = clustgp.z();
1320  if(z>0){
1321  if(DBdisk==1) {
1323  meClSizeNotOnTrack_diskp1->Fill((*di).size());
1324  meClSizeXNotOnTrack_diskp1->Fill((*di).sizeX());
1325  meClSizeYNotOnTrack_diskp1->Fill((*di).sizeY());
1326  meClChargeNotOnTrack_diskp1->Fill((*di).charge()/1000);
1327  }
1328  if(DBdisk==2) {
1330  meClSizeNotOnTrack_diskp2->Fill((*di).size());
1331  meClSizeXNotOnTrack_diskp2->Fill((*di).sizeX());
1332  meClSizeYNotOnTrack_diskp2->Fill((*di).sizeY());
1333  meClChargeNotOnTrack_diskp2->Fill((*di).charge()/1000);
1334  }
1335  if(DBdisk==3 && isUpgrade) {
1337  meClSizeNotOnTrack_diskp3->Fill((*di).size());
1338  meClSizeXNotOnTrack_diskp3->Fill((*di).sizeX());
1339  meClSizeYNotOnTrack_diskp3->Fill((*di).sizeY());
1340  meClChargeNotOnTrack_diskp3->Fill((*di).charge()/1000);
1341  }
1342  }
1343  else{
1344  if(DBdisk==1) {
1346  meClSizeNotOnTrack_diskm1->Fill((*di).size());
1347  meClSizeXNotOnTrack_diskm1->Fill((*di).sizeX());
1348  meClSizeYNotOnTrack_diskm1->Fill((*di).sizeY());
1349  meClChargeNotOnTrack_diskm1->Fill((*di).charge()/1000);
1350  }
1351  if(DBdisk==2) {
1353  meClSizeNotOnTrack_diskm2->Fill((*di).size());
1354  meClSizeXNotOnTrack_diskm2->Fill((*di).sizeX());
1355  meClSizeYNotOnTrack_diskm2->Fill((*di).sizeY());
1356  meClChargeNotOnTrack_diskm2->Fill((*di).charge()/1000);
1357  }
1358  if(DBdisk==3 && isUpgrade) {
1360  meClSizeNotOnTrack_diskm3->Fill((*di).size());
1361  meClSizeXNotOnTrack_diskm3->Fill((*di).sizeX());
1362  meClSizeYNotOnTrack_diskm3->Fill((*di).sizeY());
1363  meClChargeNotOnTrack_diskm3->Fill((*di).charge()/1000);
1364  }
1365  }
1366 
1367  }
1368  }// end "if cluster off track"
1369  else {
1370  nofclOnTrack++;
1371  if(z == 0 && DBdisk != 10){
1372  //find cluster global position (rphi, z) get cluster
1373  //define tracker and pixel geometry and topology
1374  const TrackerGeometry& theTracker(*theTrackerGeometry);
1375  const PixelGeomDetUnit* theGeomDet = static_cast<const PixelGeomDetUnit*> (theTracker.idToDet(detId) );
1376  //test if PixelGeomDetUnit exists
1377  if(theGeomDet == 0) {
1378  if(debug_) std::cout << "NO THEGEOMDET\n";
1379  continue;
1380  }
1381  const PixelTopology * topol = &(theGeomDet->specificTopology());
1382  //center of gravity (of charge)
1383  float xcenter = di->x();
1384  float ycenter = di->y();
1385  // get the cluster position in local coordinates (cm)
1386  LocalPoint clustlp = topol->localPosition( MeasurementPoint(xcenter, ycenter) );
1387  // get the cluster position in global coordinates (cm)
1388  GlobalPoint clustgp = theGeomDet->surface().toGlobal( clustlp );
1389  z = clustgp.z();
1390  }
1391  }
1392  }
1393  }
1394  //++ fill the number of clusters on a module
1395  std::map<uint32_t, SiPixelTrackResidualModule*>::iterator pxd = theSiPixelStructure.find((*it)->geographicalId().rawId());
1396  if (pxd!=theSiPixelStructure.end()) (*pxd).second->nfill(nofclOnTrack, nofclOffTrack, reducedSet, modOn, ladOn, layOn, phiOn, bladeOn, diskOn, ringOn);
1397  if(nofclOnTrack!=0) meNClustersOnTrack_all->Fill(nofclOnTrack);
1398  if(nofclOffTrack!=0) meNClustersNotOnTrack_all->Fill(nofclOffTrack);
1399  //barrel
1400  if(DetId(detId).subdetId() == 1){
1401  if(nofclOnTrack!=0) meNClustersOnTrack_bpix->Fill(nofclOnTrack);
1402  if(nofclOffTrack!=0) meNClustersNotOnTrack_bpix->Fill(nofclOffTrack);
1403  //DBlayer = PixelBarrelName(DetId(detId)).layerName();
1404  switch(DBlayer){
1405  case 1: {
1406  if(nofclOnTrack!=0) meNClustersOnTrack_layer1->Fill(nofclOnTrack);
1407  if(nofclOffTrack!=0) meNClustersNotOnTrack_layer1->Fill(nofclOffTrack); break;
1408  }
1409  case 2: {
1410  if(nofclOnTrack!=0) meNClustersOnTrack_layer2->Fill(nofclOnTrack);
1411  if(nofclOffTrack!=0) meNClustersNotOnTrack_layer2->Fill(nofclOffTrack); break;
1412  }
1413  case 3: {
1414  if(nofclOnTrack!=0) meNClustersOnTrack_layer3->Fill(nofclOnTrack);
1415  if(nofclOffTrack!=0) meNClustersNotOnTrack_layer3->Fill(nofclOffTrack); break;
1416  }
1417  case 4: {
1418  if(nofclOnTrack!=0 && isUpgrade) meNClustersOnTrack_layer4->Fill(nofclOnTrack);
1419  if(nofclOffTrack!=0 && isUpgrade) meNClustersNotOnTrack_layer4->Fill(nofclOffTrack); break;
1420  }
1421  }
1422  }//end barrel
1423  //endcap
1424  if(DetId(detId).subdetId() == 2) {
1425  //DBdisk = PixelEndcapName(DetId(detId )).diskName();
1426  //z = clustgp.z();
1427  if(nofclOnTrack!=0) meNClustersOnTrack_fpix->Fill(nofclOnTrack);
1428  if(nofclOffTrack!=0) meNClustersNotOnTrack_fpix->Fill(nofclOffTrack);
1429  if(z>0){
1430  if(DBdisk==1) {
1431  if(nofclOnTrack!=0) meNClustersOnTrack_diskp1->Fill(nofclOnTrack);
1432  if(nofclOffTrack!=0) meNClustersNotOnTrack_diskp1->Fill(nofclOffTrack);
1433  }
1434  if(DBdisk==2) {
1435  if(nofclOnTrack!=0) meNClustersOnTrack_diskp2->Fill(nofclOnTrack);
1436  if(nofclOffTrack!=0) meNClustersNotOnTrack_diskp2->Fill(nofclOffTrack);
1437  }
1438  if(DBdisk==3) {
1439  if(nofclOnTrack!=0 && isUpgrade) meNClustersOnTrack_diskp3->Fill(nofclOnTrack);
1440  if(nofclOffTrack!=0) meNClustersNotOnTrack_diskp3->Fill(nofclOffTrack);
1441  }
1442  }
1443  if(z<0){
1444  if(DBdisk==1) {
1445  if(nofclOnTrack!=0) meNClustersOnTrack_diskm1->Fill(nofclOnTrack);
1446  if(nofclOffTrack!=0) meNClustersNotOnTrack_diskm1->Fill(nofclOffTrack);
1447  }
1448  if(DBdisk==2) {
1449  if(nofclOnTrack!=0) meNClustersOnTrack_diskm2->Fill(nofclOnTrack);
1450  if(nofclOffTrack!=0) meNClustersNotOnTrack_diskm2->Fill(nofclOffTrack);
1451  }
1452  if(DBdisk==3) {
1453  if(nofclOnTrack!=0 && isUpgrade) meNClustersOnTrack_diskm3->Fill(nofclOnTrack);
1454  if(nofclOffTrack!=0 && isUpgrade) meNClustersNotOnTrack_diskm3->Fill(nofclOffTrack);
1455  }
1456  }
1457  }
1458 
1459  }//end if it's a Pixel module
1460  }//end for loop over tracker detector geometry modules
1461 
1462 
1463  if(trackclusters>0) (meNofClustersOnTrack_)->Fill(0,trackclusters);
1464  if(barreltrackclusters>0)(meNofClustersOnTrack_)->Fill(1,barreltrackclusters);
1465  if(endcaptrackclusters>0)(meNofClustersOnTrack_)->Fill(2,endcaptrackclusters);
1466  if(otherclusters>0)(meNofClustersNotOnTrack_)->Fill(0,otherclusters);
1467  if(barrelotherclusters>0)(meNofClustersNotOnTrack_)->Fill(1,barrelotherclusters);
1468  if(endcapotherclusters>0)(meNofClustersNotOnTrack_)->Fill(2,endcapotherclusters);
1469  if(tracks>0)(meNofTracks_)->Fill(0,tracks);
1470  if(pixeltracks>0)(meNofTracks_)->Fill(1,pixeltracks);
1471  if(bpixtracks>0)(meNofTracks_)->Fill(2,bpixtracks);
1472  if(fpixtracks>0)(meNofTracks_)->Fill(3,fpixtracks);
1473 }
1474 void SiPixelTrackResidualSource::triplets(double x1,double y1,double z1,double x2,double y2,double z2,double x3,double y3,double z3,
1475  double ptsig, double & dca2,double & dz2, double kap) {
1476 
1477  //Define some constants
1478  using namespace std;
1479 
1480  //Curvature kap from global Track
1481 
1482  //inverse of the curvature is the radius in the transverse plane
1483  double rho = 1/kap;
1484  //Check that the hits are in the correct layers
1485  double r1 = sqrt( x1*x1 + y1*y1 );
1486  double r3 = sqrt( x3*x3 + y3*y3 );
1487 
1488  if( r3-r1 < 2.0 ) cout << "warn r1 = " << r1 << ", r3 = " << r3 << endl;
1489 
1490  // Calculate the centre of the helix in xy-projection with radius rho from the track.
1491  //start with a line (sekante) connecting the two points (x1,y1) and (x3,y3) vec_L = vec_x3-vec_x1
1492  //with L being the length of that vector.
1493  double L=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
1494  //lam is the line from the middel point of vec_q towards the center of the circle X0,Y0
1495  // we already have kap and rho = 1/kap
1496  double lam = sqrt(rho*rho - L*L/4);
1497 
1498  // There are two solutions, the sign of kap gives the information
1499  // which of them is correct.
1500  //
1501  if( kap > 0 ) lam = -lam;
1502 
1503  //
1504  // ( X0, Y0 ) is the centre of the circle that describes the helix in xy-projection.
1505  //
1506  double x0 = 0.5*( x1 + x3 ) + lam/L * ( -y1 + y3 );
1507  double y0 = 0.5*( y1 + y3 ) + lam/L * ( x1 - x3 );
1508 
1509  // Calculate the dipangle in z direction (needed later for z residual) :
1510  //Starting from the heliz equation whihc has to hold for both points z1,z3
1511  double num = ( y3 - y0 ) * ( x1 - x0 ) - ( x3 - x0 ) * ( y1 - y0 );
1512  double den = ( x1 - x0 ) * ( x3 - x0 ) + ( y1 - y0 ) * ( y3 - y0 );
1513  double tandip = kap * ( z3 - z1 ) / atan( num / den );
1514 
1515 
1516  // angle from first hit to dca point:
1517  //
1518  double dphi = atan( ( ( x1 - x0 ) * y0 - ( y1 - y0 ) * x0 )
1519  / ( ( x1 - x0 ) * x0 + ( y1 - y0 ) * y0 ) );
1520  //z position of the track based on the middle of the circle
1521  //track equation for the z component
1522  double uz0 = z1 + tandip * dphi * rho;
1523 
1525  //RESIDUAL IN R-PHI
1527  //Calculate distance dca2 from point (x2,y2) to the circle which is given by
1528  //the distance of the point to the middlepoint dcM = sqrt((x0-x2)^2+(y0-y2)) and rho
1529  //dca = rho +- dcM
1530  if(kap>0) dca2=rho-sqrt((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2));
1531  else dca2=rho+sqrt((-x0+x2)*(-x0+x2)+(-y0+y2)*(-y0+y2));
1532 
1534  //RESIDUAL IN Z
1536  double xx =0 ;
1537  double yy =0 ;
1538  //sign of kappa determines the calculation
1539  //xx and yy are the new coordinates starting from x2, y2 that are on the track itself
1540  //vec_X2+-dca2*vec(X0-X2)/|(X0-X2)|
1541  if(kap<0){
1542  xx = x2+(dca2*((x0-x2))/sqrt((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2)));
1543  yy = y2+(dca2*((y0-y2))/sqrt((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2)));
1544  }
1545  else if(kap>=0){
1546  xx = x2-(dca2*((x0-x2))/sqrt((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2)));
1547  yy = y2-(dca2*((y0-y2))/sqrt((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2)));
1548  }
1549 
1550  //to get residual in z start with calculating the new uz2 position if one has moved to xx, yy
1551  //on the track. First calculate the change in phi2 with respect to the center X0, Y0
1552  double dphi2 = atan( ( ( xx - x0 ) * y0 - ( yy - y0 ) * x0 )
1553  / ( ( xx - x0 ) * x0 + ( yy - y0 ) * y0 ) );
1554  //Solve track equation for this new z depending on the dip angle of the track (see above
1555  //calculated based on X1, X3 and X0, use uz0 as reference point again.
1556  double uz2= uz0 - dphi2*tandip*rho;
1557 
1558  //subtract new z position from the old one
1559  dz2=z2-uz2;
1560 
1561  //if we are interested in the arclength this is unsigned though
1562  // double cosphi2 = (x2*xx+y2*yy)/(sqrt(x2*x2+y2*y2)*sqrt(xx*xx+yy*yy));
1563  //double arcdca2=sqrt(x2*x2+y2*y2)*acos(cosphi2);
1564 
1565 }
1566 
1567 
1568 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
bool hasFilledProb() const
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
float clusterProbability(unsigned int flags=0) 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:446
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
key_type key() const
Accessor for product key.
Definition: Ref.h:266
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
SiPixelTrackResidualSource(const edm::ParameterSet &)
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
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:115
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_
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
T const * product() const
Definition: Handle.h:81
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
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.
int layerName() const
layer id
T const * product() const
Definition: ESHandle.h:86
edm::EDGetTokenT< reco::VertexCollection > offlinePrimaryVerticesToken_
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:47
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
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
Definition: Run.h:41
virtual const TrackerGeomDet * idToDet(DetId) const
Our base class.
Definition: SiPixelRecHit.h:23
Definition: DDAxes.h:10