CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FFTJetCorrectorSequence.h
Go to the documentation of this file.
1 //
2 // A sequence of jet correction metods for FFTJet
3 //
4 // I. Volobouev, 08/02/2012
5 //
6 
7 #ifndef JetMETCorrections_FFTJetObjects_FFTJetCorrectorSequence_h
8 #define JetMETCorrections_FFTJetObjects_FFTJetCorrectorSequence_h
9 
11 
12 //
13 // Both InitialConverter and FinalConverter must publish
14 // result_type typedef.
15 //
16 // InitialConverter must have a method with the signature
17 // "result_type operator()(const Jet&) const". The
18 // variable of the type returned by this method will be
19 // propagated through the correction chain. This should
20 // be a simple type with copy constructor and assignment
21 // operator, for example "double" or "LorentzVector".
22 //
23 // FinalConverter must have a method with the signature
24 // "result_type operator()(const Jet&, const T&) const",
25 // where T is now the result_type of InitialConverter.
26 // It can be a different result type from that defined
27 // in InitialConverter. result_type from FinalConverter
28 // will be the type of variable returned by the "correct"
29 // method of the FFTJetCorrectorSequence class.
30 //
31 template
32 <
33  class Jet,
34  template<class> class InitialConverter,
35  template<class> class FinalConverter
36 >
38 {
39 public:
40  typedef Jet jet_type;
41  typedef typename InitialConverter<Jet>::result_type adjustable_type;
42  typedef typename FinalConverter<Jet>::result_type result_type;
44 
46 
47  inline FFTJetCorrectorSequence(const std::vector<Corrector>& s)
48  : sequence_(s) {}
49 
50  inline FFTJetCorrectorSequence(const std::vector<Corrector>& s,
51  const InitialConverter<Jet>& i,
52  const FinalConverter<Jet>& f)
53  : sequence_(s), cinit_(i), cfinal_(f) {}
54 
55  inline FFTJetCorrectorSequence(const InitialConverter<Jet>& i,
56  const FinalConverter<Jet>& f)
57  : cinit_(i), cfinal_(f) {}
58 
59  inline void addCorrector(const Corrector& c)
60  {sequence_.push_back(c);}
61 
62  inline unsigned nLevels() const {return sequence_.size();}
63 
64  inline const std::vector<Corrector>& getCorrectors() const
65  {return sequence_;}
66 
67  result_type correct(const Jet& jet, const bool isMC) const
68  {
69  adjustable_type a1(cinit_(jet));
70  adjustable_type a2(a1);
71  adjustable_type* first = &a1;
72  adjustable_type* second = &a2;
73 
74  const unsigned nLevels = sequence_.size();
75  for (unsigned level=0; level<nLevels; ++level)
76  {
77  first = level % 2 ? &a2 : &a1;
78  second = level % 2 ? &a1 : &a2;
79  sequence_[level].correct(jet, isMC, *first, second);
80  }
81 
82  return cfinal_(jet, *second);
83  }
84 
85  const Corrector& operator[](const unsigned i) const
86  {return sequence_.at(i);}
87 
88 private:
89  std::vector<Corrector> sequence_;
90  InitialConverter<Jet> cinit_;
91  FinalConverter<Jet> cfinal_;
92 };
93 
94 #endif // JetMETCorrections_FFTJetObjects_FFTJetCorrectorSequence_h
int i
Definition: DBlmapReader.cc:9
result_type correct(const Jet &jet, const bool isMC) const
FinalConverter< Jet >::result_type result_type
const std::vector< Corrector > & getCorrectors() const
FFTJetCorrectorSequence(const std::vector< Corrector > &s)
FFTJetCorrectorSequence(const InitialConverter< Jet > &i, const FinalConverter< Jet > &f)
U second(std::pair< T, U > const &p)
double f[11][100]
InitialConverter< Jet > cinit_
std::vector< Corrector > sequence_
InitialConverter< Jet >::result_type adjustable_type
FFTJetCorrector< jet_type, adjustable_type > Corrector
FFTJetCorrectorSequence(const std::vector< Corrector > &s, const InitialConverter< Jet > &i, const FinalConverter< Jet > &f)
FinalConverter< Jet > cfinal_
tuple level
Definition: testEve_cfg.py:34
const Corrector & operator[](const unsigned i) const
void addCorrector(const Corrector &c)