00001
00002
00003
00004
00005
00006
00007
00008 #include "RecoParticleFlow/PFTracking/interface/GoodSeedProducer.h"
00009 #include "RecoParticleFlow/PFTracking/interface/PFTrackTransformer.h"
00010 #include "RecoParticleFlow/PFClusterTools/interface/PFResolutionMap.h"
00011
00012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00013 #include "FWCore/ParameterSet/interface/FileInPath.h"
00014
00015 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00016 #include "DataFormats/ParticleFlowReco/interface/PFRecTrack.h"
00017 #include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h"
00018 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
00019 #include "TrackingTools/PatternTools/interface/TrajectoryFitter.h"
00020 #include "TrackingTools/PatternTools/interface/TrajectorySmoother.h"
00021 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
00022 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
00023 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00024 #include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h"
00025 #include "MagneticField/Engine/interface/MagneticField.h"
00026 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00027 #include <fstream>
00028 #include <string>
00029 #include "TMath.h"
00030 #include "Math/VectorUtil.h"
00031
00032 using namespace edm;
00033 using namespace std;
00034 using namespace reco;
00035 PFResolutionMap* GoodSeedProducer::resMapEtaECAL_ = 0;
00036 PFResolutionMap* GoodSeedProducer::resMapPhiECAL_ = 0;
00037
00038 GoodSeedProducer::GoodSeedProducer(const ParameterSet& iConfig):
00039 pfTransformer_(0),
00040 conf_(iConfig)
00041 {
00042 LogInfo("GoodSeedProducer")<<"Electron PreIdentification started ";
00043
00044
00045
00046 tracksContainers_ =
00047 iConfig.getParameter< vector < InputTag > >("TkColList");
00048
00049 minPt_=iConfig.getParameter<double>("MinPt");
00050 maxPt_=iConfig.getParameter<double>("MaxPt");
00051 maxEta_=iConfig.getParameter<double>("MaxEta");
00052
00053
00054
00055 applyIsolation_ =iConfig.getParameter<bool>("ApplyIsolation");
00056 HcalIsolWindow_ =iConfig.getParameter<double>("HcalWindow");
00057 EcalStripSumE_minClusEnergy_ = iConfig.getParameter<double>("EcalStripSumE_minClusEnergy");
00058 EcalStripSumE_deltaEta_ = iConfig.getParameter<double>("EcalStripSumE_deltaEta");
00059 EcalStripSumE_deltaPhiOverQ_minValue_ = iConfig.getParameter<double>("EcalStripSumE_deltaPhiOverQ_minValue");
00060 EcalStripSumE_deltaPhiOverQ_maxValue_ = iConfig.getParameter<double>("EcalStripSumE_deltaPhiOverQ_maxValue");
00061 minEoverP_= iConfig.getParameter<double>("EOverPLead_minValue");
00062 maxHoverP_= iConfig.getParameter<double>("HOverPLead_maxValue");
00063
00064
00065
00066 pfCLusTagECLabel_=
00067 iConfig.getParameter<InputTag>("PFEcalClusterLabel");
00068
00069 pfCLusTagHCLabel_=
00070 iConfig.getParameter<InputTag>("PFHcalClusterLabel");
00071
00072 pfCLusTagPSLabel_=
00073 iConfig.getParameter<InputTag>("PFPSClusterLabel");
00074
00075 preidgsf_=iConfig.getParameter<string>("PreGsfLabel");
00076 preidckf_=iConfig.getParameter<string>("PreCkfLabel");
00077
00078
00079 fitterName_ = iConfig.getParameter<string>("Fitter");
00080 smootherName_ = iConfig.getParameter<string>("Smoother");
00081
00082
00083
00084 nHitsInSeed_=iConfig.getParameter<int>("NHitsInSeed");
00085
00086 clusThreshold_=iConfig.getParameter<double>("ClusterThreshold");
00087
00088 minEp_=iConfig.getParameter<double>("MinEOverP");
00089 maxEp_=iConfig.getParameter<double>("MaxEOverP");
00090
00091
00092 produceCkfseed_ = iConfig.getUntrackedParameter<bool>("ProduceCkfSeed",false);
00093 produceCkfPFT_ = iConfig.getUntrackedParameter<bool>("ProduceCkfPFTracks",true);
00094
00095 LogDebug("GoodSeedProducer")<<"Seeds for GSF will be produced ";
00096 produces<TrajectorySeedCollection>(preidgsf_);
00097
00098 if(produceCkfseed_){
00099 LogDebug("GoodSeedProducer")<<"Seeds for CKF will be produced ";
00100 produces<TrajectorySeedCollection>(preidckf_);
00101 }
00102
00103 if(produceCkfPFT_){
00104 LogDebug("GoodSeedProducer")<<"PFTracks from CKF tracks will be produced ";
00105 produces<PFRecTrackCollection>();
00106 }
00107
00108
00109 useQuality_ = iConfig.getParameter<bool>("UseQuality");
00110 trackQuality_=TrackBase::qualityByName(iConfig.getParameter<std::string>("TrackQuality"));
00111
00112 useTmva_= iConfig.getUntrackedParameter<bool>("UseTMVA",false);
00113
00114 usePreshower_ = iConfig.getParameter<bool>("UsePreShower");
00115 }
00116
00117
00118 GoodSeedProducer::~GoodSeedProducer()
00119 {
00120
00121
00122
00123 delete pfTransformer_;
00124 }
00125
00126
00127
00128
00129
00130
00131
00132 void
00133 GoodSeedProducer::produce(Event& iEvent, const EventSetup& iSetup)
00134 {
00135
00136 LogDebug("GoodSeedProducer")<<"START event: "<<iEvent.id().event()
00137 <<" in run "<<iEvent.id().run();
00138
00139
00140 auto_ptr<TrajectorySeedCollection> output_preid(new TrajectorySeedCollection);
00141 auto_ptr<TrajectorySeedCollection> output_nopre(new TrajectorySeedCollection);
00142 auto_ptr< PFRecTrackCollection >
00143 pOutputPFRecTrackCollection(new PFRecTrackCollection);
00144
00145
00146
00147 iSetup.get<TrackingComponentsRecord>().get(fitterName_, fitter_);
00148 iSetup.get<TrackingComponentsRecord>().get(smootherName_, smoother_);
00149
00150
00151
00152 Handle<PFClusterCollection> theECPfClustCollection;
00153 iEvent.getByLabel(pfCLusTagECLabel_,theECPfClustCollection);
00154
00155 vector<PFCluster> basClus;
00156 vector<PFCluster>::const_iterator iklus;
00157 for (iklus=theECPfClustCollection.product()->begin();
00158 iklus!=theECPfClustCollection.product()->end();
00159 iklus++){
00160 if((*iklus).energy()>clusThreshold_) basClus.push_back(*iklus);
00161 }
00162
00163
00164 Handle<PFClusterCollection> theHCPfClustCollection;
00165 iEvent.getByLabel(pfCLusTagHCLabel_,theHCPfClustCollection);
00166
00167
00168 Handle<PFClusterCollection> thePSPfClustCollection;
00169 iEvent.getByLabel(pfCLusTagPSLabel_,thePSPfClustCollection);
00170
00171 ps1Clus.clear();
00172 ps2Clus.clear();
00173
00174 for (iklus=thePSPfClustCollection.product()->begin();
00175 iklus!=thePSPfClustCollection.product()->end();
00176 iklus++){
00177
00178
00179 if ((*iklus).layer()==-11) ps1Clus.push_back(*iklus);
00180 if ((*iklus).layer()==-12) ps2Clus.push_back(*iklus);
00181 }
00182
00183
00184 for (uint istr=0; istr<tracksContainers_.size();istr++){
00185
00186
00187 Handle<TrackCollection> tkRefCollection;
00188 iEvent.getByLabel(tracksContainers_[istr], tkRefCollection);
00189 TrackCollection Tk=*(tkRefCollection.product());
00190
00191
00192 Handle<vector<Trajectory> > tjCollection;
00193 iEvent.getByLabel(tracksContainers_[istr], tjCollection);
00194 vector<Trajectory> Tj=*(tjCollection.product());
00195
00196
00197 LogDebug("GoodSeedProducer")<<"Number of tracks in collection "
00198 <<tracksContainers_[istr] <<" to be analyzed "
00199 <<Tj.size();
00200
00201
00202
00203 for(uint i=0;i<Tk.size();i++){
00204 if (useQuality_ &&
00205 (!(Tk[i].quality(trackQuality_)))) continue;
00206 int ipteta=getBin(Tk[i].eta(),Tk[i].pt());
00207 int ibin=ipteta*8;
00208 TrackRef trackRef(tkRefCollection, i);
00209 TrajectorySeed Seed=Tj[i].seed();
00210
00211 float PTOB=Tj[i].lastMeasurement().updatedState().globalMomentum().mag();
00212 float chikfred=Tk[i].normalizedChi2();
00213 int nhitpi=Tj[i].foundHits();
00214 float EP=0;
00215
00216
00217
00218
00219 float pfmass= 0.0005;
00220 float pfoutenergy=sqrt((pfmass*pfmass)+Tk[i].outerMomentum().Mag2());
00221 XYZTLorentzVector mom =XYZTLorentzVector(Tk[i].outerMomentum().x(),
00222 Tk[i].outerMomentum().y(),
00223 Tk[i].outerMomentum().z(),
00224 pfoutenergy);
00225 XYZTLorentzVector pos = XYZTLorentzVector(Tk[i].outerPosition().x(),
00226 Tk[i].outerPosition().y(),
00227 Tk[i].outerPosition().z(),
00228 0.);
00229
00230 BaseParticlePropagator theOutParticle =
00231 BaseParticlePropagator( RawParticle(mom,pos),
00232 0,0,B_.z());
00233 theOutParticle.setCharge(Tk[i].charge());
00234
00235 theOutParticle.propagateToEcalEntrance(false);
00236
00237
00238 float toteta=1000;
00239 float totphi=1000;
00240 float dr=1000;
00241 float EE=0;
00242 float feta=0;
00243 math::XYZPointF ElecTrkEcalPos(0,0,0);
00244 if(theOutParticle.getSuccess()!=0){
00245 ElecTrkEcalPos=math::XYZPointF(theOutParticle.vertex().x(),
00246 theOutParticle.vertex().y(),
00247 theOutParticle.vertex().z());
00248 bool isBelowPS=(fabs(theOutParticle.vertex().eta())>1.65) ? true :false;
00249
00250 for(vector<PFCluster>::const_iterator aClus = basClus.begin();
00251 aClus != basClus.end(); aClus++) {
00252 double ecalShowerDepth
00253 = PFCluster::getDepthCorrection(aClus->energy(),
00254 isBelowPS,
00255 false);
00256
00257 math::XYZPoint meanShower=math::XYZPoint(theOutParticle.vertex())+
00258 math::XYZTLorentzVector(theOutParticle.momentum()).Vect().Unit()*ecalShowerDepth;
00259
00260 float etarec=meanShower.eta();
00261 float phirec=meanShower.phi();
00262 float tmp_ep=aClus->energy()/PTOB;
00263 float tmp_phi=fabs(aClus->position().phi()-phirec);
00264 if (tmp_phi>TMath::TwoPi()) tmp_phi-= TMath::TwoPi();
00265 float tmp_dr=sqrt(pow(tmp_phi,2)+
00266 pow((aClus->position().eta()-etarec),2));
00267
00268 if ((tmp_dr<dr)&&(tmp_ep>minEp_)&&(tmp_ep<maxEp_)){
00269 dr=tmp_dr;
00270 toteta=aClus->position().eta()-etarec;
00271 totphi=tmp_phi;
00272 EP=tmp_ep;
00273 EE=aClus->energy();
00274 feta= aClus->position().eta();
00275 }
00276 }
00277 }
00278
00279
00280 double ecaletares
00281 = resMapEtaECAL_->GetBinContent(resMapEtaECAL_->FindBin(feta,EE));
00282 double ecalphires
00283 = resMapPhiECAL_->GetBinContent(resMapPhiECAL_->FindBin(feta,EE));
00284
00285
00286 float chieta=(toteta!=1000)? toteta/ecaletares : toteta;
00287 float chiphi=(totphi!=1000)? totphi/ecalphires : totphi;
00288 float chichi= sqrt(chieta*chieta + chiphi*chiphi);
00289
00290
00291
00292 float chi2cut=thr[ibin+0];
00293 float ep_cutmin=thr[ibin+1];
00294 bool GoodMatching= ((chichi<chi2cut) &&(EP>ep_cutmin) && (nhitpi>10));
00295
00296 if (Tk[i].pt()>maxPt_) GoodMatching=true;
00297 if (Tk[i].pt()<minPt_) GoodMatching=false;
00298
00299
00300
00301 if ((fabs(Tk[i].eta())>1.68)&&(usePreshower_)){
00302 int iptbin =4*getBin(Tk[i].pt());
00303 ps2En=0;ps1En=0;
00304 ps2chi=100.; ps1chi=100.;
00305 PSforTMVA(mom,pos);
00306 float p1e=thrPS[iptbin];
00307 float p2e=thrPS[iptbin+1];
00308 float p1c=thrPS[iptbin+2];
00309 float p2c=thrPS[iptbin+3];
00310 bool GoodPSMatching=
00311 ((ps2En>p2e)
00312 &&(ps1En>p1e)
00313 &&(ps1chi<p1c)
00314 &&(ps2chi<p2c));
00315 GoodMatching = (GoodMatching && GoodPSMatching);
00316 }
00317
00318 if(applyIsolation_){
00319 if(IsIsolated(float(Tk[i].charge()),Tk[i].p(),
00320 ElecTrkEcalPos,*theECPfClustCollection,*theHCPfClustCollection))
00321 GoodMatching=true;
00322 }
00323 bool GoodRange= ((fabs(Tk[i].eta())<maxEta_) &&
00324 (Tk[i].pt()>minPt_));
00325
00326 int hit1max=int(thr[ibin+2]);
00327 float chiredmin=thr[ibin+3];
00328 bool GoodKFFiltering =
00329 ((chikfred>chiredmin) || (nhitpi<hit1max));
00330
00331 bool GoodTkId= false;
00332
00333 if((!GoodMatching) &&(GoodKFFiltering) &&(GoodRange)){
00334 chi=chichi;
00335 chired=1000;
00336 chiRatio=1000;
00337 dpt=0;
00338 nhit=nhitpi;
00339
00340 Trajectory::ConstRecHitContainer tmp;
00341 Trajectory::ConstRecHitContainer hits=Tj[i].recHits();
00342 for (int ih=hits.size()-1; ih>=0; ih--) tmp.push_back(hits[ih]);
00343 vector<Trajectory> FitTjs=(fitter_.product())->fit(Seed,tmp,Tj[i].lastMeasurement().updatedState());
00344
00345 if(FitTjs.size()>0){
00346 if(FitTjs[0].isValid()){
00347 vector<Trajectory> SmooTjs=(smoother_.product())->trajectories(FitTjs[0]);
00348 if(SmooTjs.size()>0){
00349 if(SmooTjs[0].isValid()){
00350
00351
00352
00353 float pt_out=SmooTjs[0].firstMeasurement().
00354 updatedState().globalMomentum().perp();
00355 float pt_in=SmooTjs[0].lastMeasurement().
00356 updatedState().globalMomentum().perp();
00357 dpt=(pt_in>0) ? fabs(pt_out-pt_in)/pt_in : 0.;
00358 chiRatio=SmooTjs[0].chiSquared()/Tj[i].chiSquared();
00359 chired=chiRatio*chikfred;
00360 }
00361 }
00362 }
00363 }
00364
00365
00366 if(useTmva_){
00367
00368
00369
00370 eta=Tk[i].eta();
00371 pt=Tk[i].pt();
00372 eP=EP;
00373
00374
00375
00376 float Ytmva=reader->EvaluateMVA( method_ );
00377
00378 float BDTcut=thr[ibin+4];
00379 if ( Ytmva>BDTcut) GoodTkId=true;
00380 }else{
00381
00382
00383
00384
00385 float chiratiocut=thr[ibin+5];
00386 float gschicut=thr[ibin+6];
00387 float gsptmin=thr[ibin+7];
00388
00389 GoodTkId=((dpt>gsptmin)&&(chired<gschicut)&&(chiRatio<chiratiocut));
00390
00391 }
00392 }
00393
00394 bool GoodPreId= (GoodTkId || GoodMatching);
00395
00396
00397
00398 if(GoodPreId)
00399 LogDebug("GoodSeedProducer")<<"Track (pt= "<<Tk[i].pt()<<
00400 "GeV/c, eta= "<<Tk[i].eta() <<
00401 ") preidentified for agreement between track and ECAL cluster";
00402 if(GoodPreId &&(!GoodMatching))
00403 LogDebug("GoodSeedProducer")<<"Track (pt= "<<Tk[i].pt()<<
00404 "GeV/c, eta= "<<Tk[i].eta() <<
00405 ") preidentified only for track properties";
00406
00407
00408
00409 if (GoodPreId){
00410
00411
00412 int nHitsinSeed= min(nHitsInSeed_,Tj[i].foundHits());
00413
00414 Trajectory seedTraj;
00415 OwnVector<TrackingRecHit> rhits;
00416
00417 vector<TrajectoryMeasurement> tm=Tj[i].measurements();
00418
00419 for (int ihit=tm.size()-1; ihit>=int(tm.size()-nHitsinSeed);ihit-- ){
00420
00421
00422 if ((*tm[ihit].recHit()).hit()->isValid()){
00423 seedTraj.push(tm[ihit]);
00424 rhits.push_back((*tm[ihit].recHit()).hit()->clone());
00425 }
00426 }
00427
00428 if(!seedTraj.measurements().empty()){
00429
00430 PTrajectoryStateOnDet* state = TrajectoryStateTransform().
00431 persistentState(seedTraj.lastMeasurement().updatedState(),
00432 (*seedTraj.lastMeasurement().recHit()).hit()->geographicalId().rawId());
00433 TrajectorySeed NewSeed(*state,rhits,alongMomentum);
00434
00435 output_preid->push_back(NewSeed);
00436 delete state;
00437 }
00438 else output_preid->push_back(Seed);
00439 if(produceCkfPFT_){
00440
00441 PFRecTrack pftrack( trackRef->charge(),
00442 PFRecTrack::KF_ELCAND,
00443 i, trackRef );
00444 bool valid = pfTransformer_->addPoints( pftrack, *trackRef, Tj[i] );
00445 if(valid)
00446 pOutputPFRecTrackCollection->push_back(pftrack);
00447 }
00448 }else{
00449 if (produceCkfseed_){
00450 output_nopre->push_back(Seed);
00451 }
00452 if(produceCkfPFT_){
00453
00454 PFRecTrack pftrack( trackRef->charge(),
00455 PFRecTrack::KF,
00456 i, trackRef );
00457
00458 bool valid = pfTransformer_->addPoints( pftrack, *trackRef, Tj[i] );
00459
00460 if(valid)
00461 pOutputPFRecTrackCollection->push_back(pftrack);
00462
00463 }
00464 }
00465 }
00466 }
00467 if(produceCkfPFT_){
00468 iEvent.put(pOutputPFRecTrackCollection);
00469 }
00470
00471 iEvent.put(output_preid,preidgsf_);
00472 if (produceCkfseed_)
00473 iEvent.put(output_nopre,preidckf_);
00474
00475 }
00476
00477 void
00478 GoodSeedProducer::beginJob(const EventSetup& es)
00479 {
00480
00481 ESHandle<MagneticField> magneticField;
00482 es.get<IdealMagneticFieldRecord>().get(magneticField);
00483 B_=magneticField->inTesla(GlobalPoint(0,0,0));
00484
00485 pfTransformer_= new PFTrackTransformer(B_);
00486
00487
00488
00489
00490
00491 FileInPath ecalEtaMap(conf_.getParameter<string>("EtaMap"));
00492 FileInPath ecalPhiMap(conf_.getParameter<string>("PhiMap"));
00493 resMapEtaECAL_ = new PFResolutionMap("ECAL_eta",ecalEtaMap.fullPath().c_str());
00494 resMapPhiECAL_ = new PFResolutionMap("ECAL_phi",ecalPhiMap.fullPath().c_str());
00495
00496 if(useTmva_){
00497 reader = new TMVA::Reader();
00498 method_ = conf_.getParameter<string>("TMVAMethod");
00499
00500 reader->AddVariable("eP",&eP);
00501 reader->AddVariable("chi",&chi);
00502 reader->AddVariable("chired",&chired);
00503 reader->AddVariable("chiRatio",&chiRatio);
00504 reader->AddVariable("dpt",&dpt);
00505 reader->AddVariable("nhit",&nhit);
00506 reader->AddVariable("eta",&eta);
00507 reader->AddVariable("pt",&pt);
00508 FileInPath Weigths(conf_.getParameter<string>("Weights"));
00509 reader->BookMVA( method_, Weigths.fullPath().c_str() );
00510 }
00511
00512
00513
00514 FileInPath parFile(conf_.getParameter<string>("ThresholdFile"));
00515 ifstream ifs(parFile.fullPath().c_str());
00516 for (int iy=0;iy<72;iy++) ifs >> thr[iy];
00517
00518
00519 FileInPath parPSFile(conf_.getParameter<string>("PSThresholdFile"));
00520 ifstream ifsPS(parPSFile.fullPath().c_str());
00521 for (int iy=0;iy<12;iy++) ifsPS >> thrPS[iy];
00522
00523 }
00524 int GoodSeedProducer::getBin(float pt){
00525 int ip=0;
00526 if (pt<6) ip=0;
00527 else { if (pt<12) ip=1;
00528 else ip=2;
00529 }
00530 return ip;
00531 }
00532 int GoodSeedProducer::getBin(float eta, float pt){
00533 int ie=0;
00534 int ip=0;
00535 if (fabs(eta)<1.2) ie=0;
00536 else{ if (fabs(eta)<1.68) ie=1;
00537 else ie=2;
00538 }
00539 if (pt<6) ip=0;
00540 else { if (pt<12) ip=1;
00541 else ip=2;
00542 }
00543 int iep= ie*3+ip;
00544 LogDebug("GoodSeedProducer")<<"Track pt ="<<pt<<" eta="<<eta<<" bin="<<iep;
00545 return iep;
00546 }
00547
00548 void GoodSeedProducer::PSforTMVA(XYZTLorentzVector mom,XYZTLorentzVector pos ){
00549
00550 BaseParticlePropagator OutParticle(RawParticle(mom,pos)
00551 ,0.,0.,B_.z()) ;
00552
00553 OutParticle.propagateToPreshowerLayer1(false);
00554 if (OutParticle.getSuccess()!=0){
00555
00556 math::XYZPoint v1=math::XYZPoint(OutParticle.vertex());
00557 if ((v1.Rho() >=
00558 PFGeometry::innerRadius(PFGeometry::PS1)) &&
00559 (v1.Rho() <=
00560 PFGeometry::outerRadius(PFGeometry::PS1))) {
00561 float enPScl1=0;
00562 float chi1=100;
00563 vector<PFCluster>::const_iterator ips;
00564 for (ips=ps1Clus.begin(); ips!=ps1Clus.end();ips++){
00565 float ax=((*ips).position().x()-v1.x())/0.114;
00566 float ay=((*ips).position().y()-v1.y())/2.43;
00567 float pschi= sqrt(ax*ax+ay*ay);
00568 if (pschi<chi1){
00569 chi1=pschi;
00570 enPScl1=(*ips).energy();
00571 }
00572 }
00573 ps1En=enPScl1;
00574 ps1chi=chi1;
00575
00576
00577 OutParticle.propagateToPreshowerLayer2(false);
00578 if (OutParticle.getSuccess()!=0){
00579 math::XYZPoint v2=math::XYZPoint(OutParticle.vertex());
00580 if ((v2.Rho() >=
00581 PFGeometry::innerRadius(PFGeometry::PS2)) &&
00582 (v2.Rho() <=
00583 PFGeometry::outerRadius(PFGeometry::PS2))){
00584 float enPScl2=0;
00585 float chi2=100;
00586 for (ips=ps2Clus.begin(); ips!=ps2Clus.end();ips++){
00587 float ax=((*ips).position().x()-v2.x())/1.88;
00588 float ay=((*ips).position().y()-v2.y())/0.1449;
00589 float pschi= sqrt(ax*ax+ay*ay);
00590 if (pschi<chi2){
00591 chi2=pschi;
00592 enPScl2=(*ips).energy();
00593 }
00594 }
00595
00596 ps2En=enPScl2;
00597 ps2chi=chi2;
00598
00599 }
00600 }
00601
00602 }
00603
00604 }
00605 }
00606
00607 bool GoodSeedProducer::IsIsolated(float charge, float P,
00608 math::XYZPointF myElecTrkEcalPos,
00609 const PFClusterCollection &ecalColl,
00610 const PFClusterCollection &hcalColl){
00611
00612
00613 double myHCALenergy3x3=0.;
00614 double myStripClusterE=0.;
00615
00616
00617
00618
00619 if (fabs(myElecTrkEcalPos.z())<1. && myElecTrkEcalPos.x()<1. && myElecTrkEcalPos.y()<1. ) return false;
00620
00621
00622
00623 PFClusterCollection::const_iterator hc=hcalColl.begin();
00624 PFClusterCollection::const_iterator hcend=hcalColl.end();
00625 for (;hc!=hcend;++hc){
00626 math::XYZPoint clusPos = hc->position();
00627 double en = hc->energy();
00628 double deltaR = ROOT::Math::VectorUtil::DeltaR(myElecTrkEcalPos,clusPos);
00629 if (deltaR<HcalIsolWindow_) {
00630 myHCALenergy3x3 += en;
00631
00632 }
00633 }
00634
00635
00636
00637 PFClusterCollection::const_iterator ec=ecalColl.begin();
00638 PFClusterCollection::const_iterator ecend=ecalColl.end();
00639 for (;ec!=ecend;++ec){
00640 math::XYZPoint clusPos = ec->position();
00641 double en = ec->energy();
00642
00643
00644 double deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(myElecTrkEcalPos,clusPos);
00645 double deltaEta = abs(myElecTrkEcalPos.eta()-clusPos.eta());
00646 double deltaPhiOverQ = deltaPhi/charge;
00647 if (en >= EcalStripSumE_minClusEnergy_ && deltaEta<EcalStripSumE_deltaEta_ && deltaPhiOverQ > EcalStripSumE_deltaPhiOverQ_minValue_ && deltaPhiOverQ < EcalStripSumE_deltaPhiOverQ_maxValue_) {
00648 myStripClusterE += en;
00649 }
00650 }
00651
00652 double EoP=myStripClusterE/P;
00653 double HoP=myHCALenergy3x3/P;
00654
00655
00656 return ((EoP>minEoverP_)&&(EoP<2.5) && (HoP<maxHoverP_))?true:false;
00657 }