Fork me on GitHub

source: svn/trunk/Utilities/Fastjet/plugins/CDFCones/CDFJetCluPlugin.cc@ 102

Last change on this file since 102 was 100, checked in by severine ovyn, 16 years ago

Remove datacard bug + CaloTowers OK

File size: 6.6 KB
Line 
1//STARTHEADER
2// $Id: CDFJetCluPlugin.cc,v 1.2 2008-12-18 13:38:29 ovyn Exp $
3//
4// Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam
5//
6//----------------------------------------------------------------------
7// This file is part of FastJet.
8//
9// FastJet is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; either version 2 of the License, or
12// (at your option) any later version.
13//
14// The algorithms that underlie FastJet have required considerable
15// development and are described in hep-ph/0512210. If you use
16// FastJet as part of work towards a scientific publication, please
17// include a citation to the FastJet paper.
18//
19// FastJet is distributed in the hope that it will be useful,
20// but WITHOUT ANY WARRANTY; without even the implied warranty of
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22// GNU General Public License for more details.
23//
24// You should have received a copy of the GNU General Public License
25// along with FastJet; if not, write to the Free Software
26// Foundation, Inc.:
27// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28//----------------------------------------------------------------------
29//ENDHEADER
30
31#include "CDFJetCluPlugin.hh"
32#include "Utilities/Fastjet/include/fastjet/ClusterSequence.hh"
33#include <sstream>
34#include <cassert>
35
36// CDF stuff
37#include "interface/JetCluAlgorithm.hh"
38#include "interface/PhysicsTower.hh"
39#include "interface/Cluster.hh"
40
41FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
42
43using namespace std;
44
45string CDFJetCluPlugin::description () const {
46 ostringstream desc;
47
48 desc << "CDF JetClu jet algorithm with "
49 << "seed_threshold = " << seed_threshold () << ", "
50 << "cone_radius = " << cone_radius () << ", "
51 << "adjacency_cut = " << adjacency_cut () << ", "
52 << "max_iterations = " << max_iterations () << ", "
53 << "iratch = " << iratch () << ", "
54 << "overlap_threshold = " << overlap_threshold () ;
55
56 return desc.str();
57}
58
59
60void CDFJetCluPlugin::run_clustering(ClusterSequence & clust_seq) const {
61
62 // create the physics towers needed by the CDF code
63 vector<PhysicsTower> towers;
64 towers.reserve(clust_seq.jets().size());
65
66 // create a map to identify jets (actually just the input particles)...
67 //map<double,int> jetmap;
68
69 for (unsigned i = 0; i < clust_seq.jets().size(); i++) {
70 PseudoJet particle(clust_seq.jets()[i]);
71 //_insert_unique(particle, jetmap);
72 LorentzVector fourvect(particle.px(), particle.py(),
73 particle.pz(), particle.E());
74//std::cout<<"avant la reconstruction "<<particle.eta()<<std::endl;
75 //PhysicsTower tower(fourvect);
76 PhysicsTower tower(fourvect);
77
78std::cout<<"apres la reconstruction "<<tower.eta()<<std::endl;
79//std::cout<<"apres la reconstruction ieta "<<tower.iEta()<<std::endl;
80
81
82 // add tracking information for later
83 tower.fjindex = i;
84 towers.push_back(tower);
85 }
86
87 // prepare the CDF algorithm
88 JetCluAlgorithm j(seed_threshold(), cone_radius(), adjacency_cut(),
89 max_iterations(), iratch(), overlap_threshold());
90
91 // run the CDF algorithm
92 std::vector<Cluster> jets;
93 j.run(towers,jets);
94
95
96 // now transfer the jets back into our own structure -- we will
97 // mimic the cone code with a sequential recombination sequence in
98 // which the jets are built up by adding one particle at a time
99
100 // NB: with g++-4.0, the reverse iterator code gave problems, so switch
101 // to indices instead
102 //for(vector<Cluster>::const_reverse_iterator jetIter = jets.rbegin();
103 // jetIter != jets.rend(); jetIter++) {
104 // const vector<PhysicsTower> & tower_list = jetIter->towerList;
105 // int jet_k = jetmap[tower_list[0].fourVector.E];
106 //
107 // int ntow = int(jetIter->towerList.size());
108
109 for(int iCDFjets = jets.size()-1; iCDFjets >= 0; iCDFjets--) {
110 const vector<PhysicsTower> & tower_list = jets[iCDFjets].towerList;
111 //int jet_k = jetmap[tower_list[0].fourVector.E];
112 int jet_k = tower_list[0].fjindex;
113
114 int ntow = int(tower_list.size());
115 for (int itow = 1; itow < ntow; itow++) {
116 int jet_i = jet_k;
117 // retrieve our misappropriated index for the jet
118 int jet_j;
119 jet_j = tower_list[itow].fjindex;
120 //int alt_jet_j = jetmap[tower_list[itow].fourVector.E];
121 //assert(jet_j == alt_jet_j);
122 //cout << jet_j << endl;
123 // safety check
124 assert (jet_j >= 0 && jet_j < int(towers.size()));
125 // do a fake recombination step with dij=0
126 double dij = 0.0;
127 // JetClu does E-scheme recombination so we can stick with the
128 // simple option
129 clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, jet_k);
130 //if (itow != ntow) {
131 // clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, jet_k);
132 //} else {
133 // clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij,
134 // PseudoJet(jetIter->fourVector.px,jetIter->fourVector.py,
135 // jetIter->fourVector.pz,jetIter->fourVector.E),
136 // jet_k);
137 //}
138 }
139
140 // NB: put a sensible looking d_iB just to be nice...
141 double d_iB = clust_seq.jets()[jet_k].perp2();
142 clust_seq.plugin_record_iB_recombination(jet_k, d_iB);
143 }
144
145
146 // following code is for testing only
147 //cout << endl;
148 //for(vector<Cluster>::const_iterator jetIter = jets.begin();
149 // jetIter != jets.end(); jetIter++) {
150 // cout << jetIter->fourVector.pt() << " " << jetIter->fourVector.y() << endl;
151 //}
152 //cout << "-----------------------------------------------------\n";
153 //vector<PseudoJet> ourjets(clust_seq.inclusive_jets());
154 //for (vector<PseudoJet>::const_iterator ourjet = ourjets.begin();
155 // ourjet != ourjets.end(); ourjet++) {
156 // cout << ourjet->perp() << " " << ourjet->rap() << endl;
157 //}
158 //cout << endl;
159}
160
161
162//// following code should now be obsolete since addition of
163//// index to the physics tower in the CDF code
164// void CDFJetCluPlugin::_insert_unique(PseudoJet & jet,
165// map<double,int> & jetmap) const {
166// while (jetmap.find(jet.E()) != jetmap.end()) {
167// // deal with cases where something else has the same energy, and
168// // also with situation where that energy is zero.
169// if (jet.E() != 0.0) {
170// jet *= 1.0+1e-12;
171// } else {
172// jet += PseudoJet(0.0,0.0,0.0,1e-300);
173// }
174// }
175// jetmap[jet.E()] = jet.cluster_hist_index();
176// }
177
178
179FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
Note: See TracBrowser for help on using the repository browser.