CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetMatchingPy8Internal.h
Go to the documentation of this file.
1 // JetMatching.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2014 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL version 2, see COPYING for details.
4 // Please respect the MCnet Guidelines, see GUIDELINES for details.
5 
6 // Authors: Richard Corke (implementation of MLM matching as
7 // in Alpgen for Alpgen input)
8 // and Stephen Mrenna (implementation of MLM-style matching as
9 // in Madgraph for Alpgen or Madgraph 5 input.)
10 // and Simon de Visscher and Stefan Prestel (implementation of shower-kT
11 // MLM-style matching and flavour treatment for Madgraph input, and FxFx NLO
12 // jet matching with aMC@NLO.)
13 // This file provides the classes to perform MLM matching of
14 // Alpgen or MadGraph 5 input.
15 // Example usage is shown in main32.cc, and further details
16 // can be found in the 'Jet Matching Style' manual page.
17 
18 #ifndef Pythia8_JetMatching_H
19 #define Pythia8_JetMatching_H
20 
21 // Includes
22 #include "Pythia8/Pythia.h"
23 #include "GeneratorInput.h"
24 
25 //==========================================================================
26 
27 // Declaration of main JetMatching class to perform MLM matching.
28 // Note that it is defined with virtual inheritance, so that it can
29 // be combined with other UserHooks classes, see e.g. main33.cc.
30 
31 class JetMatching : virtual public Pythia8::UserHooks {
32 
33 public:
34 
35  // Constructor and destructor
38  if (cellJet) delete cellJet;
39  if (slowJet) delete slowJet;
40  if (slowJetHard) delete slowJetHard;
41  }
42 
43  // Initialisation
44  virtual bool initAfterBeams() = 0;
45 
46  // Process level vetos
47  bool canVetoProcessLevel() { return doMerge; }
48  bool doVetoProcessLevel(Pythia8::Event& process) {
50  return false;
51  }
52 
53  // Parton level vetos (before beam remnants and resonance decays)
54  bool canVetoPartonLevelEarly() { return doMerge; }
55  bool doVetoPartonLevelEarly(const Pythia8::Event& event);
56 
57  // Shower step vetoes (after the first emission, for Shower-kT scheme)
58  int numberVetoStep() {return 1;}
59  bool canVetoStep() { return true; }
60  bool doVetoStep(int, int, int, const Pythia8::Event& ) { return false; }
61 
62 protected:
63 
64  // Constants to be changed for debug printout or extra checks.
65  static const bool MATCHINGDEBUG, MATCHINGCHECK;
66 
67  // Different steps of the matching algorithm.
68  virtual void sortIncomingProcess(const Pythia8::Event &)=0;
69  virtual void jetAlgorithmInput(const Pythia8::Event &, int)=0;
70  virtual void runJetAlgorithm()=0;
71  virtual bool matchPartonsToJets(int)=0;
72  virtual int matchPartonsToJetsLight()=0;
73  virtual int matchPartonsToJetsHeavy()=0;
74 
78 
79  // Master switch for merging
80  bool doMerge;
81  // Switch for merging in the shower-kT scheme. Needed here because
82  // the scheme uses different UserHooks functionality.
83  bool doShowerKt;
84 
85  // Maximum and current number of jets
86  int nJetMax, nJet;
87 
88  // Jet algorithm parameters
91 
92  // Internal jet algorithms
93  Pythia8::CellJet* cellJet;
94  Pythia8::SlowJet* slowJet;
95  Pythia8::SlowJet* slowJetHard;
96 
97  // SlowJet specific
99 
100  // Event records to store original incoming process, final-state of the
101  // incoming process and what will be passed to the jet algorithm.
102  // Not completely necessary to store all steps, but makes tracking the
103  // steps of the algorithm a lot easier.
105 
106  // Sort final-state of incoming process into light/heavy jets and 'other'
107  vector<int> typeIdx[3];
108  set<int> typeSet[3];
109 
110  // Momenta output of jet algorithm (to provide same output regardless of
111  // the selected jet algorithm)
112  vector<Pythia8::Vec4> jetMomenta;
113 
114  // CellJet specific
115  int nEta, nPhi;
117 
118  // Merging procedure parameters
121  bool exclusive;
122 
123  // Store the minimum eT/pT of matched light jets
124  double eTpTlightMin;
125 
126 };
127 
128 //==========================================================================
129 
130 // Declaration of main UserHooks class to perform Alpgen matching.
131 
132 class JetMatchingAlpgen : virtual public JetMatching {
133 
134 public:
135 
136  // Constructor and destructor
139 
140  // Initialisation
141  bool initAfterBeams();
142 
143 private:
144 
145  // Different steps of the matching algorithm.
146  void sortIncomingProcess(const Pythia8::Event &);
147  void jetAlgorithmInput(const Pythia8::Event &, int);
148  void runJetAlgorithm();
149  bool matchPartonsToJets(int);
152 
153  // Sorting utility
154  void sortTypeIdx(vector < int > &vecIn);
155 
156  // Constants
157  static const double GHOSTENERGY, ZEROTHRESHOLD;
158 
159 };
160 
161 //==========================================================================
162 
163 // Declaration of main UserHooks class to perform Madgraph matching.
164 
165 class JetMatchingMadgraph : virtual public JetMatching {
166 
167 public:
168 
169  // Constructor and destructor
172 
173  // Initialisation
174  bool initAfterBeams();
175 
176  // Shower step vetoes (after the first emission, for Shower-kT scheme)
177  int numberVetoStep() {return 1;}
178  bool canVetoStep() { return doShowerKt; }
179  bool doVetoStep(int, int, int, const Pythia8::Event& );
180 
181  // Jet algorithm to access the jet separations in the cleaned event
182  // after showering.
183  Pythia8::SlowJet* slowJetDJR;
184  // Function to return the jet clustering scales.
185  vector<double> GetDJR() { return DJR;}
186  vector<int> nMEPartons(){return nME;}
187 protected:
188 
189  // Different steps of the matching algorithm.
190  void sortIncomingProcess(const Pythia8::Event &);
191  void jetAlgorithmInput(const Pythia8::Event &, int);
192  void runJetAlgorithm();
193  bool matchPartonsToJets(int);
196  bool doShowerKtVeto(double pTfirst);
197 
198  // Functions to clear and set the jet clustering scales.
199  void ClearDJR() { DJR.resize(0);}
200  void ClearnME() { nME.resize(0);}
201 
202  void SetDJR( const Pythia8::Event& event) {
203 
204  // Clear members.
205  ClearDJR();
206 
207  vector<double> result;
208 
209  // Initialize SlowJetDJR jet algorithm with event
210  if (!slowJetDJR->setup(event) ) {
211  infoPtr->errorMsg("Warning in JetMatchingMadgraph:iGetDJR"
212  ": the SlowJet algorithm failed on setup");
213  return;
214  }
215 
216  // Cluster in steps to find all hadronic jets
217  while ( slowJetDJR->sizeAll() - slowJetDJR->sizeJet() > 0 ) {
218  // Save the next clustering scale.
219  result.push_back(slowJetDJR->dNext());
220  // Perform step.
221  slowJetDJR->doStep();
222  }
223 
224  // Save clustering scales in reserve order.
225  for (int i=int(result.size())-1; i > 0; --i){
226 // std::cout<<"Saving DJR "<<i<<" "<<log10(sqrt(result[i]))<<std::endl;
227  DJR.push_back(log10(sqrt(result[i])));
228  }
229  }
230  void SetnME() {
231  ClearnME();
232  vector<int> result;
233  nME.push_back(origTypeIdx[0].size());
234  nME.push_back(typeIdx[0].size());
235  //std::cout<<"Number of partons "<<origTypeIdx[0].size()<<" "<<typeIdx[0].size()<<std::endl;
236  }
237 
238  // Variables.
239  vector<int> origTypeIdx[3];
240  int nQmatch;
241  double qCut, qCutSq, clFact;
242  bool doFxFx;
244  double qCutME, qCutMESq;
245 
246  // Vectors to store the jet clustering scales and the number of partons (old and new convention).
247  vector<double> DJR;
248  vector<int> nME;
249 
250 };
251 #endif // end Pythia8_JetMatching_H
virtual void jetAlgorithmInput(const Pythia8::Event &, int)=0
int i
Definition: DBlmapReader.cc:9
bool doVetoProcessLevel(Pythia8::Event &process)
Pythia8::Event eventProcess
Pythia8::SlowJet * slowJetHard
void jetAlgorithmInput(const Pythia8::Event &, int)
void jetAlgorithmInput(const Pythia8::Event &, int)
Pythia8::Event workEventJet
Pythia8::SlowJet * slowJet
virtual int matchPartonsToJetsLight()=0
virtual bool matchPartonsToJets(int)=0
#define NULL
Definition: scimark2.h:8
virtual bool initAfterBeams()=0
Pythia8::Event eventProcessOrig
Pythia8::SlowJet * slowJetDJR
void sortTypeIdx(vector< int > &vecIn)
virtual int matchPartonsToJetsHeavy()=0
T sqrt(T t)
Definition: SSEVec.h:48
bool doShowerKtVeto(double pTfirst)
tuple result
Definition: query.py:137
void sortIncomingProcess(const Pythia8::Event &)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
vector< int > origTypeIdx[3]
virtual void sortIncomingProcess(const Pythia8::Event &)=0
bool doVetoStep(int, int, int, const Pythia8::Event &)
bool canVetoPartonLevelEarly()
Pythia8::CellJet * cellJet
static const double ZEROTHRESHOLD
vector< double > GetDJR()
void sortIncomingProcess(const Pythia8::Event &)
static const bool MATCHINGCHECK
set< int > typeSet[3]
vector< int > typeIdx[3]
vector< Pythia8::Vec4 > jetMomenta
bool doVetoPartonLevelEarly(const Pythia8::Event &event)
virtual void runJetAlgorithm()=0
tuple process
Definition: LaserDQM_cfg.py:3
void SetDJR(const Pythia8::Event &event)
bool doVetoStep(int, int, int, const Pythia8::Event &)
static const bool MATCHINGDEBUG
tuple size
Write out results.
static const double GHOSTENERGY