#include <map>
#include "TKey.h"
#include <TROOT.h>
#include <TStyle.h>
#include <TRint.h>
#include <TTree.h>
#include <TCanvas.h>
#include "TH1.h"
#include "TF1.h"
#include <TH1I.h>
#include <TH2I.h>
#include <TFile.h>
#include <stdlib.h>
#include <TSystem.h>
#include <iostream>
#include "TApplication.h"
#include <sstream>
#include <Rtypes.h>
#include "TColor.h"
#include "TFunction.h"
#include "TAttLine.h"
#include "TPaveStats.h"
#include <string>
#include "Riostream.h"
Include dependency graph for analyze_prod.cpp:
Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 39 of file analyze_prod.cpp.
00041 { 00042 gROOT->Reset(); 00043 00044 // gROOT->SetStyle("Plain"); 00045 gStyle->SetFrameFillStyle(0); 00046 gStyle->SetPalette(1); 00047 gStyle->SetOptStat(111111); 00048 gStyle->SetFrameFillStyle(0); 00049 gStyle->SetOptStat(""); 00050 gStyle->SetOptFit(0111); 00051 gStyle->SetStatX(0.9); 00052 gStyle->SetStatY(0.9); 00053 gStyle->SetStatH(0.1); 00054 gStyle->SetStatW(0.1); 00055 00056 // gStyle->SetOptStat("") ; 00057 // gStyle->SetOptFit(0000); 00058 00059 gStyle->SetOptStat(""); 00060 gStyle->SetOptFit(10001); 00061 00062 if (argc !=2) 00063 { 00064 cout << "usage: " << argv[0] << " prod_run_number" << endl ; 00065 exit(-1) ; 00066 } 00067 Int_t prod = atoi(argv[1]); 00068 00069 const Int_t NbOfChannels = 64 ; 00070 00071 const TString directory = Form("/gpfs/LAPP-DATA/LC/Detecteurs/MicroMegas/data/MICROROC/PROD_%d/RESULTS/", prod); 00072 cout << directory << endl ; 00073 00074 Int_t start, stop ; 00075 switch (prod) 00076 { case 1: 00077 start = 1 ; 00078 stop = 341 ; 00079 //stop = 30 ; 00080 break ; 00081 case 2: 00082 start = 342 ; 00083 stop = 1136 ; 00084 break ; 00085 default: 00086 cout << "This production run does not exist yet !" << endl ; 00087 exit(-1) ; 00088 } 00089 00090 TApplication theApp("App", &argc, argv); // see $ROOTSYS/test/hworld.cxx 00091 //TApplication *theApp = NULL; // from Jean 00092 //theApp = new TRint("App",NULL,NULL ); // from Jean 00093 00094 // for (Int_t chip=start;chip<=stop;chip++) 00095 // { 00096 // const TString name_file_gain = directory + Form("chip_%d_gain_OK.txt", chip) ; 00097 // const TString name_file_gain = Form("%schip_%d_gain_OK.txt", directory, chip) ; 00098 // cout << name_file_gain << endl ; 00099 // } 00100 00101 // Variable definition 00102 Double_t n, gain ; // to read text file 00103 Double_t pedestal_inflex, pedestal_inflex_err, pedestal_noise, pedestal_noise_err ; // to read text file 00104 Double_t data_inflex, data_inflex_err, data_noise, data_noise_err ; // to read text file 00105 TH1F * h_gain = new TH1F ("h_gain", "",100, 0.12, 0.16) ; // histo to store result 00106 h_gain->SetXTitle(""); 00107 TH1F * h_ped = new TH1F ("h_ped", "", 1024, 0, 1024) ; 00108 h_ped->SetXTitle("Threshold [DACu]"); 00109 h_ped->SetYTitle("count"); 00110 TH1F * h_data = new TH1F ("h_data", "", 1024, 0, 1024) ; 00111 h_data->SetXTitle("Threshold [DACu]"); 00112 h_data->SetYTitle("count"); 00113 ifstream file_gain, file_data, file_pedestal ; 00114 for (Int_t chip=start;chip<=stop;chip++) 00115 { const TString name_file_gain = directory + Form("chip_%d_gain_OK.txt", chip) ; 00116 file_gain.open(name_file_gain.Data()) ; 00117 if (!file_gain.good()) 00118 { cout << "Chip " << chip << " has been rejected during test" << endl ; 00119 //TString name_file = Form("chip_%d_gain_BAD.txt", chip) ; 00120 //if (!fp.good()) cout << "Error opening " << name_file << endl ; 00121 //break ; 00122 } 00123 else 00124 { const TString name_file_pedestal = directory + Form("chip_%d_pedestal.txt", chip) ; 00125 file_pedestal.open(name_file_pedestal.Data()) ; 00126 const TString name_file_data = directory + Form("chip_%d_data.txt", chip) ; 00127 file_data.open(name_file_data.Data()) ; 00128 for (Int_t ch=0;ch<NbOfChannels;ch++) 00129 { file_gain >> gain ; 00130 if (!file_gain.good()) break; 00131 file_pedestal >> n >> pedestal_inflex >> pedestal_inflex_err >> pedestal_noise >> pedestal_noise_err ; 00132 file_data >> n >> data_inflex >> data_inflex_err >> data_noise >> data_noise_err ; 00133 h_gain->Fill(gain) ; 00134 h_ped->Fill(pedestal_inflex) ; 00135 h_data->Fill(data_inflex) ; 00136 } 00137 } 00138 file_gain.close(); 00139 file_pedestal.close(); 00140 file_data.close(); 00141 00142 00143 } 00144 00145 TCanvas * c1 = new TCanvas("c1","MICROROC gain"); 00146 h_gain->SetLineColor(kBlue+1); 00147 h_gain->Draw(""); 00148 h_gain->Fit("gaus","RQ", "SAME", 0.13 , 0.15); 00149 h_gain->GetFunction("gaus")->SetLineColor(kRed); 00150 h_gain->GetXaxis()->SetTitle("Conversion ratio [fCV/DACu]"); 00151 h_gain->GetYaxis()->SetTitle("Count"); 00152 00153 00154 //////////////////////////////////////////////////////////////////////////////////////// 00155 TCanvas * c2 = new TCanvas("c2","MICROROC data and pedestal"); 00156 c2->cd() ; 00157 00158 h_ped->Draw(""); 00159 //h_ped->SetLineColor(kBlue+1); 00160 h_ped->Fit("gaus","RQ", "SAME", 160, 210); 00161 h_ped->GetFunction("gaus")->SetLineColor(kBlue+1); 00162 00163 h_data->Draw("SAMES"); 00164 //h_data->SetLineColor(kGreen+1); 00165 h_data->Fit("gaus","RQ", "SAME", 500, 580); 00166 h_data->GetFunction("gaus")->SetLineColor(kOrange+5); 00167 00168 c2->Update(); // to create TGraph !!! COMPULSORY !! 00169 00170 TPaveStats * p1 = (TPaveStats*) h_ped->GetListOfFunctions()->FindObject("stats"); 00171 h_ped->GetListOfFunctions()->Print(); 00172 // p1->Print(); 00173 h_ped->GetListOfFunctions()->Remove(p1); 00174 h_ped->SetStats(0); 00175 p1->SetTextColor(kBlue+1); 00176 p1->SetX1NDC(0.75); 00177 p1->SetY1NDC(0.8); 00178 p1->SetY2NDC(0.9); 00179 p1->Draw(); 00180 00181 00182 // NEED SAMES (!=SAME) in Drawin histo !!!!! http://root.cern.ch/root/html/THistPainter.html#THistPainter:Paint find sames in text 00183 //h_data->GetListOfFunctions()->Print(); 00184 TPaveStats * p2 = (TPaveStats*) h_data->GetListOfFunctions()->FindObject("stats"); 00185 p2->Print(); 00186 h_data->GetListOfFunctions()->Remove(p2); 00187 h_data->SetStats(0); 00188 p2->SetTextColor(kOrange+5); 00189 p2->SetX1NDC(0.75); 00190 p2->SetX2NDC(0.9); 00191 p2->SetY1NDC(0.7); 00192 p2->SetY2NDC(0.8); 00193 p2->Draw(); 00194 00195 00196 00197 theApp.Run(kTRUE) ; 00198 //theApp->Run(); 00199 //delete theApp; 00200 return 0 ; 00201 00202 }