CMS 3D CMS Logo

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 // system include files
20 #include <memory>
21 
22 // user include files
25 
30 
35 
39 
48 
52 
56 
60 #include <iostream>
61 
62 //
63 // class declaration
64 //
65 
66 using namespace susybsm;
67 using namespace edm;
68 
70 public:
71  explicit ProduceIsolationMap(const edm::ParameterSet&);
72  ~ProduceIsolationMap() override;
73  void produce(edm::Event&, const edm::EventSetup&) override;
74 
75 private:
82  // ----------member data ---------------------------
83 };
84 
85 //
86 // constants, enums and typedefs
87 //
88 
89 //
90 // static data member definitions
91 //
92 
93 //
94 // constructors and destructor
95 //
97  TKToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("TKLabel"));
98  inputCollectionToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("inputCollection"));
99  TKIsolationPtcut_ = iConfig.getParameter<double>("TkIsolationPtCut");
100  IsolationConeDR_ = iConfig.getParameter<double>("IsolationConeDR");
101 
102  // TrackAssociator parameters
103  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
104  edm::ConsumesCollector iC = consumesCollector();
105  parameters_.loadParameters(parameters, iC);
106  trackAssociator_.useDefaultPropagator();
107 
108  //register your products
109  produces<ValueMap<HSCPIsolation> >();
110 }
111 
113 
115  using namespace edm;
116  using namespace std;
117 
118  using reco::TrackCollection;
119 
120  Handle<TrackCollection> TKHandle;
121  iEvent.getByToken(TKToken_, TKHandle);
122  if (!TKHandle.isValid()) {
123  edm::LogError("ProduceIsolationMap") << "TK Tracks collection not found";
124  return;
125  }
126 
127  //Create empty output collections
128  unique_ptr<ValueMap<HSCPIsolation> > trackHSCPIsolMap(new ValueMap<HSCPIsolation>);
129  ValueMap<HSCPIsolation>::Filler filler(*trackHSCPIsolMap);
130 
131  //loop through tracks.
132  Handle<TrackCollection> tkTracks;
133  iEvent.getByToken(inputCollectionToken_, tkTracks);
134  std::vector<HSCPIsolation> IsolationInfoColl(tkTracks->size());
135 
136  int TkIndex = 0;
137  for (TrackCollection::const_iterator itTrack = tkTracks->begin(); itTrack != tkTracks->end(); ++itTrack, TkIndex++) {
139  trackAssociator_.associate(iEvent, iSetup, *itTrack, parameters_, TrackDetectorAssociator::InsideOut);
140 
141  if (!info.ecalRecHits.empty()) {
142  IsolationInfoColl[TkIndex].Set_ECAL_Energy(info.coneEnergy(IsolationConeDR_, TrackDetMatchInfo::EcalRecHits));
143  }
144  if (!info.hcalRecHits.empty()) {
145  IsolationInfoColl[TkIndex].Set_HCAL_Energy(info.coneEnergy(IsolationConeDR_, TrackDetMatchInfo::HcalRecHits));
146  }
147  // if(info.hcalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_HCAL_Energy(info.hcalConeEnergy());}
148  // if(info.ecalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_ECAL_Energy(info.ecalConeEnergy());}
149 
150  double SumPt = 0;
151  double Count = 0;
152  double CountHighPt = 0;
153  for (TrackCollection::const_iterator itTrack2 = TKHandle->begin(); itTrack2 != TKHandle->end(); ++itTrack2) {
154  if (fabs(itTrack->pt() - itTrack2->pt()) < 0.1 && fabs(itTrack->eta() - itTrack2->eta()) < 0.05)
155  continue;
156  float dR = deltaR(itTrack->momentum(), itTrack2->momentum());
157  if (dR > IsolationConeDR_)
158  continue;
159  SumPt += itTrack2->pt();
160  Count++;
161  if (itTrack2->pt() < TKIsolationPtcut_)
162  continue;
163  CountHighPt++;
164  }
165  IsolationInfoColl[TkIndex].Set_TK_CountHighPt(CountHighPt);
166  IsolationInfoColl[TkIndex].Set_TK_Count(Count);
167  IsolationInfoColl[TkIndex].Set_TK_SumEt(SumPt);
168  }
169 
170  filler.insert(tkTracks, IsolationInfoColl.begin(), IsolationInfoColl.end());
171  filler.fill();
172  iEvent.put(std::move(trackHSCPIsolMap));
173 }
174 //define this as a plug-in
TrackExtra.h
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:29
Handle.h
MessageLogger.h
ESHandle.h
TrackDetectorAssociator.h
edm::EDGetTokenT< reco::TrackCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
EBDetId.h
EEDetId.h
ProduceIsolationMap::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: Skim_ProduceIsolationMap.cc:114
susybsm
Definition: HSCParticle.h:16
EDProducer.h
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
ProduceIsolationMap::~ProduceIsolationMap
~ProduceIsolationMap() override
Definition: Skim_ProduceIsolationMap.cc:112
edm::Handle
Definition: AssociativeIterator.h:50
EcalRecHitCollections.h
ProduceIsolationMap::inputCollectionToken_
edm::EDGetTokenT< reco::TrackCollection > inputCollectionToken_
Definition: Skim_ProduceIsolationMap.cc:77
TrackDetMatchInfo::EcalRecHits
Definition: TrackDetMatchInfo.h:15
MakerMacros.h
Track.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
deltaR.h
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
HcalDetId.h
TrackDetectorAssociator
Definition: TrackDetectorAssociator.h:44
CaloTopologyRecord.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
HcalSubdetector.h
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
TrackDetectorAssociator::InsideOut
Definition: TrackDetectorAssociator.h:50
EcalRecHit.h
InputTag.h
CaloTopology.h
ValueMap.h
CaloSubdetectorTopology.h
TrackDetMatchInfo
Definition: TrackDetMatchInfo.h:13
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
ProduceIsolationMap::parameters_
TrackAssociatorParameters parameters_
Definition: Skim_ProduceIsolationMap.cc:81
HSCPIsolation.h
Frameworkfwd.h
ProduceIsolationMap::TKIsolationPtcut_
double TKIsolationPtcut_
Definition: Skim_ProduceIsolationMap.cc:78
edm::ValueMap
Definition: ValueMap.h:107
ProduceIsolationMap::IsolationConeDR_
double IsolationConeDR_
Definition: Skim_ProduceIsolationMap.cc:79
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HcalRecHitCollections.h
TrackDetMatchInfo::HcalRecHits
Definition: TrackDetMatchInfo.h:15
ProduceIsolationMap::TKToken_
edm::EDGetTokenT< reco::TrackCollection > TKToken_
Definition: Skim_ProduceIsolationMap.cc:76
edm::helper::Filler
Definition: ValueMap.h:22
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
ParameterSet.h
ProduceIsolationMap
Definition: Skim_ProduceIsolationMap.cc:69
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
TrackAssociatorParameters.h
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
DetIdCollection.h
TrackDetMatchInfo.h
ProduceIsolationMap::trackAssociator_
TrackDetectorAssociator trackAssociator_
Definition: Skim_ProduceIsolationMap.cc:80
TrackAssociatorParameters
Definition: TrackAssociatorParameters.h:43
ProduceIsolationMap::ProduceIsolationMap
ProduceIsolationMap(const edm::ParameterSet &)
Definition: Skim_ProduceIsolationMap.cc:96