00001
00002
00003 #include "StChargedPionMcEvent.h"
00004
00005 #include <utility>
00006 using std::make_pair;
00007
00008 #include "TMath.h"
00009 #include "TLorentzVector.h"
00010 #include "TClass.h"
00011
00012 #include "StChargedPionTypes.h"
00013 #include "StChargedPionTrack.h"
00014 #include "StChargedPionJet.h"
00015 #include "StChargedPionVertex.h"
00016
00017 ClassImp(StChargedPionMcEvent)
00018
00019 StChargedPionMcEvent::StChargedPionMcEvent() : mSimuTriggerBits(0) {
00020 mVertices = new TClonesArray("StChargedPionVertex", 20);
00021 mTracks = new TClonesArray("StChargedPionTrack", 50);
00022 mJets = new TClonesArray("StChargedPionJet", 50);
00023
00024 memset(mL2ResultEmulated, 0, 36);
00025
00026 StChargedPionMcEvent::Class()->IgnoreTObjectStreamer();
00027 StChargedPionVertex::Class()->IgnoreTObjectStreamer();
00028 StChargedPionTrack::Class()->IgnoreTObjectStreamer();
00029 StChargedPionJet::Class()->IgnoreTObjectStreamer();
00030 StChargedPionMcTrack::Class()->IgnoreTObjectStreamer();
00031 StChargedPionMcJet::Class()->IgnoreTObjectStreamer();
00032 }
00033
00034 StChargedPionMcEvent::~StChargedPionMcEvent() {
00035 if(mVertices) delete mVertices;
00036 if(mTracks) delete mTracks;
00037 if(mJets) delete mJets;
00038 }
00039
00040 void StChargedPionMcEvent::Clear(Option_t* o) {
00041 mSimuTriggerBits = 0;
00042 mVertices->Clear();
00043 mTracks->Clear();
00044
00045
00046 mJets->Delete();
00047
00048 mHighTowers.clear();
00049 mTriggerPatches.clear();
00050 mJetPatches.clear();
00051
00052 mMcTracks.clear();
00053 mMcJets.clear();
00054 mMatchedPairs.clear();
00055 mMergedPairs.clear();
00056 mSplitPairs.clear();
00057 mContamPairs.clear();
00058 mGhostPairs.clear();
00059
00060 mPythiaRecord.clear();
00061 }
00062
00063 StChargedPionLorentzVector
00064 StChargedPionMcEvent::parton(int id, StChargedPionMcEvent::Frame frame) const {
00065 const StChargedPionLorentzVector *v;
00066 switch(id) {
00067 case 1: v = &mParton1; break;
00068 case 2: v = &mParton2; break;
00069 case 3: v = &mParton3; break;
00070 case 4: v = &mParton4; break;
00071 }
00072
00073 if(frame == CM) {
00074 Boost boost( (mParton1+mParton2).BoostToCM() );
00075 LorentzRotation rotate( RotationY(-1.0 * boost(mParton1).Theta()) );
00076 rotate *= RotationZ(-1.0 * boost(mParton1).Phi());
00077 return rotate(boost(*v));
00078 }
00079 else {
00080 return *v;
00081 }
00082 }
00083
00084 TLorentzVector StChargedPionMcEvent::lv(const StChargedPionLorentzVector& v) {
00085 return TLorentzVector(v.X(), v.Y(), v.Z(), v.E());
00086 }
00087
00088 double StChargedPionMcEvent::beta34() const {
00089 return TMath::Sqrt( pow(1 - mParton3.mass2()/s() - mParton4.mass2()/s(), 2) -
00090 4 * mParton3.mass2()/s() * mParton4.mass2()/s());
00091 }
00092
00093 double StChargedPionMcEvent::s() const {
00094 return (mParton1 + mParton2).Dot(mParton1 + mParton2);
00095 }
00096
00098 double StChargedPionMcEvent::t() const {
00099 return -0.5 * s() * (1-cosTheta());
00100 }
00101
00103 double StChargedPionMcEvent::u() const {
00104 return -0.5 * s() * (1+cosTheta());
00105 }
00106
00108 double StChargedPionMcEvent::pt() const {
00109 return parton(3, StChargedPionMcEvent::CM).Pt();
00110 }
00111
00114 double StChargedPionMcEvent::cosTheta() const {
00115 return ::cos(parton(3, StChargedPionMcEvent::CM).Theta());
00116 }
00117
00119 double StChargedPionMcEvent::Q2() const {
00120 return t() * u() / s();
00121 }
00122
00123 double StChargedPionMcEvent::x1() const {
00124 return mX1;
00125 }
00126
00127 double StChargedPionMcEvent::x2() const {
00128 return tau()/x1();
00129 }
00130
00131 double StChargedPionMcEvent::tau() const {
00132 return s() / (200*200);
00133 }
00134
00135 double StChargedPionMcEvent::y() const {
00136 return 0.5 * TMath::Log(x1()/x2());
00137 }
00138
00139 double StChargedPionMcEvent::xF() const {
00140 return (x1() - x2());
00141 }
00142
00143
00144
00145
00146 double StChargedPionMcEvent::t_alternative() const {
00147 return (mParton1 - mParton3).Dot(mParton1 - mParton3);
00148 }
00149
00150
00151 double StChargedPionMcEvent::u_alternative() const {
00152 return (mParton1 - mParton4).Dot(mParton1 - mParton4);
00153 }
00154
00156 double StChargedPionMcEvent::Q2_alternative() const {
00157 return (mParton3.mass2() + mParton4.mass2()) / 2 +
00158 (t()*u() - mParton3.mass2()*mParton4.mass2()) / s();
00159 }
00160
00161
00162 double StChargedPionMcEvent::Q2_alternative2() const {
00163 return ::pow((parton(3, StChargedPionMcEvent::CM).Et() +
00164 parton(4, StChargedPionMcEvent::CM).Et()) / 2, 2);
00165 }
00166
00167 bool StChargedPionMcEvent::isSimuTrigger(unsigned int trigId) const {
00168 map<unsigned int, unsigned int>::const_iterator it = mTriggerLookup.find(trigId);
00169 if(it==mTriggerLookup.end()) return false;
00170 return mSimuTriggerBits & it->second;
00171 }
00172
00173 int StChargedPionMcEvent::highTowerAdc(short towerId) const {
00174 map<short, int>::const_iterator it = mHighTowers.find(towerId);
00175 if(it==mHighTowers.end()) return -1;
00176 return it->second;
00177 }
00178
00179 int StChargedPionMcEvent::triggerPatchAdc(short patchId) const {
00180 map<short, int>::const_iterator it = mTriggerPatches.find(patchId);
00181 if(it==mTriggerPatches.end()) return -1;
00182 return it->second;
00183 }
00184
00185 int StChargedPionMcEvent::jetPatchAdc(short patchId) const {
00186 map<short, int>::const_iterator it = mJetPatches.find(patchId);
00187 if(it==mJetPatches.end()) return -1;
00188 return it->second;
00189 }
00190
00191 StChargedPionVertex* StChargedPionMcEvent::vertex(int i) {
00192 return static_cast<StChargedPionVertex*>(mVertices->At(i));
00193 }
00194
00195 const StChargedPionVertex* StChargedPionMcEvent::vertex(int i) const {
00196 return static_cast<StChargedPionVertex*>(mVertices->At(i));
00197 }
00198
00199 StChargedPionTrack* StChargedPionMcEvent::track(int i) {
00200 return static_cast<StChargedPionTrack*>(mTracks->At(i));
00201 }
00202
00203 const StChargedPionTrack* StChargedPionMcEvent::track(int i) const {
00204 return static_cast<StChargedPionTrack*>(mTracks->At(i));
00205 }
00206
00207 StChargedPionJet* StChargedPionMcEvent::jet(int i) {
00208 return static_cast<StChargedPionJet*>(mJets->At(i));
00209 }
00210
00211 const StChargedPionJet* StChargedPionMcEvent::jet(int i) const {
00212 return static_cast<StChargedPionJet*>(mJets->At(i));
00213 }
00214
00215 void StChargedPionMcEvent::addSimuTrigger(unsigned int trigId) {
00216 map<unsigned int, unsigned int>::const_iterator it = mTriggerLookup.find(trigId);
00217 if(it!=mTriggerLookup.end()) {
00218 mSimuTriggerBits |= it->second;
00219 }
00220 }
00221
00222 void StChargedPionMcEvent::setL2Result(const void *address, bool emulated) {
00223 if(emulated) {
00224 memcpy(mL2ResultEmulated, address, 20);
00225 memcpy(mL2ResultEmulated+5, (int*)address+6, 16);
00226 }
00227 else { }
00228 }
00229
00230 void StChargedPionMcEvent::addVertex(const StChargedPionVertex* v) {
00231 new ( (*mVertices)[mVertices->GetEntriesFast()] ) StChargedPionVertex(*v);
00232 }
00233
00234 void StChargedPionMcEvent::addTrack(const StChargedPionTrack* t) {
00235 new ( (*mTracks)[mTracks->GetEntriesFast()] ) StChargedPionTrack(*t);
00236 }
00237
00238 void StChargedPionMcEvent::addJet(const StChargedPionJet* j) {
00239 new ( (*mJets)[mJets->GetEntriesFast()] ) StChargedPionJet(*j);
00240 }
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253