Ignore:
Timestamp:
Jun 13, 2013, 3:11:41 PM (11 years ago)
Author:
moretto
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • esaf_lal/branches/camille/camille_work/KIT_phase1_study/macros/Analysis.C

    r169 r172  
    1212const char* inputfile2="/Users/moretto/Documents/thesis/ESAF/Code/esaf_lal/esaf/camille_work/KIT_phase1_study/10_ns_TimeResolution__100_event/simu.root";
    1313const 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
    1416
    1517EEvent*          ev = 0;
     
    1820EBunchPhotons*   gBunchPhotons = NULL;
    1921
     22TProfile *hprof_multi[20];
     23//TProfile *hprof;
     24TH1F *histo_multi[100];
     25TCanvas *c3, *c4;
     26TH1F *histo_total;
     27TFile *f[20];
     28TTree *etree[20];
     29
    2030void gettree();
    2131void init();
     
    2737{
    2838    //Déclaration d'un tableau de TProfile permettant de stocker les TProfiles créé par l'analyse des fichiers
    29     TProfile *hprof_multi[2];
     39   
     40    Float_t x[200], y[200];
     41    Float_t bin1, bin2;
     42    const char hprof_name[50];
    3043   
    3144    //Initialisation & process du premier fichier
    32     init(inputfile);
    33     process_profile();
    34     TCanvas *c3 = new TCanvas("c3", "TProfile of the GTU distribution for 100 events for 30 ns dead time");
    35     hprof_multi[1] = hprof;
    36     hprof_multi[1]->Draw();
    37    
     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 
    3862    //Initialisation & process du second fichier
    39     init(inputfile3);
    40     process_profile();
    41     TCanvas *c4 = new TCanvas("c4", "TProfile of the GTU distribution for 100 events for 5 ns dead time");
    42     hprof_multi[2] = hprof;
    43     hprof_multi[2]->Draw();
    44    
    45    
    46     TCanvas *c4 = new TCanvas("c5", "Efficiency vs GTU");
    47     TProfile *hprof_efficiency = new TProfile("hprof_efficiency", "Efficiency vs GTU", 128, 0, 128);
     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");
    4887 
    4988    for (Int_t i=0; i<128; i++)
    5089    {
    51         Float_t bin1 = hprof_multi[1]->GetBinContent(i);
    52         Float_t bin2 = hprof_multi[2]->GetBinContent(i);
     90        bin1 = hprof_multi[0]->GetBinContent(i);
     91        bin2 = hprof_multi[1]->GetBinContent(i);
     92       
     93        x[i] = i;
    5394       
    5495        if (bin2 == 0)
    5596        {
    56             hprof_efficiency->Fill(i, 0); //Il faut entrer des entiers dedans sinon ça ne marchera pas!!!!
     97            y[i] = 0;
    5798        }
    5899       
    59100        else
    60101        {
    61             hprof_efficiency->Fill(i, bin1/bin2); //Il faut entrer des entiers dedans sinon ça ne marchera pas!!!!
    62         }
    63     }
    64    
    65     hprof_efficiency->Draw();
    66 }
    67 
    68 //______________________________________________________________________________
    69 void process_profile()
     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)
    70115//ici on récupÚre les données de temps pour les 100 événements afin de réaliser un TProfile
    71116{
    72117    //Déclaration des histogrammes et autres
    73     TH1F *histo_total = new TH1F("histo_total", "Histogram of photons read by the electronics for 100 showers", 128, 0, 128);
    74     TH1F *histo_multi[100];
    75     hprof = new TProfile("hprof", "Average number of photons per GTU", 128, 0, 128);
    76    
    77     histo_total->Reset();
    78     hprof->Reset();
    79    
    80     //Boucle sur l'ensemble des événements pour créer une distribution totale
     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
    81128    for (Int_t  i=0; i<nb_entries ; i++)
    82129    {
     
    100147    }
    101148   
    102     /* TCanvas *c1 = new TCanvas("c1", "Distribution totale");
     149    TCanvas *c1 = new TCanvas("c1", "Distribution totale");
    103150     histo_total->GetXaxis()->SetTitle("GTU");
    104151     histo_total->Draw(); */
     
    108155    //c2->Divide(10,10);
    109156   
    110     for (Int_t i=0; i<nb_entries; i++)
    111     {
    112         histo_multi[i] = new TH1F("histo_multi", "Single shower histograms", 128, 0, 128);
    113         histo_multi[i]->Reset();
     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);
    114165    }
    115166   
     
    118169        loadevent(i);
    119170       
    120         nb_photon = gDetector->GetNumPhotons();
     171        Int_t nb_photon = gDetector->GetNumPhotons();
    121172       
    122173        for (Int_t j=0; j<nb_photon; j++)
    123174        {
    124             macrocell_status = gDetector->GetPhoton(j)->GetMacroCell();
    125             photon_type = gDetector->GetPhoton(j)->GetType();
     175            Int_t macrocell_status = gDetector->GetPhoton(j)->GetMacroCell();
     176            Int_t photon_type = gDetector->GetPhoton(j)->GetType();
    126177           
    127178            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
    128179            {
    129                 gtu = gDetector->GetPhoton(j)->GetGtu();
     180                Float_t gtu = gDetector->GetPhoton(j)->GetGtu();
    130181                histo_multi[i]->Fill(gtu);
    131182            }
     
    142193        for (Int_t i=0; i<128; i++)
    143194        {
    144             hprof->Fill(i, histo_multi[j]->GetBinContent(i));
    145         }
    146        
    147     }
    148    
    149 }
    150 
    151 //______________________________________________________________________________
    152 void init( const char* fname)
    153 {
    154     TFile *f = new TFile(fname);
    155     gettree();
    156 }
    157 
    158 //______________________________________________________________________________
    159 void gettree()
    160 {
    161     TTree *etree = (TTree*)gDirectory->Get("etree");
    162     if ( etree )
    163     {
    164         nb_entries = etree->GetEntries();
     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();
    165226        Printf("etree found with %d events stored.", nb_entries);
    166227    }
     228   
     229    std::cout << "exit gettree" << std::endl;
     230
    167231}
    168232
Note: See TracChangeset for help on using the changeset viewer.