StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StChargedPionMcEvent.cxx
1 // $Id: StChargedPionMcEvent.cxx,v 1.3 2009/01/04 17:42:58 kocolosk Exp $
2 
3 #include "StChargedPionMcEvent.h"
4 
5 #include <utility>
6 using std::make_pair;
7 
8 #include "TMath.h"
9 #include "TLorentzVector.h"
10 #include "TClass.h"
11 
12 #include "StChargedPionTypes.h"
13 #include "StChargedPionTrack.h"
14 #include "StChargedPionJet.h"
15 #include "StChargedPionVertex.h"
16 
17 ClassImp(StChargedPionMcEvent)
18 
19 StChargedPionMcEvent::StChargedPionMcEvent() : mSimuTriggerBits(0) {
20  mVertices = new TClonesArray("StChargedPionVertex", 20);
21  mTracks = new TClonesArray("StChargedPionTrack", 50);
22  mJets = new TClonesArray("StChargedPionJet", 50);
23 
24  memset(mL2ResultEmulated, 0, 36);
25 
26  StChargedPionMcEvent::Class()->IgnoreTObjectStreamer();
27  StChargedPionVertex::Class()->IgnoreTObjectStreamer();
28  StChargedPionTrack::Class()->IgnoreTObjectStreamer();
29  StChargedPionJet::Class()->IgnoreTObjectStreamer();
30  StChargedPionMcTrack::Class()->IgnoreTObjectStreamer();
31  StChargedPionMcJet::Class()->IgnoreTObjectStreamer();
32 }
33 
34 StChargedPionMcEvent::~StChargedPionMcEvent() {
35  if(mVertices) delete mVertices;
36  if(mTracks) delete mTracks;
37  if(mJets) delete mJets;
38 }
39 
40 void StChargedPionMcEvent::Clear(Option_t* o) {
41  mSimuTriggerBits = 0;
42  mVertices->Clear();
43  mTracks->Clear();
44 
45  // use ::Delete here so ROOT doesn't hold onto memory allocated for jet particles
46  mJets->Delete();
47 
48  mHighTowers.clear();
49  mTriggerPatches.clear();
50  mJetPatches.clear();
51 
52  mMcTracks.clear();
53  mMcJets.clear();
54  mMatchedPairs.clear();
55  mMergedPairs.clear();
56  mSplitPairs.clear();
57  mContamPairs.clear();
58  mGhostPairs.clear();
59 
60  mPythiaRecord.clear();
61 }
62 
63 StChargedPionLorentzVector
64 StChargedPionMcEvent::parton(int id, StChargedPionMcEvent::Frame frame) const {
65  const StChargedPionLorentzVector *v;
66  switch(id) {
67  case 1: v = &mParton1; break;
68  case 2: v = &mParton2; break;
69  case 3: v = &mParton3; break;
70  case 4: v = &mParton4; break;
71  }
72 
73  if(frame == CM) {
74  Boost boost( (mParton1+mParton2).BoostToCM() );
75  LorentzRotation rotate( RotationY(-1.0 * boost(mParton1).Theta()) );
76  rotate *= RotationZ(-1.0 * boost(mParton1).Phi());
77  return rotate(boost(*v));
78  }
79  else {
80  return *v;
81  }
82 }
83 
84 TLorentzVector StChargedPionMcEvent::lv(const StChargedPionLorentzVector& v) {
85  return TLorentzVector(v.X(), v.Y(), v.Z(), v.E());
86 }
87 
88 double StChargedPionMcEvent::beta34() const {
89  return TMath::Sqrt( pow(1 - mParton3.mass2()/s() - mParton4.mass2()/s(), 2) -
90  4 * mParton3.mass2()/s() * mParton4.mass2()/s());
91 }
92 
93 double StChargedPionMcEvent::s() const {
94  return (mParton1 + mParton2).Dot(mParton1 + mParton2);
95 }
96 
98 double StChargedPionMcEvent::t() const {
99  return -0.5 * s() * (1-cosTheta());
100 }
101 
103 double StChargedPionMcEvent::u() const {
104  return -0.5 * s() * (1+cosTheta());
105 }
106 
108 double StChargedPionMcEvent::pt() const {
109  return parton(3, StChargedPionMcEvent::CM).Pt();
110 }
111 
115  return ::cos(parton(3, StChargedPionMcEvent::CM).Theta());
116 }
117 
119 double StChargedPionMcEvent::Q2() const {
120  return t() * u() / s();
121 }
122 
123 double StChargedPionMcEvent::x1() const {
124  return mX1;
125 }
126 
127 double StChargedPionMcEvent::x2() const {
128  return tau()/x1();
129 }
130 
131 double StChargedPionMcEvent::tau() const {
132  return s() / (200*200);
133 }
134 
135 double StChargedPionMcEvent::y() const {
136  return 0.5 * TMath::Log(x1()/x2());
137 }
138 
139 double StChargedPionMcEvent::xF() const {
140  return (x1() - x2());
141 }
142 
143 // differences between the versions that neglect parton masses and the versions that do
144 // not are typically very small -- even in the case of b-quark production they are generally
145 // less then 0.5%
146 double StChargedPionMcEvent::t_alternative() const {
147  return (mParton1 - mParton3).Dot(mParton1 - mParton3);
148 }
149 
150 
151 double StChargedPionMcEvent::u_alternative() const {
152  return (mParton1 - mParton4).Dot(mParton1 - mParton4);
153 }
154 
157  return (mParton3.mass2() + mParton4.mass2()) / 2 +
158  (t()*u() - mParton3.mass2()*mParton4.mass2()) / s();
159 }
160 
161 // don't understand why masses need to be included here, but it matches Q2()
162 double StChargedPionMcEvent::Q2_alternative2() const {
163  return ::pow((parton(3, StChargedPionMcEvent::CM).Et() +
164  parton(4, StChargedPionMcEvent::CM).Et()) / 2, 2);
165 }
166 
167 bool StChargedPionMcEvent::isSimuTrigger(unsigned int trigId) const {
168  map<unsigned int, unsigned int>::const_iterator it = mTriggerLookup.find(trigId);
169  if(it==mTriggerLookup.end()) return false;
170  return mSimuTriggerBits & it->second;
171 }
172 
173 int StChargedPionMcEvent::highTowerAdc(short towerId) const {
174  map<short, int>::const_iterator it = mHighTowers.find(towerId);
175  if(it==mHighTowers.end()) return -1;
176  return it->second;
177 }
178 
179 int StChargedPionMcEvent::triggerPatchAdc(short patchId) const {
180  map<short, int>::const_iterator it = mTriggerPatches.find(patchId);
181  if(it==mTriggerPatches.end()) return -1;
182  return it->second;
183 }
184 
185 int StChargedPionMcEvent::jetPatchAdc(short patchId) const {
186  map<short, int>::const_iterator it = mJetPatches.find(patchId);
187  if(it==mJetPatches.end()) return -1;
188  return it->second;
189 }
190 
191 StChargedPionVertex* StChargedPionMcEvent::vertex(int i) {
192  return static_cast<StChargedPionVertex*>(mVertices->At(i));
193 }
194 
195 const StChargedPionVertex* StChargedPionMcEvent::vertex(int i) const {
196  return static_cast<StChargedPionVertex*>(mVertices->At(i));
197 }
198 
199 StChargedPionTrack* StChargedPionMcEvent::track(int i) {
200  return static_cast<StChargedPionTrack*>(mTracks->At(i));
201 }
202 
203 const StChargedPionTrack* StChargedPionMcEvent::track(int i) const {
204  return static_cast<StChargedPionTrack*>(mTracks->At(i));
205 }
206 
207 StChargedPionJet* StChargedPionMcEvent::jet(int i) {
208  return static_cast<StChargedPionJet*>(mJets->At(i));
209 }
210 
211 const StChargedPionJet* StChargedPionMcEvent::jet(int i) const {
212  return static_cast<StChargedPionJet*>(mJets->At(i));
213 }
214 
215 void StChargedPionMcEvent::addSimuTrigger(unsigned int trigId) {
216  map<unsigned int, unsigned int>::const_iterator it = mTriggerLookup.find(trigId);
217  if(it!=mTriggerLookup.end()) {
218  mSimuTriggerBits |= it->second;
219  }
220 }
221 
222 void StChargedPionMcEvent::setL2Result(const void *address, bool emulated) {
223  if(emulated) {
224  memcpy(mL2ResultEmulated, address, 20);
225  memcpy(mL2ResultEmulated+5, (int*)address+6, 16);
226  }
227  else { /* no-op, should throw an error */ }
228 }
229 
230 void StChargedPionMcEvent::addVertex(const StChargedPionVertex* v) {
231  new ( (*mVertices)[mVertices->GetEntriesFast()] ) StChargedPionVertex(*v);
232 }
233 
234 void StChargedPionMcEvent::addTrack(const StChargedPionTrack* t) {
235  new ( (*mTracks)[mTracks->GetEntriesFast()] ) StChargedPionTrack(*t);
236 }
237 
238 void StChargedPionMcEvent::addJet(const StChargedPionJet* j) {
239  new ( (*mJets)[mJets->GetEntriesFast()] ) StChargedPionJet(*j);
240 }
241 
242 /*****************************************************************************
243  * $Log: StChargedPionMcEvent.cxx,v $
244  * Revision 1.3 2009/01/04 17:42:58 kocolosk
245  * extra includes for standalone builds against ROOT 5.16+
246  *
247  * Revision 1.2 2008/12/29 15:58:30 kocolosk
248  * removed commented code and added Id and Log as needed
249  *
250  * Revision 1.1 2008/07/17 17:06:31 kocolosk
251  * big-bang integration StChargedPionMcEvent framework
252  *
253  *****************************************************************************/
double pt() const
doesn&#39;t quite match hard_p in the case of b quark stuff
double Q2_alternative() const
eqn 83, Chapter 7 of PYTHIA 6.400 manual
double Q2() const
this one neglects outgoing parton masses, and matches g2t_pythia-&gt;hard_p**2
double u() const
this version neglects outgoing parton masses, and matches g2t_pythia-&gt;mand_u
double t() const
this version neglects outgoing parton masses, and matches g2t_pythia-&gt;mand_t