CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelHitEfficiencySource.cc
Go to the documentation of this file.
1 // Package: SiPixelMonitorTrack
2 // Class: SiPixelHitEfficiencySource
3 //
4 // class SiPixelHitEfficiencyModule SiPixelHitEfficiencyModule.cc
5 // DQM/SiPixelMonitorTrack/src/SiPixelHitEfficiencyModule.cc
6 //
7 // Description: SiPixel hit efficiency data quality monitoring modules
8 // Implementation: prototype -> improved -> never final - end of the 1st step
9 //
10 // Original Authors: Romain Rougny & Luca Mucibello
11 // Created: Mar Nov 10 13:29:00 CET 2009
12 
13 
14 #include <iostream>
15 #include <map>
16 #include <string>
17 #include <vector>
18 #include <utility>
19 
22 
25 
32 
36 
38 
41 //#include "RecoLocalTracker/SiPixelRecHits/plugins/PixelCPEGenericESProducer.h"
42 
53 
57 
58 
59 using namespace std;
60 using namespace edm;
61 
62 
64  pSet_(pSet),
65  modOn( pSet.getUntrackedParameter<bool>("modOn",true) ),
66  ladOn( pSet.getUntrackedParameter<bool>("ladOn",false) ),
67  layOn( pSet.getUntrackedParameter<bool>("layOn",false) ),
68  phiOn( pSet.getUntrackedParameter<bool>("phiOn",false) ),
69  ringOn( pSet.getUntrackedParameter<bool>("ringOn",false) ),
70  bladeOn( pSet.getUntrackedParameter<bool>("bladeOn",false) ),
71  diskOn( pSet.getUntrackedParameter<bool>("diskOn",false) )
72  //updateEfficiencies( pSet.getUntrackedParameter<bool>("updateEfficiencies",false) )
73  {
74  pSet_ = pSet;
75  debug_ = pSet_.getUntrackedParameter<bool>("debug", false);
76  //tracksrc_ = pSet_.getParameter<edm::InputTag>("trajectoryInput");
77  applyEdgeCut_ = pSet_.getUntrackedParameter<bool>("applyEdgeCut");
78  nSigma_EdgeCut_ = pSet_.getUntrackedParameter<double>("nSigma_EdgeCut");
80  vertexCollectionToken_ = consumes<reco::VertexCollection>(std::string("offlinePrimaryVertices"));
81  tracksrc_ = consumes<TrajTrackAssociationCollection>(pSet_.getParameter<edm::InputTag>("trajectoryInput"));
82  clusterCollectionToken_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(std::string("siPixelClusters"));
83 
84  LogInfo("PixelDQM") << "SiPixelHitEfficiencySource constructor" << endl;
85  LogInfo ("PixelDQM") << "Mod/Lad/Lay/Phi " << modOn << "/" << ladOn << "/"
86  << layOn << "/" << phiOn << std::endl;
87  LogInfo ("PixelDQM") << "Blade/Disk/Ring" << bladeOn << "/" << diskOn << "/"
88  << ringOn << std::endl;
89 }
90 
91 
93  LogInfo("PixelDQM") << "SiPixelHitEfficiencySource destructor" << endl;
94 
95  std::map<uint32_t,SiPixelHitEfficiencyModule*>::iterator struct_iter;
96  for (struct_iter = theSiPixelStructure.begin() ; struct_iter != theSiPixelStructure.end() ; struct_iter++){
97  delete struct_iter->second;
98  struct_iter->second = 0;
99  }
100 }
101 
103  LogInfo("PixelDQM") << "SiPixelHitEfficiencySource beginJob()" << endl;
104  firstRun = true;
105 }
106 
108  LogInfo("PixelDQM") << "SiPixelHitEfficiencySource beginRun()" << endl;
109 
110  if(firstRun){
111  // retrieve TrackerGeometry for pixel dets
113  iSetup.get<TrackerDigiGeometryRecord>().get(TG);
114  if (debug_) LogVerbatim("PixelDQM") << "TrackerGeometry "<< &(*TG) <<" size is "<< TG->dets().size() << endl;
115 
116  // build theSiPixelStructure with the pixel barrel and endcap dets from TrackerGeometry
117  for (TrackerGeometry::DetContainer::const_iterator pxb = TG->detsPXB().begin();
118  pxb!=TG->detsPXB().end(); pxb++) {
119  if (dynamic_cast<PixelGeomDetUnit*>((*pxb))!=0) {
120  SiPixelHitEfficiencyModule* module = new SiPixelHitEfficiencyModule((*pxb)->geographicalId().rawId());
121  theSiPixelStructure.insert(pair<uint32_t, SiPixelHitEfficiencyModule*>((*pxb)->geographicalId().rawId(), module));
122  }
123  }
124  for (TrackerGeometry::DetContainer::const_iterator pxf = TG->detsPXF().begin();
125  pxf!=TG->detsPXF().end(); pxf++) {
126  if (dynamic_cast<PixelGeomDetUnit*>((*pxf))!=0) {
127  SiPixelHitEfficiencyModule* module = new SiPixelHitEfficiencyModule((*pxf)->geographicalId().rawId());
128  theSiPixelStructure.insert(pair<uint32_t, SiPixelHitEfficiencyModule*>((*pxf)->geographicalId().rawId(), module));
129  }
130  }
131  LogInfo("PixelDQM") << "SiPixelStructure size is " << theSiPixelStructure.size() << endl;
132 
133  // book residual histograms in theSiPixelFolder - one (x,y) pair of histograms per det
134  SiPixelFolderOrganizer theSiPixelFolder;
135  for (std::map<uint32_t, SiPixelHitEfficiencyModule*>::iterator pxd = theSiPixelStructure.begin();
136  pxd!=theSiPixelStructure.end(); pxd++) {
137 
138  if(modOn){
139  if (theSiPixelFolder.setModuleFolder((*pxd).first)) (*pxd).second->book(pSet_);
140  else throw cms::Exception("LogicError") << "SiPixelHitEfficiencySource Folder Creation Failed! ";
141  }
142  if(ladOn){
143  if (theSiPixelFolder.setModuleFolder((*pxd).first,1)) (*pxd).second->book(pSet_,1);
144  else throw cms::Exception("LogicError") << "SiPixelHitEfficiencySource ladder Folder Creation Failed! ";
145  }
146  if(layOn){
147  if (theSiPixelFolder.setModuleFolder((*pxd).first,2)) (*pxd).second->book(pSet_,2);
148  else throw cms::Exception("LogicError") << "SiPixelHitEfficiencySource layer Folder Creation Failed! ";
149  }
150  if(phiOn){
151  if (theSiPixelFolder.setModuleFolder((*pxd).first,3)) (*pxd).second->book(pSet_,3);
152  else throw cms::Exception("LogicError") << "SiPixelHitEfficiencySource phi Folder Creation Failed! ";
153  }
154  if(bladeOn){
155  if (theSiPixelFolder.setModuleFolder((*pxd).first,4)) (*pxd).second->book(pSet_,4);
156  else throw cms::Exception("LogicError") << "SiPixelHitEfficiencySource Blade Folder Creation Failed! ";
157  }
158  if(diskOn){
159  if (theSiPixelFolder.setModuleFolder((*pxd).first,5)) (*pxd).second->book(pSet_,5);
160  else throw cms::Exception("LogicError") << "SiPixelHitEfficiencySource Disk Folder Creation Failed! ";
161  }
162  if(ringOn){
163  if (theSiPixelFolder.setModuleFolder((*pxd).first,6)) (*pxd).second->book(pSet_,6);
164  else throw cms::Exception("LogicError") << "SiPixelHitEfficiencySource Ring Folder Creation Failed! ";
165  }
166  }
167 
168  nvalid=0;
169  nmissing=0;
170 
171  firstRun = false;
172  }
173 }
174 
175 
177  LogInfo("PixelDQM") << "SiPixelHitEfficiencySource endJob()";
178 
179  // save the residual histograms to an output root file
180  bool saveFile = pSet_.getUntrackedParameter<bool>("saveFile", true);
181  if (saveFile) {
183  LogInfo("PixelDQM") << " - saving histograms to "<< outputFile.data();
184  dbe_->save(outputFile);
185  }
186  LogInfo("PixelDQM") << endl; // dbe_->showDirStructure();
187 
188  //std::cout<< "********** SUMMARY **********"<<std::endl;
189  //std::cout<< "number of valid hits: "<<nvalid<<std::endl;
190  //std::cout<< "number of missing hits: "<<nmissing<<std::endl;
191 }
192 
193 
195 
196  edm::Handle<reco::VertexCollection> vertexCollectionHandle;
197  //iEvent.getByLabel("offlinePrimaryVertices", vertexCollectionHandle);
198  iEvent.getByToken( vertexCollectionToken_, vertexCollectionHandle );
199  if(!vertexCollectionHandle.isValid()) return;
200  nvtx_=0;
201  vtxntrk_=-9999;
202  vtxD0_=-9999.; vtxX_=-9999.; vtxY_=-9999.; vtxZ_=-9999.; vtxndof_=-9999.; vtxchi2_=-9999.;
203  const reco::VertexCollection & vertices = *vertexCollectionHandle.product();
204  reco::VertexCollection::const_iterator bestVtx=vertices.end();
205  for(reco::VertexCollection::const_iterator it=vertices.begin(); it!=vertices.end(); ++it){
206  if(!it->isValid()) continue;
207  if(vtxntrk_==-9999 ||
208  vtxntrk_<int(it->tracksSize()) ||
209  (vtxntrk_==int(it->tracksSize()) && fabs(vtxZ_)>fabs(it->z()))){
210  vtxntrk_=it->tracksSize();
211  vtxD0_=it->position().rho();
212  vtxX_=it->x();
213  vtxY_=it->y();
214  vtxZ_=it->z();
215  vtxndof_=it->ndof();
216  vtxchi2_=it->chi2();
217  bestVtx=it;
218  }
219  if(fabs(it->z())<=20. && fabs(it->position().rho())<=2. && it->ndof()>4) nvtx_++;
220  }
221  if(nvtx_<1) return;
222 
223  //Get the geometry
225  iSetup.get<TrackerDigiGeometryRecord>().get(TG);
226  const TrackerGeometry* theTrackerGeometry = TG.product();
227 
228  //get the map
230  //iEvent.getByLabel(tracksrc_,match);
231  iEvent.getByToken( tracksrc_, match );
232  const TrajTrackAssociationCollection ttac = *(match.product());
233 
234  if(debug_){
235  //std::cout << "Trajectories\t : " << trajColl.size() << std::endl;
236  //std::cout << "recoTracks \t : " << trackColl.size() << std::endl;
237  std::cout << "+++ NEW EVENT +++"<< std::endl;
238  std::cout << "Map entries \t : " << ttac.size() << std::endl;
239  }
240 
241  std::set<SiPixelCluster> clusterSet;
242  TrajectoryStateCombiner tsoscomb;
243 
244  //Loop over map entries
245  for(TrajTrackAssociationCollection::const_iterator it = ttac.begin();it != ttac.end(); ++it){
246  const edm::Ref<std::vector<Trajectory> > traj_iterator = it->key;
247  // Trajectory Map, extract Trajectory for this track
248  reco::TrackRef trackref = it->val;
249  //tracks++;
250  bool isBpixtrack = false, isFpixtrack = false;
251  int nStripHits=0; int L1hits=0; int L2hits=0; int L3hits=0; int D1hits=0; int D2hits=0;
252  std::vector<TrajectoryMeasurement> tmeasColl =traj_iterator->measurements();
253  std::vector<TrajectoryMeasurement>::const_iterator tmeasIt;
254  //loop on measurements to find out what kind of hits there are
255  for(tmeasIt = tmeasColl.begin();tmeasIt!=tmeasColl.end();tmeasIt++){
256  //if(! tmeasIt->updatedState().isValid()) continue; NOT NECESSARY (I HOPE)
257  TransientTrackingRecHit::ConstRecHitPointer testhit = tmeasIt->recHit();
258  if(testhit->geographicalId().det() != DetId::Tracker) continue;
259  uint testSubDetID = (testhit->geographicalId().subdetId());
260  const DetId & hit_detId = testhit->geographicalId();
261  if(testSubDetID==PixelSubdetector::PixelBarrel){
262  isBpixtrack = true;
263  int layer = PixelBarrelName(hit_detId).layerName();
264  if(layer==1) L1hits++;
265  if(layer==2) L2hits++;
266  if(layer==3) L3hits++;
267  }
268  if(testSubDetID==PixelSubdetector::PixelEndcap){
269  isFpixtrack = true;
270  int disk = PixelEndcapName(hit_detId).diskName();
271  if(disk==1) D1hits++;
272  if(disk==2) D2hits++;
273  }
274  if(testSubDetID==StripSubdetector::TIB) nStripHits++;
275  if(testSubDetID==StripSubdetector::TOB) nStripHits++;
276  if(testSubDetID==StripSubdetector::TID) nStripHits++;
277  if(testSubDetID==StripSubdetector::TEC) nStripHits++;
278  }
279  if(isBpixtrack || isFpixtrack){
280  if(trackref->pt()<0.6 ||
281  nStripHits<11 ||
282  fabs(trackref->dxy(bestVtx->position()))>0.05 ||
283  fabs(trackref->dz(bestVtx->position()))>0.5) continue;
284 
285  if(debug_){
286  std::cout << "isBpixtrack : " << isBpixtrack << std::endl;
287  std::cout << "isFpixtrack : " << isFpixtrack << std::endl;
288  }
289  //std::cout<<"This tracks has so many hits: "<<tmeasColl.size()<<std::endl;
290  for(std::vector<TrajectoryMeasurement>::const_iterator tmeasIt = tmeasColl.begin(); tmeasIt!=tmeasColl.end(); tmeasIt++){
291  //if(! tmeasIt->updatedState().isValid()) continue;
292 
293  TrajectoryStateOnSurface tsos = tsoscomb( tmeasIt->forwardPredictedState(), tmeasIt->backwardPredictedState() );
295  if(hit->geographicalId().det() != DetId::Tracker )
296  continue;
297  else {
298 
299 // //residual
300  const DetId & hit_detId = hit->geographicalId();
301  //uint IntRawDetID = (hit_detId.rawId());
302  uint IntSubDetID = (hit_detId.subdetId());
303 
304  if(IntSubDetID == 0 ){
305  if(debug_) std::cout << "NO IntSubDetID\n";
306  continue;
307  }
308  if(IntSubDetID!=PixelSubdetector::PixelBarrel && IntSubDetID!=PixelSubdetector::PixelEndcap)
309  continue;
310 
311  int disk=0; int layer=0; int panel=0; int module=0; bool isHalfModule=false;
312  if(IntSubDetID==PixelSubdetector::PixelBarrel){ // it's a BPIX hit
313  layer = PixelBarrelName(hit_detId).layerName();
314  isHalfModule = PixelBarrelName(hit_detId).isHalfModule();
315  }else if(IntSubDetID==PixelSubdetector::PixelEndcap){ // it's an FPIX hit
316  disk = PixelEndcapName(hit_detId).diskName();
317  panel = PixelEndcapName(hit_detId).pannelName();
318  module = PixelEndcapName(hit_detId).plaquetteName();
319  }
320  if(layer==1){
321  if(fabs(trackref->dxy(bestVtx->position()))>0.01 ||
322  fabs(trackref->dz(bestVtx->position()))>0.1) continue;
323  if(!(L2hits>0&&L3hits>0) && !(L2hits>0&&D1hits>0) && !(D1hits>0&&D2hits>0)) continue;
324  }else if(layer==2){
325  if(fabs(trackref->dxy(bestVtx->position()))>0.02 ||
326  fabs(trackref->dz(bestVtx->position()))>0.1) continue;
327  if(!(L1hits>0&&L3hits>0) && !(L1hits>0&&D1hits>0)) continue;
328  }else if(layer==3){
329  if(fabs(trackref->dxy(bestVtx->position()))>0.02 ||
330  fabs(trackref->dz(bestVtx->position()))>0.1) continue;
331  if(!(L1hits>0&&L2hits>0)) continue;
332  }else if(disk==1){
333  if(fabs(trackref->dxy(bestVtx->position()))>0.05 ||
334  fabs(trackref->dz(bestVtx->position()))>0.5) continue;
335  if(!(L1hits>0&&D2hits>0) && !(L2hits>0&&D2hits>0)) continue;
336  }else if(disk==2){
337  if(fabs(trackref->dxy(bestVtx->position()))>0.05 ||
338  fabs(trackref->dz(bestVtx->position()))>0.5) continue;
339  if(!(L1hits>0&&D1hits>0)) continue;
340  }
341 
342  //check wether hit is valid or missing using track algo flag
343  bool isHitValid =hit->hit()->getType()==TrackingRecHit::valid;
344  bool isHitMissing =hit->hit()->getType()==TrackingRecHit::missing;
345  //std::cout<<"------ New Hit"<<std::endl;
346  //std::cout<<(hit->hit()->getType()==TrackingRecHit::missing)<<std::endl;
347 
348  // get the enclosed persistent hit
349  //const TrackingRecHit *persistentHit = hit->hit();
350  // check if it's not null, and if it's a valid pixel hit
351  //if ((persistentHit != 0) && (typeid(*persistentHit) == typeid(SiPixelRecHit))) {
352 
353  if(debug_) std::cout << "the hit is persistent\n";
354 
355  // tell the C++ compiler that the hit is a pixel hit
356  //const SiPixelRecHit* pixhit = dynamic_cast<const SiPixelRecHit*>( hit->hit() );
357 
358  //define tracker and pixel geometry and topology
359  const TrackerGeometry& theTracker(*theTrackerGeometry);
360  const PixelGeomDetUnit* theGeomDet = dynamic_cast<const PixelGeomDetUnit*> (theTracker.idToDet(hit_detId) );
361  //test if PixelGeomDetUnit exists
362  if(theGeomDet == 0) {
363  if(debug_) std::cout << "NO THEGEOMDET\n";
364  continue;
365  }
366 
367  //const RectangularPixelTopology * topol = dynamic_cast<const RectangularPixelTopology*>(&(theGeomDet->specificTopology()));
368 
369  std::map<uint32_t, SiPixelHitEfficiencyModule*>::iterator pxd = theSiPixelStructure.find((*hit).geographicalId().rawId());
370 
371  // calculate alpha and beta from cluster position
373  //LocalVector localDir = ltp.momentum()/ltp.momentum().mag();
374 
375  //float clust_alpha = atan2(localDir.z(), localDir.x());
376  //float clust_beta = atan2(localDir.z(), localDir.y());
377 
378 
379 
380  // THE CUTS
381  //int nrows = theGeomDet->specificTopology().nrows();
382  //int ncols = theGeomDet->specificTopology().ncolumns();
383  //
384  //std::pair<float,float> pitchTest = theGeomDet->specificTopology().pitch();
385  //RectangularPixelTopology rectTopolTest = RectangularPixelTopology(nrows, ncols, pitch.first, pitch.second);
386  //std::pair<float,float> pixelTest = rectTopol.pixel(tsos.localPosition());
387  //
388 
389 
390  //*************** Edge cut ********************
391  //double glx=tsos.globalPosition().x();
392  //double gly=tsos.globalPosition().y();
393  //double glz=tsos.globalPosition().z();
394  double lx=tsos.localPosition().x();
395  double ly=tsos.localPosition().y();
396  //double lz=tsos.localPosition().z();
397  //double lx_err=tsos.localError().positionError().xx();
398  //double ly_err=tsos.localError().positionError().yy();
399  //int telescope=0; int telescope_valid=0;
400  if(fabs(lx)>0.55 || fabs(ly)>3.0) continue;
401  //LocalTrajectoryParameters predTrajParam=tsos.localParameters();
402  //LocalVector dir=predTrajParam.momentum()/predTrajParam.momentum().mag();
403  //double alpha=atan2(dir.z(), dir.x());
404  //double beta=atan2(dir.z(), dir.y());
405  bool passedFiducial=true;
406  // Module fiducials:
407  if(IntSubDetID==PixelSubdetector::PixelBarrel && fabs(ly)>=3.1) passedFiducial=false;
408  if(IntSubDetID==PixelSubdetector::PixelEndcap &&
409  !((panel==1 &&
410  ((module==1 && fabs(ly)<0.7) ||
411  ((module==2 && fabs(ly)<1.1) &&
412  !(disk==-1 && ly>0.8 && lx>0.2) &&
413  !(disk==1 && ly<-0.7 && lx>0.2) &&
414  !(disk==2 && ly<-0.8)) ||
415  ((module==3 && fabs(ly)<1.5) &&
416  !(disk==-2 && lx>0.1 && ly>1.0) &&
417  !(disk==2 && lx>0.1 && ly<-1.0)) ||
418  ((module==4 && fabs(ly)<1.9) &&
419  !(disk==-2 && ly>1.5) &&
420  !(disk==2 && ly<-1.5)))) ||
421  (panel==2 &&
422  ((module==1 && fabs(ly)<0.7) ||
423  (module==2 && fabs(ly)<1.2 &&
424  !(disk>0 && ly>1.1) &&
425  !(disk<0 && ly<-1.1)) ||
426  (module==3 && fabs(ly)<1.6 &&
427  !(disk>0 && ly>1.5) &&
428  !(disk<0 && ly<-1.5)))))) passedFiducial=false;
429  if(IntSubDetID==PixelSubdetector::PixelEndcap &&
430  ((panel==1 && (module==1 || (module>=3 && abs(disk)==1))) ||
431  (panel==2 && ((module==1 && abs(disk)==2) ||
432  (module==3 && abs(disk)==1))))) passedFiducial=false;
433  // ROC fiducials:
434  double ly_mod = fabs(ly);
435  if(IntSubDetID==PixelSubdetector::PixelEndcap && (panel+module)%2==1) ly_mod=ly_mod+0.405;
436  float d_rocedge = fabs(fmod(ly_mod,0.81)-0.405);
437  if(d_rocedge<=0.0625) passedFiducial=false;
438  if(!( (IntSubDetID==PixelSubdetector::PixelBarrel &&
439  ((!isHalfModule && fabs(lx)<0.6) ||
440  (isHalfModule && lx>-0.3 && lx<0.2))) ||
441  (IntSubDetID==PixelSubdetector::PixelEndcap &&
442  ((panel==1 &&
443  ((module==1 && fabs(lx)<0.2) ||
444  (module==2 &&
445  ((fabs(lx)<0.55 && abs(disk)==1) ||
446  (lx>-0.5 && lx<0.2 && disk==-2) ||
447  (lx>-0.5 && lx<0.0 && disk==2))) ||
448  (module==3 && lx>-0.6 && lx<0.5) ||
449  (module==4 && lx>-0.3 && lx<0.15))) ||
450  (panel==2 &&
451  ((module==1 && fabs(lx)<0.6) ||
452  (module==2 &&
453  ((fabs(lx)<0.55 && abs(disk)==1) ||
454  (lx>-0.6 && lx<0.5 && abs(disk)==2))) ||
455  (module==3 && fabs(lx)<0.5))))))) passedFiducial=false;
456  if(((IntSubDetID==PixelSubdetector::PixelBarrel && !isHalfModule) ||
457  (IntSubDetID==PixelSubdetector::PixelEndcap && !(panel==1 && (module==1 || module==4)))) &&
458  fabs(lx)<0.06) passedFiducial=false;
459 
460 
461  //*************** find closest clusters ********************
462  float dx_cl[2]; float dy_cl[2]; dx_cl[0]=dx_cl[1]=dy_cl[0]=dy_cl[1]=-9999.;
464  iSetup.get<TkPixelCPERecord>().get("PixelCPEGeneric", cpEstimator);
465  if(cpEstimator.isValid()){
466  const PixelClusterParameterEstimator &cpe(*cpEstimator);
468  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
469  if(tracker.isValid()){
470  const TrackerGeometry *tkgeom=&(*tracker);
471  edm::Handle<edmNew::DetSetVector<SiPixelCluster> > clusterCollectionHandle;
472  //iEvent.getByLabel("siPixelClusters", clusterCollectionHandle);
473  iEvent.getByToken( clusterCollectionToken_, clusterCollectionHandle );
474  if(clusterCollectionHandle.isValid()){
475  const edmNew::DetSetVector<SiPixelCluster>& clusterCollection=*clusterCollectionHandle;
476  edmNew::DetSetVector<SiPixelCluster>::const_iterator itClusterSet=clusterCollection.begin();
477  float minD[2]; minD[0]=minD[1]=10000.;
478  for( ; itClusterSet!=clusterCollection.end(); itClusterSet++){
479  DetId detId(itClusterSet->id());
480  if(detId.rawId()!=hit->geographicalId().rawId()) continue;
481  //unsigned int sdId=detId.subdetId();
482  const PixelGeomDetUnit *pixdet=(const PixelGeomDetUnit*) tkgeom->idToDetUnit(detId);
483  edmNew::DetSet<SiPixelCluster>::const_iterator itCluster=itClusterSet->begin();
484  for( ; itCluster!=itClusterSet->end(); ++itCluster){
485  LocalPoint lp(itCluster->x(), itCluster->y(), 0.);
486  PixelClusterParameterEstimator::LocalValues params=cpe.localParameters(*itCluster,*pixdet);
487  lp=params.first;
488  float D = sqrt((lp.x()-lx)*(lp.x()-lx)+(lp.y()-ly)*(lp.y()-ly));
489  if(D<minD[0]){
490  minD[1]=minD[0];
491  dx_cl[1]=dx_cl[0];
492  dy_cl[1]=dy_cl[0];
493  minD[0]=D;
494  dx_cl[0]=lp.x();
495  dy_cl[0]=lp.y();
496  }else if(D<minD[1]){
497  minD[1]=D;
498  dx_cl[1]=lp.x();
499  dy_cl[1]=lp.y();
500  }
501  } // loop on clusterSets
502  } // loop on clusterCollection
503  for(size_t i=0; i<2; i++){
504  if(minD[i]<9999.){
505  dx_cl[i]=fabs(dx_cl[i]-lx);
506  dy_cl[i]=fabs(dy_cl[i]-ly);
507  }
508  }
509  } // valid clusterCollectionHandle
510  } // valid tracker
511  } // valid cpEstimator
512  // distance of hit from closest cluster!
513  float d_cl[2]; d_cl[0]=d_cl[1]=-9999.;
514  if(dx_cl[0]!=-9999. && dy_cl[0]!=-9999.) d_cl[0]=sqrt(dx_cl[0]*dx_cl[0]+dy_cl[0]*dy_cl[0]);
515  if(dx_cl[1]!=-9999. && dy_cl[1]!=-9999.) d_cl[1]=sqrt(dx_cl[1]*dx_cl[1]+dy_cl[1]*dy_cl[1]);
516  if(isHitMissing && (d_cl[0]<0.05 || d_cl[1]<0.05)){ isHitMissing=0; isHitValid=1; }
517 
518 
519  if(debug_){
520  std::cout << "Ready to add hit in histogram:\n";
521  //std::cout << "detid: "<<hit_detId<<std::endl;
522  std::cout << "isHitValid: "<<isHitValid<<std::endl;
523  std::cout << "isHitMissing: "<<isHitMissing<<std::endl;
524  //std::cout << "passedEdgeCut: "<<passedFiducial<<std::endl;
525  }
526 
527 
528  if(pxd!=theSiPixelStructure.end() && isHitValid && passedFiducial)
529  ++nvalid;
530  if(pxd!=theSiPixelStructure.end() && isHitMissing && passedFiducial)
531  ++nmissing;
532 
533  if (pxd!=theSiPixelStructure.end() && passedFiducial && (isHitValid || isHitMissing))
534  (*pxd).second->fill(ltp, isHitValid, modOn, ladOn, layOn, phiOn, bladeOn, diskOn, ringOn);
535 
536  //}//end if (persistent hit exists and is pixel hit)
537 
538  }//end of else
539 
540 
541  }//end for (all traj measurements of pixeltrack)
542  }//end if (is pixeltrack)
543  else
544  if(debug_) std::cout << "no pixeltrack:\n";
545 
546  }//end loop on map entries
547 }
548 
549 
550 DEFINE_FWK_MODULE(SiPixelHitEfficiencySource); // define this as a plug-in
int plaquetteName() const
plaquetteId (in pannel)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
SiPixelHitEfficiencySource(const edm::ParameterSet &)
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
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void analyze(const edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > clusterCollectionToken_
std::map< uint32_t, SiPixelHitEfficiencyModule * > theSiPixelStructure
T y() const
Definition: PV3DBase.h:63
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
data_type const * const_iterator
Definition: DetSetNew.h:30
id_type id(size_t cell) const
std::pair< LocalPoint, LocalError > LocalValues
edm::EDGetTokenT< reco::VertexCollection > vertexCollectionToken_
int iEvent
Definition: GenABIO.cc:243
bool isHalfModule() const
full or half module
virtual void beginRun(const edm::Run &r, edm::EventSetup const &iSetup)
T sqrt(T t)
Definition: SSEVec.h:48
edm::EDGetTokenT< TrajTrackAssociationCollection > tracksrc_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2296
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
virtual const GeomDet * idToDet(DetId) const
Definition: DetId.h:18
size_type size() const
map size
const T & get() const
Definition: EventSetup.h:55
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
T const * product() const
Definition: Handle.h:81
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
const_iterator end(bool update=true) const
int pannelName() const
pannel id
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)
volatile std::atomic< bool > shutdown_flag false
const_iterator begin(bool update=true) const
bool isValid() const
Definition: ESHandle.h:37
T x() const
Definition: PV3DBase.h:62
Definition: vlib.h:208
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
virtual LocalValues localParameters(const T &, const GeomDetUnit &) const
Definition: Run.h:41
bool setModuleFolder(const uint32_t &rawdetid=0, int type=0)
Set folder name for a module or plaquette.