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);
170 es.get<
TkStripCPERecord>().
get(
"StripCPEfromTrackAngle", parameterestimator);
198 const Propagator* thePropagator = prop.product();
233 if (
DEBUG)
cout <<
"number ckf tracks found = " << tracksCKF->size() << endl;
235 if (tracksCKF->size() > 0 && tracksCKF->size()<100) {
236 if (
DEBUG)
cout <<
"starting checking good event with < 100 tracks" << endl;
258 if(e.
getByLabel(
"muonsWitht0Correction",muH)){
260 if(muonsT0.size()!=0) {
266 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
267 if (hasCaloEnergyInfo)
timeECAL = muonsT0[0].calEnergy().ecal_time;
275 for (vector<Trajectory>::const_iterator itraj = TrajectoryCollectionCKF.product()->begin();
276 itraj != TrajectoryCollectionCKF.product()->end();
280 nHits = itraj->foundHits();
282 chi2 = (itraj->chiSquared()/itraj->ndof());
283 pT =
sqrt( ( itraj->lastMeasurement().updatedState().globalMomentum().x() *
284 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
285 ( itraj->lastMeasurement().updatedState().globalMomentum().y() *
286 itraj->lastMeasurement().updatedState().globalMomentum().y()) );
287 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
292 std::vector<TrajectoryMeasurement> TMeas=itraj->measurements();
293 vector<TrajectoryMeasurement>::iterator itm;
298 double angleX = -999.;
299 double angleY = -999.;
300 double xglob,yglob,zglob;
302 for (itm=TMeas.begin();itm!=TMeas.end();itm++){
304 theInHit = (*itm).recHit();
306 if(
DEBUG)
cout <<
"theInHit is valid = " << theInHit->isValid() << endl;
308 unsigned int iidd = theInHit->geographicalId().rawId();
311 if (
DEBUG)
cout <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
314 if ( TKlayers == 10 || TKlayers == 22 ) {
315 if (
DEBUG)
cout <<
"skipping original TM for TOB 6 or TEC 9" << endl;
320 std::vector<TrajectoryAtInvalidHit> TMs;
338 if (
DEBUG)
cout <<
" found a hit with a missing partner" << endl;
350 bool isValid = theInHit->isValid();
351 bool isLast = (itm==(TMeas.end()-1));
352 bool isLastTOB5 =
true;
354 if (
checkLayer((++itm)->recHit()->geographicalId().rawId()) == 9 ) isLastTOB5 =
false;
355 else isLastTOB5 =
true;
359 if ( TKlayers==9 && isValid && isLastTOB5 ) {
362 std::vector< BarrelDetLayer*> barrelTOBLayers = measurementTrackerHandle->geometricSearchTracker()->tobLayers() ;
363 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size()-1];
367 vector<TrajectoryMeasurement>
tmp = theLayerMeasurements->
measurements(*tob6, tsosTOB5, *thePropagator, *estimator);
370 if (
DEBUG)
cout <<
"size of TM from propagation = " << tmp.size() << endl;
377 tob6Hit = tob6TM.recHit();
379 if (tob6Hit->geographicalId().rawId()!=0) {
380 if (
DEBUG)
cout <<
"tob6 hit actually being added to TM vector" << endl;
386 bool isLastTEC8 =
true;
388 if (
checkLayer((++itm)->recHit()->geographicalId().rawId()) == 21 ) isLastTEC8 =
false;
389 else isLastTEC8 =
true;
393 if ( TKlayers==21 && isValid && isLastTEC8 ) {
395 std::vector< ForwardDetLayer*> posTecLayers = measurementTrackerHandle->geometricSearchTracker()->posTecLayers() ;
396 const DetLayer* tec9pos = posTecLayers[posTecLayers.size()-1];
397 std::vector< ForwardDetLayer*> negTecLayers = measurementTrackerHandle->geometricSearchTracker()->negTecLayers() ;
398 const DetLayer* tec9neg = negTecLayers[negTecLayers.size()-1];
408 vector<TrajectoryMeasurement>
tmp;
409 if ( tecdetid.side() == 1 ) {
410 tmp = theLayerMeasurements->
measurements(*tec9neg, tsosTEC9, *thePropagator, *estimator);
413 if ( tecdetid.side() == 2 ) {
414 tmp = theLayerMeasurements->
measurements(*tec9pos, tsosTEC9, *thePropagator, *estimator);
424 tec9Hit = tec9TM.recHit();
426 unsigned int tec9id = tec9Hit->geographicalId().rawId();
427 if (
DEBUG)
cout <<
"tec9id = " << tec9id <<
" is Double sided = " <<
isDoubleSided(tec9id) <<
" and 0x3 = " << (tec9id & 0x3) << endl;
429 if (tec9Hit->geographicalId().rawId()!=0) {
430 if (
DEBUG)
cout <<
"tec9 hit actually being added to TM vector" << endl;
446 for(std::vector<TrajectoryAtInvalidHit>::const_iterator TM=TMs.begin();TM!=TMs.end();++TM) {
449 iidd = TM->monodet_id();
450 if (
DEBUG)
cout <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
455 xErr = TM->localErrorX();
456 yErr = TM->localErrorY();
458 angleX = atan( TM->localDxDz() );
459 angleY = atan( TM->localDyDz() );
461 xglob = TM->globalX();
462 yglob = TM->globalY();
463 zglob = TM->globalZ();
473 if (
DEBUG)
cout <<
"Looking at layer under study" << endl;
482 if (
input.size() > 0 ) {
483 if (
DEBUG)
cout <<
"Checking clusters with size = " <<
input.size() << endl;
485 std::vector< std::vector<float> > VCluster_info;
489 unsigned int ClusterId = DSViter->id();
490 if (ClusterId == iidd) {
491 if (
DEBUG)
cout <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
492 DetId ClusterDetId(ClusterId);
498 float res = (parameters.first.x() - xloc);
510 std::vector< float > cluster_info;
511 cluster_info.push_back(res);
512 cluster_info.push_back(sigma);
513 cluster_info.push_back(parameters.first.x());
514 cluster_info.push_back(
sqrt(parameters.second.xx()));
515 cluster_info.push_back(parameters.first.y());
516 cluster_info.push_back(
sqrt(parameters.second.yy()));
519 VCluster_info.push_back(cluster_info);
521 if (
DEBUG)
cout <<
"Have ID match. residual = " << VCluster_info.back()[0] <<
" res sigma = " << VCluster_info.back()[1] << endl;
522 if (
DEBUG)
cout <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
523 if (
DEBUG)
cout <<
"hit position = " << parameters.first.x() <<
" hit error = " <<
sqrt(parameters.second.xx()) <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
527 float FinalResSig = 1000.0;
528 float FinalCluster[7]= {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
530 if (
DEBUG)
cout <<
"found clusters > 0" << endl;
533 vector< vector<float> >::iterator
ires;
534 for (ires=VCluster_info.begin(); ires!=VCluster_info.end(); ires++){
535 if (
abs((*ires)[1]) <
abs(FinalResSig)) {
536 FinalResSig = (*ires)[1];
537 for (
unsigned int i = 0;
i<ires->size();
i++) {
538 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
539 FinalCluster[
i] = (*ires)[
i];
540 if (
DEBUG)
cout <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i] <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
543 if (
DEBUG)
cout <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1] <<
" and FinalRes = " << FinalCluster[0] << endl;
547 FinalResSig = VCluster_info.at(0)[1];
548 for (
unsigned int i = 0;
i<VCluster_info.at(0).size();
i++) {
549 FinalCluster[
i] = VCluster_info.at(0)[
i];
553 VCluster_info.clear();
556 if (
DEBUG)
cout <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0]/FinalResSig) << endl;
557 if (
DEBUG)
cout <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc) <<
" abs(xloc) = " <<
abs(xloc) << endl;
558 if (
DEBUG)
cout <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5] <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
559 if (
DEBUG)
cout <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
561 float exclusionWidth = 0.4;
562 float TOBexclusion = 0.0;
563 float TECexRing5 = -0.89;
564 float TECexRing6 = -0.56;
565 float TECexRing7 = 0.60;
567 int subdetector = ((iidd>>25) & 0x7);
568 int ringnumber = ((iidd>>5) & 0x7);
571 if((TKlayers >= 5 && TKlayers < 11)||((subdetector == 6)&&( (ringnumber >= 5)&&(ringnumber <=7) ))) {
573 float highzone = 0.0;
575 float higherr = yloc + 5.0*yErr;
576 float lowerr = yloc - 5.0*yErr;
577 if(TKlayers >= 5 && TKlayers < 11) {
579 highzone = TOBexclusion + exclusionWidth;
580 lowzone = TOBexclusion - exclusionWidth;
581 }
else if (ringnumber == 5) {
583 highzone = TECexRing5 + exclusionWidth;
584 lowzone = TECexRing5 - exclusionWidth;
585 }
else if (ringnumber == 6) {
587 highzone = TECexRing6 + exclusionWidth;
588 lowzone = TECexRing6 - exclusionWidth;
589 }
else if (ringnumber == 7) {
591 highzone = TECexRing7 + exclusionWidth;
592 lowzone = TECexRing7 - exclusionWidth;
611 if ( SiStripQuality_->getBadApvs(iidd)!=0 ) {
613 if(
DEBUG)
cout <<
"strip is bad from SiStripQuality" << endl;
616 if(
DEBUG)
cout <<
"strip is good from SiStripQuality" << endl;
620 for (
unsigned int ii=0;ii< fedErrorIds->size();ii++) {
621 if (iidd == (*fedErrorIds)[ii].rawId() )
631 ResX = FinalCluster[0];
633 if (FinalResSig != FinalCluster[1])
if (
DEBUG)
cout <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
640 if (
DEBUG)
cout <<
"before check good" << endl;
642 if ( FinalResSig < 999.0) {
644 if (
DEBUG)
cout <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " <<
645 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
646 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
651 if (
DEBUG)
cout <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0] <<
" FinalRecHit " <<
652 iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd <<
653 " matched/stereo/rphi = " << ((iidd & 0x3)==0) <<
"/" << ((iidd & 0x3)==1) <<
"/" << ((iidd & 0x3)==2) << endl;
657 if (
DEBUG)
cout <<
" RPhi Error " <<
sqrt(xErr*xErr + yErr*yErr) <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
658 }
if (
DEBUG)
cout <<
"after good location check" << endl;
659 }
if (
DEBUG)
cout <<
"after list of clusters" << endl;
660 }
if (
DEBUG)
cout <<
"After layers=TKLayers if" << endl;
661 }
if (
DEBUG)
cout <<
"After looping over TrajAtValidHit list" << endl;
662 }
if (
DEBUG)
cout <<
"end TMeasurement loop" << endl;
663 }
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
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
bool isDoubleSided(unsigned int iidd) const
std::vector< Track > TrackCollection
collection of Tracks
int bunchCrossing() const
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
float signalOverNoise() const
int nDof
number of muon stations used
unsigned int trajHitValid
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double checkConsistency(StripClusterParameterEstimator::LocalValues parameters, double xx, double xerr)
T const * product() const
unsigned int SiStripQualBad
std::vector< std::vector< double > > tmp
unsigned int checkLayer(unsigned int iidd)