88 traj = fs->
make<TTree>(
"traj",
"tree of trajectory positions");
103 traj->Branch(
"ResX",&
ResX,
"ResX/F");
110 traj->Branch(
"chi2",&
chi2,
"chi2/F");
111 traj->Branch(
"p",&
p,
"p/F");
112 traj->Branch(
"pT",&
pT,
"pT/F");
114 traj->Branch(
"Id",&
Id,
"Id/i");
115 traj->Branch(
"run",&
run,
"run/i");
122 traj->Branch(
"dedx",&
dedx,
"dedx/F");
142 if (
DEBUG)
cout <<
"beginning analyze from HitEff" << endl;
145 using namespace reco;
148 int run_nr = e.
id().
run();
159 e.
getByLabel(TkTrajCKF,TrajectoryCollectionCKF);
199 e.
getByLabel(
"MeasurementTrackerEvent", measurementTrackerEvent);
206 const Propagator* thePropagator = prop.product();
241 if (
DEBUG)
cout <<
"number ckf tracks found = " << tracksCKF->size() << endl;
243 if (tracksCKF->size() > 0 && tracksCKF->size()<100) {
244 if (
DEBUG)
cout <<
"starting checking good event with < 100 tracks" << endl;
266 if(e.
getByLabel(
"muonsWitht0Correction",muH)){
268 if(muonsT0.size()!=0) {
274 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
275 if (hasCaloEnergyInfo)
timeECAL = muonsT0[0].calEnergy().ecal_time;
283 for (vector<Trajectory>::const_iterator itraj = TrajectoryCollectionCKF.product()->begin();
284 itraj != TrajectoryCollectionCKF.product()->end();
288 nHits = itraj->foundHits();
290 chi2 = (itraj->chiSquared()/itraj->ndof());
291 pT =
sqrt( ( itraj->lastMeasurement().updatedState().globalMomentum().x() *
292 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
293 ( itraj->lastMeasurement().updatedState().globalMomentum().y() *
294 itraj->lastMeasurement().updatedState().globalMomentum().y()) );
295 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
300 std::vector<TrajectoryMeasurement> TMeas=itraj->measurements();
301 vector<TrajectoryMeasurement>::iterator itm;
306 double angleX = -999.;
307 double angleY = -999.;
308 double xglob,yglob,zglob;
310 for (itm=TMeas.begin();itm!=TMeas.end();itm++){
311 auto theInHit = (*itm).recHit();
313 if(
DEBUG)
cout <<
"theInHit is valid = " << theInHit->isValid() << endl;
315 unsigned int iidd = theInHit->geographicalId().rawId();
317 unsigned int TKlayers =
checkLayer(iidd, tTopo);
318 if (
DEBUG)
cout <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
321 if ( TKlayers == 10 || TKlayers == 22 ) {
322 if (
DEBUG)
cout <<
"skipping original TM for TOB 6 or TEC 9" << endl;
327 std::vector<TrajectoryAtInvalidHit> TMs;
345 if (
DEBUG)
cout <<
" found a hit with a missing partner" << endl;
357 bool isValid = theInHit->isValid();
358 bool isLast = (itm==(TMeas.end()-1));
359 bool isLastTOB5 =
true;
361 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 9 ) isLastTOB5 =
false;
362 else isLastTOB5 =
true;
366 if ( TKlayers==9 && isValid && isLastTOB5 ) {
369 std::vector< BarrelDetLayer const*> barrelTOBLayers = measurementTrackerHandle->geometricSearchTracker()->tobLayers() ;
370 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size()-1];
374 vector<TrajectoryMeasurement>
tmp = theLayerMeasurements->
measurements(*tob6, tsosTOB5, *thePropagator, *estimator);
377 if (
DEBUG)
cout <<
"size of TM from propagation = " << tmp.size() << endl;
383 auto tob6Hit = tob6TM.
recHit();
385 if (tob6Hit->geographicalId().rawId()!=0) {
386 if (
DEBUG)
cout <<
"tob6 hit actually being added to TM vector" << endl;
392 bool isLastTEC8 =
true;
394 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 21 ) isLastTEC8 =
false;
395 else isLastTEC8 =
true;
399 if ( TKlayers==21 && isValid && isLastTEC8 ) {
401 std::vector< const ForwardDetLayer*> posTecLayers = measurementTrackerHandle->geometricSearchTracker()->posTecLayers() ;
402 const DetLayer* tec9pos = posTecLayers[posTecLayers.size()-1];
403 std::vector< const ForwardDetLayer*> negTecLayers = measurementTrackerHandle->geometricSearchTracker()->negTecLayers() ;
404 const DetLayer* tec9neg = negTecLayers[negTecLayers.size()-1];
414 vector<TrajectoryMeasurement>
tmp;
415 if ( tTopo->
tecSide(iidd) == 1 ) {
416 tmp = theLayerMeasurements->
measurements(*tec9neg, tsosTEC9, *thePropagator, *estimator);
419 if ( tTopo->
tecSide(iidd) == 2 ) {
420 tmp = theLayerMeasurements->
measurements(*tec9pos, tsosTEC9, *thePropagator, *estimator);
429 auto tec9Hit = tec9TM.
recHit();
431 unsigned int tec9id = tec9Hit->geographicalId().rawId();
432 if (
DEBUG)
cout <<
"tec9id = " << tec9id <<
" is Double sided = " <<
isDoubleSided(tec9id, tTopo) <<
" and 0x3 = " << (tec9id & 0x3) << endl;
434 if (tec9Hit->geographicalId().rawId()!=0) {
435 if (
DEBUG)
cout <<
"tec9 hit actually being added to TM vector" << endl;
451 for(std::vector<TrajectoryAtInvalidHit>::const_iterator TM=TMs.begin();TM!=TMs.end();++TM) {
454 iidd = TM->monodet_id();
455 if (
DEBUG)
cout <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
460 xErr = TM->localErrorX();
461 yErr = TM->localErrorY();
463 angleX = atan( TM->localDxDz() );
464 angleY = atan( TM->localDyDz() );
466 xglob = TM->globalX();
467 yglob = TM->globalY();
468 zglob = TM->globalZ();
478 if (
DEBUG)
cout <<
"Looking at layer under study" << endl;
487 if (
input.size() > 0 ) {
488 if (
DEBUG)
cout <<
"Checking clusters with size = " <<
input.size() << endl;
490 std::vector< std::vector<float> > VCluster_info;
494 unsigned int ClusterId = DSViter->id();
495 if (ClusterId == iidd) {
496 if (
DEBUG)
cout <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
497 DetId ClusterDetId(ClusterId);
507 const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
508 std::array<const float, 4>
const & parameterTrap = (*trapezoidalBounds).
parameters();
509 hbedge = parameterTrap[0];
510 htedge = parameterTrap[1];
511 hapoth = parameterTrap[3];
512 uylfac = (htedge-hbedge)/(htedge+hbedge)/hapoth;
513 uxlden = 1 + yloc*uylfac;
519 float res = (parameters.first.x() - xloc);
528 res = parameters.first.x() - xloc/uxlden ;
529 sigma =
abs(res) /
sqrt(parameters.second.xx() + xErr*xErr/uxlden/uxlden + yErr*yErr*xloc*xloc*uylfac*uylfac/uxlden/uxlden/uxlden/uxlden);
536 std::vector< float > cluster_info;
537 cluster_info.push_back(res);
538 cluster_info.push_back(sigma);
539 cluster_info.push_back(parameters.first.x());
540 cluster_info.push_back(
sqrt(parameters.second.xx()));
541 cluster_info.push_back(parameters.first.y());
542 cluster_info.push_back(
sqrt(parameters.second.yy()));
545 VCluster_info.push_back(cluster_info);
547 if (
DEBUG)
cout <<
"Have ID match. residual = " << VCluster_info.back()[0] <<
" res sigma = " << VCluster_info.back()[1] << endl;
548 if (
DEBUG)
cout <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
549 if (
DEBUG)
cout <<
"hit position = " << parameters.first.x() <<
" hit error = " <<
sqrt(parameters.second.xx()) <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
553 float FinalResSig = 1000.0;
554 float FinalCluster[7]= {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
556 if (
DEBUG)
cout <<
"found clusters > 0" << endl;
559 vector< vector<float> >::iterator
ires;
560 for (ires=VCluster_info.begin(); ires!=VCluster_info.end(); ires++){
561 if (
abs((*ires)[1]) <
abs(FinalResSig)) {
562 FinalResSig = (*ires)[1];
563 for (
unsigned int i = 0;
i<ires->size();
i++) {
564 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
565 FinalCluster[
i] = (*ires)[
i];
566 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
569 if (
DEBUG)
cout <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1] <<
" and FinalRes = " << FinalCluster[0] << endl;
573 FinalResSig = VCluster_info.at(0)[1];
574 for (
unsigned int i = 0;
i<VCluster_info.at(0).size();
i++) {
575 FinalCluster[
i] = VCluster_info.at(0)[
i];
579 VCluster_info.clear();
582 if (
DEBUG)
cout <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0]/FinalResSig) << endl;
583 if (
DEBUG)
cout <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc) <<
" abs(xloc) = " <<
abs(xloc) << endl;
584 if (
DEBUG)
cout <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5] <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
585 if (
DEBUG)
cout <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
587 float exclusionWidth = 0.4;
588 float TOBexclusion = 0.0;
589 float TECexRing5 = -0.89;
590 float TECexRing6 = -0.56;
591 float TECexRing7 = 0.60;
593 int subdetector = ((iidd>>25) & 0x7);
594 int ringnumber = ((iidd>>5) & 0x7);
597 if((TKlayers >= 5 && TKlayers < 11)||((subdetector == 6)&&( (ringnumber >= 5)&&(ringnumber <=7) ))) {
599 float highzone = 0.0;
601 float higherr = yloc + 5.0*yErr;
602 float lowerr = yloc - 5.0*yErr;
603 if(TKlayers >= 5 && TKlayers < 11) {
605 highzone = TOBexclusion + exclusionWidth;
606 lowzone = TOBexclusion - exclusionWidth;
607 }
else if (ringnumber == 5) {
609 highzone = TECexRing5 + exclusionWidth;
610 lowzone = TECexRing5 - exclusionWidth;
611 }
else if (ringnumber == 6) {
613 highzone = TECexRing6 + exclusionWidth;
614 lowzone = TECexRing6 - exclusionWidth;
615 }
else if (ringnumber == 7) {
617 highzone = TECexRing7 + exclusionWidth;
618 lowzone = TECexRing7 - exclusionWidth;
637 if ( SiStripQuality_->getBadApvs(iidd)!=0 ) {
639 if(
DEBUG)
cout <<
"strip is bad from SiStripQuality" << endl;
642 if(
DEBUG)
cout <<
"strip is good from SiStripQuality" << endl;
646 for (
unsigned int ii=0;
ii< fedErrorIds->size();
ii++) {
647 if (iidd == (*fedErrorIds)[
ii].rawId() )
657 ResX = FinalCluster[0];
659 if (FinalResSig != FinalCluster[1])
if (
DEBUG)
cout <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
666 if (
DEBUG)
cout <<
"before check good" << endl;
668 if ( FinalResSig < 999.0) {
670 if (
DEBUG)
cout <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " <<
671 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
672 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
677 if (
DEBUG)
cout <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0] <<
" FinalRecHit " <<
678 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
679 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
683 if (
DEBUG)
cout <<
" RPhi Error " <<
sqrt(xErr*xErr + yErr*yErr) <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
684 }
if (
DEBUG)
cout <<
"after good location check" << endl;
685 }
if (
DEBUG)
cout <<
"after list of clusters" << endl;
686 }
if (
DEBUG)
cout <<
"After layers=TKLayers if" << endl;
687 }
if (
DEBUG)
cout <<
"After looping over TrajAtValidHit list" << endl;
688 }
if (
DEBUG)
cout <<
"end TMeasurement loop" << endl;
689 }
if (
DEBUG)
cout <<
"end of trajectories loop" << endl;
694 traj->GetDirectory()->cd();
702 double error =
sqrt(parameters.second.xx() + xerr*xerr);
703 double separation =
abs(parameters.first.x() - xx);
704 double consistency = separation/
error;
710 unsigned int subid=strip.
subdetId();
711 unsigned int layer = 0;
715 if (layer == 1 || layer == 2)
return true;
721 if (layer == 5 || layer == 6)
return true;
726 layer = tTopo->
tidRing(iidd) + 10;
727 if (layer == 11 || layer == 12)
return true;
732 layer = tTopo->
tecRing(iidd) + 13 ;
733 if (layer == 14 || layer == 15 || layer == 18)
return true;
741 unsigned int partner_iidd = 0;
742 bool found2DPartner =
false;
744 if ((iidd & 0x3)==1) partner_iidd = iidd+1;
745 if ((iidd & 0x3)==2) partner_iidd = iidd-1;
748 for (std::vector<TrajectoryMeasurement>::const_iterator iTM=traj.begin(); iTM!=traj.end(); ++iTM) {
749 if (iTM->recHit()->geographicalId().rawId()==partner_iidd) {
750 found2DPartner =
true;
753 return found2DPartner;
758 unsigned int subid=strip.
subdetId();
virtual LocalValues localParameters(const SiStripCluster &, const GeomDetUnit &) const
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
unsigned int tibLayer(const DetId &id) const
ConstRecHitPointer const & recHit() const
unsigned int tidRing(const DetId &id) const
virtual const std::array< const float, 4 > parameters() const
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
#define DEFINE_FWK_MODULE(type)
unsigned int tecRing(const DetId &id) const
ring id
std::vector< Track > TrackCollection
collection of Tracks
int bunchCrossing() const
unsigned int tidWheel(const DetId &id) const
T * make(const Args &...args) const
make new ROOT object
HitEff(const edm::ParameterSet &conf)
data_type const * const_iterator
const Plane & surface() const
The nominal surface of the GeomDet.
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
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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
unsigned int tecWheel(const DetId &id) const
tuple AnalyticalPropagator
unsigned int tobLayer(const DetId &id) const
unsigned int tecSide(const DetId &id) const