147 if (
DEBUG)
cout <<
"beginning analyze from HitEff" << endl;
150 using namespace reco;
153 int run_nr = e.
id().
run();
180 es.get<
TkStripCPERecord>().
get(
"StripCPEfromTrackAngle", parameterestimator);
214 const Propagator* thePropagator = prop.product();
249 if (
DEBUG)
cout <<
"number ckf tracks found = " << tracksCKF->size() << endl;
251 if (tracksCKF->size() > 0 && tracksCKF->size()<100) {
252 if (
DEBUG)
cout <<
"starting checking good event with < 100 tracks" << endl;
274 if(e.
getByLabel(
"muonsWitht0Correction",muH)){
276 if(muonsT0.size()!=0) {
282 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
283 if (hasCaloEnergyInfo)
timeECAL = muonsT0[0].calEnergy().ecal_time;
291 for (vector<Trajectory>::const_iterator itraj = TrajectoryCollectionCKF.product()->begin();
292 itraj != TrajectoryCollectionCKF.product()->end();
296 nHits = itraj->foundHits();
298 chi2 = (itraj->chiSquared()/itraj->ndof());
299 pT =
sqrt( ( itraj->lastMeasurement().updatedState().globalMomentum().x() *
300 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
301 ( itraj->lastMeasurement().updatedState().globalMomentum().y() *
302 itraj->lastMeasurement().updatedState().globalMomentum().y()) );
303 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
308 std::vector<TrajectoryMeasurement> TMeas=itraj->measurements();
309 vector<TrajectoryMeasurement>::iterator itm;
314 double angleX = -999.;
315 double angleY = -999.;
316 double xglob,yglob,zglob;
318 for (itm=TMeas.begin();itm!=TMeas.end();itm++){
319 auto theInHit = (*itm).recHit();
321 if(
DEBUG)
cout <<
"theInHit is valid = " << theInHit->isValid() << endl;
323 unsigned int iidd = theInHit->geographicalId().rawId();
325 unsigned int TKlayers =
checkLayer(iidd, tTopo);
326 if (
DEBUG)
cout <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
329 if ( TKlayers == 10 || TKlayers == 22 ) {
330 if (
DEBUG)
cout <<
"skipping original TM for TOB 6 or TEC 9" << endl;
335 std::vector<TrajectoryAtInvalidHit> TMs;
353 if (
DEBUG)
cout <<
" found a hit with a missing partner" << endl;
365 bool isValid = theInHit->isValid();
366 bool isLast = (itm==(TMeas.end()-1));
367 bool isLastTOB5 =
true;
369 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 9 ) isLastTOB5 =
false;
370 else isLastTOB5 =
true;
374 if ( TKlayers==9 && isValid && isLastTOB5 ) {
377 std::vector< BarrelDetLayer const*> barrelTOBLayers = measurementTrackerHandle->geometricSearchTracker()->tobLayers() ;
378 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size()-1];
382 vector<TrajectoryMeasurement>
tmp = theLayerMeasurements->
measurements(*tob6, tsosTOB5, *thePropagator, *estimator);
385 if (
DEBUG)
cout <<
"size of TM from propagation = " << tmp.size() << endl;
391 auto tob6Hit = tob6TM.
recHit();
393 if (tob6Hit->geographicalId().rawId()!=0) {
394 if (
DEBUG)
cout <<
"tob6 hit actually being added to TM vector" << endl;
400 bool isLastTEC8 =
true;
402 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 21 ) isLastTEC8 =
false;
403 else isLastTEC8 =
true;
407 if ( TKlayers==21 && isValid && isLastTEC8 ) {
409 std::vector< const ForwardDetLayer*> posTecLayers = measurementTrackerHandle->geometricSearchTracker()->posTecLayers() ;
410 const DetLayer* tec9pos = posTecLayers[posTecLayers.size()-1];
411 std::vector< const ForwardDetLayer*> negTecLayers = measurementTrackerHandle->geometricSearchTracker()->negTecLayers() ;
412 const DetLayer* tec9neg = negTecLayers[negTecLayers.size()-1];
422 vector<TrajectoryMeasurement>
tmp;
423 if ( tTopo->
tecSide(iidd) == 1 ) {
424 tmp = theLayerMeasurements->
measurements(*tec9neg, tsosTEC9, *thePropagator, *estimator);
427 if ( tTopo->
tecSide(iidd) == 2 ) {
428 tmp = theLayerMeasurements->
measurements(*tec9pos, tsosTEC9, *thePropagator, *estimator);
437 auto tec9Hit = tec9TM.
recHit();
439 unsigned int tec9id = tec9Hit->geographicalId().rawId();
440 if (
DEBUG)
cout <<
"tec9id = " << tec9id <<
" is Double sided = " <<
isDoubleSided(tec9id, tTopo) <<
" and 0x3 = " << (tec9id & 0x3) << endl;
442 if (tec9Hit->geographicalId().rawId()!=0) {
443 if (
DEBUG)
cout <<
"tec9 hit actually being added to TM vector" << endl;
459 for(std::vector<TrajectoryAtInvalidHit>::const_iterator TM=TMs.begin();TM!=TMs.end();++TM) {
462 iidd = TM->monodet_id();
463 if (
DEBUG)
cout <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
468 xErr = TM->localErrorX();
469 yErr = TM->localErrorY();
471 angleX = atan( TM->localDxDz() );
472 angleY = atan( TM->localDyDz() );
474 xglob = TM->globalX();
475 yglob = TM->globalY();
476 zglob = TM->globalZ();
486 if (
DEBUG)
cout <<
"Looking at layer under study" << endl;
495 if (
input.size() > 0 ) {
496 if (
DEBUG)
cout <<
"Checking clusters with size = " <<
input.size() << endl;
498 std::vector< std::vector<float> > VCluster_info;
502 unsigned int ClusterId = DSViter->id();
503 if (ClusterId == iidd) {
504 if (
DEBUG)
cout <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
505 DetId ClusterDetId(ClusterId);
515 const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
516 std::array<const float, 4>
const & parameterTrap = (*trapezoidalBounds).
parameters();
517 hbedge = parameterTrap[0];
518 htedge = parameterTrap[1];
519 hapoth = parameterTrap[3];
520 uylfac = (htedge-hbedge)/(htedge+hbedge)/hapoth;
521 uxlden = 1 + yloc*uylfac;
527 float res = (parameters.first.x() - xloc);
536 res = parameters.first.x() - xloc/uxlden ;
537 sigma =
abs(res) /
sqrt(parameters.second.xx() + xErr*xErr/uxlden/uxlden + yErr*yErr*xloc*xloc*uylfac*uylfac/uxlden/uxlden/uxlden/uxlden);
544 std::vector< float > cluster_info;
545 cluster_info.push_back(res);
546 cluster_info.push_back(sigma);
547 cluster_info.push_back(parameters.first.x());
548 cluster_info.push_back(
sqrt(parameters.second.xx()));
549 cluster_info.push_back(parameters.first.y());
550 cluster_info.push_back(
sqrt(parameters.second.yy()));
553 VCluster_info.push_back(cluster_info);
555 if (
DEBUG)
cout <<
"Have ID match. residual = " << VCluster_info.back()[0] <<
" res sigma = " << VCluster_info.back()[1] << endl;
556 if (
DEBUG)
cout <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
557 if (
DEBUG)
cout <<
"hit position = " << parameters.first.x() <<
" hit error = " <<
sqrt(parameters.second.xx()) <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
561 float FinalResSig = 1000.0;
562 float FinalCluster[7]= {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
564 if (
DEBUG)
cout <<
"found clusters > 0" << endl;
567 vector< vector<float> >::iterator
ires;
568 for (ires=VCluster_info.begin(); ires!=VCluster_info.end(); ires++){
569 if (
abs((*ires)[1]) <
abs(FinalResSig)) {
570 FinalResSig = (*ires)[1];
571 for (
unsigned int i = 0;
i<ires->size();
i++) {
572 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
573 FinalCluster[
i] = (*ires)[
i];
574 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
577 if (
DEBUG)
cout <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1] <<
" and FinalRes = " << FinalCluster[0] << endl;
581 FinalResSig = VCluster_info.at(0)[1];
582 for (
unsigned int i = 0;
i<VCluster_info.at(0).size();
i++) {
583 FinalCluster[
i] = VCluster_info.at(0)[
i];
587 VCluster_info.clear();
590 if (
DEBUG)
cout <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0]/FinalResSig) << endl;
591 if (
DEBUG)
cout <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc) <<
" abs(xloc) = " <<
abs(xloc) << endl;
592 if (
DEBUG)
cout <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5] <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
593 if (
DEBUG)
cout <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
595 float exclusionWidth = 0.4;
596 float TOBexclusion = 0.0;
597 float TECexRing5 = -0.89;
598 float TECexRing6 = -0.56;
599 float TECexRing7 = 0.60;
602 int ringnumber = ((iidd>>5) & 0x7);
605 if((TKlayers >= 5 && TKlayers < 11)||((subdetector == 6)&&( (ringnumber >= 5)&&(ringnumber <=7) ))) {
607 float highzone = 0.0;
609 float higherr = yloc + 5.0*yErr;
610 float lowerr = yloc - 5.0*yErr;
611 if(TKlayers >= 5 && TKlayers < 11) {
613 highzone = TOBexclusion + exclusionWidth;
614 lowzone = TOBexclusion - exclusionWidth;
615 }
else if (ringnumber == 5) {
617 highzone = TECexRing5 + exclusionWidth;
618 lowzone = TECexRing5 - exclusionWidth;
619 }
else if (ringnumber == 6) {
621 highzone = TECexRing6 + exclusionWidth;
622 lowzone = TECexRing6 - exclusionWidth;
623 }
else if (ringnumber == 7) {
625 highzone = TECexRing7 + exclusionWidth;
626 lowzone = TECexRing7 - exclusionWidth;
645 if ( SiStripQuality_->getBadApvs(iidd)!=0 ) {
647 if(
DEBUG)
cout <<
"strip is bad from SiStripQuality" << endl;
650 if(
DEBUG)
cout <<
"strip is good from SiStripQuality" << endl;
654 for (
unsigned int ii=0;
ii< fedErrorIds->size();
ii++) {
655 if (iidd == (*fedErrorIds)[
ii].rawId() )
665 ResX = FinalCluster[0];
667 if (FinalResSig != FinalCluster[1])
if (
DEBUG)
cout <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
674 if (
DEBUG)
cout <<
"before check good" << endl;
676 if ( FinalResSig < 999.0) {
678 if (
DEBUG)
cout <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " <<
679 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
680 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
685 if (
DEBUG)
cout <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0] <<
" FinalRecHit " <<
686 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
687 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
691 if (
DEBUG)
cout <<
" RPhi Error " <<
sqrt(xErr*xErr + yErr*yErr) <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
692 }
if (
DEBUG)
cout <<
"after good location check" << endl;
693 }
if (
DEBUG)
cout <<
"after list of clusters" << endl;
694 }
if (
DEBUG)
cout <<
"After layers=TKLayers if" << endl;
695 }
if (
DEBUG)
cout <<
"After looping over TrajAtValidHit list" << endl;
696 }
if (
DEBUG)
cout <<
"end TMeasurement loop" << endl;
697 }
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
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
std::pair< LocalPoint, LocalError > LocalValues
data_type const * const_iterator
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
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_
const edm::EDGetTokenT< std::vector< Trajectory > > trajectories_token_
tuple AnalyticalPropagator
unsigned int tecSide(const DetId &id) const