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< susybsm::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)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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 56 of file HSCParticleProducer.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file HSCParticleProducer.cc.

References edm::ParameterSet::getParameter(), and i.

27  {
28  using namespace edm;
29  using namespace std;
30 
31  // the Act as Event filter
32  Filter_ = iConfig.getParameter<bool> ("filter");
33 
34  // the input collections
35  m_trackTag = iConfig.getParameter<edm::InputTag>("tracks");
36  m_muonsTag = iConfig.getParameter<edm::InputTag>("muons");
37  m_trackIsoTag = iConfig.getParameter<edm::InputTag>("tracksIsolation");
38 
39  useBetaFromTk = iConfig.getParameter<bool> ("useBetaFromTk" );
40  useBetaFromMuon = iConfig.getParameter<bool> ("useBetaFromMuon");
41  useBetaFromRpc = iConfig.getParameter<bool> ("useBetaFromRpc" );
42  useBetaFromEcal = iConfig.getParameter<bool> ("useBetaFromEcal");
43 
44  // the parameters
45  minTkP = iConfig.getParameter<double> ("minTkP"); // 30
46  maxTkChi2 = iConfig.getParameter<double> ("maxTkChi2"); // 5
47  minTkHits = iConfig.getParameter<uint32_t>("minTkHits"); // 9
48  minMuP = iConfig.getParameter<double> ("minMuP"); // 30
49  minDR = iConfig.getParameter<double> ("minDR"); // 0.1
50  maxInvPtDiff = iConfig.getParameter<double> ("maxInvPtDiff"); // 0.005
51 
56 
57  // Load all the selections
58  std::vector<edm::ParameterSet> SelectionParameters = iConfig.getParameter<std::vector<edm::ParameterSet> >("SelectionParameters");
59  for(unsigned int i=0;i<SelectionParameters.size();i++){
60  Selectors.push_back(new CandidateSelector(SelectionParameters[i]) );
61  }
62 
63  // what I produce
64  produces<susybsm::HSCParticleCollection >();
65  if(useBetaFromEcal)produces<susybsm::HSCPCaloInfoCollection >();
66 
67 }
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 69 of file HSCParticleProducer.cc.

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

Member Function Documentation

void HSCParticleProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDFilter.

Definition at line 198 of file HSCParticleProducer.cc.

198  {
199 }
void HSCParticleProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDFilter.

Definition at line 203 of file HSCParticleProducer.cc.

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

Implements edm::EDFilter.

Definition at line 80 of file HSCParticleProducer.cc.

References deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, newFWLiteAna::found, edm::Event::getByLabel(), i, edm::Ref< C, T, F >::isNull(), edm::Event::put(), dt_dqm_sourceclient_common_cff::reco, query::result, alignCSCRings::s, and lumiQTWidget::t.

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

Definition at line 206 of file HSCParticleProducer.cc.

References deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, newFWLiteAna::found, i, edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::isNull(), m, metsig::muon, susybsm::HSCParticle::setMuon(), susybsm::HSCParticle::setTrack(), lumiQTWidget::t, and testEve_cfg::tracks.

207 {
208  std::vector<HSCParticle> HSCPCollection;
209 
210  // Store a local vector of track ref (that can be modified if matching)
211  std::vector<reco::TrackRef> tracks;
212  for(unsigned int i=0; i<trackCollectionHandle->size(); i++){
213  TrackRef track = reco::TrackRef( trackCollectionHandle, i );
214  if(track->p()<minTkP || (track->chi2()/track->ndof())>maxTkChi2 || track->found()<minTkHits)continue;
215  tracks.push_back( track );
216  }
217 
218  // Loop on muons with inner track ref and create Muon HSCP Candidate
219  for(unsigned int m=0; m<muonCollectionHandle->size(); m++){
220  reco::MuonRef muon = reco::MuonRef( muonCollectionHandle, m );
221  if(muon->p()<minMuP )continue;
222  TrackRef innertrack = muon->innerTrack();
223  if(innertrack.isNull())continue;
224 
225  // Check if the inner track match any track in order to create a Muon+Track HSCP Candidate
226  // Matching is needed because input track collection and muon inner track may lightly differs due to track refit
227  float dRMin=1000; int found = -1;
228  for(unsigned int t=0; t<tracks.size();t++) {
229  reco::TrackRef track = tracks[t];
230  if( fabs( (1.0/innertrack->pt())-(1.0/track->pt())) > maxInvPtDiff) continue;
231  float dR = deltaR(innertrack->momentum(), track->momentum());
232  if(dR <= minDR && dR < dRMin){ dRMin=dR; found = t;}
233  }
234 
235  HSCParticle candidate;
236  candidate.setMuon(muon);
237  if(found>=0){
238 // 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() );
239  candidate.setTrack(tracks[found]);
240  tracks.erase(tracks.begin()+found);
241  }
242  HSCPCollection.push_back(candidate);
243  }
244 
245  // Loop on muons without inner tracks and create Muon HSCP Candidate
246  for(unsigned int m=0; m<muonCollectionHandle->size(); m++){
247  reco::MuonRef muon = reco::MuonRef( muonCollectionHandle, m );
248  if(muon->p()<minMuP)continue;
249  TrackRef innertrack = muon->innerTrack();
250  if(innertrack.isNonnull())continue;
251 
252  // Check if the muon match any track in order to create a Muon+Track HSCP Candidate
253  float dRMin=1000; int found = -1;
254  for(unsigned int t=0; t<tracks.size();t++) {
255  reco::TrackRef track = tracks[t];
256  if( fabs( (1.0/muon->pt())-(1.0/track->pt())) > maxInvPtDiff) continue;
257  float dR = deltaR(muon->momentum(), track->momentum());
258  if(dR <= minDR && dR < dRMin){ dRMin=dR; found = t;}
259  }
260 
261  HSCParticle candidate;
262  candidate.setMuon(muon);
263  if(found>=0){
264 // 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() );
265  candidate.setTrack(tracks[found]);
266  tracks.erase(tracks.begin()+found);
267  }
268  HSCPCollection.push_back(candidate);
269  }
270 
271  // Loop on tracks not matching muon and create Track HSCP Candidate
272  for(unsigned int i=0; i<tracks.size(); i++){
273  HSCParticle candidate;
274  candidate.setTrack(tracks[i]);
275  HSCPCollection.push_back(candidate);
276  }
277 
278  return HSCPCollection;
279 }
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:250
bool isNull() const
Checks for null.
Definition: Ref.h:247
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 90 of file HSCParticleProducer.h.

BetaCalculatorMUON* HSCParticleProducer::beta_calculator_MUON
private

Definition at line 88 of file HSCParticleProducer.h.

BetaCalculatorRPC* HSCParticleProducer::beta_calculator_RPC
private

Definition at line 89 of file HSCParticleProducer.h.

BetaCalculatorTK* HSCParticleProducer::beta_calculator_TK
private

Definition at line 87 of file HSCParticleProducer.h.

bool HSCParticleProducer::Filter_
private

Definition at line 69 of file HSCParticleProducer.h.

edm::InputTag HSCParticleProducer::m_muonsTag
private

Definition at line 73 of file HSCParticleProducer.h.

edm::InputTag HSCParticleProducer::m_trackIsoTag
private

Definition at line 72 of file HSCParticleProducer.h.

edm::InputTag HSCParticleProducer::m_trackTag
private

Definition at line 71 of file HSCParticleProducer.h.

float HSCParticleProducer::maxInvPtDiff
private

Definition at line 85 of file HSCParticleProducer.h.

float HSCParticleProducer::maxTkChi2
private

Definition at line 81 of file HSCParticleProducer.h.

float HSCParticleProducer::minDR
private

Definition at line 84 of file HSCParticleProducer.h.

float HSCParticleProducer::minMuP
private

Definition at line 83 of file HSCParticleProducer.h.

unsigned int HSCParticleProducer::minTkHits
private

Definition at line 82 of file HSCParticleProducer.h.

float HSCParticleProducer::minTkP
private

Definition at line 80 of file HSCParticleProducer.h.

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

Definition at line 92 of file HSCParticleProducer.h.

bool HSCParticleProducer::useBetaFromEcal
private

Definition at line 78 of file HSCParticleProducer.h.

bool HSCParticleProducer::useBetaFromMuon
private

Definition at line 76 of file HSCParticleProducer.h.

bool HSCParticleProducer::useBetaFromRpc
private

Definition at line 77 of file HSCParticleProducer.h.

bool HSCParticleProducer::useBetaFromTk
private

Definition at line 75 of file HSCParticleProducer.h.