test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Skim_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:
83  // ----------member data ---------------------------
84 };
85 
86 //
87 // constants, enums and typedefs
88 //
89 
90 
91 //
92 // static data member definitions
93 //
94 
95 //
96 // constructors and destructor
97 //
99 {
100  TKToken_ = consumes<reco::TrackCollection>(iConfig.getParameter< edm::InputTag > ("TKLabel"));
101  inputCollectionToken_ = consumes<reco::TrackCollection>(iConfig.getParameter< edm::InputTag > ("inputCollection"));
102  TKIsolationPtcut_ = iConfig.getParameter< double > ("TkIsolationPtCut");
103  IsolationConeDR_ = iConfig.getParameter< double > ("IsolationConeDR");
104 
105 
106  // TrackAssociator parameters
107  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
108  edm::ConsumesCollector iC = consumesCollector();
109  parameters_.loadParameters( parameters, iC );
110  trackAssociator_.useDefaultPropagator();
111 
112  //register your products
113  produces<ValueMap<HSCPIsolation> >();
114 }
115 
116 
118 {
119 }
120 
121 void
123 {
124  using namespace edm;
125  using namespace std;
126 
127  using reco::TrackCollection;
128 
129  Handle<TrackCollection> TKHandle;
130  iEvent.getByToken(TKToken_,TKHandle);
131  if(!TKHandle.isValid() ){ edm::LogError("ProduceIsolationMap") << "TK Tracks collection not found"; return; }
132 
133  //Create empty output collections
134  auto_ptr<ValueMap<HSCPIsolation> > trackHSCPIsolMap(new ValueMap<HSCPIsolation> );
135  ValueMap<HSCPIsolation>::Filler filler(*trackHSCPIsolMap);
136 
137  //loop through tracks.
138  Handle<TrackCollection> tkTracks;
139  iEvent.getByToken(inputCollectionToken_,tkTracks);
140  std::vector<HSCPIsolation> IsolationInfoColl(tkTracks->size());
141 
142  int TkIndex=0;
143  for(TrackCollection::const_iterator itTrack = tkTracks->begin(); itTrack != tkTracks->end(); ++itTrack, TkIndex++) {
144  TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup, *itTrack, parameters_, TrackDetectorAssociator::InsideOut);
145 
146 
147  if(info.ecalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_ECAL_Energy(info.coneEnergy(IsolationConeDR_, TrackDetMatchInfo::EcalRecHits));}
148  if(info.hcalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_HCAL_Energy(info.coneEnergy(IsolationConeDR_, TrackDetMatchInfo::HcalRecHits));}
149 // if(info.hcalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_HCAL_Energy(info.hcalConeEnergy());}
150 // if(info.ecalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_ECAL_Energy(info.ecalConeEnergy());}
151 
152  double SumPt = 0;
153  double Count = 0;
154  double CountHighPt = 0;
155  for(TrackCollection::const_iterator itTrack2 = TKHandle->begin(); itTrack2 != TKHandle->end(); ++itTrack2){
156  if(fabs(itTrack->pt()-itTrack2->pt())<0.1 && fabs(itTrack->eta()-itTrack2->eta())<0.05)continue;
157  float dR = deltaR(itTrack->momentum(), itTrack2->momentum());
158  if(dR>IsolationConeDR_)continue;
159  SumPt+= itTrack2->pt();
160  Count++;
161  if(itTrack2->pt()<TKIsolationPtcut_)continue;
162  CountHighPt++;
163  }
164  IsolationInfoColl[TkIndex].Set_TK_CountHighPt(CountHighPt);
165  IsolationInfoColl[TkIndex].Set_TK_Count (Count);
166  IsolationInfoColl[TkIndex].Set_TK_SumEt (SumPt);
167  }
168 
169  filler.insert(tkTracks, IsolationInfoColl.begin(), IsolationInfoColl.end());
170  filler.fill();
171  iEvent.put(trackHSCPIsolMap);
172 }
173 //define this as a plug-in
T getParameter(std::string const &) const
double coneEnergy(double dR, EnergyType)
static const TGPicture * info(bool iBackgroundIsBlack)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#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:14
edm::EDGetTokenT< reco::TrackCollection > inputCollectionToken_
ProduceIsolationMap(const edm::ParameterSet &)
edm::EDGetTokenT< reco::TrackCollection > TKToken_
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
TrackDetectorAssociator trackAssociator_
TrackAssociatorParameters parameters_
std::vector< const HBHERecHit * > hcalRecHits
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
virtual void produce(edm::Event &, const edm::EventSetup &) override