Created
May 16, 2013 19:24
-
-
Save gipi/5594338 to your computer and use it in GitHub Desktop.
ROOT exercise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/TestEvent.C b/TestEvent.C | |
index 36e3303..e91311e 100644 | |
--- a/TestEvent.C | |
+++ b/TestEvent.C | |
@@ -21,9 +21,10 @@ void TestEvent() { | |
cout << " 2) Istogramma 2 " << endl; | |
cout << " 3) Distribuzione fissa " << endl; | |
cout << " 4) Distribuzione uniforme " << endl; | |
-Bool_t with_scattering = kTRUE; | |
+Bool_t with_scattering = kFALSE; | |
Int_t tipo_molteplicita; | |
cin >> tipo_molteplicita; | |
+ | |
TH1D * distr_m = NULL; | |
TH1D * distr_d =(TH1D*) distribuzione->Get("heta"); | |
Int_t fissa=0; | |
@@ -53,6 +54,10 @@ Bool_t with_scattering = kTRUE; | |
TClonesArray *punti_silicio_1 = new TClonesArray("Point"); | |
TClonesArray *punti_silicio_2 = new TClonesArray("Point"); | |
+ TClonesArray &p1 = *punti_silicio_1; | |
+ TClonesArray &p2 = *punti_silicio_2; | |
+ | |
+ | |
cout << "Calcoliamo interazioni con rivelatori" << endl; | |
for(Int_t i = 0; i < evento->GetMolteplicita(); i++) { | |
@@ -61,6 +66,8 @@ for(Int_t i = 0; i < evento->GetMolteplicita(); i++) { | |
Double_t phi = evento->GetPhi(i); | |
Point *punto_evento = new Point(evento->GetX(),evento->GetY(),evento->GetZ()); | |
+ //cout << "Z: " << punto_evento->GetZ() << endl; | |
+ | |
Point *prima_intersezione = new Point(); //conterrà le coordinate di uscita dal berillio | |
Point *seconda_intersezione = new Point(); | |
Point *terza_intersezione = new Point(); | |
@@ -68,19 +75,21 @@ for(Int_t i = 0; i < evento->GetMolteplicita(); i++) { | |
Double_t out_theta, out_phi, out_theta2, out_phi2, theta3, phi3; | |
if(rivelatore_berillio->GetIntersezione(theta, phi, punto_evento, prima_intersezione)) { | |
+ cout << "intersezione Z" << prima_intersezione->GetZ() << endl; | |
rivelatore_berillio->CalculateMultipleScattering(theta, phi, &out_theta, &out_phi); | |
if(rivelatore_silicio_1->GetIntersezione(out_theta, out_phi, prima_intersezione, seconda_intersezione)){ | |
rivelatore_silicio_1->CalculateMultipleScattering(out_theta, out_phi, &out_theta2, &out_phi2); | |
seconda_intersezione->GetX(), | |
seconda_intersezione->GetY(), | |
seconda_intersezione->GetZ()); | |
+ | |
if(rivelatore_silicio_2->GetIntersezione(out_theta2,out_phi2,seconda_intersezione,terza_intersezione)) { | |
rivelatore_silicio_2->CalculateMultipleScattering(out_theta2,out_phi2,&theta3,&phi3); | |
- new(&punti_silicio_2[n_punti_rilevati_2++])Point( | |
+ new(p2[n_punti_rilevati_2++])Point( | |
terza_intersezione->GetX(), | |
terza_intersezione->GetY(), | |
terza_intersezione->GetZ()); | |
@@ -88,34 +97,39 @@ for(Int_t i = 0; i < evento->GetMolteplicita(); i++) { | |
} | |
} | |
- //delete prima_intersezione; | |
- //delete seconda_intersezione; | |
- //delete terza_intersezione; | |
+ delete prima_intersezione; | |
+ delete seconda_intersezione; | |
+ delete terza_intersezione; | |
} | |
+ // chiudiamo il file altrimenti dice che lo vuole sovrascrivere | |
distribuzione->Close(); | |
cout << endl; | |
- cout << "Calcolo Z" << endl; | |
+ cout << "Calcolo Z (" << n_punti_rilevati_1 << "," << n_punti_rilevati_2 << ")" << endl; | |
TFile* output_file = new TFile("kebab.root", "recreate"); | |
- //TH1D *histZ = new TH1D ("Tracklets","Origine tracklets", 5000, -20, 20); | |
+ TH1D *histZ = new TH1D ("Tracklets","Origine tracklets", 5000, -20, 20); | |
TStopwatch tempo; | |
tempo.Start(); | |
+ | |
for(Int_t j = 0 ; j < n_punti_rilevati_1 ; j++){ | |
Point* primo_punto = (Point*)punti_silicio_1->At(j); | |
for(Int_t k = 0 ; k < n_punti_rilevati_2 ; k++){ | |
Point* secondo_punto = (Point*)punti_silicio_2->At(k); | |
- Double_t alpha = (TMath::ATan(4/TMath::Abs(primo_punto->GetZ() - secondo_punto->GetZ()))); | |
+ //cout << primo_punto->GetZ() << " - " << secondo_punto->GetZ() << endl; | |
+ Double_t alpha = TMath::ATan(4/TMath::Abs(primo_punto->GetZ() - secondo_punto->GetZ())); | |
+ //cout << "alpha: " << alpha << endl; | |
Double_t Z_vertice = (TMath::Cos(alpha))*4; | |
- // histZ->Fill(Z_vertice); | |
+ //cout << Z_vertice << endl; | |
+ histZ->Fill(Z_vertice); | |
cout << "."; | |
} | |
} | |
cout << "Salva histogramma" << endl; | |
- //histZ->Write(); | |
- //histZ->Reset(); | |
+ histZ->Write(); | |
+ output_file->Close(); | |
tempo.Stop(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment