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