141 if (
DEBUG)
cout <<
"beginning analyze from HitEff" << endl;
144 using namespace reco;
147 int run_nr = e.
id().
run();
158 e.
getByLabel(TkTrajCKF,TrajectoryCollectionCKF);
173 es.get<
TkStripCPERecord>().
get(
"StripCPEfromTrackAngle", parameterestimator);
198 e.
getByLabel(
"MeasurementTrackerEvent", measurementTrackerEvent);
205 const Propagator* thePropagator = prop.product();
240 if (
DEBUG)
cout <<
"number ckf tracks found = " << tracksCKF->size() << endl;
242 if (tracksCKF->size() > 0 && tracksCKF->size()<100) {
243 if (
DEBUG)
cout <<
"starting checking good event with < 100 tracks" << endl;
265 if(e.
getByLabel(
"muonsWitht0Correction",muH)){
267 if(muonsT0.size()!=0) {
273 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
274 if (hasCaloEnergyInfo)
timeECAL = muonsT0[0].calEnergy().ecal_time;
282 for (vector<Trajectory>::const_iterator itraj = TrajectoryCollectionCKF.product()->begin();
283 itraj != TrajectoryCollectionCKF.product()->end();
287 nHits = itraj->foundHits();
289 chi2 = (itraj->chiSquared()/itraj->ndof());
290 pT =
sqrt( ( itraj->lastMeasurement().updatedState().globalMomentum().x() *
291 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
292 ( itraj->lastMeasurement().updatedState().globalMomentum().y() *
293 itraj->lastMeasurement().updatedState().globalMomentum().y()) );
294 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
299 std::vector<TrajectoryMeasurement> TMeas=itraj->measurements();
300 vector<TrajectoryMeasurement>::iterator itm;
305 double angleX = -999.;
306 double angleY = -999.;
307 double xglob,yglob,zglob;
309 for (itm=TMeas.begin();itm!=TMeas.end();itm++){
310 auto theInHit = (*itm).recHit();
312 if(
DEBUG)
cout <<
"theInHit is valid = " << theInHit->isValid() << endl;
314 unsigned int iidd = theInHit->geographicalId().rawId();
316 unsigned int TKlayers =
checkLayer(iidd, tTopo);
317 if (
DEBUG)
cout <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
320 if ( TKlayers == 10 || TKlayers == 22 ) {
321 if (
DEBUG)
cout <<
"skipping original TM for TOB 6 or TEC 9" << endl;
326 std::vector<TrajectoryAtInvalidHit> TMs;
344 if (
DEBUG)
cout <<
" found a hit with a missing partner" << endl;
356 bool isValid = theInHit->isValid();
357 bool isLast = (itm==(TMeas.end()-1));
358 bool isLastTOB5 =
true;
360 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 9 ) isLastTOB5 =
false;
361 else isLastTOB5 =
true;
365 if ( TKlayers==9 && isValid && isLastTOB5 ) {
368 std::vector< BarrelDetLayer const*> barrelTOBLayers = measurementTrackerHandle->geometricSearchTracker()->tobLayers() ;
369 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size()-1];
373 vector<TrajectoryMeasurement>
tmp = theLayerMeasurements->
measurements(*tob6, tsosTOB5, *thePropagator, *estimator);
376 if (
DEBUG)
cout <<
"size of TM from propagation = " << tmp.size() << endl;
382 auto tob6Hit = tob6TM.
recHit();
384 if (tob6Hit->geographicalId().rawId()!=0) {
385 if (
DEBUG)
cout <<
"tob6 hit actually being added to TM vector" << endl;
391 bool isLastTEC8 =
true;
393 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 21 ) isLastTEC8 =
false;
394 else isLastTEC8 =
true;
398 if ( TKlayers==21 && isValid && isLastTEC8 ) {
400 std::vector< const ForwardDetLayer*> posTecLayers = measurementTrackerHandle->geometricSearchTracker()->posTecLayers() ;
401 const DetLayer* tec9pos = posTecLayers[posTecLayers.size()-1];
402 std::vector< const ForwardDetLayer*> negTecLayers = measurementTrackerHandle->geometricSearchTracker()->negTecLayers() ;
403 const DetLayer* tec9neg = negTecLayers[negTecLayers.size()-1];
413 vector<TrajectoryMeasurement>
tmp;
414 if ( tTopo->
tecSide(iidd) == 1 ) {
415 tmp = theLayerMeasurements->
measurements(*tec9neg, tsosTEC9, *thePropagator, *estimator);
418 if ( tTopo->
tecSide(iidd) == 2 ) {
419 tmp = theLayerMeasurements->
measurements(*tec9pos, tsosTEC9, *thePropagator, *estimator);
428 auto tec9Hit = tec9TM.
recHit();
430 unsigned int tec9id = tec9Hit->geographicalId().rawId();
431 if (
DEBUG)
cout <<
"tec9id = " << tec9id <<
" is Double sided = " <<
isDoubleSided(tec9id, tTopo) <<
" and 0x3 = " << (tec9id & 0x3) << endl;
433 if (tec9Hit->geographicalId().rawId()!=0) {
434 if (
DEBUG)
cout <<
"tec9 hit actually being added to TM vector" << endl;
450 for(std::vector<TrajectoryAtInvalidHit>::const_iterator TM=TMs.begin();TM!=TMs.end();++TM) {
453 iidd = TM->monodet_id();
454 if (
DEBUG)
cout <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
459 xErr = TM->localErrorX();
460 yErr = TM->localErrorY();
462 angleX = atan( TM->localDxDz() );
463 angleY = atan( TM->localDyDz() );
465 xglob = TM->globalX();
466 yglob = TM->globalY();
467 zglob = TM->globalZ();
477 if (
DEBUG)
cout <<
"Looking at layer under study" << endl;
486 if (
input.size() > 0 ) {
487 if (
DEBUG)
cout <<
"Checking clusters with size = " <<
input.size() << endl;
489 std::vector< std::vector<float> > VCluster_info;
493 unsigned int ClusterId = DSViter->id();
494 if (ClusterId == iidd) {
495 if (
DEBUG)
cout <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
496 DetId ClusterDetId(ClusterId);
502 float res = (parameters.first.x() - xloc);
514 std::vector< float > cluster_info;
515 cluster_info.push_back(res);
516 cluster_info.push_back(sigma);
517 cluster_info.push_back(parameters.first.x());
518 cluster_info.push_back(
sqrt(parameters.second.xx()));
519 cluster_info.push_back(parameters.first.y());
520 cluster_info.push_back(
sqrt(parameters.second.yy()));
523 VCluster_info.push_back(cluster_info);
525 if (
DEBUG)
cout <<
"Have ID match. residual = " << VCluster_info.back()[0] <<
" res sigma = " << VCluster_info.back()[1] << endl;
526 if (
DEBUG)
cout <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
527 if (
DEBUG)
cout <<
"hit position = " << parameters.first.x() <<
" hit error = " <<
sqrt(parameters.second.xx()) <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
531 float FinalResSig = 1000.0;
532 float FinalCluster[7]= {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
534 if (
DEBUG)
cout <<
"found clusters > 0" << endl;
537 vector< vector<float> >::iterator
ires;
538 for (ires=VCluster_info.begin(); ires!=VCluster_info.end(); ires++){
539 if (
abs((*ires)[1]) <
abs(FinalResSig)) {
540 FinalResSig = (*ires)[1];
541 for (
unsigned int i = 0;
i<ires->size();
i++) {
542 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
543 FinalCluster[
i] = (*ires)[
i];
544 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
547 if (
DEBUG)
cout <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1] <<
" and FinalRes = " << FinalCluster[0] << endl;
551 FinalResSig = VCluster_info.at(0)[1];
552 for (
unsigned int i = 0;
i<VCluster_info.at(0).size();
i++) {
553 FinalCluster[
i] = VCluster_info.at(0)[
i];
557 VCluster_info.clear();
560 if (
DEBUG)
cout <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0]/FinalResSig) << endl;
561 if (
DEBUG)
cout <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc) <<
" abs(xloc) = " <<
abs(xloc) << endl;
562 if (
DEBUG)
cout <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5] <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
563 if (
DEBUG)
cout <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
565 float exclusionWidth = 0.4;
566 float TOBexclusion = 0.0;
567 float TECexRing5 = -0.89;
568 float TECexRing6 = -0.56;
569 float TECexRing7 = 0.60;
571 int subdetector = ((iidd>>25) & 0x7);
572 int ringnumber = ((iidd>>5) & 0x7);
575 if((TKlayers >= 5 && TKlayers < 11)||((subdetector == 6)&&( (ringnumber >= 5)&&(ringnumber <=7) ))) {
577 float highzone = 0.0;
579 float higherr = yloc + 5.0*yErr;
580 float lowerr = yloc - 5.0*yErr;
581 if(TKlayers >= 5 && TKlayers < 11) {
583 highzone = TOBexclusion + exclusionWidth;
584 lowzone = TOBexclusion - exclusionWidth;
585 }
else if (ringnumber == 5) {
587 highzone = TECexRing5 + exclusionWidth;
588 lowzone = TECexRing5 - exclusionWidth;
589 }
else if (ringnumber == 6) {
591 highzone = TECexRing6 + exclusionWidth;
592 lowzone = TECexRing6 - exclusionWidth;
593 }
else if (ringnumber == 7) {
595 highzone = TECexRing7 + exclusionWidth;
596 lowzone = TECexRing7 - exclusionWidth;
615 if ( SiStripQuality_->getBadApvs(iidd)!=0 ) {
617 if(
DEBUG)
cout <<
"strip is bad from SiStripQuality" << endl;
620 if(
DEBUG)
cout <<
"strip is good from SiStripQuality" << endl;
624 for (
unsigned int ii=0;
ii< fedErrorIds->size();
ii++) {
625 if (iidd == (*fedErrorIds)[
ii].rawId() )
635 ResX = FinalCluster[0];
637 if (FinalResSig != FinalCluster[1])
if (
DEBUG)
cout <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
644 if (
DEBUG)
cout <<
"before check good" << endl;
646 if ( FinalResSig < 999.0) {
648 if (
DEBUG)
cout <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " <<
649 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
650 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
655 if (
DEBUG)
cout <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0] <<
" FinalRecHit " <<
656 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
657 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
661 if (
DEBUG)
cout <<
" RPhi Error " <<
sqrt(xErr*xErr + yErr*yErr) <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
662 }
if (
DEBUG)
cout <<
"after good location check" << endl;
663 }
if (
DEBUG)
cout <<
"after list of clusters" << endl;
664 }
if (
DEBUG)
cout <<
"After layers=TKLayers if" << endl;
665 }
if (
DEBUG)
cout <<
"After looping over TrajAtValidHit list" << endl;
666 }
if (
DEBUG)
cout <<
"end TMeasurement loop" << endl;
667 }
if (
DEBUG)
cout <<
"end of trajectories loop" << endl;
T getParameter(std::string const &) const
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
std::vector< Track > TrackCollection
collection of Tracks
int bunchCrossing() const
data_type const * const_iterator
std::vector< Muon > MuonCollection
collection of Muon objects
static std::string const input
float signalOverNoise() const
bool isDoubleSided(unsigned int iidd, const TrackerTopology *tTopo) const
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
std::pair< LocalPoint, LocalError > LocalValues
unsigned int SiStripQualBad
std::vector< std::vector< double > > tmp
tuple AnalyticalPropagator
unsigned int tecSide(const DetId &id) const