CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTPixlMBFilt.cc
Go to the documentation of this file.
1 
11 
17 
19 
21 
24 
26 
27 //
28 // constructors and destructor
29 //
30 
32  pixlTag_ (iConfig.getParameter<edm::InputTag>("pixlTag")),
33  min_Pt_ (iConfig.getParameter<double>("MinPt")),
34  min_trks_ (iConfig.getParameter<unsigned int>("MinTrks")),
35  min_sep_ (iConfig.getParameter<double>("MinSep"))
36 
37 {
38  pixlToken_ = consumes<reco::RecoChargedCandidateCollection>(pixlTag_);
39  LogDebug("") << "MinPt cut " << min_Pt_ << "pixl: " << pixlTag_.encode();
40  LogDebug("") << "Requesting : " << min_trks_ << " tracks from same vertex ";
41  LogDebug("") << "Requesting tracks from same vertex eta-phi separation by " << min_sep_;
42 }
43 
45 {
46 }
47 
48 void
52  desc.add<edm::InputTag>("pixlTag",edm::InputTag("hltPixelCands"));
53  desc.add<double>("MinPt",0.);
54  desc.add<unsigned int>("MinTrks",2);
55  desc.add<double>("MinSep",1.);
56  descriptions.add("hltPixlMBFilt",desc);
57 }
58 
59 //
60 // member functions
61 //
62 
63 // ------------ method called to produce the data ------------
65 {
66  using namespace std;
67  using namespace edm;
68  using namespace reco;
69  using namespace trigger;
70 
71  // All HLT filters must create and fill an HLT filter object,
72  // recording any reconstructed physics objects satisfying (or not)
73  // this HLT filter, and place it in the Event.
74  if (saveTags()) {
75  filterproduct.addCollectionTag(pixlTag_);
76  }
77 
78  // Specific filter code
79 
80  // get hold of products from Event
81 
84 
85  // pixel tracks
86  int npixl_tot = 0;
87  vector<double> etastore;
88  vector<double> phistore;
89  vector<int> itstore;
90  bool accept;
91  RecoChargedCandidateCollection::const_iterator apixl(tracks->begin());
92  RecoChargedCandidateCollection::const_iterator epixl(tracks->end());
93  RecoChargedCandidateCollection::const_iterator ipixl, jpixl;
94  unsigned int nsame_vtx=0;
95  int itrk = -1;
96  if (tracks->size() >= min_trks_) {
97  for (ipixl=apixl; ipixl!=epixl; ipixl++){
98  if (ipixl->pt() < min_Pt_) continue;
99  itrk++;
100  const double& ztrk1 = ipixl->vz();
101  const double& etatrk1 = ipixl->momentum().eta();
102  const double& phitrk1 = ipixl->momentum().phi();
103  nsame_vtx=1;
104  etastore.clear();
105  phistore.clear();
106  itstore.clear();
107  etastore.push_back(etatrk1);
108  phistore.push_back(phitrk1);
109  itstore.push_back(itrk);
110  if (fabs(ztrk1) < 15.0) {
111  // check this track against all others to see if others start from same point
112  int jtrk=-1;
113  for (jpixl=apixl; jpixl!=epixl; jpixl++) {
114  if (jpixl->pt() < min_Pt_) continue;
115  jtrk++;
116  if (jpixl==ipixl) continue;
117  const double& ztrk2 = jpixl->vz();
118  const double& etatrk2 = jpixl->momentum().eta();
119  const double& phitrk2 = jpixl->momentum().phi();
120  double eta_dist=etatrk2-etatrk1;
121  double phi_dist=phitrk2-phitrk1;
122  double etaphi_dist=sqrt(eta_dist*eta_dist + phi_dist*phi_dist);
123  if (fabs(ztrk2-ztrk1) < 1.0 && etaphi_dist > min_sep_) {
124  if (min_trks_ <= 2 || itstore.size() <= 1) {
125  etastore.push_back(etatrk2);
126  phistore.push_back(phitrk2);
127  itstore.push_back(jtrk);
128  nsame_vtx++;
129  } else {
130  // check also separation to already found 'second' tracks
131  LogDebug("") << "HLTPixlMBFilt: with mintrks=2 we should not be here...";
132  bool isok = true;
133  for (unsigned int k=1; k < itstore.size(); k++) {
134  eta_dist=etatrk2-etastore.at(k);
135  phi_dist=phitrk2-phistore.at(k);
136  etaphi_dist=sqrt(eta_dist*eta_dist + phi_dist*phi_dist);
137  if (etaphi_dist < min_sep_) {
138  isok=false;
139  break;
140  }
141  }
142  if (isok) {
143  etastore.push_back(etatrk2);
144  phistore.push_back(phitrk2);
145  itstore.push_back(jtrk);
146  nsame_vtx++;
147  }
148  }
149  }
150  if (nsame_vtx >= min_trks_) break;
151  }
152  }
153  npixl_tot++;
154 
155  if (nsame_vtx >= min_trks_) break;
156  }
157 
158  // final filter decision:
159  // request at least min_trks_ tracks compatible with vertex-region
160  accept = (nsame_vtx >= min_trks_ ) ;
161 
162  } else {
163  accept = false;
164  }
165 
166  // At this point we have the indices of the accepted tracks stored in itstore
167  // we now move them to the filterproduct
168 
169  if (accept) {
170  for (unsigned int ipos=0; ipos < itstore.size(); ipos++) {
171  int iaddr=itstore.at(ipos);
173  }
174  }
175 
176  LogDebug("") << "Number of pixel-track objects accepted:"
177  << " " << npixl_tot;
178 
179  // return with final filter decision
180  return accept;
181 
182 }
#define LogDebug(id)
HLTPixlMBFilt(const edm::ParameterSet &)
edm::InputTag pixlTag_
Definition: HLTPixlMBFilt.h:37
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::Ref< RecoChargedCandidateCollection > RecoChargedCandidateRef
reference to an object in a collection of RecoChargedCandidate objects
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:24
std::string encode() const
Definition: InputTag.cc:164
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref&lt;C&gt;)
int iEvent
Definition: GenABIO.cc:230
virtual bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
T sqrt(T t)
Definition: SSEVec.h:48
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > pixlToken_
Definition: HLTPixlMBFilt.h:38
unsigned int min_trks_
Definition: HLTPixlMBFilt.h:41
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void makeHLTFilterDescription(edm::ParameterSetDescription &desc)
Definition: HLTFilter.cc:29
tuple tracks
Definition: testEve_cfg.py:39
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool saveTags() const
Definition: HLTFilter.h:45