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