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 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
31 
32 
37 
41 
50 
54 
58 
62 #include <iostream>
63 
64 //
65 // class declaration
66 //
67 
68 using namespace susybsm;
69 using namespace edm;
70 
72  public:
73  explicit ProduceIsolationMap(const edm::ParameterSet&);
75  virtual void produce(edm::Event&, const edm::EventSetup&) override;
76  private:
86  // ----------member data ---------------------------
87 };
88 
89 //
90 // constants, enums and typedefs
91 //
92 
93 
94 //
95 // static data member definitions
96 //
97 
98 //
99 // constructors and destructor
100 //
102 {
103  TKLabel_ = iConfig.getParameter< edm::InputTag > ("TKLabel");
104  inputCollection_ = iConfig.getParameter< edm::InputTag > ("inputCollection");
105  TKIsolationPtcut_ = iConfig.getParameter< double > ("TkIsolationPtCut");
106  IsolationConeDR_ = iConfig.getParameter< double > ("IsolationConeDR");
107 
108 
109  // TrackAssociator parameters
110  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
111  parameters_.loadParameters( parameters );
112  trackAssociator_.useDefaultPropagator();
113 
114  //register your products
115  produces<ValueMap<HSCPIsolation> >();
116 }
117 
118 
120 {
121 }
122 
123 void
125 {
126  using namespace edm;
127  using namespace std;
128 
129  using reco::TrackCollection;
130 
131  Handle<TrackCollection> TKHandle;
132  iEvent.getByLabel(TKLabel_,TKHandle);
133  if(!TKHandle.isValid() ){ edm::LogError("ProduceIsolationMap") << "TK Tracks collection not found"; return; }
134 
135  //Create empty output collections
136  auto_ptr<ValueMap<HSCPIsolation> > trackHSCPIsolMap(new ValueMap<HSCPIsolation> );
137  ValueMap<HSCPIsolation>::Filler filler(*trackHSCPIsolMap);
138 
139  //loop through tracks.
140  Handle<TrackCollection> tkTracks;
141  iEvent.getByLabel(inputCollection_,tkTracks);
142  std::vector<HSCPIsolation> IsolationInfoColl(tkTracks->size());
143 
144  int TkIndex=0;
145  for(TrackCollection::const_iterator itTrack = tkTracks->begin(); itTrack != tkTracks->end(); ++itTrack, TkIndex++) {
146  TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup, *itTrack, parameters_, TrackDetectorAssociator::InsideOut);
147 
148 
149  if(info.ecalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_ECAL_Energy(info.coneEnergy(IsolationConeDR_, TrackDetMatchInfo::EcalRecHits));}
150  if(info.hcalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_HCAL_Energy(info.coneEnergy(IsolationConeDR_, TrackDetMatchInfo::HcalRecHits));}
151 // if(info.hcalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_HCAL_Energy(info.hcalConeEnergy());}
152 // if(info.ecalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_ECAL_Energy(info.ecalConeEnergy());}
153 
154  double SumPt = 0;
155  double Count = 0;
156  double CountHighPt = 0;
157  for(TrackCollection::const_iterator itTrack2 = TKHandle->begin(); itTrack2 != TKHandle->end(); ++itTrack2){
158  if(fabs(itTrack->pt()-itTrack2->pt())<0.1 && fabs(itTrack->eta()-itTrack2->eta())<0.05)continue;
159  float dR = deltaR(itTrack->momentum(), itTrack2->momentum());
160  if(dR>IsolationConeDR_)continue;
161  SumPt+= itTrack2->pt();
162  Count++;
163  if(itTrack2->pt()<TKIsolationPtcut_)continue;
164  CountHighPt++;
165  }
166  IsolationInfoColl[TkIndex].Set_TK_CountHighPt(CountHighPt);
167  IsolationInfoColl[TkIndex].Set_TK_Count (Count);
168  IsolationInfoColl[TkIndex].Set_TK_SumEt (SumPt);
169  }
170 
171  filler.insert(tkTracks, IsolationInfoColl.begin(), IsolationInfoColl.end());
172  filler.fill();
173  iEvent.put(trackHSCPIsolMap);
174 }
175 //define this as a plug-in
T getParameter(std::string const &) const
double coneEnergy(double dR, EnergyType)
dictionary parameters
Definition: Parameters.py:2
static const TGPicture * info(bool iBackgroundIsBlack)
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:52
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:116
TrackDetectorAssociator trackAssociator_
TrackAssociatorParameters parameters_
std::vector< const HBHERecHit * > hcalRecHits
edm::InputTag EBrecHitsLabel_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
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_