Fork me on GitHub

source: svn/trunk/src/JetsUtil.cc@ 942

Last change on this file since 942 was 567, checked in by Xavier Rouby, 14 years ago

version 1.9

File size: 9.7 KB
Line 
1/***********************************************************************
2** **
3** /----------------------------------------------\ **
4** | Delphes, a framework for the fast simulation | **
5** | of a generic collider experiment | **
6** \------------- arXiv:0903.2225v1 ------------/ **
7** **
8** **
9** This package uses: **
10** ------------------ **
11** ROOT: Nucl. Inst. & Meth. in Phys. Res. A389 (1997) 81-86 **
12** FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210] **
13** Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2] **
14** FROG: [hep-ex/0901.2718v1] **
15** HepMC: Comput. Phys. Commun.134 (2001) 41 **
16** **
17** ------------------------------------------------------------------ **
18** **
19** Main authors: **
20** ------------- **
21** **
22** Severine Ovyn Xavier Rouby **
23** severine.ovyn@uclouvain.be xavier.rouby@cern **
24** **
25** Center for Particle Physics and Phenomenology (CP3) **
26** Universite catholique de Louvain (UCL) **
27** Louvain-la-Neuve, Belgium **
28** **
29** Copyright (C) 2008-2009, **
30** All rights reserved. **
31** **
32***********************************************************************/
33
34#include "JetsUtil.h"
35
36using namespace std;
37
38JetsUtil::JetsUtil() : plugins(NULL) {
39 DET = new RESOLution();
40 init();
41}
42
43
44JetsUtil::JetsUtil(const string & DetDatacard) : plugins(NULL) {
45 DET = new RESOLution();
46 DET->ReadDataCard(DetDatacard);
47 init();
48}
49
50
51JetsUtil::JetsUtil(const RESOLution * DetDatacard) : plugins(NULL) {
52 DET = new RESOLution(*DetDatacard);
53 init();
54}
55
56
57JetsUtil::JetsUtil(const JetsUtil& jet){
58 DET = new RESOLution(*(jet.DET));
59}
60
61JetsUtil& JetsUtil::operator=(const JetsUtil& jet) {
62 if(this==&jet) return *this;
63 DET = new RESOLution(*(jet.DET));
64 return *this;
65}
66
67void JetsUtil::init() {
68 if(plugins) delete plugins;
69
70 switch(DET->JET_jetalgo) {
71 default:
72 case 1: {
73 // set up a CDF midpoint jet definition
74#ifdef ENABLE_PLUGIN_CDFCONES
75 plugins = new fastjet::CDFJetCluPlugin(DET->JET_seed,DET->JET_coneradius,DET->JET_C_adjacencycut,DET->JET_C_maxiterations,DET->JET_C_iratch,DET->JET_overlap);
76 jet_def = fastjet::JetDefinition(plugins);
77#else
78 plugins = NULL;
79#endif
80 }
81 break;
82
83 case 2: {
84 // set up a CDF midpoint jet definition
85#ifdef ENABLE_PLUGIN_CDFCONES
86 plugins = new fastjet::CDFMidPointPlugin (DET->JET_seed,DET->JET_coneradius,DET->JET_M_coneareafraction,DET->JET_M_maxpairsize,DET->JET_M_maxiterations,DET->JET_overlap);
87 jet_def = fastjet::JetDefinition(plugins);
88#else
89 plugins = NULL;
90#endif
91 }
92 break;
93
94 case 3: {
95 // set up a siscone jet definition
96#ifdef ENABLE_PLUGIN_SISCONE
97 plugins = new fastjet::SISConePlugin (DET->JET_coneradius,DET->JET_overlap,DET->JET_S_npass, DET->JET_S_protojet_ptmin);
98 jet_def = fastjet::JetDefinition(plugins);
99#else
100 plugins = NULL;
101#endif
102 }
103 break;
104
105 case 4: {
106
107 jet_def = fastjet::JetDefinition(fastjet::kt_algorithm, DET->JET_coneradius);
108 }
109 break;
110
111 case 5: {
112 jet_def = fastjet::JetDefinition(fastjet::cambridge_algorithm,DET->JET_coneradius);
113 }
114 break;
115
116 case 6: {
117 jet_def = fastjet::JetDefinition(fastjet::antikt_algorithm,DET->JET_coneradius);
118 }
119 break;
120 }
121
122}
123
124vector<fastjet::PseudoJet> JetsUtil::RunJets(const vector<fastjet::PseudoJet>& input_particles, const vector<TRootTracks> & TrackCentral, vector<int> &NTrackJet, vector<float> &EHADEEM,D_CaloTowerList list_of_active_towers, vector<int> &NCALO)
125{
126 inclusive_jets.clear();
127 sorted_jets.clear();
128 // run the jet clustering with the above jet definition
129 if(input_particles.size()!=0)
130 {
131 fastjet::ClusterSequence clust_seq(input_particles, jet_def);
132 // extract the inclusive jets with pt > 5 GeV
133 double ptmin = 5.0;
134 inclusive_jets = clust_seq.inclusive_jets(ptmin);
135
136 // sort jets into increasing pt
137 sorted_jets = sorted_by_pt(inclusive_jets);
138 //Bin tracks to make the link
139 float iEtaTrack[TrackCentral.size()];
140 float iPhiTrack[TrackCentral.size()];
141 for(unsigned int t = 0; t < TrackCentral.size(); t++)
142 {
143 if(!DET->JET_Eflow)
144 DET->BinEtaPhi(TrackCentral[t].PhiOuter,TrackCentral[t].EtaOuter,iPhiTrack[t],iEtaTrack[t]);
145 else {
146 iPhiTrack[t] = TrackCentral[t].Phi; iEtaTrack[t] = TrackCentral[t].Eta; // should NOT be PhiOuter and EtaOuter
147 }
148 }
149 int numTrackJet;
150 for (unsigned int i = 0; i < sorted_jets.size(); i++)
151 {
152 //check number of tracks in jets
153 numTrackJet=0;
154 vector<fastjet::PseudoJet> constituents = clust_seq.constituents(sorted_jets[i]);
155 for(unsigned int it = 0; it < TrackCentral.size(); it++)
156 {
157 for (unsigned int j = 0; j < constituents.size(); j++)
158 {
159 if(DeltaR(iPhiTrack[it], iEtaTrack[it], constituents[j].phi(), constituents[j].eta())<0.001)numTrackJet++;
160 }
161 }
162 NTrackJet.push_back(numTrackJet);
163 //now, get EHad over EEm
164 float EmVal=0,HadVal=0;
165 NCALO.push_back(constituents.size());
166 for (unsigned int j = 0; j < constituents.size(); j++)
167 {
168 //D_CaloTower calConsti(list_of_active_towers.getElement(constituents[j].eta(),constituents[j].phi()));
169 // bug fix! bad association of phi [-pi;pi] <-> [0 ; 2pi]
170 D_CaloTower calConsti(list_of_active_towers.getElement(constituents[j].eta(),constituents[j].phi_std()));
171 EmVal += calConsti.getEem();
172 HadVal += calConsti.getEhad();
173 }
174 EHADEEM.push_back(HadVal/EmVal);
175 }
176 }
177
178 return sorted_jets;
179}
180
181vector<fastjet::PseudoJet> JetsUtil::RunJetsResol(const vector<fastjet::PseudoJet>& input_particles)
182{
183 inclusive_jets.clear();
184 sorted_jets.clear();
185 // run the jet clustering with the above jet definition
186 if(input_particles.size()!=0)
187 {
188 fastjet::ClusterSequence clust_seq(input_particles, jet_def);
189 // extract the inclusive jets with pt > 5 GeV
190 double ptmin = 5.0;
191 inclusive_jets = clust_seq.inclusive_jets(ptmin);
192
193 // sort jets into increasing pt
194 sorted_jets = sorted_by_pt(inclusive_jets);
195 }
196 return sorted_jets;
197}
198
199
200void JetsUtil::RunJetBtagging(ExRootTreeWriter *treeWriter, ExRootTreeBranch *branchJet,const vector<fastjet::PseudoJet> & sorted_jets,const TSimpleArray<TRootC::GenParticle>& NFCentralQ, const vector<int> &NTrackJet, const vector<float> &EHADEEM, const vector<int> &NCALO)
201{
202 TRootJet *elementJet;
203 TLorentzVector JET;
204 for (unsigned int i = 0; i < sorted_jets.size(); i++) {
205 JET.SetPxPyPzE(sorted_jets[i].px(),sorted_jets[i].py(),sorted_jets[i].pz(),sorted_jets[i].E());
206 if(JET.Pt() > DET->PTCUT_jet)
207 {
208 elementJet = (TRootJet*) branchJet->NewEntry();
209 elementJet->Set(JET);
210 elementJet->NTracks = NTrackJet[i];
211 elementJet->EHoverEE = EHADEEM[i];
212 elementJet->NCalo = NCALO[i];
213
214 // b-jets
215 bool btag=false;
216 if((fabs(JET.Eta()) < DET->CEN_max_tracker && DET->Btaggedjet(JET, NFCentralQ)))btag=true;
217 elementJet->Btag = btag;
218 }
219 } // for itJet : loop on all jets
220}
221
222void JetsUtil::RunTauJets(ExRootTreeWriter *treeWriter, ExRootTreeBranch *branchTauJet,const vector<fastjet::PseudoJet> & sorted_jets,const vector<PhysicsTower> & towers, const vector<TRootTracks> & TrackCentral, const vector<int> &NTrackJet, const vector<float> &EHADEEM,const vector<int> &NCALO)
223{
224 TRootTauJet *elementTauJet;
225 TLorentzVector JET;
226 float charge=0;
227
228 for (unsigned int i = 0; i < sorted_jets.size(); i++) {
229 JET.SetPxPyPzE(sorted_jets[i].px(),sorted_jets[i].py(),sorted_jets[i].pz(),sorted_jets[i].E());
230 // Tau jet identification : 1! or 3! track and electromagnetic collimation
231 if(fabs(JET.Eta()) < (DET->CEN_max_tracker - DET->TAU_track_scone)) {
232 double Energie_tau_central = DET->EnergySmallCone(towers,JET.Eta(),JET.Phi());
233 int NumTrackTau = DET->NumTracks(charge,TrackCentral,DET->TAU_track_pt,JET.Eta(),JET.Phi());
234 if(
235 ( Energie_tau_central/JET.E() > DET->TAU_energy_frac ) &&
236 (( NumTrackTau == 1 ) || ( NumTrackTau == 3 )) &&
237 ( JET.Pt() > DET->PTCUT_taujet)
238 ) {
239 elementTauJet = (TRootTauJet*) branchTauJet->NewEntry();
240 elementTauJet->Set(JET);
241 elementTauJet->NTracks=NTrackJet[i];
242 elementTauJet->Charge = charge;
243 elementTauJet->EHoverEE = EHADEEM[i];
244 elementTauJet->NCalo = NCALO[i];
245 } // if tau jet
246 } // if JET.eta < tracker - tau_cone : Tau jet identification
247 } // for itJet : loop on all jets
248}
Note: See TracBrowser for help on using the repository browser.