CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTTauRefCombiner.cc
Go to the documentation of this file.
2 #include "Math/GenVector/VectorUtil.h"
3 
4 
5 
6 using namespace edm;
7 using namespace std;
8 
10 {
11  inputColl_ = iConfig.getParameter< std::vector<InputTag> >("InputCollections");
12  matchDeltaR_ = iConfig.getParameter<double>("MatchDeltaR");
13  outName_ = iConfig.getParameter<string>("OutputCollection");
14 
15  produces<LorentzVectorCollection> ( outName_);
16 }
17 
19 
21 {
22  auto_ptr<LorentzVectorCollection> out_product(new LorentzVectorCollection);
23 
24  //Create The Handles..
25  std::vector< Handle<LorentzVectorCollection> > handles;
26 
27  bool allCollectionsExist = true;
28  //Map the Handles to the collections if all collections exist
29  for(size_t i = 0;i<inputColl_.size();++i)
30  {
32  if(iEvent.getByLabel(inputColl_[i],tmp))
33  {
34  handles.push_back(tmp);
35  }
36  else
37  {
38  allCollectionsExist = false;
39  }
40 
41  }
42 
43  //The reference output object collection will be the first one..
44  if(allCollectionsExist)
45  {
46  //loop on the first collection
47  for(size_t i = 0; i < (handles[0])->size();++i)
48  {
49  bool MatchedObj = true;
50 
51  //get reference Vector
52  const LorentzVector lvRef = (*(handles[0]))[i];
53 
54  //Loop on all other collections and match
55  for(size_t j = 1; j < handles.size();++j)
56  {
57  if(!match(lvRef,*(handles[j])))
58  MatchedObj = false;
59 
60  }
61 
62  //If the Object is Matched Everywhere store
63  if(MatchedObj)
64  {
65  out_product->push_back(lvRef);
66  }
67 
68 
69  }
70 
71  //Put product to file
72  iEvent.put(out_product,outName_);
73 
74  }
75 
76 
77 
78 
79 }
80 
81 
82 
83 bool
85 {
86  bool matched=false;
87 
88  if(lvcol.size()>0)
89  for(LorentzVectorCollection::const_iterator it = lvcol.begin();it!=lvcol.end();++it)
90  {
91  double delta = ROOT::Math::VectorUtil::DeltaR(lv,*it);
92  if(delta<matchDeltaR_)
93  {
94  matched=true;
95 
96  }
97  }
98 
99 
100 
101  return matched;
102 }
dbl * delta
Definition: mlp_gen.cc:36
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool match(const LorentzVector &, const LorentzVectorCollection &)
std::vector< LorentzVector > LorentzVectorCollection
virtual void produce(edm::Event &, const edm::EventSetup &)
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName, BranchDescription::MatchMode m)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
HLTTauRefCombiner(const edm::ParameterSet &)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
math::XYZTLorentzVectorD LorentzVector
tuple size
Write out results.