00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "TH2.h"
00033 #include "TCanvas.h"
00034 #include "TFile.h"
00035 #include "TApplication.h"
00036 #include "TTree.h"
00037 #include "TF1.h"
00038 #include "TNamed.h"
00039 #include "TGraph.h"
00040 #include "TProfile.h"
00041
00042 #include "TFndHdt.h"
00043
00044
00045 using namespace FROOT;
00046
00047 Double_t langaufun(Double_t *x, Double_t *par) {
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 Double_t invsq2pi = 0.3989422804014;
00062 Double_t mpshift = -0.22278298;
00063
00064
00065 Double_t np = 100.0;
00066 Double_t sc = 5.0;
00067
00068
00069 Double_t xx;
00070 Double_t mpc;
00071 Double_t fland;
00072 Double_t sum = 0.0;
00073 Double_t xlow,xupp;
00074 Double_t step;
00075 Double_t i;
00076
00077
00078
00079 mpc = par[1] - mpshift * par[0];
00080
00081
00082 xlow = x[0] - sc * par[3];
00083 xupp = x[0] + sc * par[3];
00084
00085 step = (xupp-xlow) / np;
00086
00087
00088 for(i=1.0; i<=np/2; i++) {
00089 xx = xlow + (i-.5) * step;
00090 fland = TMath::Landau(xx,mpc,par[0]) / par[0];
00091 sum += fland * TMath::Gaus(x[0],xx,par[3]);
00092
00093 xx = xupp - (i-.5) * step;
00094 fland = TMath::Landau(xx,mpc,par[0]) / par[0];
00095 sum += fland * TMath::Gaus(x[0],xx,par[3]);
00096 }
00097
00098 return (par[2] * step * sum * invsq2pi / par[3]);
00099 }
00100
00101
00102
00103 TF1 *langaufit(TH1F *his, Double_t *fitrange, Double_t *startvalues, Double_t *parlimitslo, Double_t *parlimitshi, Double_t *fitparams, Double_t *fiterrors, Double_t *ChiSqr, Int_t *NDF)
00104 {
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 Int_t i;
00123 Char_t FunName[100];
00124
00125 sprintf(FunName,"Fitfcn_%s",his->GetName());
00126
00127 TF1 *ffitold = (TF1*)gROOT->GetListOfFunctions()->FindObject(FunName);
00128 if (ffitold) delete ffitold;
00129
00130 TF1 *ffit = new TF1(FunName,langaufun,fitrange[0],fitrange[1],4);
00131 ffit->SetParameters(startvalues);
00132 ffit->SetParNames("Width","MP","Area","GSigma");
00133
00134 for (i=0; i<4; i++) {
00135 ffit->SetParLimits(i, parlimitslo[i], parlimitshi[i]);
00136 }
00137
00138 his->Fit(FunName,"RB");
00139
00140 ffit->GetParameters(fitparams);
00141 for (i=0; i<4; i++) {
00142 fiterrors[i] = ffit->GetParError(i);
00143 }
00144 ChiSqr[0] = ffit->GetChisquare();
00145 NDF[0] = ffit->GetNDF();
00146
00147 return (ffit);
00148
00149 }
00150
00151 TTree *fCalibTree;
00152
00153 TH1F *h_LowBhaMult;
00154 TH1F *h_LowHypMult;
00155 TH1F *h_HighBhaMult;
00156 TH1F *h_HighHypMult;
00157
00158 TH1F *h_adce[K_N_TOFINO_SLABS];
00159 TH1F *h_adce_ped[K_N_TOFINO_SLABS];
00160 TH1F *h_adce_bha[K_N_TOFINO_SLABS];
00161 TH1F *h_adce_kaon[K_N_TOFINO_SLABS];
00162 TH1F *h_adce_bha_nosel[K_N_TOFINO_SLABS];
00163 TH1F *h_adce_kaon_nosel[K_N_TOFINO_SLABS];
00164 TH1F *h_adce_bhakaon[K_N_TOFINO_SLABS];
00165 TH1F *h_adce_subtr[K_N_TOFINO_SLABS];
00166 TH1F *h_adce_ped_subtr[K_N_TOFINO_SLABS];
00167 TH1F *h_adce_bha_subtr[K_N_TOFINO_SLABS];
00168 TH1F *h_adce_kaon_subtr[K_N_TOFINO_SLABS];
00169 TH1F *h_adce_bha_subtr_nosel[K_N_TOFINO_SLABS];
00170 TH1F *h_adce_kaon_subtr_nosel[K_N_TOFINO_SLABS];
00171 TH1F *h_adce_bhakaon_subtr[K_N_TOFINO_SLABS];
00172 TH1F *h_adce_equ[K_N_TOFINO_SLABS];
00173 TH1F *h_adce_ped_equ[K_N_TOFINO_SLABS];
00174 TH1F *h_adce_bha_equ[K_N_TOFINO_SLABS];
00175 TH1F *h_adce_kaon_equ[K_N_TOFINO_SLABS];
00176 TH1F *h_adce_bha_equ_nosel[K_N_TOFINO_SLABS];
00177 TH1F *h_adce_kaon_equ_nosel[K_N_TOFINO_SLABS];
00178 TH1F *h_adce_bhakaon_equ[K_N_TOFINO_SLABS];
00179
00180 TH1F *h_adcp[K_N_TOFINO_SLABS];
00181 TH1F *h_adcp_ped[K_N_TOFINO_SLABS];
00182 TH1F *h_adcp_bha[K_N_TOFINO_SLABS];
00183 TH1F *h_adcp_kaon[K_N_TOFINO_SLABS];
00184 TH1F *h_adcp_bha_nosel[K_N_TOFINO_SLABS];
00185 TH1F *h_adcp_kaon_nosel[K_N_TOFINO_SLABS];
00186 TH1F *h_adcp_bhakaon[K_N_TOFINO_SLABS];
00187 TH1F *h_adcp_subtr[K_N_TOFINO_SLABS];
00188 TH1F *h_adcp_ped_subtr[K_N_TOFINO_SLABS];
00189 TH1F *h_adcp_bha_subtr[K_N_TOFINO_SLABS];
00190 TH1F *h_adcp_kaon_subtr[K_N_TOFINO_SLABS];
00191 TH1F *h_adcp_bha_subtr_nosel[K_N_TOFINO_SLABS];
00192 TH1F *h_adcp_kaon_subtr_nosel[K_N_TOFINO_SLABS];
00193 TH1F *h_adcp_bhakaon_subtr[K_N_TOFINO_SLABS];
00194 TH1F *h_adcp_equ[K_N_TOFINO_SLABS];
00195 TH1F *h_adcp_ped_equ[K_N_TOFINO_SLABS];
00196 TH1F *h_adcp_bha_equ[K_N_TOFINO_SLABS];
00197 TH1F *h_adcp_kaon_equ[K_N_TOFINO_SLABS];
00198 TH1F *h_adcp_bha_equ_nosel[K_N_TOFINO_SLABS];
00199 TH1F *h_adcp_kaon_equ_nosel[K_N_TOFINO_SLABS];
00200 TH1F *h_adcp_bhakaon_equ[K_N_TOFINO_SLABS];
00201
00202 TH1F *h_lowtdce[K_N_TOFINO_SLABS];
00203 TH1F *h_lowtdcp[K_N_TOFINO_SLABS];
00204 TH1F *h_hightdce[K_N_TOFINO_SLABS];
00205 TH1F *h_hightdcp[K_N_TOFINO_SLABS];
00206
00207 TH1F *h_adc_bha_sqr[K_N_TOFINO_SLABS];
00208 TH1F *h_adc_kaon_sqr[K_N_TOFINO_SLABS];
00209 TH1F *h_adc_bhakaon_sqr[K_N_TOFINO_SLABS];
00210 TH1F *h_adc_bha_rawsqr[K_N_TOFINO_SLABS];
00211 TH1F *h_adc_kaon_rawsqr[K_N_TOFINO_SLABS];
00212 TH1F *h_adc_bhakaon_rawsqr[K_N_TOFINO_SLABS];
00213
00214 TH1F *h_adce_bha_equ_all[K_N_TOFINO_SLABS];
00215 TH1F *h_adcp_bha_equ_all[K_N_TOFINO_SLABS];
00216 TH1F *h_adc_bha_sqr_all[K_N_TOFINO_SLABS];
00217 TH1F *h_adce_kaon_equ_all[K_N_TOFINO_SLABS];
00218 TH1F *h_adcp_kaon_equ_all[K_N_TOFINO_SLABS];
00219 TH1F *h_adc_kaon_sqr_all[K_N_TOFINO_SLABS];
00220
00221 TH1F *p_ped_e[12];
00222 TH1F *p_ped_p[12];
00223 TH1F *p_bha_e[12];
00224 TH1F *p_bha_p[12];
00225 TH1F *p_kaon_e[12];
00226 TH1F *p_kaon_p[12];
00227 TH1F *p_eq_e[12];
00228 TH1F *p_eq_p[12];
00229
00230 TH1F *p_EQbha_e[12];
00231 TH1F *p_EQbha_p[12];
00232
00233 TH1F *p_EQkaon_e[12];
00234 TH1F *p_EQkaon_p[12];
00235
00236
00237 TH1F *p_EQ_e[12];
00238 TH1F *p_EQ_p[12];
00239 TH1F *p_OverKaonThreshold[12];
00240 Int_t CurrentRunNumber;
00241
00242 Int_t start_unixtime, stop_unixtime;
00243 Float_t ped_e[K_N_TOFINO_SLABS];
00244 Float_t ped_p[K_N_TOFINO_SLABS];
00245 Float_t bhapeak_e[K_N_TOFINO_SLABS];
00246 Float_t bhapeak_p[K_N_TOFINO_SLABS];
00247 Float_t kaonpeak_e[K_N_TOFINO_SLABS];
00248 Float_t kaonpeak_p[K_N_TOFINO_SLABS];
00249 Float_t eq_e[K_N_TOFINO_SLABS];
00250 Float_t eq_p[K_N_TOFINO_SLABS];
00251
00252 Float_t ped_table_e[K_N_TOFINO_SLABS];
00253 Float_t ped_table_p[K_N_TOFINO_SLABS];
00254 Float_t eq_table_e[K_N_TOFINO_SLABS];
00255 Float_t eq_table_p[K_N_TOFINO_SLABS];
00256
00257 Int_t KaonThreshold[K_N_TOFINO_SLABS];
00258 Int_t NevOverThreshold[K_N_TOFINO_SLABS];
00259
00260 TFile *fHdtFile = 0;
00261
00262 TFndHdt *fCurHdtEv = 0;
00263 TTree *fHdtTree = 0;
00264
00265 void DeclareHistos(){
00266
00267 TString hname;
00268 TString htitle;
00269
00270 hname.Form("LowBhaMult");
00271 htitle.Form("Multiplicity (Low threshold & Bhabha trigger)");
00272 h_LowBhaMult = new TH1F(hname,htitle,12,0,12);
00273 Printf("Histo name: \"%s\"",hname.Data());
00274
00275 hname.Form("LowHypMult");
00276 htitle.Form("Multiplicity (Low threshold & Hyp trigger)");
00277 h_LowHypMult = new TH1F(hname,htitle,12,0,12);
00278 Printf("Histo name: \"%s\"",hname.Data());
00279
00280 hname.Form("HighBhaMult");
00281 htitle.Form("Multiplicity (High threshold & Bhabha trigger)");
00282 h_HighBhaMult = new TH1F(hname,htitle,12,0,12);
00283 Printf("Histo name: \"%s\"",hname.Data());
00284
00285 hname.Form("HighHypMult");
00286 htitle.Form("Multiplicity (High threshold Hyp trigger)");
00287 h_HighHypMult = new TH1F(hname,htitle,12,0,12);
00288 Printf("Histo name: \"%s\"",hname.Data());
00289
00290 for(Int_t sl=0;sl<K_N_TOFINO_SLABS;sl++ ){
00291
00292 hname.Form("TofinoAdcE_%d",sl+1);
00293 htitle.Form("Tofino slab: %d e",sl+1);
00294 h_adce[sl] = new TH1F(hname,htitle,1000,0,4000);
00295 Printf("Histo name: \"%s\"",hname.Data());
00296
00297 hname.Form("TofinoAdcEPed_%d",sl+1);
00298 htitle.Form("Tofino Pedestal slab: %d e",sl+1);
00299 h_adce_ped[sl] = new TH1F(hname,htitle,1000,0,4000);
00300 Printf("Histo name: \"%s\"",hname.Data());
00301
00302 hname.Form("TofinoAdcEBha_%d",sl+1);
00303 htitle.Form("Tofino Bhabha slab: %d e",sl+1);
00304 h_adce_bha[sl] = new TH1F(hname,htitle,1000,0,4000);
00305 Printf("Histo name: \"%s\"",hname.Data());
00306
00307 hname.Form("TofinoAdcEKaon_%d",sl+1);
00308 htitle.Form("Tofino Kaon slab: %d e",sl+1);
00309 h_adce_kaon[sl] = new TH1F(hname,htitle,1000,0,4000);
00310 Printf("Histo name: \"%s\"",hname.Data());
00311
00312 hname.Form("TofinoAdcEBhaNosel_%d",sl+1);
00313 htitle.Form("Tofino Bhabha slab: %d e",sl+1);
00314 h_adce_bha_nosel[sl] = new TH1F(hname,htitle,1000,0,4000);
00315 Printf("Histo name: \"%s\"",hname.Data());
00316
00317 hname.Form("TofinoAdcEKaonNosel_%d",sl+1);
00318 htitle.Form("Tofino Kaon slab: %d e",sl+1);
00319 h_adce_kaon_nosel[sl] = new TH1F(hname,htitle,1000,0,4000);
00320 Printf("Histo name: \"%s\"",hname.Data());
00321
00322 hname.Form("TofinoAdcEBhaKaon_%d",sl+1);
00323 htitle.Form("Tofino Bhabha+Kaon slab: %d e",sl+1);
00324 h_adce_bhakaon[sl] = new TH1F(hname,htitle,1000,0,4000);
00325 Printf("Histo name: \"%s\"",hname.Data());
00326
00327 hname.Form("TofinoAdcESubtr_%d",sl+1);
00328 htitle.Form("Tofino subtracted slab: %d e",sl+1);
00329 h_adce_subtr[sl] = new TH1F(hname,htitle,1050,-200,4000);
00330 Printf("Histo name: \"%s\"",hname.Data());
00331
00332 hname.Form("TofinoAdcEPedSubtr_%d",sl+1);
00333 htitle.Form("Tofino Pedestal subtracted slab: %d e",sl+1);
00334 h_adce_ped_subtr[sl] = new TH1F(hname,htitle,1050,-200,4000);
00335 Printf("Histo name: \"%s\"",hname.Data());
00336
00337 hname.Form("TofinoAdcEBhaSubtr_%d",sl+1);
00338 htitle.Form("Tofino Bhabha subtracted slab: %d e",sl+1);
00339 h_adce_bha_subtr[sl] = new TH1F(hname,htitle,1050,-200,4000);
00340 Printf("Histo name: \"%s\"",hname.Data());
00341
00342 hname.Form("TofinoAdcEKaonSubtr_%d",sl+1);
00343 htitle.Form("Tofino Kaon subtracted slab: %d e",sl+1);
00344 h_adce_kaon_subtr[sl] = new TH1F(hname,htitle,1050,-200,4000);
00345 Printf("Histo name: \"%s\"",hname.Data());
00346
00347 hname.Form("TofinoAdcEBhaSubtrNosel_%d",sl+1);
00348 htitle.Form("Tofino Bhabha subtracted slab: %d e",sl+1);
00349 h_adce_bha_subtr_nosel[sl] = new TH1F(hname,htitle,1050,-200,4000);
00350 Printf("Histo name: \"%s\"",hname.Data());
00351
00352 hname.Form("TofinoAdcEKaonSubtrNosel_%d",sl+1);
00353 htitle.Form("Tofino Kaon subtracted slab: %d e",sl+1);
00354 h_adce_kaon_subtr_nosel[sl] = new TH1F(hname,htitle,1050,-200,4000);
00355 Printf("Histo name: \"%s\"",hname.Data());
00356
00357 hname.Form("TofinoAdcEBhaKaonSubtr_%d",sl+1);
00358 htitle.Form("Tofino Bhabha+Kaon subtracted slab: %d e",sl+1);
00359 h_adce_bhakaon_subtr[sl] = new TH1F(hname,htitle,1050,-200,4000);
00360 Printf("Histo name: \"%s\"",hname.Data());
00361
00362 hname.Form("TofinoAdcEEqu_%d",sl+1);
00363 htitle.Form("Tofino equalized slab: %d e",sl+1);
00364 h_adce_equ[sl] = new TH1F(hname,htitle,300,-200,1000);
00365 Printf("Histo name: \"%s\"",hname.Data());
00366
00367 hname.Form("TofinoAdcEPedEqu_%d",sl+1);
00368 htitle.Form("Tofino Pedestal equalized slab: %d e",sl+1);
00369 h_adce_ped_equ[sl] = new TH1F(hname,htitle,300,-200,1000);
00370 Printf("Histo name: \"%s\"",hname.Data());
00371
00372 hname.Form("TofinoAdcEBhaEqu_%d",sl+1);
00373 htitle.Form("Tofino Bhabha equalized slab: %d e",sl+1);
00374 h_adce_bha_equ[sl] = new TH1F(hname,htitle,300,-200,1000);
00375 Printf("Histo name: \"%s\"",hname.Data());
00376
00377 hname.Form("TofinoAdcEKaonEqu_%d",sl+1);
00378 htitle.Form("Tofino Kaon equalized slab: %d e",sl+1);
00379 h_adce_kaon_equ[sl] = new TH1F(hname,htitle,300,-200,1000);
00380 Printf("Histo name: \"%s\"",hname.Data());
00381
00382 hname.Form("TofinoAdcEBhaEquNosel_%d",sl+1);
00383 htitle.Form("Tofino Bhabha equalized slab: %d e",sl+1);
00384 h_adce_bha_equ_nosel[sl] = new TH1F(hname,htitle,300,-200,1000);
00385 Printf("Histo name: \"%s\"",hname.Data());
00386
00387 hname.Form("TofinoAdcEKaonEquNosel_%d",sl+1);
00388 htitle.Form("Tofino Kaon equalized slab: %d e",sl+1);
00389 h_adce_kaon_equ_nosel[sl] = new TH1F(hname,htitle,300,-200,1000);
00390 Printf("Histo name: \"%s\"",hname.Data());
00391
00392 hname.Form("TofinoAdcEBhaKaonEqu_%d",sl+1);
00393 htitle.Form("Tofino Bhabha+Kaon equalized slab: %d e",sl+1);
00394 h_adce_bhakaon_equ[sl] = new TH1F(hname,htitle,300,-200,1000);
00395 Printf("Histo name: \"%s\"",hname.Data());
00396
00397 hname.Form("TofinoAdcP_%d",sl+1);
00398 htitle.Form("Tofino slab: %d p",sl+1);
00399 h_adcp[sl] = new TH1F(hname,htitle,1000,0,4000);
00400 Printf("Histo name: \"%s\"",hname.Data());
00401
00402 hname.Form("TofinoAdcPPed_%d",sl+1);
00403 htitle.Form("Tofino Pedestal slab: %d p",sl+1);
00404 h_adcp_ped[sl] = new TH1F(hname,htitle,1000,0,4000);
00405 Printf("Histo name: \"%s\"",hname.Data());
00406
00407 hname.Form("TofinoAdcPBha_%d",sl+1);
00408 htitle.Form("Tofino Bhabha slab: %d p",sl+1);
00409 h_adcp_bha[sl] = new TH1F(hname,htitle,1000,0,4000);
00410 Printf("Histo name: \"%s\"",hname.Data());
00411
00412 hname.Form("TofinoAdcPKaon_%d",sl+1);
00413 htitle.Form("Tofino Kaon slab: %d p",sl+1);
00414 h_adcp_kaon[sl] = new TH1F(hname,htitle,1000,0,4000);
00415 Printf("Histo name: \"%s\"",hname.Data());
00416
00417 hname.Form("TofinoAdcPBhaNosel_%d",sl+1);
00418 htitle.Form("Tofino Bhabha slab: %d p",sl+1);
00419 h_adcp_bha_nosel[sl] = new TH1F(hname,htitle,1000,0,4000);
00420 Printf("Histo name: \"%s\"",hname.Data());
00421
00422 hname.Form("TofinoAdcPKaonNosel_%d",sl+1);
00423 htitle.Form("Tofino Kaon slab: %d p",sl+1);
00424 h_adcp_kaon_nosel[sl] = new TH1F(hname,htitle,1000,0,4000);
00425 Printf("Histo name: \"%s\"",hname.Data());
00426
00427 hname.Form("TofinoAdcPBhaKaon_%d",sl+1);
00428 htitle.Form("Tofino Bhabha+Kaon slab: %d p",sl+1);
00429 h_adcp_bhakaon[sl] = new TH1F(hname,htitle,1000,0,4000);
00430 Printf("Histo name: \"%s\"",hname.Data());
00431
00432 hname.Form("TofinoAdcPSubtr_%d",sl+1);
00433 htitle.Form("Tofino subtracted slab: %d p",sl+1);
00434 h_adcp_subtr[sl] = new TH1F(hname,htitle,1050,-200,4000);
00435 Printf("Histo name: \"%s\"",hname.Data());
00436
00437 hname.Form("TofinoAdcPPedSubtr_%d",sl+1);
00438 htitle.Form("Tofino Pedestal subtracted slab: %d p",sl+1);
00439 h_adcp_ped_subtr[sl] = new TH1F(hname,htitle,1050,-200,4000);
00440 Printf("Histo name: \"%s\"",hname.Data());
00441
00442 hname.Form("TofinoAdcPBhaSubtr_%d",sl+1);
00443 htitle.Form("Tofino Bhabha subtracted slab: %d p",sl+1);
00444 h_adcp_bha_subtr[sl] = new TH1F(hname,htitle,1050,-200,4000);
00445 Printf("Histo name: \"%s\"",hname.Data());
00446
00447 hname.Form("TofinoAdcPKaonSubtr_%d",sl+1);
00448 htitle.Form("Tofino Kaon subtracted slab: %d p",sl+1);
00449 h_adcp_kaon_subtr[sl] = new TH1F(hname,htitle,1050,-200,4000);
00450 Printf("Histo name: \"%s\"",hname.Data());
00451
00452 hname.Form("TofinoAdcPBhaSubtrNosel_%d",sl+1);
00453 htitle.Form("Tofino Bhabha subtracted slab: %d p",sl+1);
00454 h_adcp_bha_subtr_nosel[sl] = new TH1F(hname,htitle,1050,-200,4000);
00455 Printf("Histo name: \"%s\"",hname.Data());
00456
00457 hname.Form("TofinoAdcPKaonSubtrNosel_%d",sl+1);
00458 htitle.Form("Tofino Kaon subtracted slab: %d p",sl+1);
00459 h_adcp_kaon_subtr_nosel[sl] = new TH1F(hname,htitle,1050,-200,4000);
00460 Printf("Histo name: \"%s\"",hname.Data());
00461
00462 hname.Form("TofinoAdcPBhaKaonSubtr_%d",sl+1);
00463 htitle.Form("Tofino Bhabha+Kaon subtracted slab: %d p",sl+1);
00464 h_adcp_bhakaon_subtr[sl] = new TH1F(hname,htitle,1050,-200,4000);
00465 Printf("Histo name: \"%s\"",hname.Data());
00466
00467 hname.Form("TofinoAdcPEqu_%d",sl+1);
00468 htitle.Form("Tofino equalized slab: %d p",sl+1);
00469 h_adcp_equ[sl] = new TH1F(hname,htitle,300,-200,1000);
00470 Printf("Histo name: \"%s\"",hname.Data());
00471
00472 hname.Form("TofinoAdcPPedEqu_%d",sl+1);
00473 htitle.Form("Tofino Pedestal equalized slab: %d p",sl+1);
00474 h_adcp_ped_equ[sl] = new TH1F(hname,htitle,300,-200,1000);
00475 Printf("Histo name: \"%s\"",hname.Data());
00476
00477 hname.Form("TofinoAdcPBhaEqu_%d",sl+1);
00478 htitle.Form("Tofino Bhabha equalized slab: %d p",sl+1);
00479 h_adcp_bha_equ[sl] = new TH1F(hname,htitle,300,-200,1000);
00480 Printf("Histo name: \"%s\"",hname.Data());
00481
00482 hname.Form("TofinoAdcPKaonEqu_%d",sl+1);
00483 htitle.Form("Tofino Kaon equalized slab: %d p",sl+1);
00484 h_adcp_kaon_equ[sl] = new TH1F(hname,htitle,300,-200,1000);
00485 Printf("Histo name: \"%s\"",hname.Data());
00486
00487 hname.Form("TofinoAdcPBhaEquNosel_%d",sl+1);
00488 htitle.Form("Tofino Bhabha equalized slab: %d p",sl+1);
00489 h_adcp_bha_equ_nosel[sl] = new TH1F(hname,htitle,300,-200,1000);
00490 Printf("Histo name: \"%s\"",hname.Data());
00491
00492 hname.Form("TofinoAdcPKaonEquNosel_%d",sl+1);
00493 htitle.Form("Tofino Kaon equalized slab: %d p",sl+1);
00494 h_adcp_kaon_equ_nosel[sl] = new TH1F(hname,htitle,300,-200,1000);
00495 Printf("Histo name: \"%s\"",hname.Data());
00496
00497 hname.Form("TofinoAdcPBhaKaonEqu_%d",sl+1);
00498 htitle.Form("Tofino Bhabha+Kaon equalized slab: %d p",sl+1);
00499 h_adcp_bhakaon_equ[sl] = new TH1F(hname,htitle,300,-200,1000);
00500 Printf("Histo name: \"%s\"",hname.Data());
00501
00502 hname.Form("TofinoAdcBhaSqr_%d",sl+1);
00503 htitle.Form("Tofino Bhabha equalized sqrt(e*p) slab: %d",sl+1);
00504 h_adc_bha_sqr[sl] = new TH1F(hname,htitle,300,-200,1000);
00505 Printf("Histo name: \"%s\"",hname.Data());
00506
00507 hname.Form("TofinoAdcKaonSqr_%d",sl+1);
00508 htitle.Form("Tofino Kaon equalized sqrt(e*p) slab: %d",sl+1);
00509 h_adc_kaon_sqr[sl] = new TH1F(hname,htitle,300,-200,1000);
00510 Printf("Histo name: \"%s\"",hname.Data());
00511
00512 hname.Form("TofinoAdcBhaKaonSqr_%d",sl+1);
00513 htitle.Form("Tofino Bhabha+Kaon equalized sqrt(e*p) slab: %d",sl+1);
00514 h_adc_bhakaon_sqr[sl] = new TH1F(hname,htitle,300,-200,1000);
00515 Printf("Histo name: \"%s\"",hname.Data());
00516
00517 hname.Form("TofinoAdcBhaRawSqr_%d",sl+1);
00518 htitle.Form("Tofino Bhabha equalized RAW sqrt(e*p) slab: %d",sl+1);
00519 h_adc_bha_rawsqr[sl] = new TH1F(hname,htitle,300,0,3000);
00520 Printf("Histo name: \"%s\"",hname.Data());
00521
00522 hname.Form("TofinoAdcKaonRawSqr_%d",sl+1);
00523 htitle.Form("Tofino Kaon equalized RAW sqrt(e*p) slab: %d",sl+1);
00524 h_adc_kaon_rawsqr[sl] = new TH1F(hname,htitle,300,0,3000);
00525 Printf("Histo name: \"%s\"",hname.Data());
00526
00527 hname.Form("TofinoAdcBhaKaonRawSqr_%d",sl+1);
00528 htitle.Form("Tofino Bhabha+Kaon equalized RAW sqrt(e*p) slab: %d",sl+1);
00529 h_adc_bhakaon_rawsqr[sl] = new TH1F(hname,htitle,300,0,3000);
00530 Printf("Histo name: \"%s\"",hname.Data());
00531
00532 hname.Form("TofinoLowTdcE_%d",sl+1);
00533 htitle.Form("Low TDC Tofino slab: %d e",sl+1); h_lowtdce[sl] = new TH1F(hname,htitle,1000,0,4000);
00534 Printf("Histo name: \"%s\"",hname.Data());
00535
00536 hname.Form("TofinoLowTdcP_%d",sl+1);
00537 htitle.Form("Low TDC Tofino slab: %d p",sl+1);
00538 h_lowtdcp[sl] = new TH1F(hname,htitle,1000,0,4000);
00539 Printf("Histo name: \"%s\"",hname.Data());
00540
00541 hname.Form("TofinoHighTdcE_%d",sl+1);
00542 htitle.Form("High TDC Tofino slab: %d e",sl+1);
00543 h_hightdce[sl] = new TH1F(hname,htitle,1000,0,4000);
00544 Printf("Histo name: \"%s\"",hname.Data());
00545
00546 hname.Form("TofinoHighTdcP_%d",sl+1);
00547 htitle.Form("High TDC Tofino slab: %d p",sl+1);
00548 h_hightdcp[sl] = new TH1F(hname,htitle,1000,0,4000);
00549 Printf("Histo name: \"%s\"",hname.Data());
00550
00551 hname.Form("TofinoAdcEBhaEquAll_%d",sl+1);
00552 htitle.Form("Tofino Bhabha equalized (all) slab: %d e",sl+1);
00553 h_adce_bha_equ_all[sl] = new TH1F(hname,htitle,300,-200,1000);
00554 Printf("Histo name: \"%s\"",hname.Data());
00555
00556 hname.Form("TofinoAdcPBhaEquAll_%d",sl+1);
00557 htitle.Form("Tofino Bhabha equalized (all) slab: %d p",sl+1);
00558 h_adcp_bha_equ_all[sl] = new TH1F(hname,htitle,300,-200,1000);
00559 Printf("Histo name: \"%s\"",hname.Data());
00560
00561 hname.Form("TofinoAdcBhaSqrAll_%d",sl+1);
00562 htitle.Form("Tofino Bhabha equalized (all) sqrt(e*p) slab: %d",sl+1);
00563 h_adc_bha_sqr_all[sl] = new TH1F(hname,htitle,400,0,1600);
00564 Printf("Histo name: \"%s\"",hname.Data());
00565
00566 hname.Form("TofinoAdcEKaonEquAll_%d",sl+1);
00567 htitle.Form("Tofino Kaon equalized (all) slab: %d e",sl+1);
00568 h_adce_kaon_equ_all[sl] = new TH1F(hname,htitle,300,-200,1000);
00569 Printf("Histo name: \"%s\"",hname.Data());
00570
00571 hname.Form("TofinoAdcPKaonEquAll_%d",sl+1);
00572 htitle.Form("Tofino Kaon equalized (all) slab: %d p",sl+1);
00573 h_adcp_kaon_equ_all[sl] = new TH1F(hname,htitle,300,-200,1000);
00574 Printf("Histo name: \"%s\"",hname.Data());
00575
00576 hname.Form("TofinoAdcKaonSqrAll_%d",sl+1);
00577 htitle.Form("Tofino Kaon equalized (all) sqrt(e*p) slab: %d",sl+1);
00578 h_adc_kaon_sqr_all[sl] = new TH1F(hname,htitle,400,0,1600);
00579 Printf("Histo name: \"%s\"",hname.Data());
00580
00581 }
00582 }
00583
00584 void DeclareProfiles(Int_t const &run_num_start, Int_t const &run_num_stop){
00585
00586 TString hname;
00587 TString htitle;
00588
00589 Int_t N=run_num_stop-run_num_start+2;
00590
00591 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
00592 hname.Form("PedE_%d",sl+1);
00593 htitle.Form("Tofino Pedestal slab: %d e",sl+1);
00594 p_ped_e[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00595
00596 hname.Form("PedP_%d",sl+1);
00597 htitle.Form("Tofino Pedestal slab: %d p",sl+1);
00598 p_ped_p[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00599
00600 hname.Form("BhaE_%d",sl+1);
00601 htitle.Form("Tofino Bhabha Peak slab: %d e",sl+1);
00602 p_bha_e[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00603
00604 hname.Form("BhaP_%d",sl+1);
00605 htitle.Form("Tofino Bhabha Peak slab: %d p",sl+1);
00606 p_bha_p[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00607
00608 hname.Form("EqBhaE_%d",sl+1);
00609 htitle.Form("Tofino Bhabha Peak (eq.) slab: %d e",sl+1);
00610 p_EQbha_e[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00611
00612 hname.Form("EqBhaP_%d",sl+1);
00613 htitle.Form("Tofino Bhabha Peak (eq.) slab: %d p",sl+1);
00614 p_EQbha_p[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00615
00616
00617
00618
00619
00620 hname.Form("KaonE_%d",sl+1);
00621 htitle.Form("Tofino Kaon Peak slab: %d e",sl+1);
00622 p_kaon_e[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00623
00624 hname.Form("KaonP_%d",sl+1);
00625 htitle.Form("Tofino Kaon Peak slab: %d p",sl+1);
00626 p_kaon_p[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00627
00628 hname.Form("EqKaonE_%d",sl+1);
00629 htitle.Form("Tofino Kaon Peak (eq.) slab: %d e",sl+1);
00630 p_EQkaon_e[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00631
00632 hname.Form("EqKaonP_%d",sl+1);
00633 htitle.Form("Tofino Kaon Peak slab (eq.): %d p",sl+1);
00634 p_EQkaon_p[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00635
00636
00637
00638
00639
00640 hname.Form("EqE_%d",sl+1);
00641 htitle.Form("Tofino Equalization Factor slab: %d e",sl+1);
00642 p_eq_e[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00643
00644 hname.Form("EqP_%d",sl+1);
00645 htitle.Form("Tofino Equalization Factor slab: %d p",sl+1);
00646 p_eq_p[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00647
00648 hname.Form("EqFactorE_%d",sl+1);
00649 htitle.Form("Tofino Equalization Factor slab: %d e",sl+1);
00650 p_EQ_e[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00651
00652 hname.Form("EqFactorP_%d",sl+1);
00653 htitle.Form("Tofino Equalization Factor slab: %d p",sl+1);
00654 p_EQ_p[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00655
00656 hname.Form("OverKaonThreshold_%d",sl+1);
00657 htitle.Form("Tofino Ratio over kaon threshold slab: %d",sl+1);
00658 p_OverKaonThreshold[sl] = new TH1F(hname, htitle, N, run_num_start-0.5, run_num_stop+1.5);
00659 }
00660 }
00661
00662 void ResetHistos(){
00663 for(Int_t sl=0;sl<K_N_TOFINO_SLABS;sl++ ){
00664 h_adce[sl]->Reset();
00665 h_adce_ped[sl]->Reset();
00666 h_adce_bha[sl]->Reset();
00667 h_adce_kaon[sl]->Reset();
00668 h_adce_bha_nosel[sl]->Reset();
00669 h_adce_kaon_nosel[sl]->Reset();
00670 h_adce_bhakaon[sl]->Reset();
00671
00672 h_adce_subtr[sl]->Reset();
00673 h_adce_ped_subtr[sl]->Reset();
00674 h_adce_bha_subtr[sl]->Reset();
00675 h_adce_kaon_subtr[sl]->Reset();
00676 h_adce_bha_subtr_nosel[sl]->Reset();
00677 h_adce_kaon_subtr_nosel[sl]->Reset();
00678 h_adce_bhakaon_subtr[sl]->Reset();
00679
00680 h_adce_equ[sl]->Reset();
00681 h_adce_ped_equ[sl]->Reset();
00682 h_adce_bha_equ[sl]->Reset();
00683 h_adce_kaon_equ[sl]->Reset();
00684 h_adce_bha_equ_nosel[sl]->Reset();
00685 h_adce_kaon_equ_nosel[sl]->Reset();
00686 h_adce_bhakaon_equ[sl]->Reset();
00687
00688 h_adcp[sl]->Reset();
00689 h_adcp_ped[sl]->Reset();
00690 h_adcp_bha[sl]->Reset();
00691 h_adcp_kaon[sl]->Reset();
00692 h_adcp_bha_nosel[sl]->Reset();
00693 h_adcp_kaon_nosel[sl]->Reset();
00694 h_adcp_bhakaon[sl]->Reset();
00695
00696 h_adcp_subtr[sl]->Reset();
00697 h_adcp_ped_subtr[sl]->Reset();
00698 h_adcp_bha_subtr[sl]->Reset();
00699 h_adcp_kaon_subtr[sl]->Reset();
00700 h_adcp_bha_subtr_nosel[sl]->Reset();
00701 h_adcp_kaon_subtr_nosel[sl]->Reset();
00702 h_adcp_bhakaon_subtr[sl]->Reset();
00703
00704 h_adcp_equ[sl]->Reset();
00705 h_adcp_ped_equ[sl]->Reset();
00706 h_adcp_bha_equ[sl]->Reset();
00707 h_adcp_kaon_equ[sl]->Reset();
00708 h_adcp_bha_equ_nosel[sl]->Reset();
00709 h_adcp_kaon_equ_nosel[sl]->Reset();
00710 h_adcp_bhakaon_equ[sl]->Reset();
00711
00712 h_adc_bha_sqr[sl]->Reset();
00713 h_adc_kaon_sqr[sl]->Reset();
00714 h_adc_bhakaon_sqr[sl]->Reset();
00715 h_adc_bha_rawsqr[sl]->Reset();
00716 h_adc_kaon_rawsqr[sl]->Reset();
00717 h_adc_bhakaon_rawsqr[sl]->Reset();
00718 }
00719 }
00720
00721
00722 void CloseHdtFile(){
00723
00724 if (fHdtTree){
00725 delete fHdtTree;
00726
00727 fHdtTree = 0;
00728 }
00729
00730 if(fHdtFile){
00731 if(fHdtFile->IsOpen()) fHdtFile->Close();
00732 delete fHdtFile;
00733 fHdtFile = 0;
00734 }
00735
00736 }
00737
00738 Int_t OpenHdtFile(const TString &runtype,const Int_t &run_num){
00739
00740
00741
00742
00743 CloseHdtFile();
00744
00745
00746 TString runname;
00747 TString fnam;
00748 if (run_num>=7000){
00749 runname=BuildRunName(runtype,run_num, kTRUE);
00750 fnam.Form("%s/%s.hdt.root",ExpandPathName("$FND_HDT").Data(),
00751 runname.Data());
00752 } else {
00753 runname=BuildRunName(runtype,run_num, kFALSE);
00754 fnam.Form("%s_v9.0/%s.hdt.root",ExpandPathName("$FND_HDT").Data(),
00755 runname.Data());
00756 }
00757
00758
00759 if(gSystem->AccessPathName(fnam)){
00760 gROOT->Warning("OpenHdtFile","file \"%s\" not found",fnam.Data());
00761 return -1;
00762 }
00763
00764 gROOT->Info("OpenHdtFile","opening file \"%s\"",fnam.Data());
00765 fHdtFile = new TFile(fnam,"OPEN");
00766
00767 return 0;
00768 }
00769
00770
00771 Int_t LoadHdtTree(){
00772
00773
00774
00775
00776 if (fHdtTree){
00777 delete fHdtTree;
00778
00779 fHdtTree = 0;
00780 }
00781
00782 fHdtTree = (TTree *) ( fHdtFile->Get("FIN_HDT_TREE") );
00783 if(!fHdtTree){
00784 gROOT->Warning("LoadHdtTree","Problems while getting HDT tree from file");
00785 return -1;
00786 }
00787
00788
00789 fHdtTree->SetBranchAddress("fndhdt",&fCurHdtEv);
00790
00791 return 0;
00792 }
00793
00794
00795 void FillHistosPed(){
00796
00797 TClonesArray *TofHits = fCurHdtEv->GetTofHits();
00798
00799 Int_t lay, slab;
00800 TFndHTof *cur_hit = 0;
00801 for(Int_t ic=0;ic< TofHits->GetEntries(); ic++) {
00802 cur_hit = (TFndHTof *) ( TofHits->At(ic) );
00803
00804 cur_hit->GetLayer_Slab(lay, slab);
00805
00806
00807 if(lay==E_FIN_OUTER_LAYER) continue;
00808
00809 Bool_t both_adc = kFALSE;
00810 Bool_t both_tdcl = kFALSE;
00811 Bool_t both_tdch = kFALSE;
00812 if(cur_hit->GetBothAdc() == TFndHit::E_HIT_BOTH_CH ) both_adc = kTRUE;
00813 if(cur_hit->GetBothLowTdc() == TFndHit::E_HIT_BOTH_CH ) both_tdcl = kTRUE;
00814 if(cur_hit->GetBothHighTdc() == TFndHit::E_HIT_BOTH_CH ) both_tdch = kTRUE;
00815
00816
00817
00818
00819
00820
00821
00822 Double_t adce=cur_hit->GetAdcE();
00823 Double_t adcp=cur_hit->GetAdcP();
00824 if (adce>1) h_adce[slab-1]->Fill(adce);
00825 if (adcp>1) h_adcp[slab-1]->Fill(adcp);
00826 if(!both_tdcl){
00827 if (adce>1) h_adce_ped[slab-1]->Fill(adce);
00828 if (adcp>1) h_adcp_ped[slab-1]->Fill(adcp);
00829 }
00830 h_lowtdce[slab-1]->Fill(cur_hit->GetLowTdcE());
00831 h_lowtdcp[slab-1]->Fill(cur_hit->GetLowTdcP());
00832 h_hightdce[slab-1]->Fill(cur_hit->GetHighTdcE());
00833 h_hightdcp[slab-1]->Fill(cur_hit->GetHighTdcP());
00834 }
00835 }
00836
00837 Int_t GetTrigType(){
00838 TFndTrig *cur_trig = (TFndTrig *) (fCurHdtEv->GetGts());
00839 Short_t hyp_bit=cur_trig->GetPU_cont_bit(0, 0);
00840 Short_t bha_bit=cur_trig->GetPU_cont_bit(0, 1);
00841 Short_t cosm_bit=cur_trig->GetPU_cont_bit(0, 5);
00842 if ((CurrentRunNumber>=5872&&CurrentRunNumber<=5880)||
00843 (CurrentRunNumber>=5887&&CurrentRunNumber<=5905)||
00844 (CurrentRunNumber>=5912&&CurrentRunNumber<=5935)||
00845 (CurrentRunNumber>=5941&&CurrentRunNumber<=5957)||
00846 (CurrentRunNumber>=5998&&CurrentRunNumber<=6014)||
00847 (CurrentRunNumber>=6020&&CurrentRunNumber<=6014)||
00848 (CurrentRunNumber>=7290&&CurrentRunNumber<=7316)||
00849 (CurrentRunNumber>=7319&&CurrentRunNumber<=7329)||
00850 (CurrentRunNumber>=7332&&CurrentRunNumber<=7346)||
00851 (CurrentRunNumber>=7349&&CurrentRunNumber<=7364)||
00852 (CurrentRunNumber>=7367&&CurrentRunNumber<=7382)||
00853 (CurrentRunNumber>=7385&&CurrentRunNumber<=7400)||
00854 (CurrentRunNumber>=7403&&CurrentRunNumber<=7405)||
00855 (CurrentRunNumber>=7403&&CurrentRunNumber<=7405)||
00856 (CurrentRunNumber>=7407&&CurrentRunNumber<=7421)||
00857 (CurrentRunNumber>=7423&&CurrentRunNumber<=7433)||
00858 (CurrentRunNumber>=7436&&CurrentRunNumber<=7445)||
00859 (CurrentRunNumber>=7447&&CurrentRunNumber<=7453)||
00860 (CurrentRunNumber>=7458&&CurrentRunNumber<=7463)||
00861 (CurrentRunNumber>=7465&&CurrentRunNumber<=7475)||
00862 (CurrentRunNumber>=7477&&CurrentRunNumber<=7486)||
00863 (CurrentRunNumber>=7488&&CurrentRunNumber<=7497)||
00864 (CurrentRunNumber>=7499&&CurrentRunNumber<=7517)||
00865 (CurrentRunNumber>=7519&&CurrentRunNumber<=7528)||
00866 (CurrentRunNumber>=7530&&CurrentRunNumber<=7541)||
00867 (CurrentRunNumber>=7543&&CurrentRunNumber<=7552)||
00868 (CurrentRunNumber>=7554&&CurrentRunNumber<=7563)||
00869 (CurrentRunNumber>=7565&&CurrentRunNumber<=7574)||
00870 (CurrentRunNumber>=7576&&CurrentRunNumber<=7585))
00871 { hyp_bit=1; bha_bit=0; cosm_bit=0;}
00872 if ((CurrentRunNumber>=5881&&CurrentRunNumber<=5886)||
00873 (CurrentRunNumber>=5906&&CurrentRunNumber<=5911)||
00874 (CurrentRunNumber>=5936&&CurrentRunNumber<=5940)||
00875 (CurrentRunNumber>=5969&&CurrentRunNumber<=5973)||
00876 (CurrentRunNumber>=5986&&CurrentRunNumber<=5991)||
00877 (CurrentRunNumber>=7289&&CurrentRunNumber<=7289)||
00878 (CurrentRunNumber>=7317&&CurrentRunNumber<=7318)||
00879 (CurrentRunNumber>=7330&&CurrentRunNumber<=7331)||
00880 (CurrentRunNumber>=7347&&CurrentRunNumber<=7348)||
00881 (CurrentRunNumber>=7365&&CurrentRunNumber<=7366)||
00882 (CurrentRunNumber>=7383&&CurrentRunNumber<=7384)||
00883 (CurrentRunNumber>=7401&&CurrentRunNumber<=7402)||
00884 (CurrentRunNumber>=7406&&CurrentRunNumber<=7406)||
00885 (CurrentRunNumber>=7422&&CurrentRunNumber<=7422)||
00886 (CurrentRunNumber>=7434&&CurrentRunNumber<=7435)||
00887 (CurrentRunNumber>=7446&&CurrentRunNumber<=7446)||
00888 (CurrentRunNumber>=7454&&CurrentRunNumber<=7457)||
00889 (CurrentRunNumber>=7464&&CurrentRunNumber<=7464)||
00890 CurrentRunNumber==7476||CurrentRunNumber==7487||
00891 CurrentRunNumber==7498||CurrentRunNumber==7518||
00892 CurrentRunNumber==7529||CurrentRunNumber==7542||
00893 CurrentRunNumber==7553||CurrentRunNumber==7564||
00894 CurrentRunNumber==7575||CurrentRunNumber==7586)
00895 { hyp_bit=0; bha_bit=1; cosm_bit=0;}
00896 if ((CurrentRunNumber>=7587&&CurrentRunNumber<=8335)||
00897 (CurrentRunNumber>=9027&&CurrentRunNumber<=9084)||
00898 (CurrentRunNumber>=9394&&CurrentRunNumber<=9585))
00899 {
00900 if (CurrentRunNumber==7597||
00901 CurrentRunNumber==7608||
00902 CurrentRunNumber==7619||
00903 CurrentRunNumber==7630||
00904 CurrentRunNumber==7639||
00905 CurrentRunNumber==7650||
00906 CurrentRunNumber==7661||
00907 CurrentRunNumber==7670||
00908 CurrentRunNumber==7690||
00909 CurrentRunNumber==7691||
00910 CurrentRunNumber==7702||
00911 CurrentRunNumber==7713||
00912 CurrentRunNumber==7719||
00913 CurrentRunNumber==7733||
00914 CurrentRunNumber==7744||
00915 CurrentRunNumber==7756||
00916 CurrentRunNumber==7777||
00917 CurrentRunNumber==7788||
00918 CurrentRunNumber==7792||
00919 CurrentRunNumber==7793||
00920 (CurrentRunNumber>=7799&&CurrentRunNumber<=7802)||
00921 CurrentRunNumber==7814||
00922 CurrentRunNumber==7825||
00923 CurrentRunNumber==7836||
00924 CurrentRunNumber==7847||
00925 CurrentRunNumber==7858||
00926 CurrentRunNumber==7869||
00927 CurrentRunNumber==7873||
00928 CurrentRunNumber==7874||
00929 CurrentRunNumber==7885||
00930 CurrentRunNumber==7896||
00931 CurrentRunNumber==7907||
00932 CurrentRunNumber==7919||
00933 CurrentRunNumber==7921||
00934 CurrentRunNumber==7932||
00935 CurrentRunNumber==7943||
00936 CurrentRunNumber==7954||
00937 CurrentRunNumber==7965||
00938 CurrentRunNumber==7976||
00939 CurrentRunNumber==7987||
00940 CurrentRunNumber==7991||
00941 CurrentRunNumber==7992||
00942 CurrentRunNumber==7993||
00943 CurrentRunNumber==8004||
00944 CurrentRunNumber==8005||
00945 CurrentRunNumber==8023||
00946 CurrentRunNumber==8064||
00947 CurrentRunNumber==8065||
00948 CurrentRunNumber==8074||
00949 CurrentRunNumber==8085||
00950 CurrentRunNumber==8098||
00951 CurrentRunNumber==8109||
00952 CurrentRunNumber==8120||
00953 CurrentRunNumber==8131||
00954 CurrentRunNumber==8142||
00955 CurrentRunNumber==8153||
00956 CurrentRunNumber==8163||
00957 CurrentRunNumber==8174||
00958 CurrentRunNumber==8185||
00959 CurrentRunNumber==8208||
00960 CurrentRunNumber==8222||
00961 CurrentRunNumber==8233||
00962 CurrentRunNumber==8244||
00963 CurrentRunNumber==8255||
00964 CurrentRunNumber==8266||
00965 CurrentRunNumber==8277||
00966 CurrentRunNumber==8288||
00967 CurrentRunNumber==8299||
00968 CurrentRunNumber==8303||
00969 CurrentRunNumber==8308||
00970 CurrentRunNumber==8319||
00971 CurrentRunNumber==8334||
00972 CurrentRunNumber==8335||
00973 CurrentRunNumber==9029||
00974 CurrentRunNumber==9040||
00975 CurrentRunNumber==9051||
00976 CurrentRunNumber==9062||
00977 CurrentRunNumber==9073||
00978 CurrentRunNumber==9401||
00979 CurrentRunNumber==9412||
00980 CurrentRunNumber==9416||
00981 CurrentRunNumber==9428||
00982 CurrentRunNumber==9439||
00983 CurrentRunNumber==9450||
00984 CurrentRunNumber==9461||
00985 CurrentRunNumber==9472||
00986 CurrentRunNumber==9483||
00987 CurrentRunNumber==9494||
00988 CurrentRunNumber==9505||
00989 CurrentRunNumber==9516||
00990 CurrentRunNumber==9527||
00991 CurrentRunNumber==9538||
00992 CurrentRunNumber==9549||
00993 CurrentRunNumber==9560||
00994 CurrentRunNumber==9571||
00995 CurrentRunNumber==9582)
00996 { hyp_bit=0; bha_bit=1; cosm_bit=0;}
00997 else { hyp_bit=1; bha_bit=0; cosm_bit=0;}
00998 }
00999 return (Int_t) hyp_bit+2*bha_bit+32*cosm_bit;
01000 }
01001
01002 void GetMultiplicity(Int_t *mult){
01003
01004
01005 mult[0]=0; mult[1]=0;
01006
01007 TClonesArray *TofHits = fCurHdtEv->GetTofHits();
01008 Int_t lay, slab;
01009 TFndHTof *cur_hit = 0;
01010
01011 for(Int_t ic=0;ic< TofHits->GetEntries(); ic++) {
01012 cur_hit = (TFndHTof *) ( TofHits->At(ic) );
01013 cur_hit->GetLayer_Slab(lay, slab);
01014 if(lay==E_FIN_OUTER_LAYER) continue;
01015
01016 Bool_t both_adc = kFALSE;
01017 Bool_t both_tdcl = kFALSE;
01018 Bool_t both_tdch = kFALSE;
01019 if(cur_hit->GetBothAdc() == TFndHit::E_HIT_BOTH_CH ) both_adc = kTRUE;
01020 if(cur_hit->GetBothLowTdc() == TFndHit::E_HIT_BOTH_CH ) both_tdcl = kTRUE;
01021 if(cur_hit->GetBothHighTdc() == TFndHit::E_HIT_BOTH_CH ) both_tdch = kTRUE;
01022
01023 Double_t adce=cur_hit->GetAdcE();
01024 Double_t adcp=cur_hit->GetAdcP();
01025
01026 if(both_tdch&&adce>0&&adcp>0){
01027 mult[1]++;
01028 }
01029 if(both_tdcl&&adce>0&&adcp>0){
01030 mult[0]++;
01031 }
01032 }
01033 }
01034
01035
01036 void FillHistos(){
01037
01038 TClonesArray *TofHits = fCurHdtEv->GetTofHits();
01039
01040 Int_t lay, slab;
01041 TFndHTof *cur_hit = 0;
01042 Int_t mult[2];
01043 GetMultiplicity(mult);
01044 for(Int_t ic=0;ic< TofHits->GetEntries(); ic++) {
01045 cur_hit = (TFndHTof *) ( TofHits->At(ic) );
01046
01047 cur_hit->GetLayer_Slab(lay, slab);
01048
01049
01050 if(lay==E_FIN_OUTER_LAYER) continue;
01051
01052 Bool_t both_adc = kFALSE;
01053 Bool_t both_tdcl = kFALSE;
01054 Bool_t both_tdch = kFALSE;
01055 if(cur_hit->GetBothAdc() == TFndHit::E_HIT_BOTH_CH ) both_adc = kTRUE;
01056 if(cur_hit->GetBothLowTdc() == TFndHit::E_HIT_BOTH_CH ) both_tdcl = kTRUE;
01057 if(cur_hit->GetBothHighTdc() == TFndHit::E_HIT_BOTH_CH ) both_tdch = kTRUE;
01058
01059
01060
01061
01062
01063
01064
01065 Double_t adce=cur_hit->GetAdcE();
01066 Double_t adcp=cur_hit->GetAdcP();
01067
01068 if (adce>1) h_adce_subtr[slab-1]->Fill(adce-ped_e[slab-1]);
01069 if (adcp>1) h_adcp_subtr[slab-1]->Fill(adcp-ped_p[slab-1]);
01070 if(!both_tdcl){
01071 if (adce>1)
01072 h_adce_ped_subtr[slab-1]->Fill(adce-ped_e[slab-1]);
01073 if (adcp>1)
01074 h_adcp_ped_subtr[slab-1]->Fill(adcp-ped_p[slab-1]);
01075 }
01076 if(both_tdcl && !both_tdch){
01077 if (adce>1){
01078 h_adce_bha_nosel[slab-1]->Fill(adce);
01079 h_adce_bha_subtr_nosel[slab-1]->Fill(adce-ped_e[slab-1]);
01080 if ((GetTrigType()==2||GetTrigType()==32)&&mult[0]==2){
01081 h_adce_bha[slab-1]->Fill(adce);
01082 h_adce_bha_subtr[slab-1]->Fill(adce-ped_e[slab-1]);
01083 }
01084 }
01085 if (adcp>1){
01086 h_adcp_bha_nosel[slab-1]->Fill(adcp);
01087 h_adcp_bha_subtr_nosel[slab-1]->Fill(adcp-ped_p[slab-1]);
01088 if ((GetTrigType()==2||GetTrigType()==32)&&mult[0]==2){
01089 h_adcp_bha[slab-1]->Fill(adcp);
01090 h_adcp_bha_subtr[slab-1]->Fill(adcp-ped_p[slab-1]);
01091 }
01092 }
01093 }
01094 if(both_tdch){
01095 if (adce>1){
01096 h_adce_kaon_nosel[slab-1]->Fill(adce);
01097 h_adce_kaon_subtr_nosel[slab-1]->Fill(adce-ped_e[slab-1]);
01098 if (GetTrigType()==1&&mult[1]==2){
01099 h_adce_kaon[slab-1]->Fill(adce);
01100 h_adce_kaon_subtr[slab-1]->Fill(adce-ped_e[slab-1]);
01101 }
01102 }
01103 if (adcp>1){
01104 h_adcp_kaon_nosel[slab-1]->Fill(adcp);
01105 h_adcp_kaon_subtr_nosel[slab-1]->Fill(adcp-ped_p[slab-1]);
01106 if (GetTrigType()==1&&mult[1]==2){
01107 h_adcp_kaon[slab-1]->Fill(adcp);
01108 h_adcp_kaon_subtr[slab-1]->Fill(adcp-ped_p[slab-1]);
01109 }
01110 }
01111 }
01112 if(both_tdcl){
01113 if (adce>1){
01114 h_adce_bhakaon[slab-1]->Fill(adce);
01115 h_adce_bhakaon_subtr[slab-1]->Fill(adce-ped_e[slab-1]);
01116 }
01117 if (adcp>1){
01118 h_adcp_bhakaon[slab-1]->Fill(adcp);
01119 h_adcp_bhakaon_subtr[slab-1]->Fill(adcp-ped_p[slab-1]);
01120 }
01121 }
01122 }
01123 if (GetTrigType()==2){
01124 h_LowBhaMult->Fill(mult[0]);
01125 h_HighBhaMult->Fill(mult[1]);
01126 }
01127 if (GetTrigType()==1){
01128 h_LowHypMult->Fill(mult[0]);
01129 h_HighHypMult->Fill(mult[1]);
01130 }
01131 }
01132
01133 void FillHistosEqu(){
01134
01135 TClonesArray *TofHits = fCurHdtEv->GetTofHits();
01136
01137 Int_t lay, slab;
01138 TFndHTof *cur_hit = 0;
01139 Int_t mult[2];
01140 GetMultiplicity(mult);
01141 for(Int_t ic=0;ic< TofHits->GetEntries(); ic++) {
01142 cur_hit = (TFndHTof *) ( TofHits->At(ic) );
01143
01144 cur_hit->GetLayer_Slab(lay, slab);
01145
01146
01147 if(lay==E_FIN_OUTER_LAYER) continue;
01148
01149 Bool_t both_adc = kFALSE;
01150 Bool_t both_tdcl = kFALSE;
01151 Bool_t both_tdch = kFALSE;
01152 if(cur_hit->GetBothAdc() == TFndHit::E_HIT_BOTH_CH ) both_adc = kTRUE;
01153 if(cur_hit->GetBothLowTdc() == TFndHit::E_HIT_BOTH_CH ) both_tdcl = kTRUE;
01154 if(cur_hit->GetBothHighTdc() == TFndHit::E_HIT_BOTH_CH ) both_tdch = kTRUE;
01155
01156
01157
01158
01159
01160
01161
01162 Double_t adce=cur_hit->GetAdcE();
01163 Double_t adcp=cur_hit->GetAdcP();
01164 if (adce>1)
01165 h_adce_equ[slab-1]->Fill((adce-ped_e[slab-1])*eq_e[slab-1]);
01166 if (adcp>1)
01167 h_adcp_equ[slab-1]->Fill((adcp-ped_p[slab-1])*eq_p[slab-1]);
01168 if(!both_tdcl){
01169 if (adce>1)
01170 h_adce_ped_equ[slab-1]->Fill((adce-ped_e[slab-1])*eq_e[slab-1]);
01171 if (adcp>1)
01172 h_adcp_ped_equ[slab-1]->Fill((adcp-ped_p[slab-1])*eq_p[slab-1]);
01173 }
01174 if(both_tdcl && !both_tdch){
01175 if (adce>1)
01176 h_adce_bha_equ_nosel[slab-1]->Fill((adce-ped_e[slab-1])*eq_e[slab-1]);
01177 if (adcp>1)
01178 h_adcp_bha_equ_nosel[slab-1]->Fill((adcp-ped_p[slab-1])*eq_p[slab-1]);
01179 if ((GetTrigType()==2||GetTrigType()==32)&&mult[0]==2){
01180 if (adce>1)
01181 h_adce_bha_equ[slab-1]->Fill((adce-ped_e[slab-1])*eq_e[slab-1]);
01182 if (adcp>1)
01183 h_adcp_bha_equ[slab-1]->Fill((adcp-ped_p[slab-1])*eq_p[slab-1]);
01184 if (adce>1&&adcp>1){
01185 h_adc_bha_sqr[slab-1]->Fill(sqrt((adce-ped_e[slab-1])*eq_e[slab-1]
01186 *(adcp-ped_p[slab-1])*eq_p[slab-1]));
01187 h_adc_bha_rawsqr[slab-1]->Fill(sqrt(adce*adcp));
01188 }
01189 }
01190 }
01191 if(both_tdch){
01192 if (adce>1)
01193 h_adce_kaon_equ_nosel[slab-1]->Fill((adce-ped_e[slab-1])*eq_e[slab-1]);
01194 if (adcp>1)
01195 h_adcp_kaon_equ_nosel[slab-1]->Fill((adcp-ped_p[slab-1])*eq_p[slab-1]);
01196 if (GetTrigType()==1&&mult[1]==2){
01197 if (adce>1)
01198 h_adce_kaon_equ[slab-1]->Fill((adce-ped_e[slab-1])*eq_e[slab-1]);
01199 if (adcp>1)
01200 h_adcp_kaon_equ[slab-1]->Fill((adcp-ped_p[slab-1])*eq_p[slab-1]);
01201 if (adce>1&&adcp>1){
01202 h_adc_kaon_sqr[slab-1]->Fill(sqrt((adce-ped_e[slab-1])*eq_e[slab-1]
01203 *(adcp-ped_p[slab-1])*eq_p[slab-1]));
01204 h_adc_kaon_rawsqr[slab-1]->Fill(sqrt(adce*adcp));
01205 }
01206 }
01207 }
01208 if(both_tdcl){
01209 if (adce>1)
01210 h_adce_bhakaon_equ[slab-1]->Fill((adce-ped_e[slab-1])*eq_e[slab-1]);
01211 if (adcp>1)
01212 h_adcp_bhakaon_equ[slab-1]->Fill((adcp-ped_p[slab-1])*eq_p[slab-1]);
01213 if (adce>1&&adcp>1){
01214 h_adc_bhakaon_sqr[slab-1]->Fill(sqrt((adce-ped_e[slab-1])*eq_e[slab-1]
01215 *(adcp-ped_p[slab-1])*eq_p[slab-1]));
01216 h_adc_bhakaon_rawsqr[slab-1]->Fill(sqrt(adce*adcp));
01217 }
01218 }
01219 }
01220 }
01221
01222 void FillHistosAll(){
01223
01224 TClonesArray *TofHits = fCurHdtEv->GetTofHits();
01225
01226 Int_t lay, slab;
01227 TFndHTof *cur_hit = 0;
01228 Int_t mult[2];
01229 GetMultiplicity(mult);
01230 for(Int_t ic=0;ic< TofHits->GetEntries(); ic++) {
01231 cur_hit = (TFndHTof *) ( TofHits->At(ic) );
01232
01233 cur_hit->GetLayer_Slab(lay, slab);
01234
01235
01236 if(lay==E_FIN_OUTER_LAYER) continue;
01237
01238 Bool_t both_adc = kFALSE;
01239 Bool_t both_tdcl = kFALSE;
01240 Bool_t both_tdch = kFALSE;
01241 if(cur_hit->GetBothAdc() == TFndHit::E_HIT_BOTH_CH ) both_adc = kTRUE;
01242 if(cur_hit->GetBothLowTdc() == TFndHit::E_HIT_BOTH_CH ) both_tdcl = kTRUE;
01243 if(cur_hit->GetBothHighTdc() == TFndHit::E_HIT_BOTH_CH ) both_tdch = kTRUE;
01244
01245
01246
01247
01248
01249
01250
01251 Double_t adce=cur_hit->GetAdcE();
01252 Double_t adcp=cur_hit->GetAdcP();
01253 Double_t sqradc;
01254 sqradc=sqrt((adce-ped_table_e[slab-1])*eq_table_e[slab-1]
01255 *(adcp-ped_table_p[slab-1])*eq_table_p[slab-1]);
01256
01257 if(both_tdcl && !both_tdch){
01258 if ((GetTrigType()==2||GetTrigType()==32)&&mult[0]==2){
01259 if (adce>1)
01260 h_adce_bha_equ_all[slab-1]->Fill((adce-ped_table_e[slab-1])*eq_table_e[slab-1]);
01261 if (adcp>1)
01262 h_adcp_bha_equ_all[slab-1]->Fill((adce-ped_table_p[slab-1])*eq_table_p[slab-1]);
01263 if (adce>1&&adcp>1)
01264 h_adc_bha_sqr_all[slab-1]->Fill(sqradc);
01265 }
01266 }
01267
01268 if(both_tdch){
01269 if (GetTrigType()==1&&mult[1]==2){
01270 if (adce>1)
01271 h_adce_kaon_equ_all[slab-1]->Fill((adce-ped_table_e[slab-1])*eq_table_e[slab-1]);
01272 if (adcp>1)
01273 h_adcp_kaon_equ_all[slab-1]->Fill((adcp-ped_table_p[slab-1])*eq_table_p[slab-1]);
01274 if (adce>1&&adcp>1){
01275 h_adc_kaon_sqr_all[slab-1]->Fill(sqradc);
01276 if (sqradc>KaonThreshold[slab-1]) NevOverThreshold[slab-1]++;
01277 }
01278 }
01279 }
01280 }
01281 }
01282
01283 Double_t FindPedestal(TH1F* histo){
01284 Int_t min_bin = 2;
01285 Int_t max_bin = 100;
01286 Double_t max_entry = -1.;
01287 Int_t max_entry_bin = -1;
01288 for (Int_t bin=min_bin; bin<max_bin; bin++){
01289 Double_t entry=histo->GetBinContent(bin);
01290 if (max_entry<entry){
01291 max_entry=entry;
01292 max_entry_bin=bin;
01293 }
01294 }
01295 return histo->GetBinCenter(max_entry_bin);
01296 }
01297
01298 Double_t FindBhaPeak(TH1F* histo, Int_t B){
01299
01300
01301
01302
01303
01304 Double_t fr[2];
01305 Double_t sv[4], pllo[4], plhi[4], fp[4], fpe[4];
01306
01307
01308 fr[0]=-20.;
01309 fr[1]=400.;
01310
01311
01312
01313
01314 pllo[0]=1.0; pllo[1]=10.; pllo[2]=1.0; pllo[3]=0.1;
01315
01316 plhi[0]=100.0; plhi[1]=150.; plhi[2]=100000000.0; plhi[3]=30.0;
01317 sv[0]=1.0; sv[1]=50.0; sv[2]=50000.0; sv[3]=4.0;
01318
01319
01320
01321
01322
01323 Double_t chisqr;
01324 Int_t ndf;
01325 if (B==1){
01326 TF1 *fitsnr = langaufit(histo,fr,sv,pllo,plhi,fp,fpe,&chisqr,&ndf);
01327 fitsnr->Draw("lsame");
01328 delete fitsnr;
01329 return fp[1];
01330 } else {
01331 histo->Fit("landau","Q0","",0,3000);
01332 TF1 *landau=(TF1*)gROOT->FindObject("landau");
01333 return landau->GetParameter(1);
01334 }
01335 }
01336
01337 Double_t FindKaonPeak(TH1F* histo){
01338 cout << "histo:Entry" << histo->GetEntries() << endl;
01339 if (histo->GetEntries()<100) {return -1;}
01340
01341 TH1F *histo_clone_old=(TH1F*)gROOT->FindObject("histo_clone");
01342 if (histo_clone_old) delete histo_clone_old;
01343 TH1F *histo_clone=(TH1F*)histo->Clone();
01344 histo_clone->SetName("histo_clone");
01345 cout << "pointer " << histo << " " << histo_clone << endl;
01346 histo_clone->Rebin(5);
01347
01348 histo->Fit("gaus","Q0","",300,1000);
01349 TF1 *gaus=(TF1*)gROOT->FindObject("gaus");
01350 Double_t center0=0., center2=0.;
01351 Double_t center=gaus->GetParameter(1);
01352 cout << "GAUS" << gaus << endl;
01353
01354 Int_t count=0;
01355 TF1* landau=(TF1*)gROOT->FindObject("landau");
01356 do {
01357 if (count>0) center2=center0;
01358 center0=center;
01359 histo_clone->Fit("landau","Q0","",center*0.75,1000);
01360 center=landau->GetParameter(1);
01361 cout << center2 << " --> " << center0 << " -- > " << center << endl;
01362 if (center2==center){
01363 cout << "the fit result is oscillating..." << endl;
01364 center=(center+center0)/2.;
01365 }
01366 if (center>1000) center=1000;
01367 count++;
01368 } while (fabs(center-center0)>0.1&&count<20);
01369 return center;
01370 }
01371
01372 void EvaluatePed(){
01373 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
01374 ped_e[sl]=FindPedestal(h_adce_ped[sl]);
01375 ped_p[sl]=FindPedestal(h_adcp_ped[sl]);
01376 }
01377 }
01378
01379 void EvaluateEqu(Int_t B){
01380 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
01381 if (B==1){
01382 if (h_adce_bha_subtr[sl]->GetEntries()>500){
01383 bhapeak_e[sl]=FindBhaPeak(h_adce_bha_subtr[sl],B);
01384 } else {
01385 bhapeak_e[sl]=FindBhaPeak(h_adce_bha_subtr_nosel[sl],B);
01386 }
01387 if (h_adcp_bha_subtr[sl]->GetEntries()>500){
01388 bhapeak_p[sl]=FindBhaPeak(h_adcp_bha_subtr[sl],B);
01389 } else {
01390 bhapeak_p[sl]=FindBhaPeak(h_adcp_bha_subtr_nosel[sl],B);
01391 }
01392
01393
01394 } else {
01395 bhapeak_e[sl]=FindBhaPeak(h_adce_kaon_subtr_nosel[sl],B);
01396 bhapeak_p[sl]=FindBhaPeak(h_adcp_kaon_subtr_nosel[sl],B);
01397 }
01398 }
01399 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
01400 eq_e[sl]= 50.0/bhapeak_e[sl];
01401 eq_p[sl]= 50.0/bhapeak_p[sl];
01402 }
01403 }
01404
01405 void EvaluateKaonPeak(){
01406 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
01407 cout << h_adce_kaon_equ[sl]->GetEntries() << endl;
01408 kaonpeak_e[sl]=FindKaonPeak(h_adce_kaon_equ[sl]);
01409 kaonpeak_p[sl]=FindKaonPeak(h_adcp_kaon_equ[sl]);
01410 }
01411 }
01412 void EventLoopPed(const Int_t &nevs){
01413
01414 Int_t entries = fHdtTree->GetEntries();
01415
01416 Int_t cur_ev = 0;
01417 while(1){
01418 if(cur_ev >= entries){
01419 gROOT->Info("EventLoop","run completed");
01420 break;
01421 }
01422 if(nevs != -1 && cur_ev >= nevs){
01423 gROOT->Info("EventLoop","requested number of events reached");
01424 break;
01425 }
01426
01427 fHdtTree->GetEntry(cur_ev);
01428
01429 FillHistosPed();
01430 if(cur_ev%3000 == 0 ) cout << "cur_ev: " << cur_ev << endl;
01431
01432
01433 cur_ev++;
01434 }
01435 }
01436
01437 void EventLoop(const Int_t &nevs){
01438
01439 Int_t entries = fHdtTree->GetEntries();
01440
01441 Int_t cur_ev = 0;
01442 while(1){
01443 if(cur_ev >= entries){
01444 gROOT->Info("EventLoop","run completed");
01445 break;
01446 }
01447 if(nevs != -1 && cur_ev >= nevs){
01448 gROOT->Info("EventLoop","requested number of events reached");
01449 break;
01450 }
01451
01452 fHdtTree->GetEntry(cur_ev);
01453
01454 FillHistos();
01455 if(cur_ev%3000 == 0 ) cout << "cur_ev: " << cur_ev << endl;
01456
01457
01458 cur_ev++;
01459 }
01460 }
01461
01462 void EventLoopEqu(const Int_t &nevs){
01463
01464 Int_t entries = fHdtTree->GetEntries();
01465
01466 Int_t cur_ev = 0;
01467 while(1){
01468 if(cur_ev >= entries){
01469 gROOT->Info("EventLoop","run completed");
01470 break;
01471 }
01472 if(nevs != -1 && cur_ev >= nevs){
01473 gROOT->Info("EventLoop","requested number of events reached");
01474 break;
01475 }
01476
01477 fHdtTree->GetEntry(cur_ev);
01478
01479 FillHistosEqu();
01480 if(cur_ev%3000 == 0 ) cout << "cur_ev: " << cur_ev << endl;
01481
01482
01483 cur_ev++;
01484 }
01485 }
01486
01487 void EventLoopEquAll(const Int_t &nevs){
01488
01489 Int_t entries = fHdtTree->GetEntries();
01490
01491 Int_t cur_ev = 0;
01492 while(1){
01493 if(cur_ev >= entries){
01494 gROOT->Info("EventLoop","run completed");
01495 break;
01496 }
01497 if(nevs != -1 && cur_ev >= nevs){
01498 gROOT->Info("EventLoop","requested number of events reached");
01499 break;
01500 }
01501
01502 fHdtTree->GetEntry(cur_ev);
01503
01504 FillHistosEqu();
01505 FillHistosAll();
01506 if(cur_ev%3000 == 0 ) cout << "cur_ev: " << cur_ev << endl;
01507
01508
01509 cur_ev++;
01510 }
01511 }
01512
01513 void SaveHistos(const TString &fname){
01514 TFile *fOutFile = new TFile(fname,"RECREATE");
01515 h_LowBhaMult->Write();
01516 h_LowHypMult->Write();
01517 h_HighBhaMult->Write();
01518 h_HighHypMult->Write();
01519
01520 for(Int_t sl=0;sl<K_N_TOFINO_SLABS;sl++ ){
01521 h_adce[sl]->Write();
01522 h_adce_ped[sl]->Write();
01523 h_adce_bha[sl]->Write();
01524 h_adce_kaon[sl]->Write();
01525 h_adce_bha_nosel[sl]->Write();
01526 h_adce_kaon_nosel[sl]->Write();
01527 h_adce_bhakaon[sl]->Write();
01528 h_adce_subtr[sl]->Write();
01529 h_adce_ped_subtr[sl]->Write();
01530 h_adce_bha_subtr[sl]->Write();
01531 h_adce_kaon_subtr[sl]->Write();
01532 h_adce_bha_subtr_nosel[sl]->Write();
01533 h_adce_kaon_subtr_nosel[sl]->Write();
01534 h_adce_bhakaon_subtr[sl]->Write();
01535 h_adce_equ[sl]->Write();
01536 h_adce_ped_equ[sl]->Write();
01537 h_adce_bha_equ[sl]->Write();
01538 h_adce_kaon_equ[sl]->Write();
01539 h_adce_bha_equ_nosel[sl]->Write();
01540 h_adce_kaon_equ_nosel[sl]->Write();
01541 h_adce_bhakaon_equ[sl]->Write();
01542 h_adcp[sl]->Write();
01543 h_adcp_ped[sl]->Write();
01544 h_adcp_bha[sl]->Write();
01545 h_adcp_kaon[sl]->Write();
01546 h_adcp_bha_nosel[sl]->Write();
01547 h_adcp_kaon_nosel[sl]->Write();
01548 h_adcp_bhakaon[sl]->Write();
01549 h_adcp_subtr[sl]->Write();
01550 h_adcp_ped_subtr[sl]->Write();
01551 h_adcp_bha_subtr[sl]->Write();
01552 h_adcp_kaon_subtr[sl]->Write();
01553 h_adcp_bha_subtr_nosel[sl]->Write();
01554 h_adcp_kaon_subtr_nosel[sl]->Write();
01555 h_adcp_bhakaon_subtr[sl]->Write();
01556 h_adcp_equ[sl]->Write();
01557 h_adcp_ped_equ[sl]->Write();
01558 h_adcp_bha_equ[sl]->Write();
01559 h_adcp_kaon_equ[sl]->Write();
01560 h_adcp_bha_equ_nosel[sl]->Write();
01561 h_adcp_kaon_equ_nosel[sl]->Write();
01562 h_adcp_bhakaon_equ[sl]->Write();
01563 h_adc_bha_sqr[sl]->Write();
01564 h_adc_kaon_sqr[sl]->Write();
01565 h_adc_bhakaon_sqr[sl]->Write();
01566 h_adc_bha_rawsqr[sl]->Write();
01567 h_adc_kaon_rawsqr[sl]->Write();
01568 h_adc_bhakaon_rawsqr[sl]->Write();
01569 h_lowtdce[sl]->Write();
01570 h_lowtdcp[sl]->Write();
01571 h_hightdce[sl]->Write();
01572 h_hightdcp[sl]->Write();
01573 }
01574
01575
01576
01577
01578 fCalibTree->Fill();
01579 fCalibTree->Write();
01580
01581 fOutFile->Close();
01582 delete fOutFile;
01583 fOutFile = 0;
01584
01585 }
01586
01587 void SaveProfiles(const TString &fname){
01588 TFile *fOutFile = new TFile(fname,"RECREATE");
01589
01590 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
01591 p_ped_e[sl]->Write();
01592 p_ped_p[sl]->Write();
01593 p_bha_e[sl]->Write();
01594 p_bha_p[sl]->Write();
01595 p_kaon_e[sl]->Write();
01596 p_kaon_p[sl]->Write();
01597 p_eq_e[sl]->Write();
01598 p_eq_p[sl]->Write();
01599 p_EQbha_e[sl]->Write();
01600 p_EQbha_p[sl]->Write();
01601
01602 p_EQkaon_e[sl]->Write();
01603 p_EQkaon_p[sl]->Write();
01604
01605 p_EQ_e[sl]->Write();
01606 p_EQ_p[sl]->Write();
01607 p_OverKaonThreshold[sl]->Write();
01608
01609 h_adce_bha_equ_all[sl]->Write();
01610 h_adcp_bha_equ_all[sl]->Write();
01611 h_adc_bha_sqr_all[sl]->Write();
01612 h_adce_kaon_equ_all[sl]->Write();
01613 h_adcp_kaon_equ_all[sl]->Write();
01614 h_adc_kaon_sqr_all[sl]->Write();
01615 }
01616
01617 fOutFile->Close();
01618 delete fOutFile;
01619 fOutFile = 0;
01620
01621 }
01622
01623 Int_t GetRunInfo(TString runtype,Int_t runnum){
01624
01625 TString run_path;
01626 if (runnum>=7000){
01627 run_path.Form("%s/%s.hdt.root",ExpandPathName("$FND_HDT").Data(),
01628 FROOT::BuildRunName(runtype,runnum,kTRUE).Data());
01629 } else {
01630 run_path.Form("%s_v9.0/%s.hdt.root",ExpandPathName("$FND_HDT").Data(),
01631 FROOT::BuildRunName(runtype,runnum,kFALSE).Data());
01632 }
01633
01634 TFile *hdt_file = new TFile(run_path);
01635 if (!hdt_file) return -1;
01636
01637
01638 TFndGenInfo *geninfo = (TFndGenInfo *)hdt_file->Get("TFndGenInfo");
01639
01640
01641
01642 TDatime d = geninfo->GetDateTime();
01643
01644 return (Int_t) d.Convert();
01645
01646 }
01647
01648 void FillTofFromHdt(const TString &runtype,const Int_t &run_num_start,const Int_t &run_num_stop,const TString &root_filename,const Int_t &nevs, Int_t B){
01649
01650 gStyle->SetOptFit(1);
01651
01652 Int_t start_run=run_num_start, stop_run=run_num_stop;
01653 fCalibTree = new TTree("CalibTree","Calibreatio Tree");
01654 fCalibTree->Branch("StartRun",&start_run,"/I");
01655 fCalibTree->Branch("StartTime",&start_unixtime,"/I");
01656 fCalibTree->Branch("StopRun",&stop_run,"/I");
01657 fCalibTree->Branch("StopTime",&stop_unixtime,"/I");
01658 fCalibTree->Branch("PedE",ped_e,"[12]/F");
01659 fCalibTree->Branch("PedP",ped_p,"[12]/F");
01660 fCalibTree->Branch("EqE",eq_e,"[12]/F");
01661 fCalibTree->Branch("EqP",eq_p,"[12]/F");
01662
01663 if (root_filename!=""){
01664 start_unixtime=GetRunInfo(runtype, run_num_start);
01665
01666 stop_unixtime=GetRunInfo(runtype, run_num_stop);
01667
01668 DeclareHistos();
01669 }
01670
01671
01672 for(Int_t cur_run=run_num_start; cur_run <=run_num_stop ; cur_run++){
01673 cout << "Filling from run \"" << runtype.Data() << "\" " << cur_run << endl;
01674 CurrentRunNumber = cur_run;
01675 if(OpenHdtFile(runtype,cur_run) !=0) continue;
01676 if(LoadHdtTree() != 0) continue;
01677
01678 EventLoopPed(nevs);
01679 CloseHdtFile();
01680 }
01681
01682 EvaluatePed();
01683
01684
01685 for(Int_t cur_run=run_num_start; cur_run <=run_num_stop ; cur_run++){
01686 cout << "Filling from run \"" << runtype.Data() << "\" " << cur_run << endl;
01687 CurrentRunNumber = cur_run;
01688 if(OpenHdtFile(runtype,cur_run) !=0) continue;
01689 if(LoadHdtTree() != 0) continue;
01690
01691 EventLoop(nevs);
01692 CloseHdtFile();
01693 }
01694
01695 EvaluateEqu(B);
01696
01697
01698 for(Int_t cur_run=run_num_start; cur_run <=run_num_stop ; cur_run++){
01699 cout << "Filling from run \"" << runtype.Data() << "\" " << cur_run << endl;
01700 CurrentRunNumber = cur_run;
01701 if(OpenHdtFile(runtype,cur_run) !=0) continue;
01702 if(LoadHdtTree() != 0) continue;
01703
01704 if (root_filename!=""){
01705 EventLoopEqu(nevs);}
01706 else {
01707 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
01708 NevOverThreshold[sl]=0;
01709 }
01710 EventLoopEquAll(nevs);
01711 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
01712 cout << NevOverThreshold[sl] << "***" << h_adc_kaon_sqr[sl]->GetEntries() << endl;
01713 if (h_adc_kaon_sqr[sl]->GetEntries()>0){
01714 p_OverKaonThreshold[sl]->Fill(cur_run, NevOverThreshold[sl]/h_adc_kaon_sqr[sl]->GetEntries());
01715 }
01716 }
01717 }
01718 CloseHdtFile();
01719 }
01720 EvaluateKaonPeak();
01721
01722
01723
01724
01725
01726
01727
01728 if (root_filename!="") SaveHistos(root_filename);
01729
01730 }
01731
01732 void FillTofFromHdt(const TString &runtype,const Int_t &run_num_start,const Int_t &run_num_stop,const TString &root_filename,const Int_t &nevs){
01733 Int_t B=1;
01734 if (runtype=="COSM") {cout << "By default B=0 for COSM run" << endl; B=0;}
01735 FillTofFromHdt(runtype, run_num_start, run_num_stop, root_filename, nevs, B);
01736 }
01737
01738
01739 void FillTofFromHdt_TS(const TString &runtype,const Int_t &run_num){
01740 FillTofFromHdt(runtype, run_num, run_num, "", -1, 1);
01741 }
01742
01743 void TofinoStability(const TString &runtype,const Int_t &run_num_start,const Int_t &run_num_stop,const TString &root_filename){
01744
01745 DeclareHistos();
01746 DeclareProfiles(run_num_start, run_num_stop);
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769
01770
01771
01772
01773 for (Int_t run_num=run_num_start; run_num<=run_num_stop; run_num++){
01774 ResetHistos();
01775 cout << "****" << h_adce[0]->GetEntries() << endl;
01776 FillTofFromHdt_TS(runtype, run_num);
01777 cout << "****" << h_adce[0]->GetEntries() << endl;
01778 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
01779
01780
01781
01782
01783 p_ped_e[sl]->Fill(run_num, ped_e[sl]);
01784 p_ped_p[sl]->Fill(run_num, ped_p[sl]);
01785
01786 cout << "Run : " << run_num << " Slab : " << sl << endl;
01787 cout << "**Number of Bhabha events = " << h_adce_bha[sl]->GetEntries() << endl;
01788 cout << "**Number of K+K- events = " << h_adce_kaon[sl]->GetEntries() << endl;
01789
01790 if (ped_e[sl]>0&&h_adce_bha[sl]->GetEntries()>500){
01791
01792
01793
01794
01795
01796 p_bha_e[sl]->Fill(run_num, ped_e[sl]+bhapeak_e[sl]);
01797 p_eq_e[sl]->Fill(run_num, ped_e[sl]+bhapeak_e[sl]);
01798 }
01799
01800 if (ped_p[sl]>0&&h_adcp_bha[sl]->GetEntries()>500){
01801
01802
01803
01804
01805
01806 p_bha_p[sl]->Fill(run_num, ped_p[sl]+bhapeak_p[sl]);
01807 p_eq_p[sl]->Fill(run_num, ped_p[sl]+bhapeak_p[sl]);
01808 }
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823 if (ped_e[sl]>0&&kaonpeak_e[sl]>0){
01824
01825
01826
01827
01828
01829 p_kaon_e[sl]->Fill(run_num, ped_e[sl]+kaonpeak_e[sl]/eq_e[sl]);
01830 }
01831
01832 if (ped_p[sl]>0&&kaonpeak_p[sl]>0){
01833
01834
01835
01836 p_kaon_p[sl]->Fill(run_num, ped_p[sl]+kaonpeak_p[sl]/eq_p[sl]);
01837 }
01838 }
01839 }
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932 SaveProfiles(root_filename);
01933 }
01934
01935 void TofinoStability(const TString &runtype,const Int_t &run_num_start,const Int_t &run_num_stop, const TString &calib_filename, const TString &root_filename){
01936
01937
01938 KaonThreshold[0]=350;
01939 KaonThreshold[1]=400;
01940 KaonThreshold[2]=400;
01941 KaonThreshold[3]=450;
01942 KaonThreshold[4]=470;
01943 KaonThreshold[5]=590;
01944 KaonThreshold[6]=500;
01945 KaonThreshold[7]=500;
01946 KaonThreshold[8]=500;
01947 KaonThreshold[9]=300;
01948 KaonThreshold[10]=360;
01949 KaonThreshold[11]=400;
01950
01951 Int_t start_time, stop_time;
01952 TString temp1, temp2, temp3, temp4, temp5;
01953 TString temp6, temp7, temp8, temp9, temp10;
01954
01955 std::fstream cFstrm (calib_filename.Data(), std::ios::in);
01956 if (cFstrm.fail()) return;
01957
01958 Int_t line=-1;
01959 Char_t buff[1000];
01960 while (!cFstrm.eof()){
01961 cFstrm.getline(buff, 1000);
01962 line++;
01963 }
01964 cout << "LINE=" << line << endl;
01965 cFstrm.clear();
01966 cFstrm.seekg(0, std::ios::beg);
01967 cout << cFstrm.tellp() << " " << cFstrm.tellg() << endl;
01968
01969 Int_t start_run[line], stop_run[line];
01970 Float_t PED_e[line][K_N_TOFINO_SLABS], PED_p[line][K_N_TOFINO_SLABS];
01971 Float_t EQ_e[line][K_N_TOFINO_SLABS], EQ_p[line][K_N_TOFINO_SLABS];
01972
01973 for (Int_t i=0; i<line; i++){
01974 cFstrm >> start_run[i] >> start_time >> temp1 >> temp2 >> temp3 >> temp4 >> temp5
01975 >> stop_run[i] >> stop_time >> temp6 >> temp7 >> temp8 >> temp9 >> temp10;
01976 cout << start_run[i] << " " << stop_run[i] << endl;
01977 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
01978 cFstrm >> PED_e[i][sl];
01979 }
01980 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
01981 cFstrm >> PED_p[i][sl];
01982 }
01983 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
01984 cFstrm >> EQ_e[i][sl];
01985 }
01986 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
01987 cFstrm >> EQ_p[i][sl];
01988 }
01989 }
01990
01991 DeclareHistos();
01992 DeclareProfiles(run_num_start, run_num_stop);
01993
01994 for (Int_t run_num=run_num_start; run_num<=run_num_stop; run_num++){
01995 ResetHistos();
01996 cout << "****" << h_adce[0]->GetEntries() << endl;
01997
01998
01999 Int_t i;
02000 for (i=0; i<line; i++){
02001 cout << i << " " << run_num << " " << start_run[i] << " " << stop_run[i] << endl;
02002 if (run_num>=start_run[i]&&run_num<=stop_run[i]) break;
02003 }
02004 if (i==line) continue;
02005 cout << i << endl;
02006 cout << "Use the calibration table adjusted between run " <<
02007 start_run[i] << " and " << stop_run[i] << endl;
02008 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
02009 ped_table_e[sl]=PED_e[i][sl];
02010 ped_table_p[sl]=PED_p[i][sl];
02011 eq_table_e[sl]=EQ_e[i][sl];
02012 eq_table_p[sl]=EQ_p[i][sl];
02013 }
02014 FillTofFromHdt_TS(runtype, run_num);
02015 cout << "****" << h_adce[0]->GetEntries() << endl;
02016 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
02017 p_ped_e[sl]->Fill(run_num, ped_e[sl]);
02018 p_ped_p[sl]->Fill(run_num, ped_p[sl]);
02019
02020 cout << "Run : " << run_num << " Slab : " << sl << endl;
02021 cout << "**Number of Bhabha events = " << h_adce_bha[sl]->GetEntries() << endl;
02022 cout << "**Number of K+K- events = " << h_adce_kaon[sl]->GetEntries() << endl;
02023
02024 if (ped_e[sl]>0&&h_adce_bha[sl]->GetEntries()>500){
02025 p_bha_e[sl]->Fill(run_num, ped_e[sl]+bhapeak_e[sl]);
02026 p_EQbha_e[sl]->Fill(run_num, (ped_e[sl]+bhapeak_e[sl]-PED_e[i][sl])*EQ_e[i][sl]);
02027 p_eq_e[sl]->Fill(run_num, eq_e[sl]);
02028 }
02029
02030 if (ped_p[sl]>0&&h_adcp_bha[sl]->GetEntries()>500){
02031 p_bha_p[sl]->Fill(run_num, ped_p[sl]+bhapeak_p[sl]);
02032 p_EQbha_p[sl]->Fill(run_num, (ped_p[sl]+bhapeak_p[sl]-PED_p[i][sl])*EQ_p[i][sl]);
02033 p_eq_p[sl]->Fill(run_num, eq_p[sl]);
02034 }
02035
02036 if (ped_e[sl]>0&&kaonpeak_e[sl]>0){
02037 p_kaon_e[sl]->Fill(run_num, ped_e[sl]+kaonpeak_e[sl]/eq_e[sl]);
02038 p_EQkaon_e[sl]->Fill(run_num, (ped_e[sl]+kaonpeak_e[sl]/eq_e[sl]-PED_e[i][sl])*EQ_e[i][sl]);
02039 }
02040
02041 if (ped_p[sl]>0&&kaonpeak_p[sl]>0){
02042 p_kaon_p[sl]->Fill(run_num, ped_p[sl]+kaonpeak_p[sl]/eq_p[sl]);
02043 p_EQkaon_p[sl]->Fill(run_num, (ped_p[sl]+kaonpeak_p[sl]/eq_p[sl]-PED_p[i][sl])*EQ_p[i][sl]);
02044 }
02045 p_EQ_e[sl]->Fill(run_num, EQ_e[i][sl]);
02046 p_EQ_p[sl]->Fill(run_num, EQ_p[i][sl]);
02047
02048 }
02049 }
02050 SaveProfiles(root_filename);
02051 }
02052
02053 void MakePeakTable(const TString &runtype,const Int_t &run_num_start,const Int_t &run_num_stop, const TString &directory){
02054
02055 DeclareHistos();
02056 DeclareProfiles(run_num_start, run_num_stop);
02057
02058 for (Int_t run_num=run_num_start; run_num<=run_num_stop; run_num++){
02059 ResetHistos();
02060 cout << "****" << h_adce[0]->GetEntries() << endl;
02061
02062 FillTofFromHdt_TS(runtype, run_num);
02063 cout << "****" << h_adce[0]->GetEntries() << endl;
02064
02065 TString table_filename="./";
02066 table_filename += directory;
02067 table_filename += runtype;
02068 table_filename += "_";
02069 table_filename += run_num;
02070 table_filename += ".txt";
02071
02072 std::fstream cFstrm (table_filename.Data(), std::ios::out);
02073 if (cFstrm.fail()) return;
02074
02075 for (Int_t sl=0; sl<K_N_TOFINO_SLABS; sl++){
02076 cFstrm << ped_e[sl] << " " << ped_p[sl] << " "
02077 << h_adce_bha[sl]->GetEntries() << " " << ped_e[sl]+bhapeak_e[sl] << " "
02078 << h_adcp_bha[sl]->GetEntries() << " " << ped_p[sl]+bhapeak_p[sl] << " "
02079 << h_adce_kaon[sl]->GetEntries() << " " << ped_e[sl]+kaonpeak_e[sl]/eq_e[sl] << " "
02080 << h_adcp_kaon[sl]->GetEntries() << " " << ped_p[sl]+kaonpeak_p[sl]/eq_p[sl] << " "
02081 << eq_e[sl] << " " << eq_p[sl] << std::endl;
02082 } }
02083 }