CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L2TauJetsMerger.cc
Go to the documentation of this file.
2 #include "Math/GenVector/VectorUtil.h"
5 //
6 // class decleration
7 //
8 using namespace reco;
9 using namespace std;
10 using namespace edm;
11 
13 {
14  jetSrc = iConfig.getParameter<vtag>("JetSrc");
15  for(vtag::const_iterator it = jetSrc.begin(); it != jetSrc.end(); ++it) {
16  edm::EDGetTokenT<CaloJetCollection> aToken = consumes<CaloJetCollection>(*it);
17  jetSrc_token.push_back(aToken);
18  }
19  mEt_Min = iConfig.getParameter<double>("EtMin");
20 
21  produces<CaloJetCollection>();
22 }
23 
25 
27 {
28 
29  using namespace edm;
30  using namespace std;
31  using namespace reco;
32 
33  //Getting all the L1Seeds
34 
35 
36  //Getting the Collections of L2ReconstructedJets from L1Seeds
37  //and removing the collinear jets
38  myL2L1JetsMap.clear();
39  CaloJetCollection myTmpJets;
40  myTmpJets.clear();
41 
42  int iL1Jet = 0;
43  for( vtoken_cjets::const_iterator s = jetSrc_token.begin(); s != jetSrc_token.end(); ++ s ) {
45  iEvent.getByToken( * s, tauJets );
46  for(CaloJetCollection::const_iterator iTau = tauJets->begin(); iTau !=tauJets->end(); ++iTau)
47  {
48  //Create a Map to associate to every Jet its L1SeedId, i.e. 0,1,2 or 3
49  if(iTau->et() > mEt_Min) {
50 
51  //Add the Pdg Id here
52  CaloJet myJet = *iTau;
53  myJet.setPdgId(15);
54  myTmpJets.push_back(myJet);
55  }
56  }
57  iL1Jet++;
58  }
59 
60  std::auto_ptr<CaloJetCollection> tauL2jets(new CaloJetCollection);
61 
62  //Removing the collinear jets correctly!
63 
64  //First sort the jets you have merged
66  std::sort(myTmpJets.begin(),myTmpJets.end(),sorter);
67 
68 //Remove Collinear Jets by prefering the highest ones!
69 
70  while(myTmpJets.size()>0) {
71  tauL2jets->push_back(myTmpJets.at(0));
73  for(unsigned int i=1 ;i<myTmpJets.size();++i) {
74  double DR = ROOT::Math::VectorUtil::DeltaR(myTmpJets.at(0).p4(),myTmpJets.at(i).p4());
75  if(DR>0.1)
76  tmp.push_back(myTmpJets.at(i));
77  }
78  myTmpJets.swap(tmp);
79  tmp.clear();
80  }
81 
82 
83  iEvent.put(tauL2jets);
84 
85 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
L2TauJetsMerger(const edm::ParameterSet &)
Jets made from CaloTowers.
Definition: CaloJet.h:29
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual void produce(edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::vector< edm::InputTag > vtag
virtual void setPdgId(int pdgId) GCC11_FINAL
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects