76 commonModeToken_( mayConsume<
edm::DetSetVector<
SiStripRawDigi> >(conf.getParameter<
edm::InputTag>(
"commonMode")) ),
77 combinatorialTracks_token_( consumes<
reco::
TrackCollection >(conf.getParameter<
edm::InputTag>(
"combinatorialTracks")) ),
78 trajectories_token_( consumes<
std::vector<
Trajectory> >(conf.getParameter<
edm::InputTag>(
"trajectories")) ),
79 clusters_token_( consumes<
edmNew::DetSetVector<
SiStripCluster> >(conf.getParameter<
edm::InputTag>(
"siStripClusters")) ),
80 digis_token_( consumes<
DetIdCollection >(conf.getParameter<
edm::InputTag>(
"siStripDigis")) ),
99 traj = fs->
make<TTree>(
"traj",
"tree of trajectory positions");
114 traj->Branch(
"ResX",&
ResX,
"ResX/F");
121 traj->Branch(
"chi2",&
chi2,
"chi2/F");
122 traj->Branch(
"p",&
p,
"p/F");
123 traj->Branch(
"pT",&
pT,
"pT/F");
125 traj->Branch(
"Id",&
Id,
"Id/i");
126 traj->Branch(
"run",&
run,
"run/i");
133 traj->Branch(
"dedx",&
dedx,
"dedx/F");
140 traj->Branch(
"PU",&
PU,
"PU/F");
158 if (
DEBUG)
cout <<
"beginning analyze from HitEff" << endl;
161 using namespace reco;
164 int run_nr = e.
id().
run();
173 if (lumiScalers->begin() != lumiScalers->end()) {
174 instLumi = lumiScalers->begin()->instantLumi();
175 PU = lumiScalers->begin()->pileup();
275 if (
DEBUG)
cout <<
"number ckf tracks found = " << tracksCKF->size() << endl;
277 if (tracksCKF->size() > 0) {
301 if(e.
getByLabel(
"muonsWitht0Correction",muH)){
303 if(muonsT0.size()!=0) {
309 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
310 if (hasCaloEnergyInfo)
timeECAL = muonsT0[0].calEnergy().ecal_time;
318 for (vector<Trajectory>::const_iterator itraj = TrajectoryCollectionCKF.
product()->begin();
319 itraj != TrajectoryCollectionCKF.
product()->end();
323 nHits = itraj->foundHits();
325 chi2 = (itraj->chiSquared()/itraj->ndof());
326 pT =
sqrt( ( itraj->lastMeasurement().updatedState().globalMomentum().x() *
327 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
328 ( itraj->lastMeasurement().updatedState().globalMomentum().y() *
329 itraj->lastMeasurement().updatedState().globalMomentum().y()) );
330 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
335 std::vector<TrajectoryMeasurement> TMeas=itraj->measurements();
336 vector<TrajectoryMeasurement>::iterator itm;
341 double angleX = -999.;
342 double angleY = -999.;
343 double xglob,yglob,zglob;
345 for (itm=TMeas.begin();itm!=TMeas.end();itm++){
346 auto theInHit = (*itm).recHit();
348 if(
DEBUG)
cout <<
"theInHit is valid = " << theInHit->isValid() << endl;
350 unsigned int iidd = theInHit->geographicalId().rawId();
352 unsigned int TKlayers =
checkLayer(iidd, tTopo);
353 if (
DEBUG)
cout <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
356 if ( TKlayers == 10 || TKlayers == 22 ) {
357 if (
DEBUG)
cout <<
"skipping original TM for TOB 6 or TEC 9" << endl;
362 std::vector<TrajectoryAtInvalidHit> TMs;
380 if (
DEBUG)
cout <<
" found a hit with a missing partner" << endl;
392 bool isValid = theInHit->isValid();
393 bool isLast = (itm==(TMeas.end()-1));
394 bool isLastTOB5 =
true;
396 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 9 ) isLastTOB5 =
false;
397 else isLastTOB5 =
true;
401 if ( TKlayers==9 && isValid && isLastTOB5 ) {
404 std::vector< BarrelDetLayer const*> barrelTOBLayers = measurementTrackerHandle->geometricSearchTracker()->tobLayers() ;
405 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size()-1];
409 vector<TrajectoryMeasurement>
tmp = theLayerMeasurements->
measurements(*tob6, tsosTOB5, *thePropagator, *estimator);
412 if (
DEBUG)
cout <<
"size of TM from propagation = " << tmp.size() << endl;
418 auto tob6Hit = tob6TM.
recHit();
420 if (tob6Hit->geographicalId().rawId()!=0) {
421 if (
DEBUG)
cout <<
"tob6 hit actually being added to TM vector" << endl;
427 bool isLastTEC8 =
true;
429 if (
checkLayer((++itm)->
recHit()->geographicalId().rawId(), tTopo) == 21 ) isLastTEC8 =
false;
430 else isLastTEC8 =
true;
434 if ( TKlayers==21 && isValid && isLastTEC8 ) {
436 std::vector< const ForwardDetLayer*> posTecLayers = measurementTrackerHandle->geometricSearchTracker()->posTecLayers() ;
437 const DetLayer* tec9pos = posTecLayers[posTecLayers.size()-1];
438 std::vector< const ForwardDetLayer*> negTecLayers = measurementTrackerHandle->geometricSearchTracker()->negTecLayers() ;
439 const DetLayer* tec9neg = negTecLayers[negTecLayers.size()-1];
449 vector<TrajectoryMeasurement>
tmp;
450 if ( tTopo->
tecSide(iidd) == 1 ) {
451 tmp = theLayerMeasurements->
measurements(*tec9neg, tsosTEC9, *thePropagator, *estimator);
454 if ( tTopo->
tecSide(iidd) == 2 ) {
455 tmp = theLayerMeasurements->
measurements(*tec9pos, tsosTEC9, *thePropagator, *estimator);
464 auto tec9Hit = tec9TM.
recHit();
466 unsigned int tec9id = tec9Hit->geographicalId().rawId();
467 if (
DEBUG)
cout <<
"tec9id = " << tec9id <<
" is Double sided = " <<
isDoubleSided(tec9id, tTopo) <<
" and 0x3 = " << (tec9id & 0x3) << endl;
469 if (tec9Hit->geographicalId().rawId()!=0) {
470 if (
DEBUG)
cout <<
"tec9 hit actually being added to TM vector" << endl;
486 for(std::vector<TrajectoryAtInvalidHit>::const_iterator TM=TMs.begin();TM!=TMs.end();++TM) {
489 iidd = TM->monodet_id();
490 if (
DEBUG)
cout <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
495 xErr = TM->localErrorX();
496 yErr = TM->localErrorY();
498 angleX = atan( TM->localDxDz() );
499 angleY = atan( TM->localDyDz() );
501 xglob = TM->globalX();
502 yglob = TM->globalY();
503 zglob = TM->globalZ();
514 if (
DEBUG)
cout <<
"Looking at layer under study" << endl;
523 if (input.
size() > 0 ) {
524 if (
DEBUG)
cout <<
"Checking clusters with size = " << input.
size() << endl;
526 std::vector< std::vector<float> > VCluster_info;
530 unsigned int ClusterId = DSViter->id();
531 if (ClusterId == iidd) {
532 if (
DEBUG)
cout <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
533 DetId ClusterDetId(ClusterId);
544 const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
545 std::array<const float, 4>
const & parameterTrap = (*trapezoidalBounds).
parameters();
546 hbedge = parameterTrap[0];
547 htedge = parameterTrap[1];
548 hapoth = parameterTrap[3];
549 uylfac = (htedge-hbedge)/(htedge+hbedge)/hapoth;
550 uxlden = 1 + yloc*uylfac;
554 if( TrajStrip==-1 ) {
557 TrajStrip = xloc/pitch + nstrips/2.0;
560 float TrajLocXMid = xloc / (1 + (htedge-hbedge)*yloc/(htedge+hbedge)/hapoth) ;
561 TrajStrip = TrajLocXMid/pitch + nstrips/2.0;
570 float res = (parameters.first.x() - xloc);
579 res = parameters.first.x() - xloc/uxlden ;
580 sigma =
abs(res) /
sqrt(parameters.second.xx() + xErr*xErr/uxlden/uxlden + yErr*yErr*xloc*xloc*uylfac*uylfac/uxlden/uxlden/uxlden/uxlden);
587 std::vector< float > cluster_info;
588 cluster_info.push_back(res);
589 cluster_info.push_back(sigma);
590 cluster_info.push_back(parameters.first.x());
591 cluster_info.push_back(
sqrt(parameters.second.xx()));
592 cluster_info.push_back(parameters.first.y());
593 cluster_info.push_back(
sqrt(parameters.second.yy()));
594 cluster_info.push_back( clusterInfo.signalOverNoise() );
596 VCluster_info.push_back(cluster_info);
598 if (
DEBUG)
cout <<
"Have ID match. residual = " << VCluster_info.back()[0] <<
" res sigma = " << VCluster_info.back()[1] << endl;
599 if (
DEBUG)
cout <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
600 if (
DEBUG)
cout <<
"hit position = " << parameters.first.x() <<
" hit error = " <<
sqrt(parameters.second.xx()) <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
604 float FinalResSig = 1000.0;
605 float FinalCluster[7]= {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
607 if (
DEBUG)
cout <<
"found clusters > 0" << endl;
610 vector< vector<float> >::iterator
ires;
611 for (ires=VCluster_info.begin(); ires!=VCluster_info.end(); ires++){
612 if (
abs((*ires)[1]) <
abs(FinalResSig)) {
613 FinalResSig = (*ires)[1];
614 for (
unsigned int i = 0;
i<ires->size();
i++) {
615 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
616 FinalCluster[
i] = (*ires)[
i];
617 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
620 if (
DEBUG)
cout <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1] <<
" and FinalRes = " << FinalCluster[0] << endl;
624 FinalResSig = VCluster_info.at(0)[1];
625 for (
unsigned int i = 0;
i<VCluster_info.at(0).size();
i++) {
626 FinalCluster[
i] = VCluster_info.at(0)[
i];
630 VCluster_info.clear();
633 if (
DEBUG)
cout <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0]/FinalResSig) << endl;
634 if (
DEBUG)
cout <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc) <<
" abs(xloc) = " <<
abs(xloc) << endl;
635 if (
DEBUG)
cout <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5] <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
636 if (
DEBUG)
cout <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
638 float exclusionWidth = 0.4;
639 float TOBexclusion = 0.0;
640 float TECexRing5 = -0.89;
641 float TECexRing6 = -0.56;
642 float TECexRing7 = 0.60;
645 int ringnumber = ((iidd>>5) & 0x7);
648 if((TKlayers >= 5 && TKlayers < 11)||((subdetector == 6)&&( (ringnumber >= 5)&&(ringnumber <=7) ))) {
650 float highzone = 0.0;
652 float higherr = yloc + 5.0*yErr;
653 float lowerr = yloc - 5.0*yErr;
654 if(TKlayers >= 5 && TKlayers < 11) {
656 highzone = TOBexclusion + exclusionWidth;
657 lowzone = TOBexclusion - exclusionWidth;
658 }
else if (ringnumber == 5) {
660 highzone = TECexRing5 + exclusionWidth;
661 lowzone = TECexRing5 - exclusionWidth;
662 }
else if (ringnumber == 6) {
664 highzone = TECexRing6 + exclusionWidth;
665 lowzone = TECexRing6 - exclusionWidth;
666 }
else if (ringnumber == 7) {
668 highzone = TECexRing7 + exclusionWidth;
669 lowzone = TECexRing7 - exclusionWidth;
690 if(
DEBUG)
cout <<
"strip is bad from SiStripQuality" << endl;
693 if(
DEBUG)
cout <<
"strip is good from SiStripQuality" << endl;
697 for (
unsigned int ii=0;
ii< fedErrorIds->
size();
ii++) {
698 if (iidd == (*fedErrorIds)[
ii].rawId() )
708 ResX = FinalCluster[0];
710 if (FinalResSig != FinalCluster[1])
if (
DEBUG)
cout <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
719 if(commonModeDigis.
isValid() && TrajStrip>=0 && TrajStrip<=768) {
721 if(digiframe != commonModeDigis->end())
722 if( (
unsigned) TrajStrip/128 < digiframe->data.
size())
723 commonMode = digiframe->data.at(TrajStrip/128).adc();
726 if (
DEBUG)
cout <<
"before check good" << endl;
728 if ( FinalResSig < 999.0) {
730 if (
DEBUG)
cout <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " <<
731 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
732 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
737 if (
DEBUG)
cout <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0] <<
" FinalRecHit " <<
738 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
739 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
743 if (
DEBUG)
cout <<
" RPhi Error " <<
sqrt(xErr*xErr + yErr*yErr) <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
744 }
if (
DEBUG)
cout <<
"after good location check" << endl;
745 }
if (
DEBUG)
cout <<
"after list of clusters" << endl;
746 }
if (
DEBUG)
cout <<
"After layers=TKLayers if" << endl;
747 }
if (
DEBUG)
cout <<
"After looping over TrajAtValidHit list" << endl;
748 }
if (
DEBUG)
cout <<
"end TMeasurement loop" << endl;
749 }
if (
DEBUG)
cout <<
"end of trajectories loop" << endl;
754 traj->GetDirectory()->cd();
762 double error =
sqrt(parameters.second.xx() + xerr*xerr);
763 double separation =
abs(parameters.first.x() -
xx);
764 double consistency = separation/
error;
770 unsigned int subid=strip.
subdetId();
771 unsigned int layer = 0;
775 if (layer == 1 || layer == 2)
return true;
781 if (layer == 5 || layer == 6)
return true;
786 layer = tTopo->
tidRing(iidd) + 10;
787 if (layer == 11 || layer == 12)
return true;
792 layer = tTopo->
tecRing(iidd) + 13 ;
793 if (layer == 14 || layer == 15 || layer == 18)
return true;
801 unsigned int partner_iidd = 0;
802 bool found2DPartner =
false;
804 if ((iidd & 0x3)==1) partner_iidd = iidd+1;
805 if ((iidd & 0x3)==2) partner_iidd = iidd-1;
808 for (std::vector<TrajectoryMeasurement>::const_iterator iTM=traj.begin(); iTM!=traj.end(); ++iTM) {
809 if (iTM->recHit()->geographicalId().rawId()==partner_iidd) {
810 found2DPartner =
true;
813 return found2DPartner;
818 unsigned int subid=strip.
subdetId();
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) 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
const_iterator end(bool update=false) const
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
bool getByToken(EDGetToken token, Handle< PROD > &result) 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
virtual void localParameters(AClusters const &clusters, ALocalValues &retValues, const GeomDetUnit &gd, const LocalTrajectoryParameters <p) const
std::vector< Track > TrackCollection
collection of Tracks
int bunchCrossing() const
const Bounds & bounds() const
unsigned int tidWheel(const DetId &id) const
T * make(const Args &...args) const
make new ROOT object
std::pair< LocalPoint, LocalError > LocalValues
HitEff(const edm::ParameterSet &conf)
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
virtual float width() const =0
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
bool isDoubleSided(unsigned int iidd, const TrackerTopology *tTopo) const
short getBadApvs(const uint32_t &detid) const
const edm::EDGetTokenT< DetIdCollection > digis_token_
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
size_type size() const
Return the number of contained DetSets.
double checkConsistency(const StripClusterParameterEstimator::LocalValues ¶meters, double xx, double xerr)
T const * product() const
virtual int nstrips() const =0
unsigned int trackMultiplicityCut_
unsigned int checkLayer(unsigned int iidd, const TrackerTopology *tTopo)
const edm::EDGetTokenT< reco::TrackCollection > combinatorialTracks_token_
unsigned int SiStripQualBad
std::vector< std::vector< double > > tmp
std::vector< LumiScalers > LumiScalersCollection
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
collection_type::const_iterator const_iterator
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
const edm::EDGetTokenT< LumiScalersCollection > scalerToken_
const edm::EDGetTokenT< std::vector< Trajectory > > trajectories_token_
unsigned int tecWheel(const DetId &id) const
T const * product() const
const edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > commonModeToken_
const_iterator begin(bool update=false) const
unsigned int tobLayer(const DetId &id) const
unsigned int tecSide(const DetId &id) const