CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTElectronDetaDphiProducer.cc
Go to the documentation of this file.
1 
10 
11 // Framework
18 
21 
25 
29 
32 
35 
38 
40 
44 
46 {
47 
48  electronProducer_ = conf_.getParameter<edm::InputTag>("electronProducer");
50  useTrackProjectionToEcal_ = conf_.getUntrackedParameter<bool>("useTrackProjectionToEcal",false);
51 
52  //register your products
53  produces < reco::ElectronIsolationMap >( "Deta" ).setBranchAlias( "deta" );
54  produces < reco::ElectronIsolationMap >( "Dphi" ).setBranchAlias( "dphi" );
55 
56 }
57 
59 
60 
61 //
62 // member functions
63 //
64 
65 // ------------ method called to produce the data ------------
66 void
68 {
69 
70  // Get the HLT filtered objects
72  iEvent.getByLabel(electronProducer_,electronHandle);
73 
74  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
75  iEvent.getByLabel(BSProducer_,recoBeamSpotHandle);
76  // gets its position
77  const reco::BeamSpot::Point& BSPosition = recoBeamSpotHandle->position();
78 
79  edm::ESHandle<MagneticField> theMagField;
80  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
81 
84 
85  for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){
86 
87  reco::ElectronRef eleref(reco::ElectronRef(electronHandle,iElectron - electronHandle->begin()));
88  const reco::SuperClusterRef theClus = eleref->superCluster();
89  const math::XYZVector trackMom = eleref->track()->momentum();
90 
91  math::XYZPoint SCcorrPosition(theClus->x()-BSPosition.x(), theClus->y()-BSPosition.y() , theClus->z()-eleref->track()->vz() );
92  float deltaeta = fabs(SCcorrPosition.eta()-eleref->track()->eta());
93  float deltaphi;
94 
96 
97  ECALPositionCalculator posCalc;
98  const math::XYZPoint vertex(BSPosition.x(),BSPosition.y(),eleref->track()->vz());
99 
100  float phi1= posCalc.ecalPhi(theMagField.product(),trackMom,vertex,1);
101  float phi2= posCalc.ecalPhi(theMagField.product(),trackMom,vertex,-1);
102 
103  float deltaphi1=fabs( phi1 - theClus->position().phi() );
104  if(deltaphi1>6.283185308) deltaphi1 -= 6.283185308;
105  if(deltaphi1>3.141592654) deltaphi1 = 6.283185308-deltaphi1;
106 
107  float deltaphi2=fabs( phi2 - theClus->position().phi() );
108  if(deltaphi2>6.283185308) deltaphi2 -= 6.283185308;
109  if(deltaphi2>3.141592654) deltaphi2 = 6.283185308-deltaphi2;
110 
111  deltaphi = deltaphi1;
112  if(deltaphi2<deltaphi1){ deltaphi = deltaphi2;}
113 
114  } else {
115 
116  deltaphi=fabs(eleref->track()->outerPosition().phi()-theClus->phi());
117  if(deltaphi>6.283185308) deltaphi -= 6.283185308;
118  if(deltaphi>3.141592654) deltaphi = 6.283185308-deltaphi;
119 
120  }
121 
122  detaMap.insert(eleref, deltaeta);
123  dphiMap.insert(eleref, deltaphi);
124 
125  }
126 
127  std::auto_ptr<reco::ElectronIsolationMap> detMap(new reco::ElectronIsolationMap(detaMap));
128  std::auto_ptr<reco::ElectronIsolationMap> dphMap(new reco::ElectronIsolationMap(dphiMap));
129  iEvent.put(detMap, "Deta" );
130  iEvent.put(dphMap, "Dphi" );
131 
132 }
133 
134 //define this as a plug-in
135 //DEFINE_FWK_MODULE(EgammaHLTTrackIsolationProducers);
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:30
double ecalPhi(const MagneticField *magField, const math::XYZVector &momentum, const math::XYZPoint &vertex, const int charge)
int iEvent
Definition: GenABIO.cc:243
virtual void produce(edm::Event &, const edm::EventSetup &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
EgammaHLTElectronDetaDphiProducer(const edm::ParameterSet &)
void insert(const key_type &k, const data_type &v)
insert an association
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62