Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JetAnalyzer.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file JetAnalyzer.hh
1 
39 /*
40  Author self-assessment statement: It gets the job done for A_J.
41 */
42 
43 #ifndef JETANALYZER_H
44 #define JETANALYZER_H
45 
46 // Includes and namespaces
47 //#include "FastJet3.h"
48 #include "fastjet/ClusterSequence.hh"
49 #include "fastjet/ClusterSequenceArea.hh"
50 #include "fastjet/ClusterSequencePassiveArea.hh"
51 #include "fastjet/ClusterSequenceActiveArea.hh"
52 #include "fastjet/ClusterSequenceActiveAreaExplicitGhosts.hh"
53 #include "fastjet/Selector.hh"
54 
55 #include <TLorentzVector.h>
56 #include <TClonesArray.h>
57 
58 #include "fastjet/tools/JetMedianBackgroundEstimator.hh"
59 #include "fastjet/tools/Subtractor.hh"
60 #include "fastjet/tools/Filter.hh"
61 #include "fastjet/FunctionOfPseudoJet.hh"
62 
63 #include <iostream>
64 #include <string>
65 #include <sstream>
66 
67 // For pairs and sorting in the dijet finding
68 #include <utility>
69 #include <algorithm>
70 
71 
74 class JetAnalyzer : public fastjet::ClusterSequenceArea {
75 
76 private :
81  std::vector<fastjet::PseudoJet>& OrigParticles;
82 
85 
90  fastjet::JetMedianBackgroundEstimator* bkgd_estimator;
92  fastjet::Subtractor* bkgd_subtractor;
93 
95  fastjet::Selector selector_bkgd;
97  fastjet::JetDefinition* jet_def_bkgd;
99  fastjet::AreaDefinition* area_def_bkgd;
100 
101 public :
102  // ------------
103  // Constructors
104  // ------------
115  JetAnalyzer ( std::vector<fastjet::PseudoJet>& InOrigParticles, fastjet::JetDefinition& JetDef, fastjet::AreaDefinition& AreaDef,
116  fastjet::Selector selector_bkgd=fastjet::SelectorAbsRapMax( 0.6 ) * (!fastjet::SelectorNHardest(2)) );
117 
122  JetAnalyzer ( std::vector<fastjet::PseudoJet>& InOrigParticles, fastjet::JetDefinition& JetDef );
123 
127  if ( area_def_bkgd ) {
128  delete area_def_bkgd;
129  area_def_bkgd = 0 ;
130  }
131  if ( jet_def_bkgd ) {
132  delete jet_def_bkgd;
133  jet_def_bkgd = 0 ;
134  }
135  if ( bkgd_estimator ) {
136  delete bkgd_estimator;
137  bkgd_estimator = 0 ;
138  }
139  if ( bkgd_subtractor ) {
140  delete bkgd_subtractor;
141  bkgd_subtractor = 0 ;
142  }
143 
144  };
145 
146 
147  // ----------------
148  // Analysis methods
149  // ----------------
150 
151  // -------------
152  // Other Methods
153  // -------------
158  fastjet::Subtractor* GetBackgroundSubtractor();
162  fastjet::JetMedianBackgroundEstimator* GetBackgroundEstimator() { return bkgd_estimator; };
163  // ---------
164  // Operators
165  // ---------
166  // May eventually be added.
167  // bool operator==(JetAnalyzer& rhs);
168 
169  // -------
170  // Helpers
171  // -------
174  static const double pi;
175 
178  static double phimod2pi ( double phi );
179 
180 };
181 
182 // NOT part of the class!
183 // =============================================================================
196 class SelectorDijetWorker : public fastjet::SelectorWorker{
197 public:
202  : dPhi(dPhi){};
203 
206  std::ostringstream oss;
207  oss << "Searches for and returns dijet pairs within |phi1 - phi2 - pi| < " << dPhi;
208  return oss.str() ;
209  };
210 
212  bool applies_jet_by_jet() const { return false;};
213 
215  bool pass(const fastjet::PseudoJet& pj) const{
216  if (!applies_jet_by_jet())
217  throw ( std::string("Cannot apply this selector worker to an individual jet") );
218  return false;
219  };
220 
222  void terminator(std::vector<const fastjet::PseudoJet *> & jets) const;
223 
224 private:
225  const double dPhi;
226 };
227 
232  bool operator()(const std::pair<int,double> &left, const std::pair<int,double> &right) {
233  return left.second < right.second;
234  }
235 };
240 fastjet::Selector SelectorDijets( const double dPhi=0.4);
241 
242 
243 
244 // =============================================================================
252 bool IsMatched ( const std::vector<fastjet::PseudoJet>& jetset1, const std::vector<fastjet::PseudoJet>& jetset2, const double Rmax );
253 
257 bool IsMatched ( const std::vector<fastjet::PseudoJet>& jetset1, const fastjet::PseudoJet& reference, const double Rmax );
258 
262 bool IsMatched ( const fastjet::PseudoJet& jet1, const fastjet::PseudoJet& jet2, const double Rmax );
263 
264 
265 
266 // =============================================================================
270 // ------------------------------------------------------------------------
271 TLorentzVector MakeTLorentzVector ( const fastjet::PseudoJet& pj );
272 // ------------------------------------------------------------------------
273 
274 // // =============================================================================
275 // Experimental, not working.
276 // Should work if this class is _instantiated_ and then the instance is used.
277 // That's not really the usage scenario.
278 // class MakeTLorentzVector : public fastjet::FunctionOfPseudoJet<TLorentzVector>{
279 // TLorentzVector result(const fastjet::PseudoJet &pj) const{
280 // return TLorentzVector( pj.px(), pj.py(), pj.pz(), pj.E() );
281 // };
282 // std::string description() const {return "Translates Pseudojet into ROOT TLorentzVector";}
283 // TLorentzVector operator()(const fastjet::PseudoJet & pj) const {return result(pj);};
284 // };
285 
286 
287 // =============================================================================
292 fastjet::PseudoJet MakePseudoJet ( const TLorentzVector* const lv );
293 // =============================================================================
294 // =============================================================================
295 
300 class JetAnalysisUserInfo: public fastjet::PseudoJet::UserInfoBase {
301 public:
304 
306  int GetQuarkCharge() const { return quarkcharge; };
307 
308 private:
309  const int quarkcharge;
310 };
311 
312 // =============================================================================
322 class SelectorChargeWorker : public fastjet::SelectorWorker{
323 public:
328  SelectorChargeWorker( const int cmin, const int cmax) : cmin(cmin), cmax(cmax) {};
329 
332  std::ostringstream oss;
333  oss.str("");
334  oss << cmin << " <= quark charge <= " << cmax;
335  return oss.str() ;
336  };
337 
339  bool pass(const fastjet::PseudoJet &p) const{
340  const int & quarkcharge = p.user_info<JetAnalysisUserInfo>().GetQuarkCharge();
341  return (quarkcharge >= cmin) && (quarkcharge<= cmax);
342  };
343 
344 private:
345  const int cmin;
346  const int cmax;
347 
348 };
349 // =============================================================================
354 fastjet::Selector SelectorChargeRange( const int cmin=-999, const int cmax=999);
355 
356 // =============================================================================
357 // =============================================================================
358 // =============================================================================
363 
364 
365 #endif // JETANALYZER_H