CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L2TauJetsProvider.cc
Go to the documentation of this file.
2 #include "Math/GenVector/VectorUtil.h"
7 //
8 // class decleration
9 //
10 using namespace reco;
11 using namespace std;
12 using namespace edm;
13 using namespace l1extra;
14 
16 {
17  jetSrc = iConfig.getParameter<vtag>("JetSrc");
18  l1ParticlesTau = iConfig.getParameter<InputTag>("L1ParticlesTau");
19  l1ParticlesJet = iConfig.getParameter<InputTag>("L1ParticlesJet");
20  tauTrigger = iConfig.getParameter<InputTag>("L1TauTrigger");
21  mEt_Min = iConfig.getParameter<double>("EtMin");
22 
23  produces<CaloJetCollection>();
24 }
25 
27 
29 {
30 
31  using namespace edm;
32  using namespace std;
33  using namespace reco;
34  using namespace trigger;
35  using namespace l1extra;
36 
37 
38  //Getting all the L1Seeds
39 
40 
41  //Getting the Collections of L2ReconstructedJets from L1Seeds
42  //and removing the collinear jets
43  myL2L1JetsMap.clear();
44  int iL1Jet = 0;
45  for( vtag::const_iterator s = jetSrc.begin(); s != jetSrc.end(); ++ s ) {
47  iEvent.getByLabel( * s, tauJets );
48  CaloJetCollection::const_iterator iTau = tauJets->begin();
49  if(iTau != tauJets->end()){
50  //Create a Map to associate to every Jet its L1SeedId, i.e. 0,1,2 or 3
51  myL2L1JetsMap.insert(std::pair<int, const CaloJet>(iL1Jet, *(iTau)));
52  }
53  iL1Jet++;
54  }
55  std::auto_ptr<CaloJetCollection> tauL2jets(new CaloJetCollection);
56 
57  //Loop over the jetSrc to select the proper jets
58 
59  double deltaR = 0.1;
60  double matchingR = 0.01;
61  //Loop over the Map to find which jets has fired the trigger
62  //myL1Tau is the Collection of L1TauCandidates (from 0 to max 4 elements)
63  //get the list of trigger candidates from the HLTL1SeedGT filter
66 
67  iEvent.getByLabel( l1ParticlesTau, tauColl );
68  iEvent.getByLabel(l1ParticlesJet, jetColl);
69 
70  const L1JetParticleCollection myL1Tau = *(tauColl.product());
71 
72  const L1JetParticleCollection myL1Jet = *(jetColl.product());
73 
75  myL1Obj.reserve(8);
76 
77  for(unsigned int i=0;i<myL1Tau.size();i++)
78  {
79  myL1Obj.push_back(myL1Tau[i]);
80  }
81  for(unsigned int j=0;j<myL1Jet.size();j++)
82  {
83  myL1Obj.push_back(myL1Jet[j]);
84  }
85 
86 
88  if(iEvent.getByLabel(tauTrigger,l1TriggeredTaus)){
89 
90 
91  tauCandRefVec.clear();
92  jetCandRefVec.clear();
93 
94  l1TriggeredTaus->getObjects( trigger::TriggerL1TauJet,tauCandRefVec);
95  l1TriggeredTaus->getObjects( trigger::TriggerL1CenJet,jetCandRefVec);
96 
97  for( unsigned int iL1Tau=0; iL1Tau <tauCandRefVec.size();iL1Tau++)
98  {
99  for(unsigned int iJet=0;iJet<myL1Obj.size();iJet++)
100  {
101  //Find the relative L2TauJets, to see if it has been reconstructed
102  std::map<int, const reco::CaloJet>::const_iterator myL2itr = myL2L1JetsMap.find(iJet);
103  if(myL2itr!=myL2L1JetsMap.end()){
104  //Calculate the DeltaR between L1TauCandidate and L1Tau which fired the trigger
105  if(&tauCandRefVec[iL1Tau])
106  deltaR = ROOT::Math::VectorUtil::DeltaR(myL1Obj[iJet].p4().Vect(), (tauCandRefVec[iL1Tau]->p4()).Vect());
107  if(deltaR < matchingR ) {
108  // Getting back from the map the L2TauJet
109  const CaloJet myL2TauJet = myL2itr->second;
110  if(myL2TauJet.pt() > mEt_Min) tauL2jets->push_back(myL2TauJet);
111  myL2L1JetsMap.erase(myL2itr->first);
112  break;
113 
114  }
115  }
116 
117  }
118  }
119 
120  for(unsigned int iL1Tau=0; iL1Tau <jetCandRefVec.size();iL1Tau++)
121  {
122  for(unsigned int iJet=0;iJet<myL1Obj.size();iJet++)
123  {
124  //Find the relative L2TauJets, to see if it has been reconstructed
125  std::map<int, const reco::CaloJet>::const_iterator myL2itr = myL2L1JetsMap.find(iJet);
126  if(myL2itr!=myL2L1JetsMap.end()){
127  //Calculate the DeltaR between L1TauCandidate and L1Tau which fired the trigger
128  if(&jetCandRefVec[iL1Tau])
129  deltaR = ROOT::Math::VectorUtil::DeltaR(myL1Obj[iJet].p4().Vect(), (jetCandRefVec[iL1Tau]->p4()).Vect());
130  if(deltaR < matchingR) {
131  // Getting back from the map the L2TauJet
132  const CaloJet myL2TauJet = myL2itr->second;
133 
134  if(myL2TauJet.pt() > mEt_Min) tauL2jets->push_back(myL2TauJet);
135  myL2L1JetsMap.erase(myL2itr->first);
136  break;
137 
138  }
139  }
140 
141  }
142  }
143 
144  }
145  // std::cout <<"Size of L2 jets "<<tauL2jets->size()<<std::endl;
146 
147  iEvent.put(tauL2jets);
148 
149 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
Jets made from CaloTowers.
Definition: CaloJet.h:29
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
double p4[4]
Definition: TauolaWrapper.h:92
int j
Definition: DBlmapReader.cc:9
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
L2TauJetsProvider(const edm::ParameterSet &)
virtual void produce(edm::Event &, const edm::EventSetup &) override
virtual float pt() const GCC11_FINAL
transverse momentum
std::vector< edm::InputTag > vtag
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects