157 if (
DEBUG)
cout <<
"beginning analyze from HitEff" << endl;
160 using namespace reco;
163 int run_nr = e.
id().
run();
172 if (lumiScalers->begin() != lumiScalers->end()) {
173 instLumi = lumiScalers->begin()->instantLumi();
174 PU = lumiScalers->begin()->pileup();
205 es.get<
TkStripCPERecord>().
get(
"StripCPEfromTrackAngle", parameterestimator);
274 if (
DEBUG)
cout <<
"number ckf tracks found = " << tracksCKF->size() << endl;
276 if (!tracksCKF->empty()) {
300 if(e.
getByLabel(
"muonsWitht0Correction",muH)){
302 if(!muonsT0.empty()) {
308 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
309 if (hasCaloEnergyInfo)
timeECAL = muonsT0[0].calEnergy().ecal_time;
317 for (vector<Trajectory>::const_iterator itraj = TrajectoryCollectionCKF.
product()->begin();
318 itraj != TrajectoryCollectionCKF.
product()->end();
322 nHits = itraj->foundHits();
324 chi2 = (itraj->chiSquared()/itraj->ndof());
325 pT =
sqrt( ( itraj->lastMeasurement().updatedState().globalMomentum().x() *
326 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
327 ( itraj->lastMeasurement().updatedState().globalMomentum().y() *
328 itraj->lastMeasurement().updatedState().globalMomentum().y()) );
329 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
334 std::vector<TrajectoryMeasurement> TMeas=itraj->measurements();
335 vector<TrajectoryMeasurement>::iterator itm;
340 double angleX = -999.;
341 double angleY = -999.;
342 double xglob,yglob,zglob;
344 for (itm=TMeas.begin();itm!=TMeas.end();itm++){
345 auto theInHit = (*itm).recHit();
347 if(
DEBUG)
cout <<
"theInHit is valid = " << theInHit->isValid() << endl;
349 unsigned int iidd = theInHit->geographicalId().rawId();
351 unsigned int TKlayers =
checkLayer(iidd, tTopo);
352 if (
DEBUG)
cout <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
355 if ( TKlayers == 10 || TKlayers == 22 ) {
356 if (
DEBUG)
cout <<
"skipping original TM for TOB 6 or TEC 9" << endl;
361 std::vector<TrajectoryAtInvalidHit> TMs;
379 if (
DEBUG)
cout <<
" found a hit with a missing partner" << endl;
391 bool isValid = theInHit->isValid();
392 bool isLast = (itm==(TMeas.end()-1));
393 bool isLastTOB5 =
true;
395 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 9 ) isLastTOB5 =
false;
396 else isLastTOB5 =
true;
400 if ( TKlayers==9 && isValid && isLastTOB5 ) {
403 std::vector< BarrelDetLayer const*> barrelTOBLayers = measurementTrackerHandle->geometricSearchTracker()->tobLayers() ;
404 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size()-1];
408 vector<TrajectoryMeasurement>
tmp = theLayerMeasurements->
measurements(*tob6, tsosTOB5, *thePropagator, *estimator);
411 if (
DEBUG)
cout <<
"size of TM from propagation = " << tmp.size() << endl;
417 const auto& tob6Hit = tob6TM.
recHit();
419 if (tob6Hit->geographicalId().rawId()!=0) {
420 if (
DEBUG)
cout <<
"tob6 hit actually being added to TM vector" << endl;
426 bool isLastTEC8 =
true;
428 if (
checkLayer((++itm)->
recHit()->geographicalId().rawId(), tTopo) == 21 ) isLastTEC8 =
false;
429 else isLastTEC8 =
true;
433 if ( TKlayers==21 && isValid && isLastTEC8 ) {
435 std::vector< const ForwardDetLayer*> posTecLayers = measurementTrackerHandle->geometricSearchTracker()->posTecLayers() ;
436 const DetLayer* tec9pos = posTecLayers[posTecLayers.size()-1];
437 std::vector< const ForwardDetLayer*> negTecLayers = measurementTrackerHandle->geometricSearchTracker()->negTecLayers() ;
438 const DetLayer* tec9neg = negTecLayers[negTecLayers.size()-1];
448 vector<TrajectoryMeasurement>
tmp;
449 if ( tTopo->
tecSide(iidd) == 1 ) {
450 tmp = theLayerMeasurements->
measurements(*tec9neg, tsosTEC9, *thePropagator, *estimator);
453 if ( tTopo->
tecSide(iidd) == 2 ) {
454 tmp = theLayerMeasurements->
measurements(*tec9pos, tsosTEC9, *thePropagator, *estimator);
463 const auto& tec9Hit = tec9TM.
recHit();
465 unsigned int tec9id = tec9Hit->geographicalId().rawId();
466 if (
DEBUG)
cout <<
"tec9id = " << tec9id <<
" is Double sided = " <<
isDoubleSided(tec9id, tTopo) <<
" and 0x3 = " << (tec9id & 0x3) << endl;
468 if (tec9Hit->geographicalId().rawId()!=0) {
469 if (
DEBUG)
cout <<
"tec9 hit actually being added to TM vector" << endl;
485 for(std::vector<TrajectoryAtInvalidHit>::const_iterator TM=TMs.begin();TM!=TMs.end();++TM) {
488 iidd = TM->monodet_id();
489 if (
DEBUG)
cout <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
494 xErr = TM->localErrorX();
495 yErr = TM->localErrorY();
497 angleX = atan( TM->localDxDz() );
498 angleY = atan( TM->localDyDz() );
500 xglob = TM->globalX();
501 yglob = TM->globalY();
502 zglob = TM->globalZ();
513 if (
DEBUG)
cout <<
"Looking at layer under study" << endl;
522 if (!input.
empty() ) {
523 if (
DEBUG)
cout <<
"Checking clusters with size = " << input.
size() << endl;
525 std::vector< std::vector<float> > VCluster_info;
529 unsigned int ClusterId = DSViter->id();
530 if (ClusterId == iidd) {
531 if (
DEBUG)
cout <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
532 DetId ClusterDetId(ClusterId);
543 const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
544 std::array<const float, 4>
const & parameterTrap = (*trapezoidalBounds).
parameters();
545 hbedge = parameterTrap[0];
546 htedge = parameterTrap[1];
547 hapoth = parameterTrap[3];
548 uylfac = (htedge-hbedge)/(htedge+hbedge)/hapoth;
549 uxlden = 1 + yloc*uylfac;
553 if( TrajStrip==-1 ) {
556 TrajStrip = xloc/pitch + nstrips/2.0;
559 float TrajLocXMid = xloc / (1 + (htedge-hbedge)*yloc/(htedge+hbedge)/hapoth) ;
560 TrajStrip = TrajLocXMid/pitch + nstrips/2.0;
569 float res = (parameters.first.x() - xloc);
578 res = parameters.first.x() - xloc/uxlden ;
579 sigma =
abs(res) /
sqrt(parameters.second.xx() + xErr*xErr/uxlden/uxlden + yErr*yErr*xloc*xloc*uylfac*uylfac/uxlden/uxlden/uxlden/uxlden);
586 std::vector< float > cluster_info;
587 cluster_info.push_back(res);
588 cluster_info.push_back(sigma);
589 cluster_info.push_back(parameters.first.x());
590 cluster_info.push_back(
sqrt(parameters.second.xx()));
591 cluster_info.push_back(parameters.first.y());
592 cluster_info.push_back(
sqrt(parameters.second.yy()));
593 cluster_info.push_back( clusterInfo.signalOverNoise() );
595 VCluster_info.push_back(cluster_info);
597 if (
DEBUG)
cout <<
"Have ID match. residual = " << VCluster_info.back()[0] <<
" res sigma = " << VCluster_info.back()[1] << endl;
598 if (
DEBUG)
cout <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
599 if (
DEBUG)
cout <<
"hit position = " << parameters.first.x() <<
" hit error = " <<
sqrt(parameters.second.xx()) <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
603 float FinalResSig = 1000.0;
604 float FinalCluster[7]= {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
606 if (
DEBUG)
cout <<
"found clusters > 0" << endl;
609 vector< vector<float> >::iterator
ires;
610 for (ires=VCluster_info.begin(); ires!=VCluster_info.end(); ires++){
611 if (
abs((*ires)[1]) <
abs(FinalResSig)) {
612 FinalResSig = (*ires)[1];
613 for (
unsigned int i = 0;
i<ires->size();
i++) {
614 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
615 FinalCluster[
i] = (*ires)[
i];
616 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
619 if (
DEBUG)
cout <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1] <<
" and FinalRes = " << FinalCluster[0] << endl;
623 FinalResSig = VCluster_info.at(0)[1];
624 for (
unsigned int i = 0;
i<VCluster_info.at(0).size();
i++) {
625 FinalCluster[
i] = VCluster_info.at(0)[
i];
629 VCluster_info.clear();
632 if (
DEBUG)
cout <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0]/FinalResSig) << endl;
633 if (
DEBUG)
cout <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc) <<
" abs(xloc) = " <<
abs(xloc) << endl;
634 if (
DEBUG)
cout <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5] <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
635 if (
DEBUG)
cout <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
637 float exclusionWidth = 0.4;
638 float TOBexclusion = 0.0;
639 float TECexRing5 = -0.89;
640 float TECexRing6 = -0.56;
641 float TECexRing7 = 0.60;
644 int ringnumber = ((iidd>>5) & 0x7);
647 if((TKlayers >= 5 && TKlayers < 11)||((subdetector == 6)&&( (ringnumber >= 5)&&(ringnumber <=7) ))) {
649 float highzone = 0.0;
651 float higherr = yloc + 5.0*yErr;
652 float lowerr = yloc - 5.0*yErr;
653 if(TKlayers >= 5 && TKlayers < 11) {
655 highzone = TOBexclusion + exclusionWidth;
656 lowzone = TOBexclusion - exclusionWidth;
657 }
else if (ringnumber == 5) {
659 highzone = TECexRing5 + exclusionWidth;
660 lowzone = TECexRing5 - exclusionWidth;
661 }
else if (ringnumber == 6) {
663 highzone = TECexRing6 + exclusionWidth;
664 lowzone = TECexRing6 - exclusionWidth;
665 }
else if (ringnumber == 7) {
667 highzone = TECexRing7 + exclusionWidth;
668 lowzone = TECexRing7 - exclusionWidth;
689 if(
DEBUG)
cout <<
"strip is bad from SiStripQuality" << endl;
692 if(
DEBUG)
cout <<
"strip is good from SiStripQuality" << endl;
696 for (
unsigned int ii=0;
ii< fedErrorIds->
size();
ii++) {
697 if (iidd == (*fedErrorIds)[
ii].rawId() )
707 ResX = FinalCluster[0];
709 if (FinalResSig != FinalCluster[1])
if (
DEBUG)
cout <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
718 if(commonModeDigis.
isValid() && TrajStrip>=0 && TrajStrip<=768) {
720 if(digiframe != commonModeDigis->end())
721 if( (
unsigned) TrajStrip/128 < digiframe->data.
size())
722 commonMode = digiframe->data.at(TrajStrip/128).adc();
725 if (
DEBUG)
cout <<
"before check good" << endl;
727 if ( FinalResSig < 999.0) {
729 if (
DEBUG)
cout <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " <<
730 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
731 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
736 if (
DEBUG)
cout <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0] <<
" FinalRecHit " <<
737 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
738 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
742 if (
DEBUG)
cout <<
" RPhi Error " <<
sqrt(xErr*xErr + yErr*yErr) <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
743 }
if (
DEBUG)
cout <<
"after good location check" << endl;
744 }
if (
DEBUG)
cout <<
"after list of clusters" << endl;
745 }
if (
DEBUG)
cout <<
"After layers=TKLayers if" << endl;
746 }
if (
DEBUG)
cout <<
"After looping over TrajAtValidHit list" << endl;
747 }
if (
DEBUG)
cout <<
"end TMeasurement loop" << endl;
748 }
if (
DEBUG)
cout <<
"end of trajectories loop" << endl;
EventNumber_t event() const
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
bool check2DPartner(unsigned int iidd, const std::vector< TrajectoryMeasurement > &traj)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
ConstRecHitPointer const & recHit() const
virtual const std::array< const float, 4 > parameters() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< Track > TrackCollection
collection of Tracks
int bunchCrossing() const
const Bounds & bounds() const
std::pair< LocalPoint, LocalError > LocalValues
data_type const * const_iterator
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
const Plane & surface() const
The nominal surface of the GeomDet.
std::vector< Muon > MuonCollection
collection of Muon objects
const edm::EDGetTokenT< MeasurementTrackerEvent > trackerEvent_token_
static std::string const input
virtual float width() const =0
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
bool isDoubleSided(unsigned int iidd, const TrackerTopology *tTopo) const
short getBadApvs(const uint32_t &detid) const
const edm::EDGetTokenT< DetIdCollection > digis_token_
int nDof
number of muon stations used
Abs< T >::type abs(const T &t)
unsigned int trajHitValid
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
size_type size() const
Return the number of contained DetSets.
double checkConsistency(const StripClusterParameterEstimator::LocalValues ¶meters, double xx, double xerr)
T const * product() const
virtual int nstrips() const =0
unsigned int trackMultiplicityCut_
unsigned int checkLayer(unsigned int iidd, const TrackerTopology *tTopo)
const edm::EDGetTokenT< reco::TrackCollection > combinatorialTracks_token_
unsigned int SiStripQualBad
std::vector< std::vector< double > > tmp
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
collection_type::const_iterator const_iterator
const edm::EDGetTokenT< LumiScalersCollection > scalerToken_
const edm::EDGetTokenT< std::vector< Trajectory > > trajectories_token_
T const * product() const
const edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > commonModeToken_
const_iterator begin(bool update=false) const
unsigned int tecSide(const DetId &id) const