CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
HSCParticleProducer Class Reference

#include <SUSYBSMAnalysis/HSCParticleProducer/src/HSCParticleProducer.cc>

Inheritance diagram for HSCParticleProducer:
edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 HSCParticleProducer (const edm::ParameterSet &)
 
 ~HSCParticleProducer ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual bool filter (edm::Event &, const edm::EventSetup &)
 
std::vector< HSCParticlegetHSCPSeedCollection (edm::Handle< reco::TrackCollection > &trackCollectionHandle, edm::Handle< reco::MuonCollection > &muonCollectionHandle)
 

Private Attributes

BetaCalculatorECALbeta_calculator_ECAL
 
BetaCalculatorMUONbeta_calculator_MUON
 
BetaCalculatorRPCbeta_calculator_RPC
 
BetaCalculatorTKbeta_calculator_TK
 
bool Filter_
 
edm::InputTag m_muonsTag
 
edm::InputTag m_trackIsoTag
 
edm::InputTag m_trackTag
 
float maxInvPtDiff
 
float maxTkChi2
 
float minDR
 
float minMuP
 
unsigned int minTkHits
 
float minTkP
 
std::vector< CandidateSelector * > Selectors
 
bool useBetaFromEcal
 
bool useBetaFromMuon
 
bool useBetaFromRpc
 
bool useBetaFromTk
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
typedef WorkerT< EDFilterWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDFilter
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: Producer for HSCP candidates, merging tracker dt information and rpc information

Implementation: <Notes on="" implementation>="">

Definition at line 57 of file HSCParticleProducer.h.

Constructor & Destructor Documentation

HSCParticleProducer::HSCParticleProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 24 of file HSCParticleProducer.cc.

References beta_calculator_ECAL, beta_calculator_MUON, beta_calculator_RPC, beta_calculator_TK, Filter_, edm::ParameterSet::getParameter(), i, m_muonsTag, m_trackIsoTag, m_trackTag, maxInvPtDiff, maxTkChi2, minDR, minMuP, minTkHits, minTkP, Selectors, useBetaFromEcal, useBetaFromMuon, useBetaFromRpc, and useBetaFromTk.

24  {
25  using namespace edm;
26  using namespace std;
27 
28  // the Act as Event filter
29  Filter_ = iConfig.getParameter<bool> ("filter");
30 
31  // the input collections
32  m_trackTag = iConfig.getParameter<edm::InputTag>("tracks");
33  m_muonsTag = iConfig.getParameter<edm::InputTag>("muons");
34  m_trackIsoTag = iConfig.getParameter<edm::InputTag>("tracksIsolation");
35 
36  useBetaFromTk = iConfig.getParameter<bool> ("useBetaFromTk" );
37  useBetaFromMuon = iConfig.getParameter<bool> ("useBetaFromMuon");
38  useBetaFromRpc = iConfig.getParameter<bool> ("useBetaFromRpc" );
39  useBetaFromEcal = iConfig.getParameter<bool> ("useBetaFromEcal");
40 
41  // the parameters
42  minTkP = iConfig.getParameter<double> ("minTkP"); // 30
43  maxTkChi2 = iConfig.getParameter<double> ("maxTkChi2"); // 5
44  minTkHits = iConfig.getParameter<uint32_t>("minTkHits"); // 9
45  minMuP = iConfig.getParameter<double> ("minMuP"); // 30
46  minDR = iConfig.getParameter<double> ("minDR"); // 0.1
47  maxInvPtDiff = iConfig.getParameter<double> ("maxInvPtDiff"); // 0.005
48 
53 
54  // Load all the selections
55  std::vector<edm::ParameterSet> SelectionParameters = iConfig.getParameter<std::vector<edm::ParameterSet> >("SelectionParameters");
56  for(unsigned int i=0;i<SelectionParameters.size();i++){
57  Selectors.push_back(new CandidateSelector(SelectionParameters[i]) );
58  }
59 
60  // what I produce
61  produces<susybsm::HSCParticleCollection >();
62  if(useBetaFromEcal)produces<susybsm::HSCPCaloInfoCollection >();
63 
64 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
BetaCalculatorMUON * beta_calculator_MUON
BetaCalculatorTK * beta_calculator_TK
BetaCalculatorECAL * beta_calculator_ECAL
BetaCalculatorRPC * beta_calculator_RPC
std::vector< CandidateSelector * > Selectors
edm::InputTag m_trackIsoTag
HSCParticleProducer::~HSCParticleProducer ( )

Definition at line 66 of file HSCParticleProducer.cc.

66  {
67  // do anything here that needs to be done at desctruction time
68  // (e.g. close files, deallocate resources etc.)
69 }

Member Function Documentation

void HSCParticleProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDFilter.

Definition at line 195 of file HSCParticleProducer.cc.

195  {
196 }
void HSCParticleProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDFilter.

Definition at line 200 of file HSCParticleProducer.cc.

200  {
201 }
bool HSCParticleProducer::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDFilter.

Definition at line 77 of file HSCParticleProducer.cc.

References BetaCalculatorMUON::addInfoToCandidate(), BetaCalculatorTK::addInfoToCandidate(), BetaCalculatorRPC::addInfoToCandidate(), BetaCalculatorECAL::addInfoToCandidate(), beta_calculator_ECAL, beta_calculator_MUON, beta_calculator_RPC, beta_calculator_TK, deltaR(), Filter_, newFWLiteAna::found, edm::Event::getByLabel(), getHSCPSeedCollection(), i, edm::Ref< C, T, F >::isNull(), m_muonsTag, m_trackIsoTag, m_trackTag, maxInvPtDiff, minDR, edm::Event::put(), dt_dqm_sourceclient_common_cff::reco, query::result, asciidump::s, Selectors, matplotRender::t, useBetaFromEcal, useBetaFromMuon, useBetaFromRpc, and useBetaFromTk.

77  {
78 
79  using namespace edm;
80  using namespace reco;
81  using namespace std;
82  using namespace susybsm;
83 
84  // information from the muons
85  edm::Handle<reco::MuonCollection> muonCollectionHandle;
86  iEvent.getByLabel(m_muonsTag,muonCollectionHandle);
87 
88  // information from the tracks
89  edm::Handle<reco::TrackCollection> trackCollectionHandle;
90  iEvent.getByLabel(m_trackTag,trackCollectionHandle);
91 
92  // information from the tracks iso
93  edm::Handle<reco::TrackCollection> trackIsoCollectionHandle;
94  iEvent.getByLabel(m_trackIsoTag,trackIsoCollectionHandle);
95 
96 
97  // creates the output collection
99  std::auto_ptr<susybsm::HSCParticleCollection> result(hscp);
100 
102  std::auto_ptr<susybsm::HSCPCaloInfoCollection> caloInfoCollaptr(caloInfoColl);
103 
104 
105  // Fill the output collection with HSCP Candidate (the candiate only contains ref to muon AND/OR track object)
106  *hscp = getHSCPSeedCollection(trackCollectionHandle, muonCollectionHandle);
107 
108  // find the track ref for isolation purposed (main track is supposed to be the Iso track after refitting)
109  for(susybsm::HSCParticleCollection::iterator hscpcandidate = hscp->begin(); hscpcandidate != hscp->end(); ++hscpcandidate) {
110  // Matching is needed because input track collection and muon inner track may lightly differs due to track refit
111  reco::TrackRef track = hscpcandidate->trackRef();
112  if(track.isNull())continue;
113  float dRMin=1000; int found = -1;
114  for(unsigned int t=0; t<trackIsoCollectionHandle->size();t++) {
115  reco::TrackRef Isotrack = reco::TrackRef( trackIsoCollectionHandle, t );
116  if( fabs( (1.0/track->pt())-(1.0/Isotrack->pt())) > maxInvPtDiff) continue;
117  float dR = deltaR(track->momentum(), Isotrack->momentum());
118  if(dR <= minDR && dR < dRMin){ dRMin=dR; found = t;}
119  }
120  if(found>=0)hscpcandidate->setTrackIso(reco::TrackRef( trackIsoCollectionHandle, found ));
121  }
122 
123  // compute the TRACKER contribution
124  if(useBetaFromTk){
125  for(susybsm::HSCParticleCollection::iterator hscpcandidate = hscp->begin(); hscpcandidate != hscp->end(); ++hscpcandidate) {
126  beta_calculator_TK->addInfoToCandidate(*hscpcandidate, iEvent,iSetup);
127  }}
128 
129  // compute the MUON contribution
130  if(useBetaFromMuon){
131  for(susybsm::HSCParticleCollection::iterator hscpcandidate = hscp->begin(); hscpcandidate != hscp->end(); ++hscpcandidate) {
132  beta_calculator_MUON->addInfoToCandidate(*hscpcandidate, iEvent,iSetup);
133  }}
134 
135  // compute the RPC contribution
136  if(useBetaFromRpc){
137  for(susybsm::HSCParticleCollection::iterator hscpcandidate = hscp->begin(); hscpcandidate != hscp->end(); ++hscpcandidate) {
138  beta_calculator_RPC->addInfoToCandidate(*hscpcandidate, iEvent, iSetup);
139  }}
140 
141  // compute the ECAL contribution
142 // auto_ptr<ValueMap<HSCPCaloInfo> > CaloInfoMap(new ValueMap<HSCPCaloInfo> );
143 // ValueMap<HSCPCaloInfo>::Filler filler(*CaloInfoMap);
144 // std::vector<HSCPCaloInfo> CaloInfoColl(hscp->size());
145  if(useBetaFromEcal){
146  int Index=0;
147  caloInfoColl->resize(hscp->size());
148  for(susybsm::HSCParticleCollection::iterator hscpcandidate = hscp->begin(); hscpcandidate != hscp->end(); ++hscpcandidate, Index++) {
149  beta_calculator_ECAL->addInfoToCandidate(*hscpcandidate,trackCollectionHandle,iEvent,iSetup, (*caloInfoColl)[Index]);
150  }}
151 
152  // cleanup the collection based on the input selection
153  for(int i=0;i<(int)hscp->size();i++) {
154  susybsm::HSCParticleCollection::iterator hscpcandidate = hscp->begin() + i;
155  bool decision = false;
156  for(unsigned int s=0;s<Selectors.size();s++){decision |= Selectors[s]->isSelected(*hscpcandidate);}
157  if(!decision){
158  hscp->erase(hscpcandidate);
159  if(useBetaFromEcal)caloInfoColl->erase(caloInfoColl->begin() + i);
160  i--;
161  }
162  }
163  bool filterResult = !Filter_ || (Filter_ && hscp->size()>=1);
164 
165 
166 
167 
168  // output result
169  if(useBetaFromEcal){
170  edm::OrphanHandle<susybsm::HSCPCaloInfoCollection> caloInfoHandle= iEvent.put(caloInfoCollaptr);
171  // adding the reftoCaloInfoObject to the HSCP Object
172  for(int i=0;i<(int)hscp->size();i++) {
173  susybsm::HSCParticleCollection::iterator hscpcandidate = hscp->begin() + i;
174  hscpcandidate->setCaloInfo(HSCPCaloInfoRef(caloInfoHandle,i));
175  }
176  }
177 
178 
179  // output result
180 
181 
183 // if(useBetaFromEcal){
184 // edm::RefProd<susybsm::HSCParticleCollection> hscpCollectionHandle = iEvent.getRefBeforePut<susybsm::HSCParticleCollection>();
185 // filler.insert(putHandle, CaloInfoColl.begin(), CaloInfoColl.end());
186 // filler.fill();
187 // iEvent.put(CaloInfoMap);
188 // }
189 
190  return filterResult;
191 }
int i
Definition: DBlmapReader.cc:9
std::vector< HSCParticle > getHSCPSeedCollection(edm::Handle< reco::TrackCollection > &trackCollectionHandle, edm::Handle< reco::MuonCollection > &muonCollectionHandle)
std::vector< HSCPCaloInfo > HSCPCaloInfoCollection
Definition: HSCPCaloInfo.h:58
void addInfoToCandidate(HSCParticle &candidate, const edm::Event &iEvent, const edm::EventSetup &iSetup)
BetaCalculatorMUON * beta_calculator_MUON
BetaCalculatorTK * beta_calculator_TK
BetaCalculatorECAL * beta_calculator_ECAL
edm::Ref< HSCPCaloInfoCollection > HSCPCaloInfoRef
Definition: HSCPCaloInfo.h:60
std::vector< HSCParticle > HSCParticleCollection
Definition: HSCParticle.h:90
bool isNull() const
Checks for null.
Definition: Ref.h:246
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
tuple result
Definition: query.py:137
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
void addInfoToCandidate(HSCParticle &candidate, edm::Event &iEvent, const edm::EventSetup &iSetup)
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
BetaCalculatorRPC * beta_calculator_RPC
std::vector< CandidateSelector * > Selectors
void addInfoToCandidate(HSCParticle &candidate, edm::Event &iEvent, const edm::EventSetup &iSetup)
string s
Definition: asciidump.py:422
edm::InputTag m_trackIsoTag
void addInfoToCandidate(HSCParticle &candidate, edm::Handle< reco::TrackCollection > &tracks, edm::Event &iEvent, const edm::EventSetup &iSetup, HSCPCaloInfo &caloInfo)
std::vector< HSCParticle > HSCParticleProducer::getHSCPSeedCollection ( edm::Handle< reco::TrackCollection > &  trackCollectionHandle,
edm::Handle< reco::MuonCollection > &  muonCollectionHandle 
)
private

Definition at line 203 of file HSCParticleProducer.cc.

References deltaR(), newFWLiteAna::found, i, edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::isNull(), m, maxInvPtDiff, maxTkChi2, minDR, minMuP, minTkHits, minTkP, metsig::muon, susybsm::HSCParticle::setMuon(), susybsm::HSCParticle::setTrack(), matplotRender::t, and testEve_cfg::tracks.

Referenced by filter().

204 {
205  std::vector<HSCParticle> HSCPCollection;
206 
207  // Store a local vector of track ref (that can be modified if matching)
208  std::vector<reco::TrackRef> tracks;
209  for(unsigned int i=0; i<trackCollectionHandle->size(); i++){
210  TrackRef track = reco::TrackRef( trackCollectionHandle, i );
211  if(track->p()<minTkP || (track->chi2()/track->ndof())>maxTkChi2 || track->found()<minTkHits)continue;
212  tracks.push_back( track );
213  }
214 
215  // Loop on muons with inner track ref and create Muon HSCP Candidate
216  for(unsigned int m=0; m<muonCollectionHandle->size(); m++){
217  reco::MuonRef muon = reco::MuonRef( muonCollectionHandle, m );
218  if(muon->p()<minMuP )continue;
219  TrackRef innertrack = muon->innerTrack();
220  if(innertrack.isNull())continue;
221 
222  // Check if the inner track match any track in order to create a Muon+Track HSCP Candidate
223  // Matching is needed because input track collection and muon inner track may lightly differs due to track refit
224  float dRMin=1000; int found = -1;
225  for(unsigned int t=0; t<tracks.size();t++) {
226  reco::TrackRef track = tracks[t];
227  if( fabs( (1.0/innertrack->pt())-(1.0/track->pt())) > maxInvPtDiff) continue;
228  float dR = deltaR(innertrack->momentum(), track->momentum());
229  if(dR <= minDR && dR < dRMin){ dRMin=dR; found = t;}
230  }
231 
232  HSCParticle candidate;
233  candidate.setMuon(muon);
234  if(found>=0){
235 // printf("MUON with Inner Track Matching --> DR = %6.2f (%6.2f %+6.2f %+6.2f):(%6.2f %+6.2f %+6.2f) vs (%6.2f %+6.2f %+6.2f)\n",dRMin,muon->pt(), muon->eta(), muon->phi(), innertrack->pt(), innertrack->eta(), innertrack->phi(), tracks[found]->pt(), tracks[found]->eta(), tracks[found]->phi() );
236  candidate.setTrack(tracks[found]);
237  tracks.erase(tracks.begin()+found);
238  }
239  HSCPCollection.push_back(candidate);
240  }
241 
242  // Loop on muons without inner tracks and create Muon HSCP Candidate
243  for(unsigned int m=0; m<muonCollectionHandle->size(); m++){
244  reco::MuonRef muon = reco::MuonRef( muonCollectionHandle, m );
245  if(muon->p()<minMuP)continue;
246  TrackRef innertrack = muon->innerTrack();
247  if(innertrack.isNonnull())continue;
248 
249  // Check if the muon match any track in order to create a Muon+Track HSCP Candidate
250  float dRMin=1000; int found = -1;
251  for(unsigned int t=0; t<tracks.size();t++) {
252  reco::TrackRef track = tracks[t];
253  if( fabs( (1.0/muon->pt())-(1.0/track->pt())) > maxInvPtDiff) continue;
254  float dR = deltaR(muon->momentum(), track->momentum());
255  if(dR <= minDR && dR < dRMin){ dRMin=dR; found = t;}
256  }
257 
258  HSCParticle candidate;
259  candidate.setMuon(muon);
260  if(found>=0){
261 // printf("MUON without Inner Track Matching --> DR = %6.2f (%6.2f %+6.2f %+6.2f) vs (%6.2f %+6.2f %+6.2f)\n",dRMin,muon->pt(), muon->eta(), muon->phi(), tracks[found]->pt(), tracks[found]->eta(), tracks[found]->phi() );
262  candidate.setTrack(tracks[found]);
263  tracks.erase(tracks.begin()+found);
264  }
265  HSCPCollection.push_back(candidate);
266  }
267 
268  // Loop on tracks not matching muon and create Track HSCP Candidate
269  for(unsigned int i=0; i<tracks.size(); i++){
270  HSCParticle candidate;
271  candidate.setTrack(tracks[i]);
272  HSCPCollection.push_back(candidate);
273  }
274 
275  return HSCPCollection;
276 }
void setMuon(const reco::MuonRef &data)
Definition: HSCParticle.h:62
int i
Definition: DBlmapReader.cc:9
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:249
bool isNull() const
Checks for null.
Definition: Ref.h:246
edm::Ref< MuonCollection > MuonRef
presistent reference to a Muon
Definition: MuonFwd.h:13
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
tuple tracks
Definition: testEve_cfg.py:39
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
void setTrack(const reco::TrackRef &data)
Definition: HSCParticle.h:63

Member Data Documentation

BetaCalculatorECAL* HSCParticleProducer::beta_calculator_ECAL
private

Definition at line 91 of file HSCParticleProducer.h.

Referenced by filter(), and HSCParticleProducer().

BetaCalculatorMUON* HSCParticleProducer::beta_calculator_MUON
private

Definition at line 89 of file HSCParticleProducer.h.

Referenced by filter(), and HSCParticleProducer().

BetaCalculatorRPC* HSCParticleProducer::beta_calculator_RPC
private

Definition at line 90 of file HSCParticleProducer.h.

Referenced by filter(), and HSCParticleProducer().

BetaCalculatorTK* HSCParticleProducer::beta_calculator_TK
private

Definition at line 88 of file HSCParticleProducer.h.

Referenced by filter(), and HSCParticleProducer().

bool HSCParticleProducer::Filter_
private

Definition at line 70 of file HSCParticleProducer.h.

Referenced by filter(), and HSCParticleProducer().

edm::InputTag HSCParticleProducer::m_muonsTag
private

Definition at line 74 of file HSCParticleProducer.h.

Referenced by filter(), and HSCParticleProducer().

edm::InputTag HSCParticleProducer::m_trackIsoTag
private

Definition at line 73 of file HSCParticleProducer.h.

Referenced by filter(), and HSCParticleProducer().

edm::InputTag HSCParticleProducer::m_trackTag
private

Definition at line 72 of file HSCParticleProducer.h.

Referenced by filter(), and HSCParticleProducer().

float HSCParticleProducer::maxInvPtDiff
private

Definition at line 86 of file HSCParticleProducer.h.

Referenced by filter(), getHSCPSeedCollection(), and HSCParticleProducer().

float HSCParticleProducer::maxTkChi2
private

Definition at line 82 of file HSCParticleProducer.h.

Referenced by getHSCPSeedCollection(), and HSCParticleProducer().

float HSCParticleProducer::minDR
private

Definition at line 85 of file HSCParticleProducer.h.

Referenced by filter(), getHSCPSeedCollection(), and HSCParticleProducer().

float HSCParticleProducer::minMuP
private

Definition at line 84 of file HSCParticleProducer.h.

Referenced by getHSCPSeedCollection(), and HSCParticleProducer().

unsigned int HSCParticleProducer::minTkHits
private

Definition at line 83 of file HSCParticleProducer.h.

Referenced by getHSCPSeedCollection(), and HSCParticleProducer().

float HSCParticleProducer::minTkP
private

Definition at line 81 of file HSCParticleProducer.h.

Referenced by getHSCPSeedCollection(), and HSCParticleProducer().

std::vector<CandidateSelector*> HSCParticleProducer::Selectors
private

Definition at line 93 of file HSCParticleProducer.h.

Referenced by filter(), and HSCParticleProducer().

bool HSCParticleProducer::useBetaFromEcal
private

Definition at line 79 of file HSCParticleProducer.h.

Referenced by filter(), and HSCParticleProducer().

bool HSCParticleProducer::useBetaFromMuon
private

Definition at line 77 of file HSCParticleProducer.h.

Referenced by filter(), and HSCParticleProducer().

bool HSCParticleProducer::useBetaFromRpc
private

Definition at line 78 of file HSCParticleProducer.h.

Referenced by filter(), and HSCParticleProducer().

bool HSCParticleProducer::useBetaFromTk
private

Definition at line 76 of file HSCParticleProducer.h.

Referenced by filter(), and HSCParticleProducer().