75 modOn( pSet.getUntrackedParameter<bool>(
"modOn",
true) ),
76 ladOn( pSet.getUntrackedParameter<bool>(
"ladOn",
false) ),
77 layOn( pSet.getUntrackedParameter<bool>(
"layOn",
false) ),
78 phiOn( pSet.getUntrackedParameter<bool>(
"phiOn",
false) ),
79 ringOn( pSet.getUntrackedParameter<bool>(
"ringOn",
false) ),
80 bladeOn( pSet.getUntrackedParameter<bool>(
"bladeOn",
false) ),
81 diskOn( pSet.getUntrackedParameter<bool>(
"diskOn",
false) ),
82 isUpgrade( pSet.getUntrackedParameter<bool>(
"isUpgrade",
false) )
98 LogInfo(
"PixelDQM") <<
"SiPixelHitEfficiencySource constructor" << endl;
107 LogInfo(
"PixelDQM") <<
"SiPixelHitEfficiencySource destructor" << endl;
109 std::map<uint32_t,SiPixelHitEfficiencyModule*>::iterator struct_iter;
111 delete struct_iter->second;
112 struct_iter->second = 0;
153 LogInfo(
"PixelDQM") <<
"SiPixelHitEfficiencySource beginRun()" << endl;
166 if (
debug_)
LogVerbatim(
"PixelDQM") <<
"TrackerGeometry "<< &(*TG) <<
" size is "<< TG->
dets().size() << endl;
169 for (TrackerGeometry::DetContainer::const_iterator pxb = TG->
detsPXB().begin();
170 pxb!=TG->
detsPXB().end(); pxb++) {
171 if (dynamic_cast<PixelGeomDetUnit const *>((*pxb))!=0) {
176 for (TrackerGeometry::DetContainer::const_iterator pxf = TG->
detsPXF().begin();
177 pxf!=TG->
detsPXF().end(); pxf++) {
178 if (dynamic_cast<PixelGeomDetUnit const *>((*pxf))!=0) {
191 for (std::map<uint32_t, SiPixelHitEfficiencyModule*>::iterator pxd =
theSiPixelStructure.begin();
196 else throw cms::Exception(
"LogicError") <<
"SiPixelHitEfficiencySource Folder Creation Failed! ";
200 else throw cms::Exception(
"LogicError") <<
"SiPixelHitEfficiencySource ladder Folder Creation Failed! ";
204 else throw cms::Exception(
"LogicError") <<
"SiPixelHitEfficiencySource layer Folder Creation Failed! ";
208 else throw cms::Exception(
"LogicError") <<
"SiPixelHitEfficiencySource phi Folder Creation Failed! ";
212 else throw cms::Exception(
"LogicError") <<
"SiPixelHitEfficiencySource Blade Folder Creation Failed! ";
216 else throw cms::Exception(
"LogicError") <<
"SiPixelHitEfficiencySource Disk Folder Creation Failed! ";
220 else throw cms::Exception(
"LogicError") <<
"SiPixelHitEfficiencySource Ring Folder Creation Failed! ";
269 if(!vertexCollectionHandle.
isValid())
return;
274 reco::VertexCollection::const_iterator bestVtx=vertices.end();
275 for(reco::VertexCollection::const_iterator it=vertices.begin(); it!=vertices.end(); ++it){
276 if(!it->isValid())
continue;
279 (
vtxntrk_==
int(it->tracksSize()) && fabs(
vtxZ_)>fabs(it->z()))){
281 vtxD0_=it->position().rho();
289 if(fabs(it->z())<=20. && fabs(it->position().rho())<=2. && it->ndof()>4)
nvtx_++;
308 std::cout <<
"+++ NEW EVENT +++"<< std::endl;
309 std::cout <<
"Map entries \t : " << ttac.
size() << std::endl;
312 std::set<SiPixelCluster> clusterSet;
315 int extrapolateFrom_ = 2;
316 int extrapolateTo_ = 1;
317 float maxlxmatch_=0.2;
318 float maxlymatch_=0.2;
319 bool keepOriginalMissingHit_=
true;
332 if (extrapolateFrom_>=extrapolateTo_) {
341 std::vector<TrajectoryMeasurement> expTrajMeasurements;
348 bool isBpixtrack =
false, isFpixtrack =
false;
349 int nStripHits=0;
int L1hits=0;
int L2hits=0;
int L3hits=0;
int L4hits=0;
int D1hits=0;
int D2hits=0;
int D3hits=0;
350 std::vector<TrajectoryMeasurement> tmeasColl =traj_iterator->measurements();
351 std::vector<TrajectoryMeasurement>::const_iterator tmeasIt;
353 for(tmeasIt = tmeasColl.begin();tmeasIt!=tmeasColl.end();tmeasIt++){
357 uint testSubDetID = (testhit->geographicalId().subdetId());
358 const DetId & hit_detId = testhit->geographicalId();
371 if(hit_layer==1) L1hits++;
372 if(hit_layer==2) L2hits++;
373 if(hit_layer==3) L3hits++;
374 if(hit_layer==4) L4hits++;
380 if(hit_disk==1) D1hits++;
381 if(hit_disk==2) D2hits++;
382 if(hit_disk==3) D3hits++;
390 bool lastValidL2 =
false;
393 if (testhit->isValid()) {
394 if (tmeasIt == tmeasColl.end()-1) {
399 uint nextSubDetID = (nextRecHit->geographicalId().subdetId());
400 int nextlayer =
PixelBarrelName(nextRecHit->geographicalId()).layerName();
409 std::vector< const BarrelDetLayer*> pxbLayers = measurementTrackerHandle->geometricSearchTracker()->pixelBarrelLayers();
410 const DetLayer* pxb1 = pxbLayers[extrapolateTo_-1];
414 expTrajMeasurements = theLayerMeasurements->
measurements(*pxb1, tsosPXB2, *thePropagator, *estimator);
415 delete theLayerMeasurements;
416 if ( !expTrajMeasurements.empty()) {
417 for(uint
p=0;
p<expTrajMeasurements.size();
p++){
419 auto pxb1Hit = pxb1TM.
recHit();
421 if(pxb1Hit->geographicalId().rawId()==0){
422 expTrajMeasurements.erase(expTrajMeasurements.begin()+
p);
430 TrajectoryStateOnSurface chkPredTrajState=trajStateComb(tmeasIt->forwardPredictedState(), tmeasIt->backwardPredictedState());
431 if (!chkPredTrajState.
isValid())
continue;
438 vector<int > imatches;
441 for (
size_t iexp=0; iexp<expTrajMeasurements.size(); iexp++) {
442 const DetId & exphit_detId = expTrajMeasurements[iexp].recHit()->geographicalId();
445 int dladder =
abs( exphit_ladder - hit_ladder );
446 if (dladder > 10) dladder = 20 - dladder;
447 int dmodule =
abs( exphit_mod - hit_mod);
448 if (dladder != 0 || dmodule != 0) {
456 float dxyz=
sqrt((chkx-x)*(chkx-x)+(chky-y)*(chky-y)+(chkz-z)*(chkz-z));
461 imatches.push_back(
int(imatch));
466 float lxmatch = 9999.0;
467 float lymatch = 9999.0;
468 if(!expTrajMeasurements.empty()){
470 const DetId & matchhit_detId = expTrajMeasurements[imatch].recHit()->geographicalId();
473 int dladder =
abs(matchhit_ladder-hit_ladder);
474 if (dladder > 10) dladder = 20 - dladder;
475 LocalPoint lp = expTrajMeasurements[imatch].updatedState().localPosition();
476 lxmatch=fabs(lp.
x() - chklp.
x());
477 lymatch=fabs(lp.
y() - chklp.
y());
479 if (lxmatch < maxlxmatch_ && lymatch < maxlymatch_) {
482 expTrajMeasurements.erase(expTrajMeasurements.begin()+imatch);
493 if(!expTrajMeasurements.empty()){
494 for (
size_t f=0;
f<expTrajMeasurements.size();
f++) {
497 tmeasColl.push_back(AddHit);
505 if(isBpixtrack || isFpixtrack){
506 if(trackref->pt()<0.6 ||
508 fabs(trackref->dxy(bestVtx->position()))>0.05 ||
509 fabs(trackref->dz(bestVtx->position()))>0.5)
continue;
512 std::cout <<
"isBpixtrack : " << isBpixtrack << std::endl;
513 std::cout <<
"isFpixtrack : " << isFpixtrack << std::endl;
516 for(std::vector<TrajectoryMeasurement>::const_iterator tmeasIt = tmeasColl.begin(); tmeasIt!=tmeasColl.end(); tmeasIt++){
526 const DetId & hit_detId = hit->geographicalId();
528 uint IntSubDetID = (hit_detId.
subdetId());
530 if(IntSubDetID == 0 ){
531 if(debug_)
std::cout <<
"NO IntSubDetID\n";
537 int disk=0;
int layer=0;
int panel=0;
int module=0;
bool isHalfModule=
false;
566 if(fabs(trackref->dxy(bestVtx->position()))>0.01 ||
567 fabs(trackref->dz(bestVtx->position()))>0.1)
continue;
568 if(!(L2hits>0&&L3hits>0) && !(L2hits>0&&D1hits>0) && !(D1hits>0&&D2hits>0))
continue;
570 if(fabs(trackref->dxy(bestVtx->position()))>0.02 ||
571 fabs(trackref->dz(bestVtx->position()))>0.1)
continue;
572 if(!(L1hits>0&&L3hits>0) && !(L1hits>0&&D1hits>0))
continue;
574 if(fabs(trackref->dxy(bestVtx->position()))>0.02 ||
575 fabs(trackref->dz(bestVtx->position()))>0.1)
continue;
576 if(!(L1hits>0&&L2hits>0))
continue;
578 if(fabs(trackref->dxy(bestVtx->position()))>0.02 ||
579 fabs(trackref->dz(bestVtx->position()))>0.1)
continue;
581 if(fabs(trackref->dxy(bestVtx->position()))>0.05 ||
582 fabs(trackref->dz(bestVtx->position()))>0.5)
continue;
583 if(!(L1hits>0&&D2hits>0) && !(L2hits>0&&D2hits>0))
continue;
585 if(fabs(trackref->dxy(bestVtx->position()))>0.05 ||
586 fabs(trackref->dz(bestVtx->position()))>0.5)
continue;
587 if(!(L1hits>0&&D1hits>0))
continue;
589 if(fabs(trackref->dxy(bestVtx->position()))>0.05 ||
590 fabs(trackref->dz(bestVtx->position()))>0.5)
continue;
597 if(debug_)
std::cout <<
"the hit is persistent\n";
599 std::map<uint32_t, SiPixelHitEfficiencyModule*>::iterator pxd =
theSiPixelStructure.find((*hit).geographicalId().rawId());
609 if(fabs(lx)>0.55 || fabs(ly)>3.0)
continue;
611 bool passedFiducial=
true;
617 ((module==1 && fabs(ly)<0.7) ||
618 ((module==2 && fabs(ly)<1.1) &&
619 !(disk==-1 && ly>0.8 && lx>0.2) &&
620 !(disk==1 && ly<-0.7 && lx>0.2) &&
621 !(disk==2 && ly<-0.8)) ||
622 ((module==3 && fabs(ly)<1.5) &&
623 !(disk==-2 && lx>0.1 && ly>1.0) &&
624 !(disk==2 && lx>0.1 && ly<-1.0)) ||
625 ((module==4 && fabs(ly)<1.9) &&
626 !(disk==-2 && ly>1.5) &&
627 !(disk==2 && ly<-1.5)))) ||
629 ((module==1 && fabs(ly)<0.7) ||
630 (module==2 && fabs(ly)<1.2 &&
631 !(disk>0 && ly>1.1) &&
632 !(disk<0 && ly<-1.1)) ||
633 (module==3 && fabs(ly)<1.6 &&
634 !(disk>0 && ly>1.5) &&
635 !(disk<0 && ly<-1.5)))))) passedFiducial=
false;
637 ((panel==1 && (module==1 || (module>=3 &&
abs(disk)==1))) ||
638 (panel==2 && ((module==1 &&
abs(disk)==2) ||
639 (module==3 &&
abs(disk)==1))))) passedFiducial=
false;
641 double ly_mod = fabs(ly);
643 float d_rocedge = fabs(fmod(ly_mod,0.81)-0.405);
644 if(d_rocedge<=0.0625) passedFiducial=
false;
646 ((!isHalfModule && fabs(lx)<0.6) ||
647 (isHalfModule && lx>-0.3 && lx<0.2))) ||
650 ((module==1 && fabs(lx)<0.2) ||
652 ((fabs(lx)<0.55 &&
abs(disk)==1) ||
653 (lx>-0.5 && lx<0.2 && disk==-2) ||
654 (lx>-0.5 && lx<0.0 && disk==2))) ||
655 (module==3 && lx>-0.6 && lx<0.5) ||
656 (module==4 && lx>-0.3 && lx<0.15))) ||
658 ((module==1 && fabs(lx)<0.6) ||
660 ((fabs(lx)<0.55 &&
abs(disk)==1) ||
661 (lx>-0.6 && lx<0.5 &&
abs(disk)==2))) ||
662 (module==3 && fabs(lx)<0.5))))))) passedFiducial=
false;
665 fabs(lx)<0.06) passedFiducial=
false;
669 float dx_cl[2];
float dy_cl[2]; dx_cl[0]=dx_cl[1]=dy_cl[0]=dy_cl[1]=-9999.;
680 if(clusterCollectionHandle.
isValid()){
683 float minD[2]; minD[0]=minD[1]=10000.;
684 for( ; itClusterSet!=clusterCollection.
end(); itClusterSet++){
685 DetId detId(itClusterSet->
id());
686 if(detId.rawId()!=hit->geographicalId().rawId())
continue;
690 for( ; itCluster!=itClusterSet->
end(); ++itCluster){
691 LocalPoint lp(itCluster->x(), itCluster->y(), 0.);
693 lp=std::get<0>(params);
694 float D =
sqrt((lp.
x()-lx)*(lp.
x()-lx)+(lp.
y()-ly)*(lp.
y()-ly));
709 for(
size_t i=0;
i<2;
i++){
711 dx_cl[
i]=fabs(dx_cl[
i]-lx);
712 dy_cl[
i]=fabs(dy_cl[
i]-ly);
719 float d_cl[2]; d_cl[0]=d_cl[1]=-9999.;
720 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]);
721 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]);
722 if(isHitMissing && (d_cl[0]<0.05 || d_cl[1]<0.05)){ isHitMissing=0; isHitValid=1; }
725 std::cout <<
"Ready to add hit in histogram:\n";
727 std::cout <<
"isHitValid: "<<isHitValid<<std::endl;
728 std::cout <<
"isHitMissing: "<<isHitMissing<<std::endl;
732 if (nStripHits<11)
continue;
750 if(debug_)
std::cout <<
"no pixeltrack:\n";
int plaquetteName() const
plaquetteId (in pannel)
edm::EDGetTokenT< MeasurementTrackerEvent > measurementTrackerEventToken_
T getParameter(std::string const &) const
~SiPixelHitEfficiencySource()
MonitorElement * meClusterProbabilityL2_Plus_
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)
virtual ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const =0
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
virtual Propagator * clone() const =0
float clusterProbability(unsigned int flags=0) 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
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > clusterCollectionToken_
std::map< uint32_t, SiPixelHitEfficiencyModule * > theSiPixelStructure
MonitorElement * meClusterProbabilityL1_Minus_
GlobalPoint globalPosition() const
std::vector< Vertex > VertexCollection
collection of Vertex objects
MonitorElement * meClusterProbabilityL3_Plus_
unsigned int ladder() const
ladder id
data_type const * const_iterator
key_type key() const
Accessor for product key.
virtual void fillClusterProbability(int, int, bool, double)
id_type id(size_t cell) const
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< reco::VertexCollection > vertexCollectionToken_
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
bool isHalfModule() const
full or half module
MonitorElement * meClusterProbabilityL3_Minus_
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
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_
const DetContainer & detsPXB() const
MonitorElement * book1D(Args &&...args)
unsigned int module() const
det id
Abs< T >::type abs(const T &t)
MonitorElement * meClusterProbabilityD1_Minus_
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
MonitorElement * meClusterProbabilityD1_Plus_
MonitorElement * meClusterProbabilityL1_Plus_
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
void setCurrentFolder(const std::string &fullpath)
DecomposeProduct< arg, typename Div::arg > D
size_type size() const
map size
T const * product() const
int layerName() const
layer id
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
int pannelName() const
pannel id
const DetContainer & detsPXF() const
int diskName() const
disk id
MonitorElement * meClusterProbabilityD2_Plus_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
MonitorElement * meClusterProbabilityL2_Minus_
const_iterator begin() const
first iterator over the map (read only)
std::tuple< LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType > ReturnType
MonitorElement * meClusterProbabilityD2_Minus_
HalfCylinder halfCylinder() const
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
T const * product() const
virtual void dqmBeginRun(const edm::Run &r, edm::EventSetup const &iSetup) override
const_iterator begin(bool update=false) const