CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
FastJetFWLiteWrapper Class Reference

#include <FastJetFWLiteWrapper.h>

Public Member Functions

 FastJetFWLiteWrapper ()
 
double getPtMin ()
 
double getRParam ()
 
void run (const JetReco::InputCollection &fInput, JetReco::OutputCollection *fOutput)
 
void setPtMin (double aPtMin)
 
void setRParam (double aRparam)
 
 ~FastJetFWLiteWrapper ()
 

Private Attributes

fastjet::GhostedAreaSpec * mActiveArea
 
fastjet::JetDefinition * mJetDefinition
 
int theActive_Area_Repeats_
 
double theDcut_
 
bool theDoSubtraction_
 
double theGhost_EtaMax_
 
double theGhostArea_
 
double theMedian_Pt_Per_Area_
 
int theMode_
 
int theNjets_
 
double thePtMin_
 
double theRparam_
 

Detailed Description

FastJetFWLiteWrapper is the Wrapper subclass which runs the FastJetAlgorithm for jetfinding.

The FastJet package, written by Matteo Cacciari and Gavin Salam, provides a fast implementation of the longitudinally invariant kt and longitudinally invariant inclusive Cambridge/Aachen jet finders. More information can be found at: http://parthe.lpthe.jussieu.fr/~salam/fastjet/

Authors
Andreas Oehler, University Karlsruhe (TH) and Dorian Kcira, Institut de Physique Nucleaire Departement de Physique Universite Catholique de Louvain have written the FastJetFWLiteWrapper class which uses the above mentioned package within the Framework of CMSSW
Version
1st Version Nov. 6 2006

Definition at line 45 of file FastJetFWLiteWrapper.h.

Constructor & Destructor Documentation

FastJetFWLiteWrapper::FastJetFWLiteWrapper ( )

Definition at line 39 of file FastJetFWLiteWrapper.cc.

References gather_cfg::cout, mActiveArea, theActive_Area_Repeats_, theDcut_, theDoSubtraction_, theGhost_EtaMax_, theGhostArea_, theMode_, theNjets_, thePtMin_, and theRparam_.

40  : mJetDefinition (0),
41  mActiveArea (0)
42 {
43 
44  //default ktRParam should be 1
45  theRparam_=1;
46  //default PtMin should be 10
47  thePtMin_=10.;
48  //default JetFinder should be "kt_algorithm"
49  string JetFinder="kt_algorithm";;
50  //default Strategy should be "Best"
51  string Strategy="Best";
52  //default dcut should be -1 (off)
53  theDcut_=-1.;
54  //default njets should be -1 (off)
55  theNjets_=-1;
56  //default UE_Subtraction should be false (off)
57  theDoSubtraction_=false;
58  //default Ghost_EtaMax should be 6
60  //default Active_Area_Repeats 5
62  //default GhostArea 0.01
63  theGhostArea_=0.01;
64  mActiveArea = new fastjet::GhostedAreaSpec ( theGhost_EtaMax_, theActive_Area_Repeats_ , theGhostArea_);
65 
66 
67  //configuring algorithm
68 
69 
70 // fastjet::JetFinder jet_finder;
71 // if (JetFinder=="cambridge_algorithm") jet_finder=fastjet::cambridge_algorithm;
72 // else jet_finder=fastjet::kt_algorithm;
73 
74  //choosing search-strategy:
75 
76 // fastjet::Strategy strategy;
77 // if (Strategy=="N2Plain") strategy=fastjet::N2Plain;
78 // // N2Plain is best for N<50
79 // else if (Strategy=="N2Tiled") strategy=fastjet::N2Tiled;
80 // // N2Tiled is best for 50<N<400
81 // else if (Strategy=="N2MinHeapTiled") strategy=fastjet::N2MinHeapTiled;
82 // // N2MinHeapTiles is best for 400<N<15000
83 // else if (Strategy=="NlnN") strategy=fastjet::NlnN;
84 // // NlnN is best for N>15000
85 // else if (Strategy=="NlnNCam") strategy=fastjet::NlnNCam;
86 // // NlnNCam is best for N>6000
87 // else strategy=fastjet::Best;
88 // // Chooses best Strategy for every event, depending on N and ktRParam
89 
90  //additional strategies are possible, but not documented in the manual as they are experimental,
91  //they are also not used by the "Best" method. Note: "NlnNCam" only works with
92  //the cambridge_algorithm and does not link against CGAL, "NlnN" is only
93  //available if fastjet is linked against CGAL.
94  //The above given numbers of N are for ktRaram=1.0, for other ktRParam the numbers would be
95  //different.
96 
97  theMode_=0;
98  if ((theNjets_!=-1)&&(theDcut_==-1)){
99  theMode_=3;
100  }
101  else if ((theNjets_==-1)&&(theDcut_!=-1)){
102  theMode_=2;
103  }
104  else if ((theNjets_!=-1)&&(theDcut_!=-1)){
105  cout <<"[FastJetWrapper] `njets` and `dcut` set!=-1! - running inclusive Mode"<<endl;
106  theMode_=1;
107  }
108  else {
109  theMode_=0;
110  }
111 
112  // theJetConfig_->theJetDef=fastjet::JetDefinition(jet_finder, theRparam_, strategy);
113  cout <<"*******************************************"<<endl;
114  cout <<"* Configuration of FastJet "<<endl;
115  if (theDoSubtraction_) cout <<"* running with ActiveAreaSubtraction(median)"<<endl;
116  switch (theMode_){
117  case 0:
118  cout <<"* Mode : inclusive"<<endl;
119  cout <<"* PtMin : "<<thePtMin_<<endl;
120  break;
121  case 1:
122  cout <<"* [WARNING] Mode : inclusive - dcut and njets set!"<<endl;
123  cout <<"* PtMin : "<<thePtMin_<<endl;
124  break;
125  case 2:
126  cout <<"* Mode : exclusive"<<endl;
127  cout <<"* dcut : "<<theDcut_<<endl;
128  break;
129  case 3:
130  cout <<"* Mode : exclusive"<<endl;
131  cout <<"* njets : "<<theNjets_<<endl;
132  break;
133  }
134  cout <<"* Rparam : "<<theRparam_<<endl;
135  cout <<"* JetFinder: "<<JetFinder<<endl;
136  cout <<"* Strategy : "<<Strategy<<endl;
137  cout <<"*******************************************"<<endl;
138 
139 }
fastjet::GhostedAreaSpec * mActiveArea
fastjet::JetDefinition * mJetDefinition
tuple cout
Definition: gather_cfg.py:121
FastJetFWLiteWrapper::~FastJetFWLiteWrapper ( )

Definition at line 34 of file FastJetFWLiteWrapper.cc.

34  {
35  delete mJetDefinition;
36  delete mActiveArea;
37 }
fastjet::GhostedAreaSpec * mActiveArea
fastjet::JetDefinition * mJetDefinition

Member Function Documentation

double FastJetFWLiteWrapper::getPtMin ( )
inline

Definition at line 79 of file FastJetFWLiteWrapper.h.

References thePtMin_.

79 {return thePtMin_ ;}
double FastJetFWLiteWrapper::getRParam ( )
inline

Definition at line 80 of file FastJetFWLiteWrapper.h.

References theRparam_.

80 {return theRparam_;}
void FastJetFWLiteWrapper::run ( const JetReco::InputCollection fInput,
JetReco::OutputCollection fOutput 
)

Definition at line 141 of file FastJetFWLiteWrapper.cc.

References trackerHits::c, reco::Candidate::energy(), i, metsig::jet, fwrapper::jets, mActiveArea, mJetDefinition, p4, reco::Candidate::px(), reco::Candidate::py(), reco::Candidate::pz(), and thePtMin_.

141  {
142  if (!fOutput) return;
143  fOutput->clear();
144 
145  // convert inputs
146  std::vector<fastjet::PseudoJet> fjInputs;
147  fjInputs.reserve (fInput.size());
148 
149  for (unsigned i = 0; i < fInput.size(); ++i) {
150  const JetReco::InputItem& c = fInput[i];
151  fjInputs.push_back (fastjet::PseudoJet (c->px(),c->py(),c->pz(),c->energy()));
152  fjInputs.back().set_user_index(i);
153  }
154 
155  // create an object that represents your choice of jet finder and
156  // the associated parameters
157  // run the jet clustering with the above jet definition
158 
159  // here we need to keep both pointers, as "area" interfaces are missing in base class
160  fastjet::ClusterSequenceActiveArea* clusterSequenceWithArea = 0;
161  fastjet::ClusterSequenceArea* clusterSequence = 0;
162  // if (mActiveArea) {
163  // clusterSequenceWithArea = new fastjet::ClusterSequenceActiveArea (fjInputs, *mJetDefinition, *mActiveArea);
164  // clusterSequence = clusterSequenceWithArea;
165  // }
166  // else {
167  clusterSequence = new fastjet::ClusterSequenceArea (fjInputs, *mJetDefinition, *mActiveArea);
168  // }
169  // retrieve jets for selected mode
170  std::vector<fastjet::PseudoJet> jets = clusterSequence->inclusive_jets (thePtMin_);
171 
172  // get PU pt
173  double median_Pt_Per_Area = clusterSequenceWithArea ? clusterSequenceWithArea->pt_per_unit_area() : 0.;
174 
175  // process found jets
176  for (std::vector<fastjet::PseudoJet>::const_iterator jet=jets.begin(); jet!=jets.end();++jet) {
177  // jet itself
178  double px=jet->px();
179  double py=jet->py();
180  double pz=jet->pz();
181  double E=jet->E();
182  double jetArea=clusterSequence->area(*jet);
183  double pu=0.;
184  // PU subtraction
185  if (clusterSequenceWithArea) {
186  fastjet::PseudoJet pu_p4 = median_Pt_Per_Area * clusterSequenceWithArea->area_4vector(*jet);
187  pu = pu_p4.E();
188  if (pu_p4.perp2() >= jet->perp2() || pu_p4.E() >= jet->E()) { // if the correction is too large, set the jet to zero
189  px = py = pz = E = 0.;
190  }
191  else { // otherwise do an E-scheme subtraction
192  px -= pu_p4.px();
193  py -= pu_p4.py();
194  pz -= pu_p4.pz();
195  E -= pu_p4.E();
196  }
197  }
198  math::XYZTLorentzVector p4(px,py,pz,E);
199  // constituents
200  std::vector<fastjet::PseudoJet> fastjet_constituents = clusterSequence->constituents(*jet);
201  JetReco::InputCollection jetConstituents;
202  jetConstituents.reserve (fastjet_constituents.size());
203  for (std::vector<fastjet::PseudoJet>::const_iterator itConst=fastjet_constituents.begin();
204  itConst!=fastjet_constituents.end();itConst++){
205  jetConstituents.push_back(fInput[(*itConst).user_index()]);
206  }
207  // Build ProtoJet
208  fOutput->push_back(ProtoJet(p4,jetConstituents));
209  fOutput->back().setJetArea (jetArea);
210  fOutput->back().setPileup (pu);
211  }
212  // cleanup
213  if (clusterSequenceWithArea) delete clusterSequenceWithArea;
214  else delete clusterSequence; // sigh... No plymorphism in fastjet
215 }
int i
Definition: DBlmapReader.cc:9
virtual double energy() const =0
energy
std::vector< InputItem > InputCollection
Definition: JetRecoTypes.h:62
virtual double pz() const =0
z coordinate of momentum vector
Transient Jet class used by the reconstruction algorithms.
Definition: ProtoJet.h:25
fastjet::GhostedAreaSpec * mActiveArea
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
double p4[4]
Definition: TauolaWrapper.h:92
vector< PseudoJet > jets
virtual double py() const =0
y coordinate of momentum vector
virtual double px() const =0
x coordinate of momentum vector
fastjet::JetDefinition * mJetDefinition
void FastJetFWLiteWrapper::setPtMin ( double  aPtMin)
inline

Definition at line 75 of file FastJetFWLiteWrapper.h.

References thePtMin_.

75 {thePtMin_=aPtMin;}
void FastJetFWLiteWrapper::setRParam ( double  aRparam)
inline

Definition at line 76 of file FastJetFWLiteWrapper.h.

References theRparam_.

76 { theRparam_=aRparam;}

Member Data Documentation

fastjet::GhostedAreaSpec* FastJetFWLiteWrapper::mActiveArea
private

Definition at line 70 of file FastJetFWLiteWrapper.h.

Referenced by FastJetFWLiteWrapper(), and run().

fastjet::JetDefinition* FastJetFWLiteWrapper::mJetDefinition
private

Definition at line 69 of file FastJetFWLiteWrapper.h.

Referenced by run().

int FastJetFWLiteWrapper::theActive_Area_Repeats_
private

Definition at line 65 of file FastJetFWLiteWrapper.h.

Referenced by FastJetFWLiteWrapper().

double FastJetFWLiteWrapper::theDcut_
private

Definition at line 60 of file FastJetFWLiteWrapper.h.

Referenced by FastJetFWLiteWrapper().

bool FastJetFWLiteWrapper::theDoSubtraction_
private

Definition at line 63 of file FastJetFWLiteWrapper.h.

Referenced by FastJetFWLiteWrapper().

double FastJetFWLiteWrapper::theGhost_EtaMax_
private

Definition at line 64 of file FastJetFWLiteWrapper.h.

Referenced by FastJetFWLiteWrapper().

double FastJetFWLiteWrapper::theGhostArea_
private

Definition at line 67 of file FastJetFWLiteWrapper.h.

Referenced by FastJetFWLiteWrapper().

double FastJetFWLiteWrapper::theMedian_Pt_Per_Area_
private

Definition at line 68 of file FastJetFWLiteWrapper.h.

int FastJetFWLiteWrapper::theMode_
private

Definition at line 56 of file FastJetFWLiteWrapper.h.

Referenced by FastJetFWLiteWrapper().

int FastJetFWLiteWrapper::theNjets_
private

Definition at line 61 of file FastJetFWLiteWrapper.h.

Referenced by FastJetFWLiteWrapper().

double FastJetFWLiteWrapper::thePtMin_
private

Definition at line 58 of file FastJetFWLiteWrapper.h.

Referenced by FastJetFWLiteWrapper(), getPtMin(), run(), and setPtMin().

double FastJetFWLiteWrapper::theRparam_
private

Definition at line 59 of file FastJetFWLiteWrapper.h.

Referenced by FastJetFWLiteWrapper(), getRParam(), and setRParam().