29 const Int_t MAXMEC = 30;
31 class Gctrak :
public TObject {
53 Gctrak() {lmec=0; namec=0;}
59 void helixStep(Float_t step, Float_t *vect, Float_t *vout)
63 enum Evect {kX,kY,kZ,kPX,kPY,kPZ,kPP};
64 vout[kPP] = vect[kPP];
65 Float_t h4 = field*2.99792e-4;
66 Float_t rho = -h4/vect[kPP];
67 Float_t tet = rho*step;
68 Float_t tsint = tet*tet/6;
69 Float_t sintt = 1 - tsint;
70 Float_t sint = tet*sintt;
71 Float_t cos1t = tet/2;
72 Float_t f1 = step*sintt;
73 Float_t f2 = step*cos1t;
74 Float_t f3 = step*tsint*vect[kPZ];
75 Float_t f4 = -tet*cos1t;
77 Float_t f6 = tet*cos1t*vect[kPZ];
78 vout[kX] = vect[kX] + (f1*vect[kPX] - f2*vect[kPY]);
79 vout[kY] = vect[kY] + (f1*vect[kPY] + f2*vect[kPX]);
80 vout[kZ] = vect[kZ] + (f1*vect[kPZ] + f3);
81 vout[kPX] = vect[kPX] + (f4*vect[kPX] - f5*vect[kPY]);
82 vout[kPY] = vect[kPY] + (f4*vect[kPY] + f5*vect[kPX]);
83 vout[kPZ] = vect[kPZ] + (f4*vect[kPZ] + f6);
92 TFile f(
"tree2.root",
"recreate");
93 TTree t2(
"t2",
"a Tree with data from a fake Geant3");
94 Gctrak *gstep =
new Gctrak;
95 t2.Branch(
"track",&gstep,8000,1);
98 Float_t px,py,pz,p,charge=0;
100 Float_t mass = 0.137;
101 Bool_t newParticle = kTRUE;
102 gstep->lmec =
new Int_t[MAXMEC];
103 gstep->namec =
new Int_t[MAXMEC];
110 for (Int_t i=0;i<10000;i++) {
113 px = gRandom->Gaus(0,.02);
114 py = gRandom->Gaus(0,.02);
115 pz = gRandom->Gaus(0,.02);
116 p = TMath::Sqrt(px*px+py*py+pz*pz);
117 charge = 1;
if (gRandom->Rndm() < 0.5) charge = -1;
122 gstep->vect[3] = px/p;
123 gstep->vect[4] = py/p;
124 gstep->vect[5] = pz/p;
125 gstep->vect[6] = p*charge;
126 gstep->getot = TMath::Sqrt(p*p + mass*mass);
127 gstep->gekin = gstep->getot - mass;
128 newParticle = kFALSE;
135 helixStep(gstep->step, gstep->vect, vout);
138 gstep->destep = gstep->step*gRandom->Gaus(0.0002,0.00001);
139 gstep->gekin -= gstep->destep;
140 gstep->getot = gstep->gekin + mass;
141 gstep->vect[6] = charge*TMath::Sqrt(gstep->getot*gstep->getot - mass*mass);
142 gstep->vect[0] = vout[0];
143 gstep->vect[1] = vout[1];
144 gstep->vect[2] = vout[2];
145 gstep->vect[3] = vout[3];
146 gstep->vect[4] = vout[4];
147 gstep->vect[5] = vout[5];
148 gstep->nmec = (Int_t)(5*gRandom->Rndm());
149 for (Int_t l=0;l<gstep->nmec;l++) {
151 gstep->namec[l] = l+100;
153 if (gstep->gekin < 0.001) newParticle = kTRUE;
154 if (TMath::Abs(gstep->vect[2]) > 30) newParticle = kTRUE;
170 TFile *f =
new TFile(
"tree2.root");
171 TTree *t2 = (TTree*)f->Get(
"t2");
173 t2->SetBranchAddress(
"track",&gstep);
174 TBranch *b_destep = t2->GetBranch(
"destep");
177 TH1F *hdestep =
new TH1F(
"hdestep",
"destep in Mev",100,1e-5,3e-5);
180 Long64_t nentries = t2->GetEntries();
181 for (Long64_t i=0;i<nentries;i++) {
182 b_destep->GetEntry(i);
183 hdestep->Fill(gstep->destep);
189 TCanvas *c1 =
new TCanvas(
"c1",
"c1",600,800);
190 c1->SetFillColor(42);
193 hdestep->SetFillColor(45);
194 hdestep->Fit(
"gaus");
196 gPad->SetFillColor(37);
197 t2->SetMarkerColor(kRed);
198 t2->Draw(
"vect[0]:vect[1]:vect[2]");
199 if (gROOT->IsBatch())
return;
202 gPad->GetViewer3D(
"x3d");