CMS 3D CMS Logo

SoftElectronProducer Class Reference

Id
SoftElectronProducer.h,v 1.2 2008/05/29 07:38:08 arizzi Exp
Date
2008/05/29 07:38:08
Revision
1.2
More...

#include <RecoBTag/SoftLepton/plugins/SoftElectronProducer.h>

Inheritance diagram for SoftElectronProducer:

edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 SoftElectronProducer (const edm::ParameterSet &iConf)
 ~SoftElectronProducer ()

Private Member Functions

virtual void beginJob (edm::EventSetup const &iSetup)
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)

Private Attributes

edm::InputTag barrelRecHitCollection_
edm::InputTag endcapRecHitCollection_
edm::InputTag theBasicClusterTag
edm::ParameterSet theConf
double theDiscriminatorCut
ElectronIdMLPtheElecNN
edm::InputTag theHBHERecHitTag
double theHOverEConeSize
edm::InputTag thePrimaryVertexTag
TrackDetectorAssociatortheTrackAssociator
TrackAssociatorParameterstheTrackAssociatorParameters
edm::InputTag theTrackTag


Detailed Description

Id
SoftElectronProducer.h,v 1.2 2008/05/29 07:38:08 arizzi Exp
Date
2008/05/29 07:38:08
Revision
1.2

Author:
P. Demin - UCL, Louvain-la-Neuve - Belgium

Definition at line 24 of file SoftElectronProducer.h.


Constructor & Destructor Documentation

SoftElectronProducer::SoftElectronProducer ( const edm::ParameterSet iConf  ) 

Definition at line 44 of file SoftElectronProducer.cc.

References barrelRecHitCollection_, endcapRecHitCollection_, edm::ParameterSet::getParameter(), python::trackProbabilityAnalysis_cff::parameters, theBasicClusterTag, theConf, theDiscriminatorCut, theElecNN, theHBHERecHitTag, theHOverEConeSize, theTrackAssociator, theTrackAssociatorParameters, theTrackTag, and default_cfi::TrackAssociatorParameters.

00044                                                                        :
00045   theConf(iConf), theTrackAssociator(0), theElecNN(0)
00046 {
00047   theTrackTag             = theConf.getParameter<InputTag>("TrackTag");
00048 
00049   theHBHERecHitTag        = theConf.getParameter<InputTag>("HBHERecHitTag");
00050   theBasicClusterTag      = theConf.getParameter<InputTag>("BasicClusterTag");
00051  // theBasicClusterShapeTag = theConf.getParameter<InputTag>("BasicClusterShapeTag");
00052 
00053   theHOverEConeSize = theConf.getParameter<double>("HOverEConeSize");
00054 
00055   barrelRecHitCollection_ = theConf.getParameter<edm::InputTag>("BarrelRecHitCollection");
00056   endcapRecHitCollection_ = theConf.getParameter<edm::InputTag>("EndcapRecHitCollection");
00057 
00058   // TrackAssociator and its parameters
00059   theTrackAssociator = new TrackDetectorAssociator();
00060   theTrackAssociator->useDefaultPropagator();
00061   edm::ParameterSet parameters = iConf.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
00062   theTrackAssociatorParameters = new TrackAssociatorParameters( parameters );
00063 
00064   theDiscriminatorCut = theConf.getParameter<double>("DiscriminatorCut");
00065 
00066   theElecNN = new ElectronIdMLP;
00067 
00068   // register the product
00069   produces<reco::ElectronCollection>();
00070 }

SoftElectronProducer::~SoftElectronProducer (  ) 

Definition at line 74 of file SoftElectronProducer.cc.

References theElecNN, theTrackAssociator, and theTrackAssociatorParameters.

00075 {
00076   if (theElecNN)                    delete theElecNN;
00077   if (theTrackAssociator)           delete theTrackAssociator;
00078   if (theTrackAssociatorParameters) delete theTrackAssociatorParameters;
00079 }


Member Function Documentation

void SoftElectronProducer::beginJob ( edm::EventSetup const &  iSetup  )  [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 83 of file SoftElectronProducer.cc.

00084 {
00085 
00086 }

void SoftElectronProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 90 of file SoftElectronProducer.cc.

References funct::abs(), TrackDetectorAssociator::associate(), barrelRecHitCollection_, TestMuL1L2Filter_cff::cerr, EcalClusterLazyTools::covariances(), dist(), e, EcalClusterLazyTools::e2x2(), EcalClusterLazyTools::e3x3(), EcalClusterLazyTools::e5x5(), EcalClusterLazyTools::eMax(), endcapRecHitCollection_, lat::endl(), reco::CaloCluster::energy(), eta, reco::TrackBase::eta(), edm::EventSetup::get(), edm::Event::getByLabel(), TrackDetectorAssociator::getFreeTrajectoryState(), DetId::Hcal, info, TrackDetMatchInfo::isGoodEcal, reco::TrackBase::numberOfValidHits(), reco::TrackBase::p(), p4, phi, edm::ESHandle< T >::product(), reco::TrackBase::pt(), edm::Event::put(), reco::Electron::setTrack(), theBasicClusterTag, theDiscriminatorCut, theElecNN, theHBHERecHitTag, theHOverEConeSize, theTrackAssociator, theTrackAssociatorParameters, theTrackTag, track, TrackDetMatchInfo::trkGlobPosAtEcal, v1, v2, v3, v4, ElectronIdMLP::value(), value, cms::Exception::what(), reco::CaloCluster::x(), x, reco::CaloCluster::y(), y, reco::CaloCluster::z(), and z.

00092 {
00093 
00094   auto_ptr<reco::ElectronCollection> candidates(new reco::ElectronCollection());
00095 
00096   Handle<reco::TrackCollection> handleTrack;
00097   reco::TrackCollection::const_iterator itTrack;
00098 
00099   Handle<reco::BasicClusterCollection> handleCluster;
00100   reco::BasicClusterCollection::const_iterator itCluster;
00101 
00102   //Handle<reco::ClusterShapeCollection> handleShape;
00103   //reco::ClusterShapeCollection::const_iterator itShape;
00104 
00105   Handle<HBHERecHitCollection> handleRecHit;
00106   CaloRecHitMetaCollectionV::const_iterator itRecHit;
00107 
00108   ESHandle<CaloGeometry> handleCaloGeom;
00109   
00110 
00111   double hcalEnergy, clusEnergy, trkP;
00112   double x[2], y[2], z[2], eta[2], phi[2];
00113   double covEtaEta, covEtaPhi, covPhiPhi, emFraction, deltaE;
00114   double eMax, e2x2, e3x3, e5x5, v1, v2, v3, v4;
00115   double value, dist, distMin;
00116 
00117   const reco::BasicCluster *matchedCluster;
00118   //const reco::ClusterShape *matchedShape;
00119   const reco::Track *track;
00120 
00121   // get basic clusters
00122   iEvent.getByLabel(theBasicClusterTag, handleCluster);
00123 
00124   // get basic cluster shapes
00125   //iEvent.getByLabel(theBasicClusterShapeTag, handleShape);
00126 
00127   // get rec. hits
00128   iEvent.getByLabel(theHBHERecHitTag, handleRecHit);
00129   HBHERecHitMetaCollection metaRecHit(*handleRecHit);
00130 
00131   //only barrel is used, giving twice the same inputag..
00132 
00133 
00134   EcalClusterLazyTools ecalTool(iEvent, iSetup, barrelRecHitCollection_, endcapRecHitCollection_ );
00135 
00136   // get calorimeter geometry
00137   iSetup.get<CaloGeometryRecord>().get(handleCaloGeom);
00138 
00139   CaloConeSelector selectorRecHit(theHOverEConeSize, handleCaloGeom.product(), DetId::Hcal);
00140 
00141   // get tracks
00142   iEvent.getByLabel(theTrackTag, handleTrack);
00143 
00144   FreeTrajectoryState tmpFTS;
00145   TrackDetMatchInfo info;
00146   unsigned int counterTrack;
00147 
00148   // loop over tracks
00149   for(itTrack = handleTrack->begin(), counterTrack = 0;
00150       itTrack != handleTrack->end();
00151       ++itTrack, ++counterTrack)
00152   {
00153     track = &(*itTrack);
00154 
00155     try {
00156       tmpFTS = theTrackAssociator->getFreeTrajectoryState(iSetup, *track);
00157       info = theTrackAssociator->associate(iEvent, iSetup, tmpFTS, *theTrackAssociatorParameters);
00158     } catch (cms::Exception e) {
00159       // extrapolation failed, skip this track
00160       std::cerr << "Caught exception during track extrapolation: " << e.what() << ". Skipping track" << endl;
00161       continue;
00162     }
00163 
00164     x[0] = info.trkGlobPosAtEcal.x();
00165     y[0] = info.trkGlobPosAtEcal.y();
00166     z[0] = info.trkGlobPosAtEcal.z();
00167     eta[0] = info.trkGlobPosAtEcal.eta();
00168     phi[0] = info.trkGlobPosAtEcal.phi();
00169 
00170     // analyse only tracks passing quality cuts
00171     if(track->numberOfValidHits() >= 8 && track->pt() > 2.0 &&
00172        abs(track->eta()) < 1.2 && info.isGoodEcal)
00173     {
00174       distMin = 1.0e6;
00175       matchedCluster = 0;
00176 //      matchedShape = 0;
00177 
00178       // loop over basic clusters
00179       for(itCluster = handleCluster->begin(); itCluster != handleCluster->end();++itCluster)
00180       {
00181         x[1] = itCluster->x();
00182         y[1] = itCluster->y();
00183         z[1] = itCluster->z();
00184 
00185         eta[1] = itCluster->eta();
00186         phi[1] = itCluster->phi();
00187 
00188 
00189         dist = hypot(x[0] - x[1], y[0] - y[1]);
00190         dist = hypot(dist, z[0] - z[1]);
00191 
00192         if(dist < distMin)
00193         {
00194           distMin = dist;
00195           matchedCluster = &(*itCluster);
00196         }
00197       }
00198 
00199       // identify electrons based on cluster properties
00200       if(matchedCluster  && distMin < 5.0)
00201       {
00202 
00203         GlobalPoint position(matchedCluster->x(), matchedCluster->y(), matchedCluster->z());
00204         auto_ptr<CaloRecHitMetaCollectionV> chosen = selectorRecHit.select(position, metaRecHit);
00205         hcalEnergy = 0.0;
00206         for(itRecHit = chosen->begin(); itRecHit != chosen->end(); ++itRecHit)
00207         {
00208           hcalEnergy += itRecHit->energy();
00209         }
00210 
00211         clusEnergy = matchedCluster->energy();
00212         trkP = track->p();
00213 
00214         deltaE = (clusEnergy - trkP)/(clusEnergy + trkP);
00215         emFraction =  clusEnergy/(clusEnergy + hcalEnergy);
00216 
00217         eMax = ecalTool.eMax(*matchedCluster);
00218         e2x2 = ecalTool.e2x2(*matchedCluster);
00219         e3x3 = ecalTool.e3x3(*matchedCluster);
00220         e5x5 = ecalTool.e5x5(*matchedCluster);
00221         v1 = eMax/e3x3;
00222         v2 = eMax/e2x2;
00223         v3 = e2x2/e5x5;
00224         v4 = ((e5x5 - eMax) < 0.001) ? 1.0 : (e3x3 - eMax)/(e5x5 - eMax);
00225         std::vector<float> cov = ecalTool.covariances(*matchedCluster); 
00226         covEtaEta = cov[0];
00227         covEtaPhi = cov[1];
00228         covPhiPhi = cov[2];
00229 
00230         value = theElecNN->value(0, covEtaEta, covEtaPhi, covPhiPhi,
00231                                  v1, v2, v3, v4, emFraction, deltaE);
00232 
00233         if (value > theDiscriminatorCut)
00234         {
00235           const reco::Particle::LorentzVector  p4(0.0, 0.0, 0.0, clusEnergy);
00236           const reco::Particle::Point vtx(0.0, 0.0, 0.0);
00237 
00238           reco::Electron newCandidate(0, p4, vtx);
00239           reco::TrackRef refTrack(handleTrack, counterTrack);
00240   
00241           newCandidate.setTrack(refTrack);
00242 
00243           candidates->push_back(newCandidate);
00244         }
00245       }
00246     }
00247   }
00248   
00249   // put the product in the event
00250   iEvent.put(candidates);
00251 
00252 }


Member Data Documentation

edm::InputTag SoftElectronProducer::barrelRecHitCollection_ [private]

Definition at line 43 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

edm::InputTag SoftElectronProducer::endcapRecHitCollection_ [private]

Definition at line 44 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

edm::InputTag SoftElectronProducer::theBasicClusterTag [private]

Definition at line 41 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

edm::ParameterSet SoftElectronProducer::theConf [private]

Definition at line 37 of file SoftElectronProducer.h.

Referenced by SoftElectronProducer().

double SoftElectronProducer::theDiscriminatorCut [private]

Definition at line 47 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

ElectronIdMLP* SoftElectronProducer::theElecNN [private]

Definition at line 52 of file SoftElectronProducer.h.

Referenced by produce(), SoftElectronProducer(), and ~SoftElectronProducer().

edm::InputTag SoftElectronProducer::theHBHERecHitTag [private]

Definition at line 40 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

double SoftElectronProducer::theHOverEConeSize [private]

Definition at line 46 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

edm::InputTag SoftElectronProducer::thePrimaryVertexTag [private]

Definition at line 42 of file SoftElectronProducer.h.

TrackDetectorAssociator* SoftElectronProducer::theTrackAssociator [private]

Definition at line 49 of file SoftElectronProducer.h.

Referenced by produce(), SoftElectronProducer(), and ~SoftElectronProducer().

TrackAssociatorParameters* SoftElectronProducer::theTrackAssociatorParameters [private]

Definition at line 50 of file SoftElectronProducer.h.

Referenced by produce(), SoftElectronProducer(), and ~SoftElectronProducer().

edm::InputTag SoftElectronProducer::theTrackTag [private]

Definition at line 39 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:32:39 2009 for CMSSW by  doxygen 1.5.4