source: JEM-EUSO/esaf_lal/branches/camille/camille_work/KIT_phase1_study/macros/Analysis.C @ 172

Last change on this file since 172 was 172, checked in by moretto, 11 years ago

tentative de debugage de Analysis.C mais sans résultat

File size: 7.3 KB
Line 
1//
2//  Analysis.C
3//
4//
5//  Created by moretto on 29/05/13.
6//
7//
8
9Int_t nb_entries = 0;
10
11const char* inputfile="/Users/moretto/Documents/thesis/ESAF/Code/esaf_lal/esaf/camille_work/KIT_phase1_study/30_ns_TimeResolution__100_event/simu.root";
12const char* inputfile2="/Users/moretto/Documents/thesis/ESAF/Code/esaf_lal/esaf/camille_work/KIT_phase1_study/10_ns_TimeResolution__100_event/simu.root";
13const char* inputfile3="/Users/moretto/Documents/thesis/ESAF/Code/esaf_lal/esaf/camille_work/KIT_phase1_study/5_ns_TimeResolution__100_event/simu.root";
14const char* inputfile4="/Users/moretto/Documents/thesis/ESAF/Code/esaf_lal/esaf/camille_work/KIT_phase1_study/0_ns_TimeResolution__100_event/simu.root";
15
16
17EEvent*          ev = 0;
18EDetector*       gDetector = NULL;
19EDetPhoton*      gDetPhoton = NULL;
20EBunchPhotons*   gBunchPhotons = NULL;
21
22TProfile *hprof_multi[20];
23//TProfile *hprof;
24TH1F *histo_multi[100];
25TCanvas *c3, *c4;
26TH1F *histo_total;
27TFile *f[20];
28TTree *etree[20];
29
30void gettree();
31void init();
32void process_profile();
33Bool_t loadevent(Int_t i=0);
34
35//______________________________________________________________________________
36void Analysis()
37{
38    //Déclaration d'un tableau de TProfile permettant de stocker les TProfiles créé par l'analyse des fichiers
39   
40    Float_t x[200], y[200];
41    Float_t bin1, bin2;
42    const char hprof_name[50];
43   
44    //Initialisation & process du premier fichier
45    init(inputfile, 0);
46//    process_profile(0);
47   
48    sprintf(hprof_name, "hprof_multi%d", 0);
49    hprof_multi[0] = new TProfile(hprof_name, "Average number of photons per GTU", 128, 0, 128);
50   
51    //f[0]->Close();
52    //etree[0]->Delete();
53
54    gDirectory->ls();
55   
56    c3 = new TCanvas("c3", "c3 - TProfile of the GTU distribution for 100 events for 30 ns dead time");
57    //hprof_multi[0] = hprof;
58    hprof_multi[0]->Print();
59//    c3->cd();
60//    hprof_multi[0]->Draw();
61 
62    //Initialisation & process du second fichier
63    init(inputfile4, 1);
64    //process_profile(1);
65   
66    sprintf(hprof_name, "hprof_multi%d", 1);
67    hprof_multi[1] = new TProfile(hprof_name, "Average number of photons per GTU", 128, 0, 128);
68
69    //f[1]->Close();
70    //etree[1]->Delete();
71
72   
73    c4 = new TCanvas("c4", "c4 - TProfile of the GTU distribution for 100 events for 0 ns dead time");
74    //hprof_multi[1] = hprof;
75    hprof_multi[1]->Print();
76   
77   
78   
79    gDirectory->ls();
80   
81//    c4->cd();
82//    hprof_multi[1]->Draw();
83   
84   
85/*
86    TCanvas *c5 = new TCanvas("c5", "Efficiency vs GTU");
87 
88    for (Int_t i=0; i<128; i++)
89    {
90        bin1 = hprof_multi[0]->GetBinContent(i);
91        bin2 = hprof_multi[1]->GetBinContent(i);
92       
93        x[i] = i;
94       
95        if (bin2 == 0)
96        {
97            y[i] = 0;
98        }
99       
100        else
101        {
102            y[i] = bin1/bin2;
103        }
104    }
105    TGraph *g_efficiency = new TGraph(128, x, y);
106    g_efficiency->SetLineColor(2);
107    g_efficiency->SetLineWidth(2));
108    g_efficiency->SetMarkerColor(4);
109    g_efficiency->SetMarkerStyle(21);
110    g_efficiency->Draw("ACP");*/
111}
112
113//______________________________________________________________________________
114void process_profile(int n)
115//ici on récupÚre les données de temps pour les 100 événements afin de réaliser un TProfile
116{
117    //Déclaration des histogrammes et autres
118   // histo_total = new TH1F("histo_total", "Histogram of photons read by the electronics for 100 showers", 128, 0, 128);
119   
120    const char hprof_name[50];
121    sprintf(hprof_name, "hprof_multi%d", n);
122    hprof_multi[n] = new TProfile(hprof_name, "Average number of photons per GTU", 128, 0, 128);
123   
124    //histo_total->Reset();
125    //hprof->Reset();
126   
127/*    //Boucle sur l'ensemble des événements pour créer une distribution totale
128    for (Int_t  i=0; i<nb_entries ; i++)
129    {
130        loadevent(i);
131       
132        Int_t nb_photon = gDetector->GetNumPhotons();
133       
134        for (Int_t j=0; j<nb_photon; j++)
135        {
136            Int_t macrocell_status = gDetector->GetPhoton(j)->GetMacroCell();
137            Int_t photon_type = gDetector->GetPhoton(j)->GetType();
138           
139            if (macrocell_status == 1 & photon_type != 2) //on ne sélectionne que les photons étant détectés par l'électronique & autre que les Cerenkov
140            {
141                Float_t gtu = gDetector->GetPhoton(j)->GetGtu();
142                histo_total->Fill(gtu);
143            }
144           
145        }
146       
147    }
148   
149     TCanvas *c1 = new TCanvas("c1", "Distribution totale");
150     histo_total->GetXaxis()->SetTitle("GTU");
151     histo_total->Draw(); */
152   
153    //Boucle sur l'ensemble des événements pour tracer séparément les histogrammes
154    //TCanvas *c2 = new TCanvas("c2", "Collection of GTU histograms for 100 events");
155    //c2->Divide(10,10);
156   
157    //TEST*******
158   
159 /*   for (Int_t i=0; i<nb_entries; i++)
160    {
161       
162        const char histoname[50];
163        sprintf(histoname,"histomulti%d",i);
164        histo_multi[i] = new TH1F(histoname, "Single shower histograms", 128, 0, 128);
165    }
166   
167    for (Int_t  i=0; i<100 ; i++)
168    {
169        loadevent(i);
170       
171        Int_t nb_photon = gDetector->GetNumPhotons();
172       
173        for (Int_t j=0; j<nb_photon; j++)
174        {
175            Int_t macrocell_status = gDetector->GetPhoton(j)->GetMacroCell();
176            Int_t photon_type = gDetector->GetPhoton(j)->GetType();
177           
178            if (macrocell_status == 1 & photon_type != 2) //on ne sélectionne que les photons étant détectés par l'électronique & autre que les Cerenkov
179            {
180                Float_t gtu = gDetector->GetPhoton(j)->GetGtu();
181                histo_multi[i]->Fill(gtu);
182            }
183        }
184       
185        //c2->cd(i+1);
186        //histo_multi[i]->Draw();
187       
188    }
189   
190    //Boucle sur le tableau d'histogrammes précédent afin de réaliser un TProfile
191    for (Int_t j=0; j<nb_entries; j++)
192    {
193        for (Int_t i=0; i<128; i++)
194        {
195            hprof_multi[n]->Fill(i, histo_multi[j]->GetBinContent(i));
196        }
197       
198    }
199   
200    for (Int_t k=0; k<nb_entries; k++)
201    {
202        histo_multi[k]->Reset();
203    }
204    */
205}
206
207//______________________________________________________________________________
208void init( const char* fname, int n_file)
209{
210    std::cout << "enter init #"<< n_file << std::endl;
211   
212    f[n_file] = new TFile(fname);
213    gettree(n_file);
214    std::cout << "exit init" << std::endl;
215}
216
217//______________________________________________________________________________
218void gettree(int n_tree)
219{
220    std::cout << "enter gettree #" << n_tree << std::endl;
221   
222    etree[n_tree] = (TTree*)gDirectory->Get("etree");
223    if ( etree[n_tree] )
224    {
225        nb_entries = etree[n_tree]->GetEntries();
226        Printf("etree found with %d events stored.", nb_entries);
227    }
228   
229    std::cout << "exit gettree" << std::endl;
230
231}
232
233//______________________________________________________________________________
234Bool_t loadevent( Int_t i)
235{
236    TTree *etree = (TTree*)gDirectory->Get("etree");
237   
238    if ( !etree )
239    {
240        Printf("init(): unable to retrieve etree from TFile. Exiting");
241        return kFALSE;
242    }
243   
244    // associate the tree and the event
245    if ( !ev )
246    {
247        ev = new EEvent();
248        ev->SetBranches(etree);
249    }
250   
251    etree->GetEntry(i);
252   
253    EDetector *detector = ev->GetDetector();
254   
255    gDetector = ev->GetDetector();
256   
257    return kTRUE;
258}
Note: See TracBrowser for help on using the repository browser.