/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/analyse/Renaud/ROOT/analyze_prod.C

Go to the documentation of this file.
00001 //#include "Riostream.h"
00002 // launch with .x analyze_prod.C (1)
00003 
00004 analyze_prod(const Int_t prod)
00005 {       
00006         gROOT->Reset();
00007 
00008 //      gROOT->SetStyle("Plain");
00009         gStyle->SetFrameFillStyle(0);
00010         gStyle->SetPalette(1);
00011         gStyle->SetOptStat(111111);
00012         gStyle->SetFrameFillStyle(0);
00013         gStyle->SetOptStat("");
00014         gStyle->SetOptFit(0111);
00015         gStyle->SetStatX(0.9);
00016         gStyle->SetStatY(0.9);
00017         gStyle->SetStatH(0.1);
00018         gStyle->SetStatW(0.1);
00019 
00020 //      gStyle->SetOptStat("") ;
00021 //      gStyle->SetOptFit(0000);        
00022         
00023         gStyle->SetOptStat("");
00024         gStyle->SetOptFit(10001);
00025         
00026         const Int_t NbOfChannels = 64 ;
00027         
00028         const TString directory = Form("/gpfs/LAPP-DATA/LC/Detecteurs/MicroMegas/data/MICROROC/PROD_%d/RESULTS/", prod);
00029         cout << directory << endl ;
00030         switch (prod)
00031         {       case 1:
00032                         Int_t start = 1 ;
00033                         //Int_t stop = 341 ;
00034                         Int_t stop = 30 ;
00035                         break ;
00036                 case 2:
00037                         Int_t start = 342 ;
00038                         Int_t stop = 1136 ;
00039                         break ;
00040                 default:
00041                         cout << "This production run does not exist yet !" << endl ;
00042                         exit(-1) ;
00043         }
00044         
00045         
00046 //      for (Int_t chip=start;chip<=stop;chip++)
00047 //      {       
00048 //              const TString name_file_gain = directory +  Form("chip_%d_gain_OK.txt", chip) ;
00049 //              const TString name_file_gain = Form("%schip_%d_gain_OK.txt", directory, chip) ;
00050 //              cout << name_file_gain << endl ;
00051 //      }
00052         
00053         // Variable definition
00054         Double_t n, gain ;      // to read text file
00055         Double_t pedestal_inflex, pedestal_inflex_err, pedestal_noise, pedestal_noise_err ; // to read text file
00056         Double_t data_inflex, data_inflex_err, data_noise, data_noise_err ;     // to read text file
00057         TH1F * h_gain = new TH1F ("h_gain", "",100, 0.12, 0.16) ; // histo to store result
00058         h_gain->SetXTitle("");
00059         TH1F * h_ped = new TH1F ("h_ped", "", 1024, 0, 1024) ;
00060         h_ped->SetXTitle("[DACu]");
00061         TH1F * h_data = new TH1F ("h_data", "", 1024, 0, 1024) ;
00062         h_data->SetXTitle("[DACu]");
00063         ifstream file_gain, file_data, file_pedestal ;
00064         for (Int_t chip=start;chip<=stop;chip++)
00065         {       const TString name_file_gain = directory + Form("chip_%d_gain_OK.txt", chip) ;
00066                 file_gain.open(name_file_gain.Data()) ;
00067                 if (!file_gain.good())
00068                 {       cout << "Chip " << chip << " has been rejected during test" << endl ;
00069                         //TString name_file = Form("chip_%d_gain_BAD.txt", chip) ;
00070                         //if (!fp.good()) cout << "Error opening " << name_file << endl ;
00071                         //break ;
00072                 }
00073                 else
00074                 {       const TString name_file_pedestal = directory + Form("chip_%d_pedestal.txt", chip) ;
00075                         file_pedestal.open(name_file_pedestal.Data()) ;
00076                         const TString name_file_data = directory + Form("chip_%d_data.txt", chip) ;
00077                         file_data.open(name_file_data.Data()) ;
00078                         for (Int_t ch=0;ch<NbOfChannels;ch++)
00079                         {       file_gain >> gain ;
00080                                 if (!file_gain.good()) break;
00081                                 file_pedestal >> n >> pedestal_inflex >> pedestal_inflex_err >> pedestal_noise >> pedestal_noise_err ;
00082                                 file_data >> n >> data_inflex >> data_inflex_err >> data_noise >> data_noise_err ;
00083                                 h_gain->Fill(gain) ;
00084                                 h_ped->Fill(pedestal_inflex) ;
00085                                 h_data->Fill(data_inflex) ;
00086                         }
00087                 }
00088                 file_gain.close();      
00089                 file_pedestal.close();  
00090                 file_data.close();      
00091                 
00092                 
00093         }
00094         
00095         TCanvas * c1 = new TCanvas("c1","MICROROC gain");
00096         h_gain->SetLineColor(kBlue+1);
00097         h_gain->Draw();
00098         h_gain->Fit("gaus","R", "SAME", 0.13 , 0.15);
00099         h_gain->GetFunction("gaus")->SetLineColor(kRed);
00100         h_gain->GetXaxis()->SetTitle("Gain [V/fC]");
00101         
00102         TCanvas * c2 = new TCanvas("c2","MICROROC pedestal");
00103         c2->cd() ;
00104 
00105         h_ped->Draw();
00106         h_ped->SetLineColor(kBlue+1);
00107         h_ped->Fit("gaus","R", "SAME", 160, 210);
00108         h_ped->GetFunction("gaus")->SetLineColor(kBlue+8);
00109 
00110         h_data->Draw("SAMES");
00111         h_data->SetLineColor(kGreen+1);
00112         h_data->Fit("gaus","R", "SAME", 500, 580);
00113         h_data->GetFunction("gaus")->SetLineColor(kGreen+5);
00114 
00115         c1->Update();
00116 
00117         const TPaveStats *p1 = (TPaveStats*) h_ped->GetListOfFunctions()->FindObject("stats");
00118         h_ped->GetListOfFunctions()->Print();
00119 //      p1->Print();
00120 //      h_ped->GetListOfFunctions()->Remove(p1);
00121         h_ped->SetStats(0);
00122         p1->SetTextColor(kBlue+8);
00123         p1->SetX1NDC(0.75);
00124         p1->SetY1NDC(0.8);
00125         p1->SetY2NDC(0.9);
00126         p1->Draw();
00127 
00128 
00129         // NEED SAMES (!=SAME) in Drawin histo !!!!!
00130         //h_data->GetListOfFunctions()->Print();
00131         const TPaveStats *p2 = (TPaveStats*) h_data->GetListOfFunctions()->FindObject("stats");
00132         p2->Print();
00133         h_data->GetListOfFunctions()->Remove(p2);
00134         h_data->SetStats(0);
00135         p2->SetTextColor(kGreen+5);
00136         p2->SetX1NDC(0.75);
00137         p2->SetX2NDC(0.9);
00138         p2->SetY1NDC(0.7);
00139         p2->SetY2NDC(0.8);
00140         p2->Draw();
00141 
00142 
00143 
00144         
00145 //      TCanvas * c3 = new TCanvas("c3","MICROROC data");
00146 //      c3->cd() ;
00147 //      h_data->Draw();
00148 //      
00149 //      const Int_t NbOfRun = 5 ; // x axis: temperature
00150 //      const Int_t NbOfPoints = 16 ; // pied: 0 to 15
00151 //      const Int_t NbOfChannels = 64 ;
00152 
00153 //      Double_t n, a, b, c, d ;
00154 
00155 //      ///////////////////////////
00156 //      // Plot noise vs t
00157 //      ///////////////////////////
00158 //      Float_t temperature[]={25.5, 47.0, 68.5, 87.0, 105.0};
00159 //      Double_t x[NbOfPoints];
00160 //      for (Int_t i=0;i<NbOfPoints;i++)
00161 //      {
00162 //              x[i]=i ;
00163 //      }
00164 //      
00165 //      Double_t data_inflex[NbOfChannels][NbOfRun][NbOfPoints] ; // first dim is for x / y
00166 //      
00167 //      Double_t mean_inflex[NbOfRun][NbOfPoints] ;
00168 //      // Gather y data from files
00169 //      for (Int_t run=0;run<NbOfRun;run++) // x axis
00170 //      {       for (Int_t ped=0;ped<NbOfPoints;ped++)
00171 //              {
00172 //                      mean_inflex [run][ped] = 0 ;
00173 //                      TString name_file = directory + "run" + Form("%d", 2*run+1) + "_pied" + Form("%d", ped) + ".txt" ;
00174 //                      cout << name_file << endl ;
00175 //                      ifstream fp ;
00176 //                      fp.open(name_file.Data()) ; 
00177 //              
00178 //                      if (!fp.good()) cout << "pb !";
00179 //                      for (Int_t ch=0;ch<NbOfChannels;ch++)
00180 //                      {               fp >> n >> a >> b >> c >> d ;
00181 //                                      //cout << n << " " << a << " " << b << " " << c << " " << d <<  endl ;
00182 //                                      if (!fp.good()) break;
00183 //                                      // fill data
00184 //                                      data_inflex [ch][run][ped] = a ; // DAC units 
00185 //                                      // fill mean for all channels
00186 //                                      mean_inflex [run][ped] += data_inflex [ch][run][ped] ;
00187 //                      }
00188 //                      fp.close();     
00189 //                      mean_inflex [run][ped] /= NbOfChannels ;
00190 //              }
00191 //      }
00192 //      
00193 ////    cout << "Temperature" ;
00194 ////    for (Int_t run=0;run<NbOfPoints;run++) // x axis
00195 ////    {       cout << "\t" << temperature[run] ;
00196 ////    }
00197 ////    cout << endl << "Offset" << "\t" ;
00198 ////    for (Int_t run=0;run<NbOfPoints;run++) // x axis
00199 ////    {       cout << "\t" << data_noise[1][run] ;
00200 ////    }
00201 ////    cout << endl ;
00202 //      
00203 ////    exit(-1);
00204 //      
00205 //      //----------------------------------------------------------------
00206 //      //                       BUILD GRAPH 
00207 //      //----------------------------------------------------------------      
00208 //      TCanvas * c1 = new TCanvas("c1","MICROROC offset dac");
00209 //      TMultiGraph * mg = new TMultiGraph("mg","");
00210 //      TGraph * gr[NbOfChannels];
00211 //      for(Int_t igraph=0;igraph<NbOfRun;igraph++)     // one graph per temperature
00212 //      {       gr [igraph] = new TGraph(NbOfPoints, x, mean_inflex [igraph] ); // TGraph (n, x, y)
00213 //              gr [igraph]->SetLineColor(kBlue+igraph) ;
00214 //              gr [igraph]->SetLineWidth(1);
00215 //              gr [igraph]->SetMarkerColor(kBlue+igraph);
00216 //              gr [igraph]->SetMarkerStyle(8);
00217 //              gr [igraph]->SetMarkerSize(1);
00218 //              mg->Add(gr [igraph]);
00219 //      }
00220 //      
00221 //      mg->Draw("ALP");
00222 //      mg->GetXaxis()->SetTitle("Pedestal [DACu]");
00223 //      mg->GetXaxis()->SetRangeUser(0.,110.);
00224 //      mg->GetYaxis()->SetTitle("Inflexion Point [DACu]");
00225 ////    mg->GetYaxis()->SetRangeUser(2.4,2.5);
00226 //      mg->GetYaxis()->SetTitleOffset(1.1);
00227 //      mg->Draw("ALP"); // to refresh
00228 ////    Legend
00229 ////    TString temp_string = Form ("%f", x[1]) ;
00230 ////    temp_string 
00231 //      TLegend * leg = new TLegend(0.1,0.75,0.25,0.9) ;
00232 //      for(Int_t igraph=0;igraph<NbOfRun;igraph++)     // one graph per temperature
00233 //      {       
00234 //              TString temp_string = Form ("%5.1f #circC", temperature[igraph]) ;
00235 //              leg->AddEntry(gr [igraph], temp_string, "lp");
00236 //      }
00237 //      leg->SetFillStyle(1);
00238 //      leg->SetFillColor(0);
00239 //      leg->Draw();
00240         
00241         return 0 ;
00242 
00243 }

Generated on Mon Jan 7 13:15:21 2013 for MicromegasFramework by  doxygen 1.4.7