stablejet is hosted by Hepforge, IPPP Durham
StableJet
QCDSmearSequence.cc
1 #include "QCDSmearSequence.h"
2 #include "mother_probability.hh"
3 
4 namespace stab {
5 
6  QCDSmearSequence::QCDSmearSequence(const AlphaStrong& alphaS)
7  : alphaS_(alphaS)
8  {
9  }
10 
11  QCDSmearSequence::QCDSmearSequence(const AlphaStrong& alphaS,
12  const std::vector<QCDSmearSequenceCallback*> cb)
13  : alphaS_(alphaS), callbacks_(cb)
14  {
15  const unsigned nCallbacks = callbacks_.size();
16  for (unsigned icall=0; icall<nCallbacks; ++icall)
17  assert(callbacks_[icall]);
18  }
19 
20  void QCDSmearSequence::smear(Event& smearedEvent)
21  {
22  m_callBackCount = 0;
23 
24  // copy event into smearedEvent
25  const unsigned sz = m_event.size();
26  //smearedEvent.clear();
27  for ( unsigned i=0; i != sz; i++ )
28  smearedEvent[i] = m_event[i];
29 
30 
31  if (sz > 1U)
32  {
33  // Calculate the transverse momentum values
34  ptValues_.clear();
35  for (unsigned i=0; i<sz; ++i)
36  ptValues_.push_back(smearedEvent[i].pt());
37 
38  // Calculate pairwise probabilities
39  probs_.clear();
40  const unsigned szm1 = sz - 1U;
41  for (unsigned i=0; i<szm1; ++i)
42  {
43  const PseudoJet& pi = smearedEvent[i];
44  for (unsigned j=i+1; j<sz; ++j)
45  {
46  const double prob = mother_probability(pi, smearedEvent[j], alphaS_);
47  probs_.push_back(ProbTriple(prob, i, j));
48  }
49  }
50  std::sort(probs_.begin(), probs_.end(), std::greater<ProbTriple>());
51 
52  // Go over all pairs calling the callbacks and marking
53  // the "softer" of the two particles as "used"
54  used_.clear();
55  for (unsigned i=0; i<sz; ++i)
56  used_.push_back(0);
57 
58  const unsigned nCallbacks = callbacks_.size();
59  const unsigned long nprobs = probs_.size();
60  for (unsigned long iprob=0; iprob<nprobs; ++iprob)
61  {
62  const ProbTriple& t(probs_[iprob]);
63  unsigned soft, hard;
64 
65  if (ptValues_[t.second] < ptValues_[t.third])
66  {
67  soft = t.second;
68  hard = t.third;
69  }
70  else
71  {
72  soft = t.third;
73  hard = t.second;
74  }
75  if (!used_[soft])
76  {
77  // Call various callbacks
78  bool continueIterating = true;
79  for (unsigned icall=0; icall<nCallbacks && continueIterating; ++icall)
80  {
81  continueIterating = (*callbacks_[icall])(
82  t.first, m_callBackCount, hard,
83  soft, smearedEvent[hard], smearedEvent[soft]);
84  if (continueIterating)
85  ++m_callBackCount;
86  }
87  used_[soft] = 1;
88  if (!continueIterating)
89  break;
90  }
91  }
92  }
93 
94  }
95 
96 } // end stab namespace
virtual void smear(Event &event)
smear the event, return the smeared event via the function argument.