74 modOn( pSet.getUntrackedParameter<bool>(
"modOn",
true) ),
75 ladOn( pSet.getUntrackedParameter<bool>(
"ladOn",
false) ),
76 layOn( pSet.getUntrackedParameter<bool>(
"layOn",
false) ),
77 phiOn( pSet.getUntrackedParameter<bool>(
"phiOn",
false) ),
78 ringOn( pSet.getUntrackedParameter<bool>(
"ringOn",
false) ),
79 bladeOn( pSet.getUntrackedParameter<bool>(
"bladeOn",
false) ),
80 diskOn( pSet.getUntrackedParameter<bool>(
"diskOn",
false) ),
81 isUpgrade( pSet.getUntrackedParameter<bool>(
"isUpgrade",
false) )
96 LogInfo(
"PixelDQM") <<
"SiPixelHitEfficiencySource constructor" << endl;
105 LogInfo(
"PixelDQM") <<
"SiPixelHitEfficiencySource destructor" << endl;
107 std::map<uint32_t,SiPixelHitEfficiencyModule*>::iterator struct_iter;
109 delete struct_iter->second;
110 struct_iter->second = 0;
115 LogInfo(
"PixelDQM") <<
"SiPixelHitEfficiencySource beginJob()" << endl;
120 LogInfo(
"PixelDQM") <<
"SiPixelHitEfficiencySource beginRun()" << endl;
126 if (
debug_)
LogVerbatim(
"PixelDQM") <<
"TrackerGeometry "<< &(*TG) <<
" size is "<< TG->dets().size() << endl;
129 for (TrackerGeometry::DetContainer::const_iterator pxb = TG->detsPXB().begin();
130 pxb!=TG->detsPXB().end(); pxb++) {
131 if (dynamic_cast<PixelGeomDetUnit const *>((*pxb))!=0) {
136 for (TrackerGeometry::DetContainer::const_iterator pxf = TG->detsPXF().begin();
137 pxf!=TG->detsPXF().end(); pxf++) {
138 if (dynamic_cast<PixelGeomDetUnit const *>((*pxf))!=0) {
147 for (std::map<uint32_t, SiPixelHitEfficiencyModule*>::iterator pxd =
theSiPixelStructure.begin();
152 else throw cms::Exception(
"LogicError") <<
"SiPixelHitEfficiencySource Folder Creation Failed! ";
156 else throw cms::Exception(
"LogicError") <<
"SiPixelHitEfficiencySource ladder Folder Creation Failed! ";
160 else throw cms::Exception(
"LogicError") <<
"SiPixelHitEfficiencySource layer Folder Creation Failed! ";
164 else throw cms::Exception(
"LogicError") <<
"SiPixelHitEfficiencySource phi Folder Creation Failed! ";
168 else throw cms::Exception(
"LogicError") <<
"SiPixelHitEfficiencySource Blade Folder Creation Failed! ";
172 else throw cms::Exception(
"LogicError") <<
"SiPixelHitEfficiencySource Disk Folder Creation Failed! ";
176 else throw cms::Exception(
"LogicError") <<
"SiPixelHitEfficiencySource Ring Folder Creation Failed! ";
189 LogInfo(
"PixelDQM") <<
"SiPixelHitEfficiencySource endJob()";
195 LogInfo(
"PixelDQM") <<
" - saving histograms to "<< outputFile.data();
210 if(!vertexCollectionHandle.
isValid())
return;
215 reco::VertexCollection::const_iterator bestVtx=vertices.end();
216 for(reco::VertexCollection::const_iterator it=vertices.begin(); it!=vertices.end(); ++it){
217 if(!it->isValid())
continue;
220 (
vtxntrk_==
int(it->tracksSize()) && fabs(
vtxZ_)>fabs(it->z()))){
222 vtxD0_=it->position().rho();
230 if(fabs(it->z())<=20. && fabs(it->position().rho())<=2. && it->ndof()>4)
nvtx_++;
247 std::cout <<
"+++ NEW EVENT +++"<< std::endl;
248 std::cout <<
"Map entries \t : " << ttac.
size() << std::endl;
251 std::set<SiPixelCluster> clusterSet;
254 int extrapolateFrom_ = 2;
255 int extrapolateTo_ = 1;
256 float maxlxmatch_=0.2;
257 float maxlymatch_=0.2;
258 bool keepOriginalMissingHit_=
true;
271 if (extrapolateFrom_>=extrapolateTo_) {
280 std::vector<TrajectoryMeasurement> expTrajMeasurements;
287 bool isBpixtrack =
false, isFpixtrack =
false;
288 int nStripHits=0;
int L1hits=0;
int L2hits=0;
int L3hits=0;
int L4hits=0;
int D1hits=0;
int D2hits=0;
int D3hits=0;
289 std::vector<TrajectoryMeasurement> tmeasColl =traj_iterator->measurements();
290 std::vector<TrajectoryMeasurement>::const_iterator tmeasIt;
292 for(tmeasIt = tmeasColl.begin();tmeasIt!=tmeasColl.end();tmeasIt++){
296 uint testSubDetID = (testhit->geographicalId().subdetId());
297 const DetId & hit_detId = testhit->geographicalId();
314 if(hit_layer==1) L1hits++;
315 if(hit_layer==2) L2hits++;
316 if(hit_layer==3) L3hits++;
324 if(hit_disk==1) D1hits++;
325 if(hit_disk==2) D2hits++;
334 bool lastValidL2 =
false;
337 if (testhit->isValid()) {
338 if (tmeasIt == tmeasColl.end()-1) {
343 uint nextSubDetID = (nextRecHit->geographicalId().subdetId());
344 int nextlayer =
PixelBarrelName(nextRecHit->geographicalId()).layerName();
353 std::vector< const BarrelDetLayer*> pxbLayers = measurementTrackerHandle->geometricSearchTracker()->pixelBarrelLayers();
354 const DetLayer* pxb1 = pxbLayers[extrapolateTo_-1];
358 expTrajMeasurements = theLayerMeasurements->
measurements(*pxb1, tsosPXB2, *thePropagator, *estimator);
359 delete theLayerMeasurements;
360 if ( !expTrajMeasurements.empty()) {
361 for(uint
p=0;
p<expTrajMeasurements.size();
p++){
363 auto pxb1Hit = pxb1TM.
recHit();
365 if(pxb1Hit->geographicalId().rawId()==0){
366 expTrajMeasurements.erase(expTrajMeasurements.begin()+
p);
374 TrajectoryStateOnSurface chkPredTrajState=trajStateComb(tmeasIt->forwardPredictedState(), tmeasIt->backwardPredictedState());
381 vector<int > imatches;
384 for (
size_t iexp=0; iexp<expTrajMeasurements.size(); iexp++) {
385 const DetId & exphit_detId = expTrajMeasurements[iexp].recHit()->geographicalId();
388 int dladder =
abs( exphit_ladder - hit_ladder );
389 if (dladder > 10) dladder = 20 - dladder;
390 int dmodule =
abs( exphit_mod - hit_mod);
391 if (dladder != 0 || dmodule != 0) {
399 float dxyz=
sqrt((chkx-x)*(chkx-x)+(chky-y)*(chky-y)+(chkz-z)*(chkz-z));
404 imatches.push_back(
int(imatch));
409 float lxmatch = 9999.0;
410 float lymatch = 9999.0;
411 if(!expTrajMeasurements.empty()){
413 const DetId & matchhit_detId = expTrajMeasurements[imatch].recHit()->geographicalId();
416 int dladder =
abs(matchhit_ladder-hit_ladder);
417 if (dladder > 10) dladder = 20 - dladder;
418 LocalPoint lp = expTrajMeasurements[imatch].updatedState().localPosition();
419 lxmatch=fabs(lp.
x() - chklp.
x());
420 lymatch=fabs(lp.
y() - chklp.
y());
422 if (lxmatch < maxlxmatch_ && lymatch < maxlymatch_) {
425 expTrajMeasurements.erase(expTrajMeasurements.begin()+imatch);
436 if(!expTrajMeasurements.empty()){
437 for (
size_t f=0;
f<expTrajMeasurements.size();
f++) {
440 tmeasColl.push_back(AddHit);
450 if(isBpixtrack || isFpixtrack){
451 if(trackref->pt()<0.6 ||
453 fabs(trackref->dxy(bestVtx->position()))>0.05 ||
454 fabs(trackref->dz(bestVtx->position()))>0.5)
continue;
457 std::cout <<
"isBpixtrack : " << isBpixtrack << std::endl;
458 std::cout <<
"isFpixtrack : " << isFpixtrack << std::endl;
461 for(std::vector<TrajectoryMeasurement>::const_iterator tmeasIt = tmeasColl.begin(); tmeasIt!=tmeasColl.end(); tmeasIt++){
471 const DetId & hit_detId = hit->geographicalId();
473 uint IntSubDetID = (hit_detId.
subdetId());
475 if(IntSubDetID == 0 ){
476 if(debug_)
std::cout <<
"NO IntSubDetID\n";
482 int disk=0;
int layer=0;
int panel=0;
int module=0;
bool isHalfModule=
false;
505 if(fabs(trackref->dxy(bestVtx->position()))>0.01 ||
506 fabs(trackref->dz(bestVtx->position()))>0.1)
continue;
507 if(!(L2hits>0&&L3hits>0) && !(L2hits>0&&D1hits>0) && !(D1hits>0&&D2hits>0))
continue;
509 if(fabs(trackref->dxy(bestVtx->position()))>0.02 ||
510 fabs(trackref->dz(bestVtx->position()))>0.1)
continue;
511 if(!(L1hits>0&&L3hits>0) && !(L1hits>0&&D1hits>0))
continue;
513 if(fabs(trackref->dxy(bestVtx->position()))>0.02 ||
514 fabs(trackref->dz(bestVtx->position()))>0.1)
continue;
515 if(!(L1hits>0&&L2hits>0))
continue;
517 if(fabs(trackref->dxy(bestVtx->position()))>0.05 ||
518 fabs(trackref->dz(bestVtx->position()))>0.5)
continue;
519 if(!(L1hits>0&&D2hits>0) && !(L2hits>0&&D2hits>0))
continue;
521 if(fabs(trackref->dxy(bestVtx->position()))>0.05 ||
522 fabs(trackref->dz(bestVtx->position()))>0.5)
continue;
523 if(!(L1hits>0&&D1hits>0))
continue;
527 if(fabs(trackref->dxy(bestVtx->position()))>0.01 ||
528 fabs(trackref->dz(bestVtx->position()))>0.1)
continue;
529 if(!(L2hits>0&&L3hits>0&&L4hits>0) && !(L2hits>0&&D1hits>0&&D2hits) && !(D1hits>0&&D2hits>0&&D3hits>0))
continue;
531 if(fabs(trackref->dxy(bestVtx->position()))>0.02 ||
532 fabs(trackref->dz(bestVtx->position()))>0.1)
continue;
533 if(!(L1hits>0&&L3hits>0&&L4hits>0) && !(L1hits>0&&L3hits>0&&D1hits>0) && !(L1hits>0&&D1hits>0&&D2hits>0))
continue;
535 if(fabs(trackref->dxy(bestVtx->position()))>0.02 ||
536 fabs(trackref->dz(bestVtx->position()))>0.1)
continue;
537 if(!(L1hits>0&&L2hits>0&&L4hits>0) && !(L1hits>0&&L2hits>0&&D1hits>0))
continue;
539 if(fabs(trackref->dxy(bestVtx->position()))>0.02 ||
540 fabs(trackref->dz(bestVtx->position()))>0.1)
continue;
541 if(!(L1hits>0&&L2hits>0&&L3hits>0))
continue;
543 if(fabs(trackref->dxy(bestVtx->position()))>0.05 ||
544 fabs(trackref->dz(bestVtx->position()))>0.5)
continue;
545 if(!(L1hits>0&&L2hits>0&&D2hits>0) && !(L1hits>0&&D2hits>0&&D3hits>0) && !(L2hits>0&&D2hits>0&&D3hits>0))
continue;
547 if(fabs(trackref->dxy(bestVtx->position()))>0.05 ||
548 fabs(trackref->dz(bestVtx->position()))>0.5)
continue;
549 if(!(L1hits>0&&L2hits>0&&D1hits>0) && !(L1hits>0&&D1hits>0&&D3hits>0) && !(L2hits>0&&D1hits>0&&D3hits>0))
continue;
551 if(fabs(trackref->dxy(bestVtx->position()))>0.05 ||
552 fabs(trackref->dz(bestVtx->position()))>0.5)
continue;
553 if(!(L1hits>0&&D1hits>0&&D2hits>0) && !(L2hits>0&&D1hits>0&&D2hits>0))
continue;
568 if(debug_)
std::cout <<
"the hit is persistent\n";
577 if(theGeomDet == 0) {
578 if(debug_)
std::cout <<
"NO THEGEOMDET\n";
584 std::map<uint32_t, SiPixelHitEfficiencyModule*>::iterator pxd =
theSiPixelStructure.find((*hit).geographicalId().rawId());
615 if(fabs(lx)>0.55 || fabs(ly)>3.0)
continue;
620 bool passedFiducial=
true;
625 ((module==1 && fabs(ly)<0.7) ||
626 ((module==2 && fabs(ly)<1.1) &&
627 !(disk==-1 && ly>0.8 && lx>0.2) &&
628 !(disk==1 && ly<-0.7 && lx>0.2) &&
629 !(disk==2 && ly<-0.8)) ||
630 ((module==3 && fabs(ly)<1.5) &&
631 !(disk==-2 && lx>0.1 && ly>1.0) &&
632 !(disk==2 && lx>0.1 && ly<-1.0)) ||
633 ((module==4 && fabs(ly)<1.9) &&
634 !(disk==-2 && ly>1.5) &&
635 !(disk==2 && ly<-1.5)))) ||
637 ((module==1 && fabs(ly)<0.7) ||
638 (module==2 && fabs(ly)<1.2 &&
639 !(disk>0 && ly>1.1) &&
640 !(disk<0 && ly<-1.1)) ||
641 (module==3 && fabs(ly)<1.6 &&
642 !(disk>0 && ly>1.5) &&
643 !(disk<0 && ly<-1.5)))))) passedFiducial=
false;
645 ((panel==1 && (module==1 || (module>=3 &&
abs(disk)==1))) ||
646 (panel==2 && ((module==1 &&
abs(disk)==2) ||
647 (module==3 &&
abs(disk)==1))))) passedFiducial=
false;
649 double ly_mod = fabs(ly);
651 float d_rocedge = fabs(fmod(ly_mod,0.81)-0.405);
652 if(d_rocedge<=0.0625) passedFiducial=
false;
654 ((!isHalfModule && fabs(lx)<0.6) ||
655 (isHalfModule && lx>-0.3 && lx<0.2))) ||
658 ((module==1 && fabs(lx)<0.2) ||
660 ((fabs(lx)<0.55 &&
abs(disk)==1) ||
661 (lx>-0.5 && lx<0.2 && disk==-2) ||
662 (lx>-0.5 && lx<0.0 && disk==2))) ||
663 (module==3 && lx>-0.6 && lx<0.5) ||
664 (module==4 && lx>-0.3 && lx<0.15))) ||
666 ((module==1 && fabs(lx)<0.6) ||
668 ((fabs(lx)<0.55 &&
abs(disk)==1) ||
669 (lx>-0.6 && lx<0.5 &&
abs(disk)==2))) ||
670 (module==3 && fabs(lx)<0.5))))))) passedFiducial=
false;
673 fabs(lx)<0.06) passedFiducial=
false;
677 float dx_cl[2];
float dy_cl[2]; dx_cl[0]=dx_cl[1]=dy_cl[0]=dy_cl[1]=-9999.;
688 if(clusterCollectionHandle.
isValid()){
691 float minD[2]; minD[0]=minD[1]=10000.;
692 for( ; itClusterSet!=clusterCollection.
end(); itClusterSet++){
693 DetId detId(itClusterSet->
id());
694 if(detId.rawId()!=hit->geographicalId().rawId())
continue;
698 for( ; itCluster!=itClusterSet->
end(); ++itCluster){
699 LocalPoint lp(itCluster->x(), itCluster->y(), 0.);
701 lp=std::get<0>(params);
702 float D =
sqrt((lp.
x()-lx)*(lp.
x()-lx)+(lp.
y()-ly)*(lp.
y()-ly));
717 for(
size_t i=0;
i<2;
i++){
719 dx_cl[
i]=fabs(dx_cl[
i]-lx);
720 dy_cl[
i]=fabs(dy_cl[
i]-ly);
727 float d_cl[2]; d_cl[0]=d_cl[1]=-9999.;
728 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]);
729 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]);
730 if(isHitMissing && (d_cl[0]<0.05 || d_cl[1]<0.05)){ isHitMissing=0; isHitValid=1; }
734 std::cout <<
"Ready to add hit in histogram:\n";
736 std::cout <<
"isHitValid: "<<isHitValid<<std::endl;
737 std::cout <<
"isHitMissing: "<<isHitMissing<<std::endl;
758 if(debug_)
std::cout <<
"no pixeltrack:\n";
int plaquetteName() const
plaquetteId (in pannel)
edm::EDGetTokenT< MeasurementTrackerEvent > measurementTrackerEventToken_
T getParameter(std::string const &) const
~SiPixelHitEfficiencySource()
T getUntrackedParameter(std::string const &, T const &) const
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
virtual void setPropagationDirection(PropagationDirection dir)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
ConstRecHitPointer const & recHit() const
SiPixelHitEfficiencySource(const edm::ParameterSet &)
const LocalTrajectoryParameters & localParameters() const
friend struct const_iterator
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
LocalPoint localPosition() const
virtual void analyze(const edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > clusterCollectionToken_
std::map< uint32_t, SiPixelHitEfficiencyModule * > theSiPixelStructure
GlobalPoint globalPosition() const
bool isHalfModule() const
full or half module
std::vector< Vertex > VertexCollection
collection of Vertex objects
unsigned int ladder() const
ladder id
data_type const * const_iterator
id_type id(size_t cell) const
int plaquetteName() const
plaquetteId (in pannel)
edm::EDGetTokenT< reco::VertexCollection > vertexCollectionToken_
virtual ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const =0
virtual void endJob(void)
bool isHalfModule() const
full or half module
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
virtual void beginRun(const edm::Run &r, edm::EventSetup const &iSetup)
bool setModuleFolder(const uint32_t &rawdetid=0, int type=0, bool isUpgrade=false)
Set folder name for a module or plaquette.
edm::EDGetTokenT< TrajTrackAssociationCollection > tracksrc_
unsigned int module() const
det id
Abs< T >::type abs(const T &t)
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")
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
virtual const GeomDet * idToDet(DetId) const
int diskName() const
disk id
size_type size() const
map size
key_type key() const
Accessor for product key.
int layerName() const
layer id
T const * product() const
T const * product() const
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
int pannelName() const
pannel id
int diskName() const
disk id
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
const_iterator begin() const
first iterator over the map (read only)
volatile std::atomic< bool > shutdown_flag false
std::tuple< LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType > ReturnType
int pannelName() const
pannel id
DecomposeProduct< arg, typename Div::arg > D
int layerName() const
layer id
const_iterator begin(bool update=false) const