CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
SiPixelHitEfficiencySource Class Reference

#include <SiPixelHitEfficiencySource.h>

Inheritance diagram for SiPixelHitEfficiencySource:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void beginRun (const edm::Run &r, edm::EventSetup const &iSetup)
 
virtual void endJob (void)
 
 SiPixelHitEfficiencySource (const edm::ParameterSet &)
 
 ~SiPixelHitEfficiencySource ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

bool applyEdgeCut_
 
bool bladeOn
 
DQMStoredbe_
 
bool debug_
 
bool diskOn
 
bool firstRun
 
bool ladOn
 
bool layOn
 
bool modOn
 
int nmissing
 
double nSigma_EdgeCut_
 
int nvalid
 
int nvtx_
 
bool phiOn
 
edm::ParameterSet pSet_
 
bool ringOn
 
edm::InputTag src_
 
std::map< uint32_t,
SiPixelHitEfficiencyModule * > 
theSiPixelStructure
 
edm::InputTag tracksrc_
 
double vtxchi2_
 
double vtxD0_
 
double vtxndof_
 
int vtxntrk_
 
double vtxX_
 
double vtxY_
 
double vtxZ_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 40 of file SiPixelHitEfficiencySource.h.

Constructor & Destructor Documentation

SiPixelHitEfficiencySource::SiPixelHitEfficiencySource ( const edm::ParameterSet pSet)
explicit

Definition at line 63 of file SiPixelHitEfficiencySource.cc.

References applyEdgeCut_, bladeOn, dbe_, debug_, diskOn, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), ladOn, layOn, modOn, nSigma_EdgeCut_, cppFunctionSkipper::operator, phiOn, pSet_, ringOn, and tracksrc_.

63  :
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 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
SiPixelHitEfficiencySource::~SiPixelHitEfficiencySource ( )

Definition at line 89 of file SiPixelHitEfficiencySource.cc.

References theSiPixelStructure.

89  {
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 }
std::map< uint32_t, SiPixelHitEfficiencyModule * > theSiPixelStructure

Member Function Documentation

void SiPixelHitEfficiencySource::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 191 of file SiPixelHitEfficiencySource.cc.

References abs, edm::AssociationMap< Tag >::begin(), edmNew::DetSetVector< T >::begin(), bladeOn, gather_cfg::cout, debug_, PixelEndcapName::diskName(), diskOn, edm::AssociationMap< Tag >::end(), edmNew::DetSetVector< T >::end(), edm::EventSetup::get(), edm::Event::getByLabel(), i, edmNew::DetSetVector< T >::id(), TrackerGeometry::idToDet(), TrackerGeometry::idToDetUnit(), PixelBarrelName::isHalfModule(), edm::ESHandleBase::isValid(), edm::HandleBase::isValid(), edm::Ref< C, T, F >::key(), ladOn, PixelBarrelName::layerName(), layOn, ClusterParameterEstimator< T >::localParameters(), TrajectoryStateOnSurface::localParameters(), TrajectoryStateOnSurface::localPosition(), match(), TrackingRecHit::missing, modOn, nmissing, nvalid, nvtx_, PixelEndcapName::pannelName(), phiOn, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, PixelEndcapName::plaquetteName(), edm::Handle< T >::product(), edm::ESHandle< class >::product(), ringOn, edm::AssociationMap< Tag >::size(), mathSSE::sqrt(), DetId::subdetId(), StripSubdetector::TEC, theSiPixelStructure, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, DetId::Tracker, patCandidatesForDimuonsSequences_cff::tracker, tracksrc_, TrackingRecHit::valid, vtxchi2_, vtxD0_, vtxndof_, vtxntrk_, vtxX_, vtxY_, vtxZ_, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

191  {
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 }
int plaquetteName() const
plaquetteId (in pannel)
int i
Definition: DBlmapReader.cc:9
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator begin() const
const LocalTrajectoryParameters & localParameters() const
const_iterator end() const
last iterator over the map (read only)
std::map< uint32_t, SiPixelHitEfficiencyModule * > theSiPixelStructure
T y() const
Definition: PV3DBase.h:63
#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
bool isHalfModule() const
full or half module
T sqrt(T t)
Definition: SSEVec.h:48
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
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:62
Definition: vlib.h:209
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
void SiPixelHitEfficiencySource::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 99 of file SiPixelHitEfficiencySource.cc.

References firstRun.

99  {
100  LogInfo("PixelDQM") << "SiPixelHitEfficiencySource beginJob()" << endl;
101  firstRun = true;
102 }
void SiPixelHitEfficiencySource::beginRun ( const edm::Run r,
edm::EventSetup const &  iSetup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 104 of file SiPixelHitEfficiencySource.cc.

References bladeOn, debug_, diskOn, edm::hlt::Exception, firstRun, edm::EventSetup::get(), ladOn, layOn, modOn, python.rootplot.argparse::module, nmissing, nvalid, phiOn, pSet_, ringOn, SiPixelFolderOrganizer::setModuleFolder(), and theSiPixelStructure.

104  {
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 }
std::map< uint32_t, SiPixelHitEfficiencyModule * > theSiPixelStructure
Definition: vlib.h:209
bool setModuleFolder(const uint32_t &rawdetid=0, int type=0)
Set folder name for a module or plaquette.
void SiPixelHitEfficiencySource::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 173 of file SiPixelHitEfficiencySource.cc.

References dbe_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), download_sqlite_cfg::outputFile, pSet_, DQMStore::save(), and AlCaHLTBitMon_QueryRunRegistry::string.

173  {
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) {
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 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
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:2118

Member Data Documentation

bool SiPixelHitEfficiencySource::applyEdgeCut_
private

Definition at line 55 of file SiPixelHitEfficiencySource.h.

Referenced by SiPixelHitEfficiencySource().

bool SiPixelHitEfficiencySource::bladeOn
private

Definition at line 65 of file SiPixelHitEfficiencySource.h.

Referenced by analyze(), beginRun(), and SiPixelHitEfficiencySource().

DQMStore* SiPixelHitEfficiencySource::dbe_
private

Definition at line 58 of file SiPixelHitEfficiencySource.h.

Referenced by endJob(), and SiPixelHitEfficiencySource().

bool SiPixelHitEfficiencySource::debug_
private

Definition at line 60 of file SiPixelHitEfficiencySource.h.

Referenced by analyze(), beginRun(), and SiPixelHitEfficiencySource().

bool SiPixelHitEfficiencySource::diskOn
private

Definition at line 65 of file SiPixelHitEfficiencySource.h.

Referenced by analyze(), beginRun(), and SiPixelHitEfficiencySource().

bool SiPixelHitEfficiencySource::firstRun
private

Definition at line 67 of file SiPixelHitEfficiencySource.h.

Referenced by beginJob(), and beginRun().

bool SiPixelHitEfficiencySource::ladOn
private

Definition at line 63 of file SiPixelHitEfficiencySource.h.

Referenced by analyze(), beginRun(), and SiPixelHitEfficiencySource().

bool SiPixelHitEfficiencySource::layOn
private

Definition at line 63 of file SiPixelHitEfficiencySource.h.

Referenced by analyze(), beginRun(), and SiPixelHitEfficiencySource().

bool SiPixelHitEfficiencySource::modOn
private

Definition at line 61 of file SiPixelHitEfficiencySource.h.

Referenced by analyze(), beginRun(), and SiPixelHitEfficiencySource().

int SiPixelHitEfficiencySource::nmissing
private

Definition at line 71 of file SiPixelHitEfficiencySource.h.

Referenced by analyze(), and beginRun().

double SiPixelHitEfficiencySource::nSigma_EdgeCut_
private

Definition at line 56 of file SiPixelHitEfficiencySource.h.

Referenced by SiPixelHitEfficiencySource().

int SiPixelHitEfficiencySource::nvalid
private

Definition at line 71 of file SiPixelHitEfficiencySource.h.

Referenced by analyze(), and beginRun().

int SiPixelHitEfficiencySource::nvtx_
private

Definition at line 73 of file SiPixelHitEfficiencySource.h.

Referenced by analyze().

bool SiPixelHitEfficiencySource::phiOn
private

Definition at line 63 of file SiPixelHitEfficiencySource.h.

Referenced by analyze(), beginRun(), and SiPixelHitEfficiencySource().

edm::ParameterSet SiPixelHitEfficiencySource::pSet_
private

Definition at line 51 of file SiPixelHitEfficiencySource.h.

Referenced by beginRun(), endJob(), and SiPixelHitEfficiencySource().

bool SiPixelHitEfficiencySource::ringOn
private

Definition at line 65 of file SiPixelHitEfficiencySource.h.

Referenced by analyze(), beginRun(), and SiPixelHitEfficiencySource().

edm::InputTag SiPixelHitEfficiencySource::src_
private

Definition at line 52 of file SiPixelHitEfficiencySource.h.

std::map<uint32_t, SiPixelHitEfficiencyModule*> SiPixelHitEfficiencySource::theSiPixelStructure
private

Definition at line 69 of file SiPixelHitEfficiencySource.h.

Referenced by analyze(), beginRun(), and ~SiPixelHitEfficiencySource().

edm::InputTag SiPixelHitEfficiencySource::tracksrc_
private

Definition at line 53 of file SiPixelHitEfficiencySource.h.

Referenced by analyze(), and SiPixelHitEfficiencySource().

double SiPixelHitEfficiencySource::vtxchi2_
private

Definition at line 80 of file SiPixelHitEfficiencySource.h.

Referenced by analyze().

double SiPixelHitEfficiencySource::vtxD0_
private

Definition at line 75 of file SiPixelHitEfficiencySource.h.

Referenced by analyze().

double SiPixelHitEfficiencySource::vtxndof_
private

Definition at line 79 of file SiPixelHitEfficiencySource.h.

Referenced by analyze().

int SiPixelHitEfficiencySource::vtxntrk_
private

Definition at line 74 of file SiPixelHitEfficiencySource.h.

Referenced by analyze().

double SiPixelHitEfficiencySource::vtxX_
private

Definition at line 76 of file SiPixelHitEfficiencySource.h.

Referenced by analyze().

double SiPixelHitEfficiencySource::vtxY_
private

Definition at line 77 of file SiPixelHitEfficiencySource.h.

Referenced by analyze().

double SiPixelHitEfficiencySource::vtxZ_
private

Definition at line 78 of file SiPixelHitEfficiencySource.h.

Referenced by analyze().