CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
SoftElectronProducer Class Reference

#include <SoftElectronProducer.h>

Inheritance diagram for SoftElectronProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 SoftElectronProducer (const edm::ParameterSet &iConf)
 
 ~SoftElectronProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

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
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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(), Parameters::parameters, theBasicClusterTag, theConf, theDiscriminatorCut, theElecNN, theHBHERecHitTag, theHOverEConeSize, theTrackAssociator, theTrackAssociatorParameters, theTrackTag, and default_cfi::TrackAssociatorParameters.

44  :
45  theConf(iConf), theTrackAssociator(0), theElecNN(0)
46 {
48 
49  theHBHERecHitTag = theConf.getParameter<InputTag>("HBHERecHitTag");
50  theBasicClusterTag = theConf.getParameter<InputTag>("BasicClusterTag");
51  // theBasicClusterShapeTag = theConf.getParameter<InputTag>("BasicClusterShapeTag");
52 
53  theHOverEConeSize = theConf.getParameter<double>("HOverEConeSize");
54 
55  barrelRecHitCollection_ = theConf.getParameter<edm::InputTag>("BarrelRecHitCollection");
56  endcapRecHitCollection_ = theConf.getParameter<edm::InputTag>("EndcapRecHitCollection");
57 
58  // TrackAssociator and its parameters
60  theTrackAssociator->useDefaultPropagator();
61  edm::ParameterSet parameters = iConf.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
63 
64  theDiscriminatorCut = theConf.getParameter<double>("DiscriminatorCut");
65 
67 
68  // register the product
69  produces<reco::ElectronCollection>();
70 }
T getParameter(std::string const &) const
dictionary parameters
Definition: Parameters.py:2
TrackDetectorAssociator * theTrackAssociator
edm::InputTag barrelRecHitCollection_
tuple TrackAssociatorParameters
Definition: default_cfi.py:43
edm::InputTag endcapRecHitCollection_
edm::InputTag theBasicClusterTag
edm::InputTag theHBHERecHitTag
TrackAssociatorParameters * theTrackAssociatorParameters
edm::ParameterSet theConf
SoftElectronProducer::~SoftElectronProducer ( )

Definition at line 74 of file SoftElectronProducer.cc.

References theElecNN, theTrackAssociator, and theTrackAssociatorParameters.

75 {
76  if (theElecNN) delete theElecNN;
79 }
TrackDetectorAssociator * theTrackAssociator
TrackAssociatorParameters * theTrackAssociatorParameters

Member Function Documentation

void SoftElectronProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 83 of file SoftElectronProducer.cc.

References abs, TrackDetectorAssociator::associate(), barrelRecHitCollection_, benchmark_cfg::cerr, EcalClusterLazyTools::covariances(), EcalClusterLazyTools::e2x2(), EcalClusterLazyTools::e3x3(), EcalClusterLazyTools::e5x5(), jptDQMConfig_cff::eMax, EcalClusterLazyTools::eMax(), endcapRecHitCollection_, CaloRecHit::energy(), reco::TrackBase::eta(), eta(), edm::EventSetup::get(), edm::Event::getByLabel(), TrackDetectorAssociator::getFreeTrajectoryState(), DetId::Hcal, info, TrackDetMatchInfo::isGoodEcal, reco::TrackBase::numberOfValidHits(), reco::TrackBase::p(), p4, phi, position, edm::ESHandle< class >::product(), reco::TrackBase::pt(), edm::Event::put(), reco::Electron::setTrack(), theBasicClusterTag, theDiscriminatorCut, theElecNN, theHBHERecHitTag, theHOverEConeSize, theTrackAssociator, theTrackAssociatorParameters, theTrackTag, TrackDetMatchInfo::trkGlobPosAtEcal, ElectronIdMLP::value(), relativeConstraints::value, cms::Exception::what(), x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

85 {
86 
87  auto_ptr<reco::ElectronCollection> candidates(new reco::ElectronCollection());
88 
90  reco::TrackCollection::const_iterator itTrack;
91 
93  reco::BasicClusterCollection::const_iterator itCluster;
94 
95  //Handle<reco::ClusterShapeCollection> handleShape;
96  //reco::ClusterShapeCollection::const_iterator itShape;
97 
98  Handle<HBHERecHitCollection> handleRecHit;
100 
101  ESHandle<CaloGeometry> handleCaloGeom;
102 
103 
104  double hcalEnergy, clusEnergy, trkP;
105  double x[2], y[2], z[2], eta[2], phi[2];
106  double covEtaEta, covEtaPhi, covPhiPhi, emFraction, deltaE;
107  double eMax, e2x2, e3x3, e5x5, v1, v2, v3, v4;
108  double value, dist, distMin;
109 
110  const reco::BasicCluster *matchedCluster;
111  //const reco::ClusterShape *matchedShape;
112  const reco::Track *track;
113 
114  // get basic clusters
115  iEvent.getByLabel(theBasicClusterTag, handleCluster);
116 
117  // get basic cluster shapes
118  //iEvent.getByLabel(theBasicClusterShapeTag, handleShape);
119 
120  // get rec. hits
121  iEvent.getByLabel(theHBHERecHitTag, handleRecHit);
122  HBHERecHitMetaCollection metaRecHit(*handleRecHit);
123 
124  //only barrel is used, giving twice the same inputag..
125 
126 
128 
129  // get calorimeter geometry
130  iSetup.get<CaloGeometryRecord>().get(handleCaloGeom);
131 
132  CaloConeSelector selectorRecHit(theHOverEConeSize, handleCaloGeom.product(), DetId::Hcal);
133 
134  // get tracks
135  iEvent.getByLabel(theTrackTag, handleTrack);
136 
137  FreeTrajectoryState tmpFTS;
139  unsigned int counterTrack;
140 
141  // loop over tracks
142  for(itTrack = handleTrack->begin(), counterTrack = 0;
143  itTrack != handleTrack->end();
144  ++itTrack, ++counterTrack)
145  {
146  track = &(*itTrack);
147 
148  try {
149  tmpFTS = theTrackAssociator->getFreeTrajectoryState(iSetup, *track);
150  info = theTrackAssociator->associate(iEvent, iSetup, tmpFTS, *theTrackAssociatorParameters);
151  } catch (cms::Exception e) {
152  // extrapolation failed, skip this track
153  std::cerr << "Caught exception during track extrapolation: " << e.what() << ". Skipping track" << endl;
154  continue;
155  }
156 
157  x[0] = info.trkGlobPosAtEcal.x();
158  y[0] = info.trkGlobPosAtEcal.y();
159  z[0] = info.trkGlobPosAtEcal.z();
160  eta[0] = info.trkGlobPosAtEcal.eta();
161  phi[0] = info.trkGlobPosAtEcal.phi();
162 
163  // analyse only tracks passing quality cuts
164  if(track->numberOfValidHits() >= 8 && track->pt() > 2.0 &&
165  abs(track->eta()) < 1.2 && info.isGoodEcal)
166  {
167  distMin = 1.0e6;
168  matchedCluster = 0;
169 // matchedShape = 0;
170 
171  // loop over basic clusters
172  for(itCluster = handleCluster->begin(); itCluster != handleCluster->end();++itCluster)
173  {
174  x[1] = itCluster->x();
175  y[1] = itCluster->y();
176  z[1] = itCluster->z();
177 
178  eta[1] = itCluster->eta();
179  phi[1] = itCluster->phi();
180 
181 
182  dist = hypot(x[0] - x[1], y[0] - y[1]);
183  dist = hypot(dist, z[0] - z[1]);
184 
185  if(dist < distMin)
186  {
187  distMin = dist;
188  matchedCluster = &(*itCluster);
189  }
190  }
191 
192  // identify electrons based on cluster properties
193  if(matchedCluster && distMin < 10.0)
194  {
195  GlobalPoint position(matchedCluster->x(), matchedCluster->y(), matchedCluster->z());
196  auto_ptr<CaloRecHitMetaCollectionV> chosen = selectorRecHit.select(position, metaRecHit);
197  hcalEnergy = 0.0;
198  for(itRecHit = chosen->begin(); itRecHit != chosen->end(); ++itRecHit)
199  {
200  hcalEnergy += itRecHit->energy();
201  }
202 
203  clusEnergy = matchedCluster->energy();
204  trkP = track->p();
205 
206  deltaE = (clusEnergy - trkP)/(clusEnergy + trkP);
207  emFraction = clusEnergy/(clusEnergy + hcalEnergy);
208 
209  eMax = ecalTool.eMax(*matchedCluster);
210  e2x2 = ecalTool.e2x2(*matchedCluster);
211  e3x3 = ecalTool.e3x3(*matchedCluster);
212  e5x5 = ecalTool.e5x5(*matchedCluster);
213  v1 = eMax/e3x3;
214  v2 = eMax/e2x2;
215  v3 = e2x2/e5x5;
216  v4 = ((e5x5 - eMax) < 0.001) ? 1.0 : (e3x3 - eMax)/(e5x5 - eMax);
217  std::vector<float> cov = ecalTool.covariances(*matchedCluster);
218  covEtaEta = cov[0];
219  covEtaPhi = cov[1];
220  covPhiPhi = cov[2];
221 
222  value = theElecNN->value(0, covEtaEta, covEtaPhi, covPhiPhi,
223  v1, v2, v3, v4, emFraction, deltaE);
224  if (value > theDiscriminatorCut)
225  {
226  const reco::Particle::LorentzVector p4(0.0, 0.0, 0.0, clusEnergy);
227  const reco::Particle::Point vtx(0.0, 0.0, 0.0);
228  reco::Electron newCandidate(0, p4, vtx);
229  reco::TrackRef refTrack(handleTrack, counterTrack);
230  newCandidate.setTrack(refTrack);
231  candidates->push_back(newCandidate);
232  }
233  }
234  }
235  }
236 
237  // put the product in the event
238  iEvent.put(candidates);
239 
240 }
virtual char const * what() const
Definition: Exception.cc:97
double p() const
momentum vector magnitude
Definition: TrackBase.h:129
TrackDetectorAssociator * theTrackAssociator
static FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
#define abs(x)
Definition: mlp_lapack.h:159
T eta() const
double double double z
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
edm::InputTag barrelRecHitCollection_
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:141
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
float energy() const
Definition: CaloRecHit.h:19
double p4[4]
Definition: TauolaWrapper.h:92
double pt() const
track transverse momentum
Definition: TrackBase.h:131
math::XYZPoint Point
point in the space
Definition: Particle.h:30
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:232
std::vector< Electron > ElectronCollection
collectin of Electron objects
Definition: ElectronFwd.h:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
edm::InputTag endcapRecHitCollection_
double value(int index, double in0, double in1, double in2, double in3, double in4, double in5, double in6, double in7, double in8)
Definition: ElectronIdMLP.cc:4
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
edm::InputTag theBasicClusterTag
edm::InputTag theHBHERecHitTag
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
math::XYZPoint trkGlobPosAtEcal
Track position at different parts of the calorimeter.
TrackAssociatorParameters * theTrackAssociatorParameters
Definition: DDAxes.h:10
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:26
Definition: DDAxes.h:10

Member Data Documentation

edm::InputTag SoftElectronProducer::barrelRecHitCollection_
private

Definition at line 42 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

edm::InputTag SoftElectronProducer::endcapRecHitCollection_
private

Definition at line 43 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

edm::InputTag SoftElectronProducer::theBasicClusterTag
private

Definition at line 40 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

edm::ParameterSet SoftElectronProducer::theConf
private

Definition at line 36 of file SoftElectronProducer.h.

Referenced by SoftElectronProducer().

double SoftElectronProducer::theDiscriminatorCut
private

Definition at line 46 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

ElectronIdMLP* SoftElectronProducer::theElecNN
private

Definition at line 51 of file SoftElectronProducer.h.

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

edm::InputTag SoftElectronProducer::theHBHERecHitTag
private

Definition at line 39 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

double SoftElectronProducer::theHOverEConeSize
private

Definition at line 45 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

edm::InputTag SoftElectronProducer::thePrimaryVertexTag
private

Definition at line 41 of file SoftElectronProducer.h.

TrackDetectorAssociator* SoftElectronProducer::theTrackAssociator
private

Definition at line 48 of file SoftElectronProducer.h.

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

TrackAssociatorParameters* SoftElectronProducer::theTrackAssociatorParameters
private

Definition at line 49 of file SoftElectronProducer.h.

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

edm::InputTag SoftElectronProducer::theTrackTag
private

Definition at line 38 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().