00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <map>
00010 #include "TKey.h"
00011 #include <TROOT.h>
00012 #include <TStyle.h>
00013 #include <TRint.h>
00014 #include <TKey.h>
00015 #include <TTree.h>
00016 #include <TCanvas.h>
00017 #include "TH1.h"
00018 #include "TF1.h"
00019 #include <TH1I.h>
00020 #include <TH2I.h>
00021 #include <TFile.h>
00022 #include <stdlib.h>
00023 #include <TSystem.h>
00024 #include <iostream>
00025 #include "TApplication.h"
00026 #include <sstream>
00027
00028 #include <Rtypes.h>
00029 #include <TCanvas.h>
00030 #include "TColor.h"
00031 #include "TFunction.h"
00032 #include "TAttLine.h"
00033 #include "TPaveStats.h"
00034
00035 #include <string>
00036 #include "Riostream.h"
00037
00038 using namespace std;
00039
00040
00041 int main(int argc, char**argv)
00042
00043 {
00044 gROOT->Reset();
00045
00046
00047 gStyle->SetFrameFillStyle(0);
00048 gStyle->SetPalette(1);
00049 gStyle->SetOptStat(111111);
00050 gStyle->SetFrameFillStyle(0);
00051 gStyle->SetOptStat("");
00052 gStyle->SetOptFit(0111);
00053 gStyle->SetStatX(0.9);
00054 gStyle->SetStatY(0.9);
00055 gStyle->SetStatH(0.1);
00056 gStyle->SetStatW(0.1);
00057
00058
00059
00060
00061 gStyle->SetOptStat("");
00062 gStyle->SetOptFit(10001);
00063
00064 if (argc !=4)
00065 {
00066 cout << "usage: " << argv[0] << " file_scurve_noise file_offset_correction file_threshold " << endl ;
00067 exit(-1) ;
00068 }
00069
00070 TString noise_filename_arg = argv[1] ;
00071 TString offset_filename_arg = argv[2] ;
00072 TString threshold_filename_arg = argv[3] ;
00073
00074 const TString directory = "/gpfs/LAPP-DATA/LC/Detecteurs/MicroMegas/data/MICROROC/MR1/TEST_NOISE/";
00075 const TString noise_filename = directory + noise_filename_arg ;
00076 const TString offset_filename = directory + offset_filename_arg ;
00077 const TString threshold_filename = directory + threshold_filename_arg ;
00078
00079 cout << directory << endl ;
00080
00081 const Int_t NbOfChip = 48 ;
00082 const Int_t NbOfChannels = 64 ;
00083 const Double_t thr_conv_ratio = 0.14 ;
00084 const Double_t off_conv_ratio = 1.66 ;
00085 TApplication theApp("App", &argc, argv);
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 ifstream file_noise, file_offset ;
00105
00106 file_noise.open(noise_filename.Data()) ;
00107 if (!file_noise.good())
00108 { cout << "Error opening" << noise_filename.Data() << endl ;
00109 }
00110
00111 file_offset.open(offset_filename.Data()) ;
00112 if (!file_offset.good())
00113 { cout << "Error opening" << offset_filename.Data() << endl ;
00114 }
00115
00116 Double_t chip, channel, crapoffset, pedestal_inflex, pedestal_inflex_err, pedestal_noise, pedestal_noise_err, offset ;
00117 Double_t noise_data_corr[NbOfChip][NbOfChannels];
00118 Double_t noise_data[NbOfChip][NbOfChannels];
00119 for (Int_t ichip=0;ichip<NbOfChip;ichip++)
00120 { for (Int_t ichan=0;ichan<NbOfChannels;ichan++)
00121 { if (!file_noise.good()) break;
00122 if (!file_offset.good()) break;
00123 file_noise >> chip >> channel >> crapoffset >> pedestal_inflex >> pedestal_inflex_err >> pedestal_noise >> pedestal_noise_err ;
00124 file_offset >> chip >> channel >> offset ;
00125 noise_data_corr[ichip][ichan] = pedestal_inflex - offset*off_conv_ratio ;
00126 noise_data[ichip][ichan] = pedestal_inflex + offset*off_conv_ratio ;
00127
00128 }
00129 }
00130 file_noise.close() ;
00131 file_offset.close() ;
00132
00133
00134
00135
00136 ifstream file_threshold ;
00137 file_threshold.open(threshold_filename.Data()) ;
00138 if (!file_threshold.good())
00139 { cout << "Error opening" << threshold_filename.Data() << endl ;
00140 }
00141 Double_t threshold ;
00142 Double_t threshold_data[NbOfChip] ;
00143 for (Int_t ichip=0;ichip<NbOfChip;ichip++)
00144 { if (!file_threshold.good()) break;
00145 file_threshold >> chip >> threshold ;
00146 threshold_data[ichip] = threshold ;
00147 }
00148 file_offset.close() ;
00149
00150
00151
00152
00153
00154 TH1F * h_thr = new TH1F ("h_thr", "+0", 100, 0, 10) ;
00155 h_thr->SetXTitle("Threshold [fC]");
00156 h_thr->SetYTitle("count");
00157
00158 TH1F * h_thr2 = new TH1F ("h_thr2", "+3", 100, 0, 10) ;
00159 h_thr2->SetXTitle("Threshold [fC]");
00160 h_thr2->SetYTitle("count");
00161
00162 TH1F * h_thr3 = new TH1F ("h_thr3", "without offset compensation", 100, -5, 5) ;
00163 h_thr3->SetXTitle("Threshold [fC]");
00164 h_thr3->SetYTitle("count");
00165
00166 for (Int_t ichip=0;ichip<NbOfChip;ichip++)
00167 { for (Int_t ichan=0;ichan<NbOfChannels;ichan++)
00168 { h_thr->Fill((threshold_data[ichip] - noise_data_corr[ichip][ichan])*thr_conv_ratio) ;
00169 h_thr2->Fill((threshold_data[ichip] - noise_data_corr[ichip][ichan]+3)*thr_conv_ratio) ;
00170 h_thr3->Fill((threshold_data[ichip] - noise_data[ichip][ichan]+3)*thr_conv_ratio) ;
00171 }
00172 }
00173 TCanvas * c1 = new TCanvas("c1","");
00174 h_thr->Draw() ;
00175
00176 TCanvas * c2 = new TCanvas("c2","");
00177 c2->cd() ;
00178 h_thr2->Draw() ;
00179
00180 TCanvas * c3 = new TCanvas("c3","");
00181 c3->cd() ;
00182 h_thr3->Draw() ;
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240 theApp.Run(kTRUE) ;
00241
00242
00243 return 0 ;
00244
00245 }