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");
138 if (
DEBUG)
cout <<
"beginning analyze from HitEff" << endl;
141 using namespace reco;
144 int run_nr = e.
id().
run();
155 e.
getByLabel(TkTrajCKF,TrajectoryCollectionCKF);
198 const Propagator* thePropagator = prop.product();
210 unsigned int ClusterId = DSViter->id();
211 DetId ClusterDetId(ClusterId);
221 surface = &(
tracker->idToDet(ClusterDetId)->surface());
231 if (
DEBUG)
cout <<
"number ckf tracks found = " << tracksCKF->size() << endl;
233 if (tracksCKF->size() > 0 && tracksCKF->size()<100) {
234 if (
DEBUG)
cout <<
"starting checking good event with < 100 tracks" << endl;
256 if(e.
getByLabel(
"muonsWitht0Correction",muH)){
258 if(muonsT0.size()!=0) {
264 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
265 if (hasCaloEnergyInfo)
timeECAL = muonsT0[0].calEnergy().ecal_time;
273 for (vector<Trajectory>::const_iterator itraj = TrajectoryCollectionCKF.product()->begin();
274 itraj != TrajectoryCollectionCKF.product()->end();
278 nHits = itraj->foundHits();
280 chi2 = (itraj->chiSquared()/itraj->ndof());
281 pT =
sqrt( ( itraj->lastMeasurement().updatedState().globalMomentum().x() *
282 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
283 ( itraj->lastMeasurement().updatedState().globalMomentum().y() *
284 itraj->lastMeasurement().updatedState().globalMomentum().y()) );
285 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
290 std::vector<TrajectoryMeasurement> TMeas=itraj->measurements();
291 vector<TrajectoryMeasurement>::iterator itm;
296 double angleX = -999.;
297 double angleY = -999.;
298 double xglob,yglob,zglob;
300 for (itm=TMeas.begin();itm!=TMeas.end();itm++){
302 theInHit = (*itm).recHit();
304 if(
DEBUG)
cout <<
"theInHit is valid = " << theInHit->isValid() << endl;
306 unsigned int iidd = theInHit->geographicalId().rawId();
310 if (
DEBUG)
cout <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
313 if ( TKlayers == 10 || TKlayers == 22 ) {
314 if (
DEBUG)
cout <<
"skipping original TM for TOB 6 or TEC 9" << endl;
319 std::vector<TrajectoryAtInvalidHit> TMs;
337 if (
DEBUG)
cout <<
" found a hit with a missing partner" << endl;
349 bool isValid = theInHit->isValid();
350 bool isLast = (itm==(TMeas.end()-1));
351 bool isLastTOB5 =
true;
353 if (
checkLayer((++itm)->recHit()->geographicalId().rawId()) == 9 ) isLastTOB5 =
false;
354 else isLastTOB5 =
true;
358 if ( TKlayers==9 && isValid && isLastTOB5 ) {
361 std::vector< BarrelDetLayer*> barrelTOBLayers = measurementTrackerHandle->geometricSearchTracker()->tobLayers() ;
362 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size()-1];
366 vector<TrajectoryMeasurement>
tmp = theLayerMeasurements->
measurements(*tob6, tsosTOB5, *thePropagator, *estimator);
369 if (
DEBUG)
cout <<
"size of TM from propagation = " << tmp.size() << endl;
376 tob6Hit = tob6TM.recHit();
378 if (tob6Hit->geographicalId().rawId()!=0) {
379 if (
DEBUG)
cout <<
"tob6 hit actually being added to TM vector" << endl;
385 bool isLastTEC8 =
true;
387 if (
checkLayer((++itm)->recHit()->geographicalId().rawId()) == 21 ) isLastTEC8 =
false;
388 else isLastTEC8 =
true;
392 if ( TKlayers==21 && isValid && isLastTEC8 ) {
394 std::vector< ForwardDetLayer*> posTecLayers = measurementTrackerHandle->geometricSearchTracker()->posTecLayers() ;
395 const DetLayer* tec9pos = posTecLayers[posTecLayers.size()-1];
396 std::vector< ForwardDetLayer*> negTecLayers = measurementTrackerHandle->geometricSearchTracker()->negTecLayers() ;
397 const DetLayer* tec9neg = negTecLayers[negTecLayers.size()-1];
407 vector<TrajectoryMeasurement>
tmp;
408 if ( tecdetid.
side() == 1 ) {
409 tmp = theLayerMeasurements->
measurements(*tec9neg, tsosTEC9, *thePropagator, *estimator);
412 if ( tecdetid.
side() == 2 ) {
413 tmp = theLayerMeasurements->
measurements(*tec9pos, tsosTEC9, *thePropagator, *estimator);
423 tec9Hit = tec9TM.recHit();
425 unsigned int tec9id = tec9Hit->geographicalId().rawId();
426 if (
DEBUG)
cout <<
"tec9id = " << tec9id <<
" is Double sided = " <<
isDoubleSided(tec9id) <<
" and 0x3 = " << (tec9id & 0x3) << endl;
428 if (tec9Hit->geographicalId().rawId()!=0) {
429 if (
DEBUG)
cout <<
"tec9 hit actually being added to TM vector" << endl;
445 for(std::vector<TrajectoryAtInvalidHit>::const_iterator TM=TMs.begin();TM!=TMs.end();++TM) {
448 iidd = TM->monodet_id();
449 if (
DEBUG)
cout <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
454 xErr = TM->localErrorX();
455 yErr = TM->localErrorY();
457 angleX = atan( TM->localDxDz() );
458 angleY = atan( TM->localDyDz() );
460 xglob = TM->globalX();
461 yglob = TM->globalY();
462 zglob = TM->globalZ();
472 if (
DEBUG)
cout <<
"Looking at layer under study" << endl;
481 if (
input.size() > 0 ) {
482 if (
DEBUG)
cout <<
"Checking clusters with size = " <<
input.size() << endl;
484 std::vector< std::vector<float> > VCluster_info;
488 unsigned int ClusterId = DSViter->id();
489 if (ClusterId == iidd) {
490 if (
DEBUG)
cout <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
491 DetId ClusterDetId(ClusterId);
497 float res = (parameters.first.x() - xloc);
509 std::vector< float > cluster_info;
510 cluster_info.push_back(res);
511 cluster_info.push_back(sigma);
512 cluster_info.push_back(parameters.first.x());
513 cluster_info.push_back(
sqrt(parameters.second.xx()));
514 cluster_info.push_back(parameters.first.y());
515 cluster_info.push_back(
sqrt(parameters.second.yy()));
520 VCluster_info.push_back(cluster_info);
522 if (
DEBUG)
cout <<
"Have ID match. residual = " << VCluster_info.back()[0] <<
" res sigma = " << VCluster_info.back()[1] << endl;
523 if (
DEBUG)
cout <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
524 if (
DEBUG)
cout <<
"hit position = " << parameters.first.x() <<
" hit error = " <<
sqrt(parameters.second.xx()) <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
528 float FinalResSig = 1000.0;
529 float FinalCluster[7]= {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
531 if (
DEBUG)
cout <<
"found clusters > 0" << endl;
534 vector< vector<float> >::iterator ires;
535 for (ires=VCluster_info.begin(); ires!=VCluster_info.end(); ires++){
536 if (
abs((*ires)[1]) <
abs(FinalResSig)) {
537 FinalResSig = (*ires)[1];
538 for (
unsigned int i = 0;
i<ires->size();
i++) {
539 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
540 FinalCluster[
i] = (*ires)[
i];
541 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
544 if (
DEBUG)
cout <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1] <<
" and FinalRes = " << FinalCluster[0] << endl;
548 FinalResSig = VCluster_info.at(0)[1];
549 for (
unsigned int i = 0;
i<VCluster_info.at(0).size();
i++) {
550 FinalCluster[
i] = VCluster_info.at(0)[
i];
554 VCluster_info.clear();
557 if (
DEBUG)
cout <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0]/FinalResSig) << endl;
558 if (
DEBUG)
cout <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc) <<
" abs(xloc) = " <<
abs(xloc) << endl;
559 if (
DEBUG)
cout <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5] <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
560 if (
DEBUG)
cout <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
562 float exclusionWidth = 0.4;
563 float TOBexclusion = 0.0;
564 float TECexRing5 = -0.89;
565 float TECexRing6 = -0.56;
566 float TECexRing7 = 0.60;
568 int subdetector = ((iidd>>25) & 0x7);
569 int ringnumber = ((iidd>>5) & 0x7);
572 if((TKlayers >= 5 && TKlayers < 11)||((subdetector == 6)&&( (ringnumber >= 5)&&(ringnumber <=7) ))) {
574 float highzone = 0.0;
576 float higherr = yloc + 5.0*yErr;
577 float lowerr = yloc - 5.0*yErr;
578 if(TKlayers >= 5 && TKlayers < 11) {
580 highzone = TOBexclusion + exclusionWidth;
581 lowzone = TOBexclusion - exclusionWidth;
582 }
else if (ringnumber == 5) {
584 highzone = TECexRing5 + exclusionWidth;
585 lowzone = TECexRing5 - exclusionWidth;
586 }
else if (ringnumber == 6) {
588 highzone = TECexRing6 + exclusionWidth;
589 lowzone = TECexRing6 - exclusionWidth;
590 }
else if (ringnumber == 7) {
592 highzone = TECexRing7 + exclusionWidth;
593 lowzone = TECexRing7 - exclusionWidth;
612 if ( SiStripQuality_->getBadApvs(iidd)!=0 ) {
614 if(
DEBUG)
cout <<
"strip is bad from SiStripQuality" << endl;
617 if(
DEBUG)
cout <<
"strip is good from SiStripQuality" << endl;
621 for (
unsigned int ii=0;ii< fedErrorIds->size();ii++) {
622 if (iidd == (*fedErrorIds)[ii].rawId() )
632 ResX = FinalCluster[0];
634 if (FinalResSig != FinalCluster[1])
if (
DEBUG)
cout <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
641 if (
DEBUG)
cout <<
"before check good" << endl;
643 if ( FinalResSig < 999.0) {
645 if (
DEBUG)
cout <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " <<
646 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
647 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
652 if (
DEBUG)
cout <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0] <<
" FinalRecHit " <<
653 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
654 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
658 if (
DEBUG)
cout <<
" RPhi Error " <<
sqrt(xErr*xErr + yErr*yErr) <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
659 }
if (
DEBUG)
cout <<
"after good location check" << endl;
660 }
if (
DEBUG)
cout <<
"after list of clusters" << endl;
661 }
if (
DEBUG)
cout <<
"After layers=TKLayers if" << endl;
662 }
if (
DEBUG)
cout <<
"After looping over TrajAtValidHit list" << endl;
663 }
if (
DEBUG)
cout <<
"end TMeasurement loop" << endl;
664 }
if (
DEBUG)
cout <<
"end of trajectories loop" << endl;
669 traj->GetDirectory()->cd();
672 cout <<
" Events Analysed " <<
events << endl;
677 double error =
sqrt(parameters.second.xx() + xerr*xerr);
678 double separation =
abs(parameters.first.x() - xx);
679 double consistency = separation/
error;
685 unsigned int subid=strip.
subdetId();
686 unsigned int layer = 0;
689 layer = tibid.
layer();
690 if (layer == 1 || layer == 2)
return true;
695 layer = tobid.
layer() + 4 ;
696 if (layer == 5 || layer == 6)
return true;
701 layer = tidid.
ring() + 10;
702 if (layer == 11 || layer == 12)
return true;
707 layer = tecid.
ring() + 13 ;
708 if (layer == 14 || layer == 15 || layer == 18)
return true;
716 unsigned int partner_iidd = 0;
717 bool found2DPartner =
false;
719 if ((iidd & 0x3)==1) partner_iidd = iidd+1;
720 if ((iidd & 0x3)==2) partner_iidd = iidd-1;
723 for (std::vector<TrajectoryMeasurement>::const_iterator iTM=traj.begin(); iTM!=traj.end(); ++iTM) {
724 if (iTM->recHit()->geographicalId().rawId()==partner_iidd) {
725 found2DPartner =
true;
728 return found2DPartner;
733 unsigned int subid=strip.
subdetId();
736 return tibid.
layer();
740 return tobid.
layer() + 4 ;
744 return tidid.
wheel() + 10;
748 return tecid.
wheel() + 13 ;
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) 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
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
unsigned int layer() const
layer id
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
bool isDoubleSided(unsigned int iidd) const
#define DEFINE_FWK_MODULE(type)
std::vector< Track > TrackCollection
collection of Tracks
int bunchCrossing() const
HitEff(const edm::ParameterSet &conf)
data_type const * const_iterator
bool check2DPartner(unsigned int iidd, std::vector< TrajectoryMeasurement > traj)
std::pair< LocalPoint, LocalError > LocalValues
std::vector< Muon > MuonCollection
collection of Muon objects
unsigned int side() const
positive or negative id
virtual LocalValues localParameters(const T &, const GeomDetUnit &) const =0
unsigned int ring() const
ring id
int nDof
number of muon stations used
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(StripClusterParameterEstimator::LocalValues parameters, double xx, double xerr)
T const * product() const
unsigned int wheel() const
wheel id
unsigned int layer() const
layer id
unsigned int SiStripQualBad
std::vector< std::vector< double > > tmp
unsigned int ring() const
ring id
T * make() const
make new ROOT object
unsigned int checkLayer(unsigned int iidd)
unsigned int wheel() const
wheel id