156 if (
DEBUG)
cout <<
"beginning analyze from HitEff" << endl;
159 using namespace reco;
162 int run_nr = e.
id().
run();
171 if (lumiScalers->begin() != lumiScalers->end()) {
172 instLumi = lumiScalers->begin()->instantLumi();
173 PU = lumiScalers->begin()->pileup();
204 es.get<
TkStripCPERecord>().
get(
"StripCPEfromTrackAngle", parameterestimator);
238 const Propagator* thePropagator = prop.product();
273 if (
DEBUG)
cout <<
"number ckf tracks found = " << tracksCKF->size() << endl;
275 if (tracksCKF->size() > 0 && tracksCKF->size()<100) {
276 if (
DEBUG)
cout <<
"starting checking good event with < 100 tracks" << endl;
298 if(e.
getByLabel(
"muonsWitht0Correction",muH)){
300 if(muonsT0.size()!=0) {
306 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
307 if (hasCaloEnergyInfo)
timeECAL = muonsT0[0].calEnergy().ecal_time;
315 for (vector<Trajectory>::const_iterator itraj = TrajectoryCollectionCKF.product()->begin();
316 itraj != TrajectoryCollectionCKF.product()->end();
320 nHits = itraj->foundHits();
322 chi2 = (itraj->chiSquared()/itraj->ndof());
323 pT =
sqrt( ( itraj->lastMeasurement().updatedState().globalMomentum().x() *
324 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
325 ( itraj->lastMeasurement().updatedState().globalMomentum().y() *
326 itraj->lastMeasurement().updatedState().globalMomentum().y()) );
327 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
332 std::vector<TrajectoryMeasurement> TMeas=itraj->measurements();
333 vector<TrajectoryMeasurement>::iterator itm;
338 double angleX = -999.;
339 double angleY = -999.;
340 double xglob,yglob,zglob;
342 for (itm=TMeas.begin();itm!=TMeas.end();itm++){
343 auto theInHit = (*itm).recHit();
345 if(
DEBUG)
cout <<
"theInHit is valid = " << theInHit->isValid() << endl;
347 unsigned int iidd = theInHit->geographicalId().rawId();
349 unsigned int TKlayers =
checkLayer(iidd, tTopo);
350 if (
DEBUG)
cout <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
353 if ( TKlayers == 10 || TKlayers == 22 ) {
354 if (
DEBUG)
cout <<
"skipping original TM for TOB 6 or TEC 9" << endl;
359 std::vector<TrajectoryAtInvalidHit> TMs;
377 if (
DEBUG)
cout <<
" found a hit with a missing partner" << endl;
389 bool isValid = theInHit->isValid();
390 bool isLast = (itm==(TMeas.end()-1));
391 bool isLastTOB5 =
true;
393 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 9 ) isLastTOB5 =
false;
394 else isLastTOB5 =
true;
398 if ( TKlayers==9 && isValid && isLastTOB5 ) {
401 std::vector< BarrelDetLayer const*> barrelTOBLayers = measurementTrackerHandle->geometricSearchTracker()->tobLayers() ;
402 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size()-1];
406 vector<TrajectoryMeasurement>
tmp = theLayerMeasurements->
measurements(*tob6, tsosTOB5, *thePropagator, *estimator);
409 if (
DEBUG)
cout <<
"size of TM from propagation = " << tmp.size() << endl;
415 auto tob6Hit = tob6TM.
recHit();
417 if (tob6Hit->geographicalId().rawId()!=0) {
418 if (
DEBUG)
cout <<
"tob6 hit actually being added to TM vector" << endl;
424 bool isLastTEC8 =
true;
426 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 21 ) isLastTEC8 =
false;
427 else isLastTEC8 =
true;
431 if ( TKlayers==21 && isValid && isLastTEC8 ) {
433 std::vector< const ForwardDetLayer*> posTecLayers = measurementTrackerHandle->geometricSearchTracker()->posTecLayers() ;
434 const DetLayer* tec9pos = posTecLayers[posTecLayers.size()-1];
435 std::vector< const ForwardDetLayer*> negTecLayers = measurementTrackerHandle->geometricSearchTracker()->negTecLayers() ;
436 const DetLayer* tec9neg = negTecLayers[negTecLayers.size()-1];
446 vector<TrajectoryMeasurement>
tmp;
447 if ( tTopo->
tecSide(iidd) == 1 ) {
448 tmp = theLayerMeasurements->
measurements(*tec9neg, tsosTEC9, *thePropagator, *estimator);
451 if ( tTopo->
tecSide(iidd) == 2 ) {
452 tmp = theLayerMeasurements->
measurements(*tec9pos, tsosTEC9, *thePropagator, *estimator);
461 auto tec9Hit = tec9TM.
recHit();
463 unsigned int tec9id = tec9Hit->geographicalId().rawId();
464 if (
DEBUG)
cout <<
"tec9id = " << tec9id <<
" is Double sided = " <<
isDoubleSided(tec9id, tTopo) <<
" and 0x3 = " << (tec9id & 0x3) << endl;
466 if (tec9Hit->geographicalId().rawId()!=0) {
467 if (
DEBUG)
cout <<
"tec9 hit actually being added to TM vector" << endl;
483 for(std::vector<TrajectoryAtInvalidHit>::const_iterator TM=TMs.begin();TM!=TMs.end();++TM) {
486 iidd = TM->monodet_id();
487 if (
DEBUG)
cout <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
492 xErr = TM->localErrorX();
493 yErr = TM->localErrorY();
495 angleX = atan( TM->localDxDz() );
496 angleY = atan( TM->localDyDz() );
498 xglob = TM->globalX();
499 yglob = TM->globalY();
500 zglob = TM->globalZ();
511 if (
DEBUG)
cout <<
"Looking at layer under study" << endl;
520 if (
input.size() > 0 ) {
521 if (
DEBUG)
cout <<
"Checking clusters with size = " <<
input.size() << endl;
523 std::vector< std::vector<float> > VCluster_info;
527 unsigned int ClusterId = DSViter->id();
528 if (ClusterId == iidd) {
529 if (
DEBUG)
cout <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
530 DetId ClusterDetId(ClusterId);
541 const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
542 std::array<const float, 4>
const & parameterTrap = (*trapezoidalBounds).
parameters();
543 hbedge = parameterTrap[0];
544 htedge = parameterTrap[1];
545 hapoth = parameterTrap[3];
546 uylfac = (htedge-hbedge)/(htedge+hbedge)/hapoth;
547 uxlden = 1 + yloc*uylfac;
551 if( TrajStrip==-1 ) {
554 TrajStrip = xloc/pitch + nstrips/2.0;
557 float TrajLocXMid = xloc / (1 + (htedge-hbedge)*yloc/(htedge+hbedge)/hapoth) ;
558 TrajStrip = TrajLocXMid/pitch + nstrips/2.0;
567 float res = (parameters.first.x() - xloc);
576 res = parameters.first.x() - xloc/uxlden ;
577 sigma =
abs(res) /
sqrt(parameters.second.xx() + xErr*xErr/uxlden/uxlden + yErr*yErr*xloc*xloc*uylfac*uylfac/uxlden/uxlden/uxlden/uxlden);
584 std::vector< float > cluster_info;
585 cluster_info.push_back(res);
586 cluster_info.push_back(sigma);
587 cluster_info.push_back(parameters.first.x());
588 cluster_info.push_back(
sqrt(parameters.second.xx()));
589 cluster_info.push_back(parameters.first.y());
590 cluster_info.push_back(
sqrt(parameters.second.yy()));
593 VCluster_info.push_back(cluster_info);
595 if (
DEBUG)
cout <<
"Have ID match. residual = " << VCluster_info.back()[0] <<
" res sigma = " << VCluster_info.back()[1] << endl;
596 if (
DEBUG)
cout <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
597 if (
DEBUG)
cout <<
"hit position = " << parameters.first.x() <<
" hit error = " <<
sqrt(parameters.second.xx()) <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
601 float FinalResSig = 1000.0;
602 float FinalCluster[7]= {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
604 if (
DEBUG)
cout <<
"found clusters > 0" << endl;
607 vector< vector<float> >::iterator
ires;
608 for (ires=VCluster_info.begin(); ires!=VCluster_info.end(); ires++){
609 if (
abs((*ires)[1]) <
abs(FinalResSig)) {
610 FinalResSig = (*ires)[1];
611 for (
unsigned int i = 0;
i<ires->size();
i++) {
612 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
613 FinalCluster[
i] = (*ires)[
i];
614 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
617 if (
DEBUG)
cout <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1] <<
" and FinalRes = " << FinalCluster[0] << endl;
621 FinalResSig = VCluster_info.at(0)[1];
622 for (
unsigned int i = 0;
i<VCluster_info.at(0).size();
i++) {
623 FinalCluster[
i] = VCluster_info.at(0)[
i];
627 VCluster_info.clear();
630 if (
DEBUG)
cout <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0]/FinalResSig) << endl;
631 if (
DEBUG)
cout <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc) <<
" abs(xloc) = " <<
abs(xloc) << endl;
632 if (
DEBUG)
cout <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5] <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
633 if (
DEBUG)
cout <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
635 float exclusionWidth = 0.4;
636 float TOBexclusion = 0.0;
637 float TECexRing5 = -0.89;
638 float TECexRing6 = -0.56;
639 float TECexRing7 = 0.60;
642 int ringnumber = ((iidd>>5) & 0x7);
645 if((TKlayers >= 5 && TKlayers < 11)||((subdetector == 6)&&( (ringnumber >= 5)&&(ringnumber <=7) ))) {
647 float highzone = 0.0;
649 float higherr = yloc + 5.0*yErr;
650 float lowerr = yloc - 5.0*yErr;
651 if(TKlayers >= 5 && TKlayers < 11) {
653 highzone = TOBexclusion + exclusionWidth;
654 lowzone = TOBexclusion - exclusionWidth;
655 }
else if (ringnumber == 5) {
657 highzone = TECexRing5 + exclusionWidth;
658 lowzone = TECexRing5 - exclusionWidth;
659 }
else if (ringnumber == 6) {
661 highzone = TECexRing6 + exclusionWidth;
662 lowzone = TECexRing6 - exclusionWidth;
663 }
else if (ringnumber == 7) {
665 highzone = TECexRing7 + exclusionWidth;
666 lowzone = TECexRing7 - exclusionWidth;
685 if ( SiStripQuality_->getBadApvs(iidd)!=0 ) {
687 if(
DEBUG)
cout <<
"strip is bad from SiStripQuality" << endl;
690 if(
DEBUG)
cout <<
"strip is good from SiStripQuality" << endl;
694 for (
unsigned int ii=0;
ii< fedErrorIds->size();
ii++) {
695 if (iidd == (*fedErrorIds)[
ii].rawId() )
705 ResX = FinalCluster[0];
707 if (FinalResSig != FinalCluster[1])
if (
DEBUG)
cout <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
716 if(commonModeDigis.isValid() && TrajStrip>=0 && TrajStrip<=768) {
718 if(digiframe != commonModeDigis->
end())
719 if( (
unsigned) TrajStrip/128 < digiframe->data.
size())
720 commonMode = digiframe->data.at(TrajStrip/128).adc();
723 if (
DEBUG)
cout <<
"before check good" << endl;
725 if ( FinalResSig < 999.0) {
727 if (
DEBUG)
cout <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " <<
728 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
729 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
734 if (
DEBUG)
cout <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0] <<
" FinalRecHit " <<
735 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
736 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
740 if (
DEBUG)
cout <<
" RPhi Error " <<
sqrt(xErr*xErr + yErr*yErr) <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
741 }
if (
DEBUG)
cout <<
"after good location check" << endl;
742 }
if (
DEBUG)
cout <<
"after list of clusters" << endl;
743 }
if (
DEBUG)
cout <<
"After layers=TKLayers if" << endl;
744 }
if (
DEBUG)
cout <<
"After looping over TrajAtValidHit list" << endl;
745 }
if (
DEBUG)
cout <<
"end TMeasurement loop" << endl;
746 }
if (
DEBUG)
cout <<
"end of trajectories loop" << endl;
EventNumber_t event() const
virtual int nstrips() const =0
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
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
float signalOverNoise() const
bool isDoubleSided(unsigned int iidd, const TrackerTopology *tTopo) 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
iterator end()
Return the off-the-end iterator.
size_type size() const
Return the number of contained DetSets.
double checkConsistency(const StripClusterParameterEstimator::LocalValues ¶meters, double xx, double xerr)
T const * product() const
unsigned int checkLayer(unsigned int iidd, const TrackerTopology *tTopo)
T const * product() const
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_
virtual float width() const =0
const edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > commonModeToken_
tuple AnalyticalPropagator
unsigned int tecSide(const DetId &id) const