31 const Int_t MAXMEC = 30;
56 void helixStep(Float_t step, Float_t *vect, Float_t *vout)
60 enum Evect {kX,kY,kZ,kPX,kPY,kPZ,kPP};
61 vout[kPP] = vect[kPP];
62 Float_t h4 = field*2.99792e-4;
63 Float_t rho = -h4/vect[kPP];
64 Float_t tet = rho*step;
65 Float_t tsint = tet*tet/6;
66 Float_t sintt = 1 - tsint;
67 Float_t sint = tet*sintt;
68 Float_t cos1t = tet/2;
69 Float_t f1 = step*sintt;
70 Float_t f2 = step*cos1t;
71 Float_t f3 = step*tsint*vect[kPZ];
72 Float_t f4 = -tet*cos1t;
74 Float_t f6 = tet*cos1t*vect[kPZ];
75 vout[kX] = vect[kX] + (f1*vect[kPX] - f2*vect[kPY]);
76 vout[kY] = vect[kY] + (f1*vect[kPY] + f2*vect[kPX]);
77 vout[kZ] = vect[kZ] + (f1*vect[kPZ] + f3);
78 vout[kPX] = vect[kPX] + (f4*vect[kPX] - f5*vect[kPY]);
79 vout[kPY] = vect[kPY] + (f4*vect[kPY] + f5*vect[kPX]);
80 vout[kPZ] = vect[kPZ] + (f4*vect[kPZ] + f6);
89 TFile f(
"tree2.root",
"recreate");
90 TTree t2(
"t2",
"a Tree with data from a fake Geant3");
92 t2.Branch(
"vect",gstep.vect,
"vect[7]/F");
93 t2.Branch(
"getot",&gstep.getot);
94 t2.Branch(
"gekin",&gstep.gekin);
95 t2.Branch(
"nmec",&gstep.nmec);
96 t2.Branch(
"lmec",gstep.lmec,
"lmec[nmec]/I");
97 t2.Branch(
"destep",&gstep.destep);
98 t2.Branch(
"pid",&gstep.pid);
101 Float_t px,py,pz,p,charge=0;
103 Float_t mass = 0.137;
104 Bool_t newParticle = kTRUE;
111 for (Int_t i=0;i<10000;i++) {
114 px = gRandom->Gaus(0,.02);
115 py = gRandom->Gaus(0,.02);
116 pz = gRandom->Gaus(0,.02);
117 p = TMath::Sqrt(px*px+py*py+pz*pz);
118 charge = 1;
if (gRandom->Rndm() < 0.5) charge = -1;
123 gstep.vect[3] = px/p;
124 gstep.vect[4] = py/p;
125 gstep.vect[5] = pz/p;
126 gstep.vect[6] = p*charge;
127 gstep.getot = TMath::Sqrt(p*p + mass*mass);
128 gstep.gekin = gstep.getot - mass;
129 newParticle = kFALSE;
136 helixStep(gstep.step, gstep.vect, vout);
139 gstep.destep = gstep.step*gRandom->Gaus(0.0002,0.00001);
140 gstep.gekin -= gstep.destep;
141 gstep.getot = gstep.gekin + mass;
142 gstep.vect[6] = charge*TMath::Sqrt(gstep.getot*gstep.getot - mass*mass);
143 gstep.vect[0] = vout[0];
144 gstep.vect[1] = vout[1];
145 gstep.vect[2] = vout[2];
146 gstep.vect[3] = vout[3];
147 gstep.vect[4] = vout[4];
148 gstep.vect[5] = vout[5];
149 gstep.nmec = (Int_t)(5*gRandom->Rndm());
150 for (Int_t l=0;l<gstep.nmec;l++) gstep.lmec[l] = l;
151 if (gstep.gekin < 0.001) newParticle = kTRUE;
152 if (TMath::Abs(gstep.vect[2]) > 30) newParticle = kTRUE;
168 TFile *f =
new TFile(
"tree2.root");
169 TTree *t2 = (TTree*)f->Get(
"t2");
170 static Float_t destep;
171 TBranch *b_destep = t2->GetBranch(
"destep");
172 b_destep->SetAddress(&destep);
175 TH1F *hdestep =
new TH1F(
"hdestep",
"destep in Mev",100,1e-5,3e-5);
178 Long64_t nentries = t2->GetEntries();
179 for (Long64_t i=0;i<nentries;i++) {
180 b_destep->GetEntry(i);
181 hdestep->Fill(destep);
187 TCanvas *c1 =
new TCanvas(
"c1",
"c1",600,800);
188 c1->SetFillColor(42);
191 hdestep->SetFillColor(45);
192 hdestep->Fit(
"gaus");
194 gPad->SetFillColor(37);
195 t2->SetMarkerColor(kRed);
196 t2->Draw(
"vect[0]:vect[1]:vect[2]");
199 t2->ResetBranchAddresses();