Changeset 1360
- Timestamp:
- 06/13/02 08:54:51 (23 years ago)
- Location:
- trunk/WuerzburgSoft/Thomas/mphys
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WuerzburgSoft/Thomas/mphys/Changelog
r1359 r1360 1 1 -*-*- END -*-*- 2 2002/06/13: Thomas Bretz 3 4 * MParticle.h: 5 - Implemented Set/IsPrimary 6 7 * energyloss.C: 8 - changed output range for ZofR 9 10 * phys.C: 11 - changed energy randomizer 12 - added root file output 13 14 15 2 16 2002/06/12: Thomas Bretz 3 17 -
trunk/WuerzburgSoft/Thomas/mphys/MParticle.h
r1357 r1360 16 16 public: 17 17 typedef enum { kEGamma, kEElectron, kEPositron } ParticleType_t; 18 enum { kEIsPrimary = BIT(14) }; 18 19 19 20 private: 20 const ParticleType_t fPType; 21 const ParticleType_t fPType; //! Particle type 21 22 22 23 protected: … … 45 46 } 46 47 48 void SetIsPrimary(Bool_t is=kTRUE) { is ? SetBit(kEIsPrimary) : ResetBit(kEIsPrimary); } 49 Bool_t IsPrimary() const { return TestBit(kEIsPrimary); } 50 51 // ---------------------------------------------------------------- 52 47 53 virtual Double_t GetInteractionLength() const = 0; 48 54 -
trunk/WuerzburgSoft/Thomas/mphys/MPhoton.h
r1356 r1360 9 9 { 10 10 public: 11 MPhoton(Double_t e=0, Double_t z=0) : MParticle(MParticle::kEGamma) 11 12 MPhoton(Double_t e=0, Double_t z=0) 13 : MParticle(MParticle::kEGamma) 12 14 { 13 15 fEnergy = e; -
trunk/WuerzburgSoft/Thomas/mphys/energyloss.C
r1356 r1360 449 449 new TCanvas("RZ", "r and z"); 450 450 451 TF1 f1("ZofR", MParticle::ZofR, 0, 4.5e5, 0);451 TF1 f1("ZofR", MParticle::ZofR, 0, 7.1e6, 0); 452 452 TF1 f2("RofZ", MParticle::RofZ, 0, 5, 0); 453 453 … … 479 479 void energyloss() 480 480 { 481 EnergyLossRate(); 482 483 MH::MakeDefCanvas(); 481 // EnergyLossRate(); 484 482 485 483 DrawRZ(); -
trunk/WuerzburgSoft/Thomas/mphys/phys.C
r1358 r1360 8 8 #include <TH2.h> 9 9 #include <TList.h> 10 #include <TFile.h> 11 #include <TTree.h> 12 #include <TBranch.h> 10 13 #include <TStyle.h> 11 14 #include <TRandom.h> … … 64 67 } 65 68 69 Double_t GetEnergy(Int_t n, Double_t lo, Double_t hi) 70 { 71 static int bin=0; 72 static TRandom rnd(0); 73 74 Double_t w = log10(hi/lo)/n; 75 76 Double_t E = lo*pow(10, rnd.Uniform(w) + w*bin); 77 78 //cout << endl << w << " " << n << " " << w*bin << " " << E << endl; 79 80 if (++bin==n) 81 bin=0; 82 83 return E; 84 85 /* 86 // TF1 src ("PrimarySpectrum", PrimSpect, log10(lo), log10(hi), 1); // 10GeV-1000PeV 87 // src.SetParameter(0, 0); 88 // Double_t E = pow(10, src.GetRandom()); 89 90 // 91 // 0: 11111111111111|22222222222222 2 2^0 + 1 1 92 // 1: 11111111|22222222222|33333333 3 2^1 + 1 2 93 // 2: 11111|22222|33333|44444|55555 5 2^2 + 1 7 94 // 3: | | | | | | | | 15 95 // 96 97 static int run=0; 98 static int num=1; 99 100 Double_t w = log10(hi/lo)/((1<<run) + 1); 101 102 Double_t E = lo*pow(10, num*w); 103 104 if (num == (1<<run)) 105 { 106 run++; 107 num=1; 108 } 109 else 110 num++; 111 112 return E; 113 */ 114 } 115 66 116 void DoIt() 67 117 { … … 75 125 MPairProduction pair; 76 126 77 Double_t runtime = 30*60; // [s]127 Double_t runtime = 15*60; // [s] 78 128 79 129 Double_t lo = 1e4; … … 81 131 Double_t alpha = -2; 82 132 83 Double_t nbins = 24; //4*log10(hi/lo); 84 85 TF1 src ("PrimarySpectrum", PrimSpect, log10(lo), log10(hi), 1); // 10GeV-1000PeV 86 src.SetParameter(0, 0); 133 Int_t nbins = 18; //4*log10(hi/lo); 87 134 88 135 TH1D hist; … … 150 197 hist.Draw("Csame"); 151 198 152 ofstream fsrc("source.dat"); 153 ofstream fcas("cascade.dat"); 199 // ------------------------------ 200 201 MPhoton *p4file = NULL; 202 MElectron *e4file = NULL; 203 204 TFile file("cascade.root", "RECREATE", "Intergalactic cascade", 9); 205 TTree *T = new TTree("Photons", "Photons from Cascade"); 206 TTree *T2 = new TTree("Electrons", "Electrons in the Cascade"); 207 TBranch *B =T ->Branch("MPhoton.", "MPhoton", &p4file, 32000); 208 TBranch *B2=T2->Branch("MElectron.", "MElectron", &e4file, 32000); 154 209 155 210 // ------------------------------ … … 163 218 Double_t starttime = TStopwatch::GetRealTime(); // s 164 219 while (TStopwatch::GetRealTime()<starttime+runtime) 220 for (int i=0; i<nbins; i++) 165 221 { 166 222 n++; 167 223 168 Double_t E = pow(10, src.GetRandom());224 Double_t E = GetEnergy(nbins, lo, hi); 169 225 Double_t weight = pow(E, alpha); 170 171 226 histsrc.Fill(E, E*E * weight); 172 227 173 fsrc << E << endl; 228 MPhoton *gamma=new MPhoton(E, startz); 229 gamma->SetIsPrimary(); 230 listg.Add(gamma); 231 232 B->SetAddress(&gamma); 233 T->Fill(); 174 234 175 235 cout << "--> " << n << ". " << Form("%d: %3.1e", (int)(starttime+runtime-TStopwatch::GetRealTime()), E) << flush; 176 177 MPhoton *gamma=new MPhoton(E, startz);178 listg.Add(gamma);179 236 180 237 while (1) … … 185 242 TIter NextP(&listg); 186 243 MPhoton *p = NULL; 244 B->SetAddress(&p); 187 245 while ((p=(MPhoton*)NextP())) 188 246 { … … 199 257 hista.Fill(p->GetTheta()*kRad2Deg, weight); 200 258 201 fcas << Eg << endl; 259 T->Fill(); 260 202 261 delete listg.Remove(p); 203 262 continue; … … 242 301 TIter Next(&liste); 243 302 MElectron *e = NULL; 303 B2->SetAddress(&e); 244 304 while ((e=(MElectron*)Next())) 245 305 { 306 e->SetIsPrimary(); 307 T2->Fill(); 308 e->SetIsPrimary(kFALSE); 309 246 310 if (e->GetEnergy()<lo) 247 311 continue; … … 259 323 Double_t theta = rand.Uniform(TMath::Pi()*2); 260 324 MPhoton *p = e->DoInvCompton(theta); 325 326 T2->Fill(); 261 327 262 328 if (fabs(p->GetTheta()*3437)<1 && // < 1min … … 300 366 clock.Print(); 301 367 368 file.Write(); 369 302 370 cout << "Created " << n << " gammas from source with E^" << alpha << endl; 303 371 cout << "Processed " << Form("%.1f", n/(TStopwatch::GetRealTime()-starttime)) << " gammas/sec." << endl;
Note:
See TracChangeset
for help on using the changeset viewer.