87 traj = fs->
make<TTree>(
"traj",
"tree of trajectory positions");
102 traj->Branch(
"ResX",&
ResX,
"ResX/F");
109 traj->Branch(
"chi2",&
chi2,
"chi2/F");
110 traj->Branch(
"p",&
p,
"p/F");
111 traj->Branch(
"pT",&
pT,
"pT/F");
113 traj->Branch(
"Id",&
Id,
"Id/i");
114 traj->Branch(
"run",&
run,
"run/i");
121 traj->Branch(
"dedx",&
dedx,
"dedx/F");
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);
197 e.
getByLabel(
"MeasurementTrackerEvent", measurementTrackerEvent);
204 const Propagator* thePropagator = prop.product();
239 if (
DEBUG)
cout <<
"number ckf tracks found = " << tracksCKF->size() << endl;
241 if (tracksCKF->size() > 0 && tracksCKF->size()<100) {
242 if (
DEBUG)
cout <<
"starting checking good event with < 100 tracks" << endl;
264 if(e.
getByLabel(
"muonsWitht0Correction",muH)){
266 if(muonsT0.size()!=0) {
272 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
273 if (hasCaloEnergyInfo)
timeECAL = muonsT0[0].calEnergy().ecal_time;
281 for (vector<Trajectory>::const_iterator itraj = TrajectoryCollectionCKF.product()->begin();
282 itraj != TrajectoryCollectionCKF.product()->end();
286 nHits = itraj->foundHits();
288 chi2 = (itraj->chiSquared()/itraj->ndof());
289 pT =
sqrt( ( itraj->lastMeasurement().updatedState().globalMomentum().x() *
290 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
291 ( itraj->lastMeasurement().updatedState().globalMomentum().y() *
292 itraj->lastMeasurement().updatedState().globalMomentum().y()) );
293 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
298 std::vector<TrajectoryMeasurement> TMeas=itraj->measurements();
299 vector<TrajectoryMeasurement>::iterator itm;
304 double angleX = -999.;
305 double angleY = -999.;
306 double xglob,yglob,zglob;
308 for (itm=TMeas.begin();itm!=TMeas.end();itm++){
309 auto theInHit = (*itm).recHit();
311 if(
DEBUG)
cout <<
"theInHit is valid = " << theInHit->isValid() << endl;
313 unsigned int iidd = theInHit->geographicalId().rawId();
315 unsigned int TKlayers =
checkLayer(iidd, tTopo);
316 if (
DEBUG)
cout <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
319 if ( TKlayers == 10 || TKlayers == 22 ) {
320 if (
DEBUG)
cout <<
"skipping original TM for TOB 6 or TEC 9" << endl;
325 std::vector<TrajectoryAtInvalidHit> TMs;
343 if (
DEBUG)
cout <<
" found a hit with a missing partner" << endl;
355 bool isValid = theInHit->isValid();
356 bool isLast = (itm==(TMeas.end()-1));
357 bool isLastTOB5 =
true;
359 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 9 ) isLastTOB5 =
false;
360 else isLastTOB5 =
true;
364 if ( TKlayers==9 && isValid && isLastTOB5 ) {
367 std::vector< BarrelDetLayer const*> barrelTOBLayers = measurementTrackerHandle->geometricSearchTracker()->tobLayers() ;
368 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size()-1];
372 vector<TrajectoryMeasurement>
tmp = theLayerMeasurements->
measurements(*tob6, tsosTOB5, *thePropagator, *estimator);
375 if (
DEBUG)
cout <<
"size of TM from propagation = " << tmp.size() << endl;
381 auto tob6Hit = tob6TM.
recHit();
383 if (tob6Hit->geographicalId().rawId()!=0) {
384 if (
DEBUG)
cout <<
"tob6 hit actually being added to TM vector" << endl;
390 bool isLastTEC8 =
true;
392 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 21 ) isLastTEC8 =
false;
393 else isLastTEC8 =
true;
397 if ( TKlayers==21 && isValid && isLastTEC8 ) {
399 std::vector< const ForwardDetLayer*> posTecLayers = measurementTrackerHandle->geometricSearchTracker()->posTecLayers() ;
400 const DetLayer* tec9pos = posTecLayers[posTecLayers.size()-1];
401 std::vector< const ForwardDetLayer*> negTecLayers = measurementTrackerHandle->geometricSearchTracker()->negTecLayers() ;
402 const DetLayer* tec9neg = negTecLayers[negTecLayers.size()-1];
412 vector<TrajectoryMeasurement>
tmp;
413 if ( tTopo->
tecSide(iidd) == 1 ) {
414 tmp = theLayerMeasurements->
measurements(*tec9neg, tsosTEC9, *thePropagator, *estimator);
417 if ( tTopo->
tecSide(iidd) == 2 ) {
418 tmp = theLayerMeasurements->
measurements(*tec9pos, tsosTEC9, *thePropagator, *estimator);
427 auto tec9Hit = tec9TM.
recHit();
429 unsigned int tec9id = tec9Hit->geographicalId().rawId();
430 if (
DEBUG)
cout <<
"tec9id = " << tec9id <<
" is Double sided = " <<
isDoubleSided(tec9id, tTopo) <<
" and 0x3 = " << (tec9id & 0x3) << endl;
432 if (tec9Hit->geographicalId().rawId()!=0) {
433 if (
DEBUG)
cout <<
"tec9 hit actually being added to TM vector" << endl;
449 for(std::vector<TrajectoryAtInvalidHit>::const_iterator TM=TMs.begin();TM!=TMs.end();++TM) {
452 iidd = TM->monodet_id();
453 if (
DEBUG)
cout <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
458 xErr = TM->localErrorX();
459 yErr = TM->localErrorY();
461 angleX = atan( TM->localDxDz() );
462 angleY = atan( TM->localDyDz() );
464 xglob = TM->globalX();
465 yglob = TM->globalY();
466 zglob = TM->globalZ();
476 if (
DEBUG)
cout <<
"Looking at layer under study" << endl;
485 if (
input.size() > 0 ) {
486 if (
DEBUG)
cout <<
"Checking clusters with size = " <<
input.size() << endl;
488 std::vector< std::vector<float> > VCluster_info;
492 unsigned int ClusterId = DSViter->id();
493 if (ClusterId == iidd) {
494 if (
DEBUG)
cout <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
495 DetId ClusterDetId(ClusterId);
501 float res = (parameters.first.x() - xloc);
513 std::vector< float > cluster_info;
514 cluster_info.push_back(res);
515 cluster_info.push_back(sigma);
516 cluster_info.push_back(parameters.first.x());
517 cluster_info.push_back(
sqrt(parameters.second.xx()));
518 cluster_info.push_back(parameters.first.y());
519 cluster_info.push_back(
sqrt(parameters.second.yy()));
522 VCluster_info.push_back(cluster_info);
524 if (
DEBUG)
cout <<
"Have ID match. residual = " << VCluster_info.back()[0] <<
" res sigma = " << VCluster_info.back()[1] << endl;
525 if (
DEBUG)
cout <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
526 if (
DEBUG)
cout <<
"hit position = " << parameters.first.x() <<
" hit error = " <<
sqrt(parameters.second.xx()) <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
530 float FinalResSig = 1000.0;
531 float FinalCluster[7]= {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
533 if (
DEBUG)
cout <<
"found clusters > 0" << endl;
536 vector< vector<float> >::iterator
ires;
537 for (ires=VCluster_info.begin(); ires!=VCluster_info.end(); ires++){
538 if (
abs((*ires)[1]) <
abs(FinalResSig)) {
539 FinalResSig = (*ires)[1];
540 for (
unsigned int i = 0;
i<ires->size();
i++) {
541 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
542 FinalCluster[
i] = (*ires)[
i];
543 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
546 if (
DEBUG)
cout <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1] <<
" and FinalRes = " << FinalCluster[0] << endl;
550 FinalResSig = VCluster_info.at(0)[1];
551 for (
unsigned int i = 0;
i<VCluster_info.at(0).size();
i++) {
552 FinalCluster[
i] = VCluster_info.at(0)[
i];
556 VCluster_info.clear();
559 if (
DEBUG)
cout <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0]/FinalResSig) << endl;
560 if (
DEBUG)
cout <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc) <<
" abs(xloc) = " <<
abs(xloc) << endl;
561 if (
DEBUG)
cout <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5] <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
562 if (
DEBUG)
cout <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
564 float exclusionWidth = 0.4;
565 float TOBexclusion = 0.0;
566 float TECexRing5 = -0.89;
567 float TECexRing6 = -0.56;
568 float TECexRing7 = 0.60;
570 int subdetector = ((iidd>>25) & 0x7);
571 int ringnumber = ((iidd>>5) & 0x7);
574 if((TKlayers >= 5 && TKlayers < 11)||((subdetector == 6)&&( (ringnumber >= 5)&&(ringnumber <=7) ))) {
576 float highzone = 0.0;
578 float higherr = yloc + 5.0*yErr;
579 float lowerr = yloc - 5.0*yErr;
580 if(TKlayers >= 5 && TKlayers < 11) {
582 highzone = TOBexclusion + exclusionWidth;
583 lowzone = TOBexclusion - exclusionWidth;
584 }
else if (ringnumber == 5) {
586 highzone = TECexRing5 + exclusionWidth;
587 lowzone = TECexRing5 - exclusionWidth;
588 }
else if (ringnumber == 6) {
590 highzone = TECexRing6 + exclusionWidth;
591 lowzone = TECexRing6 - exclusionWidth;
592 }
else if (ringnumber == 7) {
594 highzone = TECexRing7 + exclusionWidth;
595 lowzone = TECexRing7 - exclusionWidth;
614 if ( SiStripQuality_->getBadApvs(iidd)!=0 ) {
616 if(
DEBUG)
cout <<
"strip is bad from SiStripQuality" << endl;
619 if(
DEBUG)
cout <<
"strip is good from SiStripQuality" << endl;
623 for (
unsigned int ii=0;
ii< fedErrorIds->size();
ii++) {
624 if (iidd == (*fedErrorIds)[
ii].rawId() )
634 ResX = FinalCluster[0];
636 if (FinalResSig != FinalCluster[1])
if (
DEBUG)
cout <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
643 if (
DEBUG)
cout <<
"before check good" << endl;
645 if ( FinalResSig < 999.0) {
647 if (
DEBUG)
cout <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " <<
648 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
649 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
654 if (
DEBUG)
cout <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0] <<
" FinalRecHit " <<
655 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
656 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
660 if (
DEBUG)
cout <<
" RPhi Error " <<
sqrt(xErr*xErr + yErr*yErr) <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
661 }
if (
DEBUG)
cout <<
"after good location check" << endl;
662 }
if (
DEBUG)
cout <<
"after list of clusters" << endl;
663 }
if (
DEBUG)
cout <<
"After layers=TKLayers if" << endl;
664 }
if (
DEBUG)
cout <<
"After looping over TrajAtValidHit list" << endl;
665 }
if (
DEBUG)
cout <<
"end TMeasurement loop" << endl;
666 }
if (
DEBUG)
cout <<
"end of trajectories loop" << endl;
671 traj->GetDirectory()->cd();
679 double error =
sqrt(parameters.second.xx() + xerr*xerr);
680 double separation =
abs(parameters.first.x() - xx);
681 double consistency = separation/
error;
687 unsigned int subid=strip.
subdetId();
688 unsigned int layer = 0;
692 if (layer == 1 || layer == 2)
return true;
698 if (layer == 5 || layer == 6)
return true;
703 layer = tTopo->
tidRing(iidd) + 10;
704 if (layer == 11 || layer == 12)
return true;
709 layer = tTopo->
tecRing(iidd) + 13 ;
710 if (layer == 14 || layer == 15 || layer == 18)
return true;
718 unsigned int partner_iidd = 0;
719 bool found2DPartner =
false;
721 if ((iidd & 0x3)==1) partner_iidd = iidd+1;
722 if ((iidd & 0x3)==2) partner_iidd = iidd-1;
725 for (std::vector<TrajectoryMeasurement>::const_iterator iTM=traj.begin(); iTM!=traj.end(); ++iTM) {
726 if (iTM->recHit()->geographicalId().rawId()==partner_iidd) {
727 found2DPartner =
true;
730 return found2DPartner;
735 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 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
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)
unsigned int checkLayer(unsigned int iidd, const TrackerTopology *tTopo)
T const * product() const
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