CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ProduceIsolationMap.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ProduceIsolationMap
4 // Class: ProduceIsolationMap
5 //
6 /*\class ProduceIsolationMap ProduceIsolationMap.cc
7 
8  Description: [one line class summary]
9 
10  Implementation:
11  [Notes on implementation]
12 */
13 //
14 // Original Author: Loic Quertenmont
15 // Created: Wed Nov 10 16:41:46 CDT 2010
16 // $Id: ProduceIsolationMap.cc,v 1.4 2013/02/27 22:47:59 wmtan Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
32 
33 
38 
42 
51 
55 
59 
63 #include <iostream>
64 
65 //
66 // class declaration
67 //
68 
69 using namespace susybsm;
70 using namespace edm;
71 
73  public:
74  explicit ProduceIsolationMap(const edm::ParameterSet&);
76  virtual void produce(edm::Event&, const edm::EventSetup&) override;
77  private:
87  // ----------member data ---------------------------
88 };
89 
90 //
91 // constants, enums and typedefs
92 //
93 
94 
95 //
96 // static data member definitions
97 //
98 
99 //
100 // constructors and destructor
101 //
103 {
104  TKLabel_ = iConfig.getParameter< edm::InputTag > ("TKLabel");
105  inputCollection_ = iConfig.getParameter< edm::InputTag > ("inputCollection");
106  TKIsolationPtcut_ = iConfig.getParameter< double > ("TkIsolationPtCut");
107  IsolationConeDR_ = iConfig.getParameter< double > ("IsolationConeDR");
108 
109 
110  // TrackAssociator parameters
111  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
112  parameters_.loadParameters( parameters );
113  trackAssociator_.useDefaultPropagator();
114 
115  //register your products
116  produces<ValueMap<HSCPIsolation> >();
117 }
118 
119 
121 {
122 }
123 
124 void
126 {
127  using namespace edm;
128  using namespace std;
129 
130  using reco::TrackCollection;
131 
132  Handle<TrackCollection> TKHandle;
133  iEvent.getByLabel(TKLabel_,TKHandle);
134  if(!TKHandle.isValid() ){ edm::LogError("ProduceIsolationMap") << "TK Tracks collection not found"; return; }
135 
136  //Create empty output collections
137  auto_ptr<ValueMap<HSCPIsolation> > trackHSCPIsolMap(new ValueMap<HSCPIsolation> );
138  ValueMap<HSCPIsolation>::Filler filler(*trackHSCPIsolMap);
139 
140  //loop through tracks.
141  Handle<TrackCollection> tkTracks;
142  iEvent.getByLabel(inputCollection_,tkTracks);
143  std::vector<HSCPIsolation> IsolationInfoColl(tkTracks->size());
144 
145  int TkIndex=0;
146  for(TrackCollection::const_iterator itTrack = tkTracks->begin(); itTrack != tkTracks->end(); ++itTrack, TkIndex++) {
147  TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup, *itTrack, parameters_, TrackDetectorAssociator::InsideOut);
148 
149 
150  if(info.ecalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_ECAL_Energy(info.coneEnergy(IsolationConeDR_, TrackDetMatchInfo::EcalRecHits));}
151  if(info.hcalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_HCAL_Energy(info.coneEnergy(IsolationConeDR_, TrackDetMatchInfo::HcalRecHits));}
152 // if(info.hcalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_HCAL_Energy(info.hcalConeEnergy());}
153 // if(info.ecalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_ECAL_Energy(info.ecalConeEnergy());}
154 
155  double SumPt = 0;
156  double Count = 0;
157  double CountHighPt = 0;
158  for(TrackCollection::const_iterator itTrack2 = TKHandle->begin(); itTrack2 != TKHandle->end(); ++itTrack2){
159  if(fabs(itTrack->pt()-itTrack2->pt())<0.1 && fabs(itTrack->eta()-itTrack2->eta())<0.05)continue;
160  float dR = deltaR(itTrack->momentum(), itTrack2->momentum());
161  if(dR>IsolationConeDR_)continue;
162  SumPt+= itTrack2->pt();
163  Count++;
164  if(itTrack2->pt()<TKIsolationPtcut_)continue;
165  CountHighPt++;
166  }
167  IsolationInfoColl[TkIndex].Set_TK_CountHighPt(CountHighPt);
168  IsolationInfoColl[TkIndex].Set_TK_Count (Count);
169  IsolationInfoColl[TkIndex].Set_TK_SumEt (SumPt);
170  }
171 
172  filler.insert(tkTracks, IsolationInfoColl.begin(), IsolationInfoColl.end());
173  filler.fill();
174  iEvent.put(trackHSCPIsolMap);
175 }
176 //define this as a plug-in
T getParameter(std::string const &) const
double coneEnergy(double dR, EnergyType)
dictionary parameters
Definition: Parameters.py:2
edm::InputTag inputCollection_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< const EcalRecHit * > ecalRecHits
hits in the cone
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
edm::InputTag EErecHitsLabel_
ProduceIsolationMap(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
TrackDetectorAssociator trackAssociator_
TrackAssociatorParameters parameters_
std::vector< const HBHERecHit * > hcalRecHits
edm::InputTag EBrecHitsLabel_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
virtual void produce(edm::Event &, const edm::EventSetup &) override
edm::InputTag HCALrecHitsLabel_