void raw_dumps (void) { Int_t runno=299; Int_t minevents=2; // ignore first two event on file Int_t maxevents=minevents+10000; char string[256]; sprintf(string,"%s%d%s","simple_",runno,".root"); printf ("Filename = %s\n",string); // TFile f1("fcal_395.root"); TFile *f1 = new TFile(string); TTree *t1= (TTree*)f1->Get("tree1"); Int_t nevent = t1->GetEntries(); cout << "Events on file=" << nevent << endl; if (maxevents > nevent-1) maxevents = nevent-1; // ignore last event in file cout << "Events to process=" << maxevents-minevents << endl; const int window_size = 100; Float_t x_min = 0.5; Float_t x_max = window_size + 0.5; TBranch *br_fadc_raw=t1->GetBranch("fadc_raw"); Int_t fadc_raw[2][16][window_size]; br_fadc_raw->SetAddress(&fadc_raw); // set plotting defaults gStyle->SetPalette(1,0); gStyle->SetOptStat(kTRUE); gStyle->SetPadRightMargin(0.15); gStyle->SetPadLeftMargin(0.15); gStyle->SetPadBottomMargin(0.15); gStyle->SetOptStat(111111); gStyle->SetOptFit(1111); gStyle->SetTitleFontSize(0.08); #if 1 Int_t trig_ch = 30; Float_t tdc_res = 0.058; Int_t trig_time; TBranch *br_nhit_tdc = t1->GetBranch("nhit_tdc"); TBranch *br_tdc_ch = t1->GetBranch("tdc_ch"); TBranch *br_tdc_time = t1->GetBranch("tdc_time"); Int_t nhit_tdc; Int_t tdc_ch[64]; Int_t tdc_time[64]; br_nhit_tdc->SetAddress(&nhit_tdc); br_tdc_ch->SetAddress(&tdc_ch); br_tdc_time->SetAddress(&tdc_time); TH1F *htdc_mult = new TH1F("TDC mult","TDC mult",32,-0.5,31.5); TH1F *htdc_dt[32]; for(Int_t ch = 0; ch < 32; ch++){ char title[50]; // sprintf(title,"Ttrig - Tsig ch%d",ch); // htdc_dt[ch] = new TH1F(title,title,2000,-100.,100.); sprintf(title," ch%d",ch); // htdc_dt[ch] = new TH1F(title,title,2000,0.,4000.); htdc_dt[ch] = new TH1F(title,title,200,-10,190.); } TH1F *ratio12 = new TH1F("ratio12","Ratio ch2/ch1 in peak",200,0,4); TH2F *ch1ch2 = new TH2F("ch1ch2","Ch1 vs Ch2",100,0,4000,100,0,4000); #endif TH1F *hfadc_raw[2][16]; TH1F *hfadc_sum[2][16]; TH1F *hfadc_pedestals[2][16]; for(Int_t bd = 0; bd < 2; bd++){ for(Int_t ch = 0; ch < 16; ch++){ char title[30]; sprintf(title,"fadc_raw%d_ch%d",bd,ch); // hfadc_raw[bd][ch] = new TH1F(title,title,window_size,-100.,9900.); // max signal hfadc_raw[bd][ch] = new TH1F(title,title,window_size,0,50); // ringing sprintf(title,"fadc_pedestal%d_ch%d",bd,ch); hfadc_pedestals[bd][ch] = new TH1F(title,title,window_size,400.,600.); sprintf(title,"fadc_sum%d_ch%d",bd,ch); // hfadc_sum[bd][ch] = new TH1F(title,title,window_size,-100,49900); // max signal hfadc_sum[bd][ch] = new TH1F(title,title,window_size,-1000,1000); // ringing } } TCanvas *c1 = new TCanvas("c1","FADC SLOT 14",820.,820.); c1->SetLogx(); c1->Divide(4,4); TCanvas *c2 = new TCanvas("c2","FADC SLOT 15",820.,820.); c2->Divide(4,4); TCanvas *c3 = new TCanvas("TDC hit multiplicity","TDC hit multiplicity",300.,300.); // TCanvas *c4 = new TCanvas("c4","TDC T_trig - T_hit (ch 0-15)",820.,820.); TCanvas *c4 = new TCanvas("c4","TDC T_hit (ch 0-11)",820.,820.); c4->Divide(4,4); // TCanvas *c5 = new TCanvas("c5","TDC T_trig - T_hit (ch 16-31)",820.,820.); TCanvas *c5 = new TCanvas("c5","TDC T_hit (ch 16-27)",820.,820.); c5->Divide(4,4); TCanvas *c6 = new TCanvas("c6","Ch1 Fit",820.,820.); TCanvas *c7 = new TCanvas("c7","Ratio Ch2/Ch1 in peak",820.,820.); c7 -> Divide(2,1); TCanvas *c8 = new TCanvas("c8","Pedestals SLOT 14",820.,820.); c8->Divide(4,4); TCanvas *c9 = new TCanvas("c9","Pedestals SLOT 15",820.,820.); c9->Divide(4,4); TCanvas *c11 = new TCanvas("c11","FADC SUM SLOT 14",820.,820.); c11->Divide(4,4); TCanvas *c12 = new TCanvas("c12","FADC SUm SLOT 15",820.,820.); c12->Divide(4,4); for(Int_t i = 0; i < maxevents; i++){ if (i >= minevents) { // ignore events below minevents trig_time=0; br_fadc_raw->GetEntry(i); br_nhit_tdc->GetEntry(i); br_tdc_ch->GetEntry(i); br_tdc_time->GetEntry(i); // find pedestals first Int_t pedwindow=15; Double_t fadc_pedestals[2][16]; for(Int_t bd = 0; bd < 2; bd++){ for(Int_t ch = 0; ch < 16; ch++){ Float_t pedestal = 0; for(Int_t samp = 1; samp < pedwindow; samp++){ pedestal += fadc_raw[bd][ch][samp]; } fadc_pedestals[bd][ch] = pedestal/(pedwindow-1); hfadc_pedestals[bd][ch]->Fill(pedestal/(pedwindow-1)); } } Double_t ch1max=1; Double_t ch2max=1; Double_t ratio=0; for(Int_t bd = 0; bd < 2; bd++){ // cout << " Bd = " << bd << endl; for(Int_t ch = 0; ch < 16; ch++){ // find peak value Float_t sample_max = 0; // max value Float_t sample_sum = 0; // sum for(Int_t samp = 1; samp < window_size; samp++){ if (fadc_raw[bd][ch][samp] > sample_max) sample_max = fadc_raw[bd][ch][samp]; sample_sum += fadc_raw[bd][ch][samp] - fadc_pedestals[bd][ch]; // hfadc_raw[bd][ch]->Fill(float(samp),float(fadc_raw[bd][ch][samp]),1.); } if (ch == 1 && bd==0) ch1max = sample_max; if (ch == 2 && bd==1) ch2max = sample_max; // cout << " event=" << i << " bd, ch, sample_sum=" << bd << " " << ch << " " << sample_sum << endl; hfadc_raw[bd][ch]->Fill(sample_max-fadc_pedestals[bd][ch]); hfadc_sum[bd][ch]->Fill(sample_sum); } // plot ratio of opposite ends of the same channel for pulses in the peak region if (bd == 1) { if (ch1max > 1000 && ch1max < 3000 && ch2max > 1500 && ch2max < 4000) { ratio = (ch2max-fadc_pedestals[1][2])/(ch1max-fadc_pedestals[0][1]); ratio12 -> Fill (ratio); // cout << " ratio=" << ratio << endl; } // do not make cuts on the scatter plot ch1ch2->Fill(ch2max-fadc_pedestals[1][2],ch1max-fadc_pedestals[0][1]); } } if(nhit_tdc > 0){ for(Int_t n = 0; n < nhit_tdc; n++){ // cout << tdc_time[n] << " " << tdc_ch[n] << endl; if(tdc_time[n] > 0){ htdc_mult->Fill(Float_t(tdc_ch[n])); // htdc_dt[tdc_ch[n]]->Fill(Float_t(tdc_time[n])*tdc_res); if(tdc_ch[n] == trig_ch) trig_time = tdc_time[n]; } } } // histogram times relative to trigger time if(trig_time > 0){ for(Int_t n = 0; n < nhit_tdc; n++){ if(tdc_time[n] > 0){ Float_t dt = Float_t(trig_time- tdc_time[n])*tdc_res; // cout << dt << " " << tdc_ch[n] << endl; htdc_dt[tdc_ch[n]]->Fill(dt); } } } elseif (nhit_tdc > 0) { cout << " *** Trig time =" << trig_time << " for event=" << i << endl; } } } // end of event loop // TDC cout << " F1TDC nhits = " << nhit_tdc << endl; c1->cd(1); c1_1->SetLogy(); c1_1->SetGridx(); c1_1->SetGridy(); hfadc_raw[0][0]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][0]->Draw("histo"); c1->cd(2); c1_2->SetLogy(); c1_2->SetGridx(); c1_2->SetGridy(); hfadc_raw[0][1]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][1]->Draw("histo"); c1->cd(3); c1_3->SetLogy(); c1_3->SetGridx(); c1_3->SetGridy(); hfadc_raw[0][2]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][2]->Draw("histo"); c1->cd(4); c1_4->SetLogy(); c1_4->SetGridx(); c1_4->SetGridy(); hfadc_raw[0][3]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][3]->Draw("histo"); c1->cd(5); c1_5->SetLogy(); c1_5->SetGridx(); c1_5->SetGridy(); hfadc_raw[0][4]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][4]->Draw("histo"); c1->cd(6); c1_6->SetLogy(); c1_6->SetGridx(); c1_6->SetGridy(); hfadc_raw[0][5]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][5]->Draw("histo"); c1->cd(7); c1_7->SetLogy(); c1_7->SetGridx(); c1_7->SetGridy(); hfadc_raw[0][6]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][6]->Draw("histo"); c1->cd(8); c1_8->SetLogy(); c1_8->SetGridx(); c1_8->SetGridy(); hfadc_raw[0][7]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][7]->Draw("histo"); c1->cd(9); c1_9->SetLogy(); c1_9->SetGridx(); c1_9->SetGridy(); hfadc_raw[0][8]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][8]->Draw("histo"); c1->cd(10); c1_10->SetLogy(); c1_10->SetGridx(); c1_10->SetGridy(); hfadc_raw[0][9]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][9]->Draw("histo"); c1->cd(11); c1_11->SetLogy(); c1_11->SetGridx(); c1_11->SetGridy(); hfadc_raw[0][10]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][10]->Draw("histo"); c1->cd(12); c1_12->SetLogy(); c1_12->SetGridx(); c1_12->SetGridy(); hfadc_raw[0][11]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][11]->Draw("histo"); c1->cd(13); c1_13->SetLogy(); c1_13->SetGridx(); c1_13->SetGridy(); hfadc_raw[0][12]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][12]->Draw("histo"); c1->cd(14); c1_14->SetLogy(); c1_14->SetGridx(); c1_14->SetGridy(); hfadc_raw[0][13]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][13]->Draw("histo"); c1->cd(15); c1_15->SetLogy(); c1_15->SetGridx(); c1_15->SetGridy(); hfadc_raw[0][14]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][14]->Draw("histo"); c1->cd(16); c1_16->SetLogy(); c1_16->SetGridx(); c1_16->SetGridy(); hfadc_raw[0][15]->GetXaxis()->SetNdivisions(505); hfadc_raw[0][15]->Draw("histo"); c1->Update(); #if 1 c2->cd(1); c2_1->SetLogy(); c2_1->SetGridx(); c2_1->SetGridy(); hfadc_raw[1][0]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][0]->Draw("histo"); c2->cd(2); c2_2->SetLogy(); c2_2->SetGridx(); c2_2->SetGridy(); hfadc_raw[1][1]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][1]->Draw("histo"); c2->cd(3); c2_3->SetLogy(); c2_3->SetGridx(); c2_3->SetGridy(); hfadc_raw[1][2]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][2]->Draw("histo"); c2->cd(4); c2_4->SetLogy(); c2_4->SetGridx(); c2_4->SetGridy(); hfadc_raw[1][3]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][3]->Draw("histo"); c2->cd(5); c2_5->SetLogy(); c2_5->SetGridx(); c2_5->SetGridy(); hfadc_raw[1][4]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][4]->Draw("histo"); c2->cd(6); c2_6->SetLogy(); c2_6->SetGridx(); c2_6->SetGridy(); hfadc_raw[1][5]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][5]->Draw("histo"); c2->cd(7); c2_7->SetLogy(); c2_7->SetGridx(); c2_7->SetGridy(); hfadc_raw[1][6]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][6]->Draw("histo"); c2->cd(8); c2_8->SetLogy(); c2_8->SetGridx(); c2_8->SetGridy(); hfadc_raw[1][7]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][7]->Draw("histo"); c2->cd(9); c2_9->SetLogy(); c2_9->SetGridx(); c2_9->SetGridy(); hfadc_raw[1][8]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][8]->Draw("histo"); c2->cd(10); c2_10->SetLogy(); c2_10->SetGridx(); c2_10->SetGridy(); hfadc_raw[1][9]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][9]->Draw("histo"); c2->cd(11); c2_11->SetLogy(); c2_11->SetGridx(); c2_11->SetGridy(); hfadc_raw[1][10]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][10]->Draw("histo"); c2->cd(12); c2_12->SetLogy(); c2_12->SetGridx(); c2_12->SetGridy(); hfadc_raw[1][11]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][11]->Draw("histo"); c2->cd(13); c2_13->SetLogy(); c2_13->SetGridx(); c2_13->SetGridy(); hfadc_raw[1][12]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][12]->Draw("histo"); c2->cd(14); c2_14->SetLogy(); c2_13->SetGridx(); c2_14->SetGridy(); hfadc_raw[1][13]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][13]->Draw("histo"); c2->cd(15); c2_15->SetLogy(); c2_15->SetGridx(); c2_15->SetGridy(); hfadc_raw[1][14]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][14]->Draw("histo"); c2->cd(16); c2_16->SetLogy(); c2_16->SetGridx(); c2_16->SetGridy(); hfadc_raw[1][15]->GetXaxis()->SetNdivisions(505); hfadc_raw[1][15]->Draw("histo"); c2->Update(); // output sum histograms c11->cd(1); c11_1->SetLogy(); c11_1->SetGridx(); c11_1->SetGridy(); hfadc_sum[0][0]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][0]->Draw("histo"); c11->cd(2); c11_2->SetLogy(); c11_2->SetGridx(); c11_2->SetGridy(); hfadc_sum[0][1]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][1]->Draw("histo"); c11->cd(3); c11_3->SetLogy(); c11_3->SetGridx(); c11_3->SetGridy(); hfadc_sum[0][2]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][2]->Draw("histo"); c11->cd(4); c11_4->SetLogy(); c11_4->SetGridx(); c11_4->SetGridy(); hfadc_sum[0][3]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][3]->Draw("histo"); c11->cd(5); c11_5->SetLogy(); c11_5->SetGridx(); c11_5->SetGridy(); hfadc_sum[0][4]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][4]->Draw("histo"); c11->cd(6); c11_6->SetLogy(); c11_6->SetGridx(); c11_6->SetGridy(); hfadc_sum[0][5]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][5]->Draw("histo"); c11->cd(7); c11_7->SetLogy(); c11_7->SetGridx(); c11_7->SetGridy(); hfadc_sum[0][6]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][6]->Draw("histo"); c11->cd(8); c11_8->SetLogy(); c11_8->SetGridx(); c11_8->SetGridy(); hfadc_sum[0][7]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][7]->Draw("histo"); c11->cd(9); c11_9->SetLogy(); c11_9->SetGridx(); c11_9->SetGridy(); hfadc_sum[0][8]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][8]->Draw("histo"); c11->cd(10); c11_10->SetLogy(); c11_10->SetGridx(); c11_10->SetGridy(); hfadc_sum[0][9]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][9]->Draw("histo"); c11->cd(11); c11_11->SetLogy(); c11_11->SetGridx(); c11_11->SetGridy(); hfadc_sum[0][10]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][10]->Draw("histo"); c11->cd(12); c11_12->SetLogy(); c11_12->SetGridx(); c11_12->SetGridy(); hfadc_sum[0][11]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][11]->Draw("histo"); c11->cd(13); c11_13->SetLogy(); c11_13->SetGridx(); c11_13->SetGridy(); hfadc_sum[0][12]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][12]->Draw("histo"); c11->cd(14); c11_14->SetLogy(); c11_14->SetGridx(); c11_14->SetGridy(); hfadc_sum[0][13]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][13]->Draw("histo"); c11->cd(15); c11_15->SetLogy(); c11_15->SetGridx(); c11_15->SetGridy(); hfadc_sum[0][14]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][14]->Draw("histo"); c11->cd(16); c11_16->SetLogy(); c11_16->SetGridx(); c11_16->SetGridy(); hfadc_sum[0][15]->GetXaxis()->SetNdivisions(505); hfadc_sum[0][15]->Draw("histo"); c11->Update(); #if 1 c12->cd(1); c12_1->SetLogy(); c12_1->SetGridx(); c12_1->SetGridy(); hfadc_sum[1][0]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][0]->Draw("histo"); c12->cd(2); c12_2->SetLogy(); c12_2->SetGridx(); c12_2->SetGridy(); hfadc_sum[1][1]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][1]->Draw("histo"); c12->cd(3); c12_3->SetLogy(); c12_3->SetGridx(); c12_3->SetGridy(); hfadc_sum[1][2]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][2]->Draw("histo"); c12->cd(4); c12_4->SetLogy(); c12_4->SetGridx(); c12_4->SetGridy(); hfadc_sum[1][3]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][3]->Draw("histo"); c12->cd(5); c12_5->SetLogy(); c12_5->SetGridx(); c12_5->SetGridy(); hfadc_sum[1][4]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][4]->Draw("histo"); c12->cd(6); c12_6->SetLogy(); c12_6->SetGridx(); c12_6->SetGridy(); hfadc_sum[1][5]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][5]->Draw("histo"); c12->cd(7); c12_7->SetLogy(); c12_7->SetGridx(); c12_7->SetGridy(); hfadc_sum[1][6]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][6]->Draw("histo"); c12->cd(8); c12_8->SetLogy(); c12_8->SetGridx(); c12_8->SetGridy(); hfadc_sum[1][7]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][7]->Draw("histo"); c12->cd(9); c12_9->SetLogy(); c12_9->SetGridx(); c12_9->SetGridy(); hfadc_sum[1][8]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][8]->Draw("histo"); c12->cd(10); c12_10->SetLogy(); c12_10->SetGridx(); c12_10->SetGridy(); hfadc_sum[1][9]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][9]->Draw("histo"); c12->cd(11); c12_11->SetLogy(); c12_11->SetGridx(); c12_11->SetGridy(); hfadc_sum[1][10]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][10]->Draw("histo"); c12->cd(12); c12_12->SetLogy(); c12_12->SetGridx(); c12_12->SetGridy(); hfadc_sum[1][11]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][11]->Draw("histo"); c12->cd(13); c12_13->SetLogy(); c12_13->SetGridx(); c12_13->SetGridy(); hfadc_sum[1][12]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][12]->Draw("histo"); c12->cd(14); c12_14->SetLogy(); c12_13->SetGridx(); c12_14->SetGridy(); hfadc_sum[1][13]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][13]->Draw("histo"); c12->cd(15); c12_15->SetLogy(); c12_15->SetGridx(); c12_15->SetGridy(); hfadc_sum[1][14]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][14]->Draw("histo"); c12->cd(16); c12_16->SetLogy(); c12_16->SetGridx(); c12_16->SetGridy(); hfadc_sum[1][15]->GetXaxis()->SetNdivisions(505); hfadc_sum[1][15]->Draw("histo"); c12->Update(); #endif c3->cd(); htdc_mult->Draw(); c3->Update(); for(Int_t ch = 0; ch < 16; ch++){ c4->cd(ch+1); // Double_t mean = htdc_dt[ch]->GetMean(); Double_t mean = 30; Double_t norm = 100; Double_t sigma = 5; htdc_dt[ch]->Fit("gaus","","",0, 50); // TF1 *fitfcn = htdc_dt[ch]->GetFunction("gaus"); // fitfcn->SetParameters(norm,mean,sigma); // htdc_dt[ch]->Fit("fitfcn"); htdc_dt[ch]->Draw(); htdc_dt[ch]->GetXaxis()->SetTitleSize(0.06); htdc_dt[ch]->GetXaxis()->SetNdivisions(505); htdc_dt[ch]->GetXaxis()->SetTitle("Time (ns)"); } c4->Update(); #if 1 for(Int_t ch = 16; ch < 32; ch++){ c5->cd(ch-15); htdc_dt[ch]->Fit("gaus","","",-10, 60); // htdc_dt[ch]->Draw("histo"); htdc_dt[ch]->Draw(); htdc_dt[ch]->GetXaxis()->SetTitleSize(0.06); htdc_dt[ch]->GetXaxis()->SetNdivisions(505); htdc_dt[ch]->GetXaxis()->SetTitle("Time (ns)"); } c5->Update(); #endif // fit distributions c6->cd(); c6->SetLogy(); // pick histogram to fit Int_t fitch = 2; cout << " fitch=" << fitch << endl; Double_t max = hfadc_raw[0][fitch]->GetMaximum(); Int_t maxbin = hfadc_raw[0][fitch]->GetMaximumBin(); Double_t maxx = hfadc_raw[0][fitch]->GetBinLowEdge(maxbin)+ hfadc_raw[0][fitch]->GetBinWidth(maxbin)/2; Double_t tau = 500; Double_t expmax = max*exp(maxx/tau); cout << "\n\n max=" << max << " maxbin=" << maxbin << " maxx=" << maxx << " expmax=" << expmax << endl; TF1 *fit_func= new TF1("fit_func",fit_func,450,4000,5); fit_func->SetParameters(40,2500,40,expmax,tau); fit_func->SetParNames("norm","Gmean","Gsigma","Exp0","ExpLam"); // fit exponential only fit_func->FixParameter(0,0); // fit_func->FixParameter(1,1300); fit_func->FixParameter(1,2500); fit_func->FixParameter(2,100); hfadc_raw[0][fitch]->Fit("fit_func","", "" , 450,4000); Double_t expmax = fit_func->GetParameter(3); Double_t tau = fit_func->GetParameter(4); // fit gaussian only fit_func->ReleaseParameter(0); fit_func->ReleaseParameter(1); fit_func->ReleaseParameter(2); fit_func->FixParameter(3,0); fit_func->FixParameter(4,tau); hfadc_raw[0][fitch]->Fit("fit_func","", "" , 900,3000); Double_t norm = fit_func->GetParameter(0); Double_t mean = fit_func->GetParameter(1); Double_t sigma = fit_func->GetParameter(2); fit_func->SetParameters(norm,mean,sigma,expmax,tau); fit_func->ReleaseParameter(0); fit_func->ReleaseParameter(1); fit_func->ReleaseParameter(2); fit_func->ReleaseParameter(3); fit_func->ReleaseParameter(4); hfadc_raw[0][fitch]->Fit("fit_func","", "" , 450,4000); hfadc_raw[0][fitch]->Draw(); // Plot ratio of ch2/ch1 c7->cd(1); // c7->SetLogy(); ch1ch2->Draw(); ch1ch2->GetXaxis()->SetNdivisions(505); c7->cd(2); ratio12->Fit("gaus"); ratio12->Draw(); c8->cd(1); c8_1->SetLogy(); c8_1->SetGridx(); c8_1->SetGridy(); hfadc_pedestals[0][0]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][0]->Draw("histo"); c8->cd(2); c8_2->SetLogy(); c8_2->SetGridx(); c8_2->SetGridy(); hfadc_pedestals[0][1]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][1]->Draw("histo"); c8->cd(3); c8_3->SetLogy(); c8_3->SetGridx(); c8_3->SetGridy(); hfadc_pedestals[0][2]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][2]->Draw("histo"); c8->cd(4); c8_4->SetLogy(); c8_4->SetGridx(); c8_4->SetGridy(); hfadc_pedestals[0][3]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][3]->Draw("histo"); c8->cd(5); c8_5->SetLogy(); c8_5->SetGridx(); c8_5->SetGridy(); hfadc_pedestals[0][4]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][4]->Draw("histo"); c8->cd(6); c8_6->SetLogy(); c8_6->SetGridx(); c8_6->SetGridy(); hfadc_pedestals[0][5]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][5]->Draw("histo"); c8->cd(7); c8_7->SetLogy(); c8_7->SetGridx(); c8_7->SetGridy(); hfadc_pedestals[0][6]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][6]->Draw("histo"); c8->cd(8); c8_8->SetLogy(); c8_8->SetGridx(); c8_8->SetGridy(); hfadc_pedestals[0][7]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][7]->Draw("histo"); c8->cd(9); c8_9->SetLogy(); c8_9->SetGridx(); c8_9->SetGridy(); hfadc_pedestals[0][8]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][8]->Draw("histo"); c8->cd(10); c8_10->SetLogy(); c8_10->SetGridx(); c8_10->SetGridy(); hfadc_pedestals[0][9]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][9]->Draw("histo"); c8->cd(11); c8_11->SetLogy(); c8_11->SetGridx(); c8_11->SetGridy(); hfadc_pedestals[0][10]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][10]->Draw("histo"); c8->cd(12); c8_12->SetLogy(); c8_12->SetGridx(); c8_12->SetGridy(); hfadc_pedestals[0][11]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][11]->Draw("histo"); c8->cd(13); c8_13->SetLogy(); c8_13->SetGridx(); c8_13->SetGridy(); hfadc_pedestals[0][12]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][12]->Draw("histo"); c8->cd(14); c8_14->SetLogy(); c8_14->SetGridx(); c8_14->SetGridy(); hfadc_pedestals[0][13]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][13]->Draw("histo"); c8->cd(15); c8_15->SetLogy(); c8_15->SetGridx(); c8_15->SetGridy(); hfadc_pedestals[0][14]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][14]->Draw("histo"); c8->cd(16); c8_16->SetLogy(); c8_16->SetGridx(); c8_16->SetGridy(); hfadc_pedestals[0][15]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[0][15]->Draw("histo"); c8->Update(); #if 1 c9->cd(1); c9_1->SetLogy(); c9_1->SetGridx(); c9_1->SetGridy(); hfadc_pedestals[1][0]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][0]->Draw("histo"); c9->cd(2); c9_2->SetLogy(); c9_2->SetGridx(); c9_2->SetGridy(); hfadc_pedestals[1][1]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][1]->Draw("histo"); c9->cd(3); c9_3->SetLogy(); c9_3->SetGridx(); c9_3->SetGridy(); hfadc_pedestals[1][2]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][2]->Draw("histo"); c9->cd(4); c9_4->SetLogy(); c9_4->SetGridx(); c9_4->SetGridy(); hfadc_pedestals[1][3]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][3]->Draw("histo"); c9->cd(5); c9_5->SetLogy(); c9_5->SetGridx(); c9_5->SetGridy(); hfadc_pedestals[1][4]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][4]->Draw("histo"); c9->cd(6); c9_6->SetLogy(); c9_6->SetGridx(); c9_6->SetGridy(); hfadc_pedestals[1][5]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][5]->Draw("histo"); c9->cd(7); c9_7->SetLogy(); c9_7->SetGridx(); c9_7->SetGridy(); hfadc_pedestals[1][6]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][6]->Draw("histo"); c9->cd(8); c9_8->SetLogy(); c9_8->SetGridx(); c9_8->SetGridy(); hfadc_pedestals[1][7]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][7]->Draw("histo"); c9->cd(9); c9_9->SetLogy(); c9_9->SetGridx(); c9_9->SetGridy(); hfadc_pedestals[1][8]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][8]->Draw("histo"); c9->cd(10); c9_10->SetLogy(); c9_10->SetGridx(); c9_10->SetGridy(); hfadc_pedestals[1][9]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][9]->Draw("histo"); c9->cd(11); c9_11->SetLogy(); c9_11->SetGridx(); c9_11->SetGridy(); hfadc_pedestals[1][10]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][10]->Draw("histo"); c9->cd(12); c9_12->SetLogy(); c9_12->SetGridx(); c9_12->SetGridy(); hfadc_pedestals[1][11]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][11]->Draw("histo"); c9->cd(13); c9_13->SetLogy(); c9_13->SetGridx(); c9_13->SetGridy(); hfadc_pedestals[1][12]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][12]->Draw("histo"); c9->cd(14); c9_14->SetLogy(); c9_13->SetGridx(); c9_14->SetGridy(); hfadc_pedestals[1][13]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][13]->Draw("histo"); c9->cd(15); c9_15->SetLogy(); c9_15->SetGridx(); c9_15->SetGridy(); hfadc_pedestals[1][14]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][14]->Draw("histo"); c9->cd(16); c9_16->SetLogy(); c9_16->SetGridx(); c9_16->SetGridy(); hfadc_pedestals[1][15]->GetXaxis()->SetNdivisions(505); hfadc_pedestals[1][15]->Draw("histo"); c9->Update(); #endif cout << " Event number = " << i << endl; // ouput histograms sprintf(string,"%s%d%s","Run",runno,"_fadc_c1.pdf"); printf ("Print %s\n",string); c1->SaveAs(string); sprintf(string,"%s%d%s","Run",runno,"_fadc_c2.pdf"); printf ("Print %s\n",string); c2->SaveAs(string); sprintf(string,"%s%d%s","Run",runno,"_tdc_c3.pdf"); printf ("Print %s\n",string); c3->SaveAs(string); sprintf(string,"%s%d%s","Run",runno,"_tdc_c4.pdf"); printf ("Print %s\n",string); c4->SaveAs(string); sprintf(string,"%s%d%s","Run",runno,"_tdc_c5.pdf"); printf ("Print %s\n",string); c5->SaveAs(string); sprintf(string,"%s%d%s","Run",runno,"_fadcfit_c6.pdf"); printf ("Print %s\n",string); c6->SaveAs(string); sprintf(string,"%s%d%s","Run",runno,"_ratio12_c7.pdf"); printf ("Print %s\n",string); c7->SaveAs(string); sprintf(string,"%s%d%s","Run",runno,"_ratio12_c8.pdf"); printf ("Print %s\n",string); c8->SaveAs(string); sprintf(string,"%s%d%s","Run",runno,"_ratio12_c9.pdf"); printf ("Print %s\n",string); c9->SaveAs(string); sprintf(string,"%s%d%s","Run",runno,"_fsum_c11.pdf"); printf ("Print %s\n",string); c11->SaveAs(string); sprintf(string,"%s%d%s","Run",runno,"_fsum_c12.pdf"); printf ("Print %s\n",string); c12->SaveAs(string); } Double_t fit_func (Double_t *x, Double_t *par) { // Function is Gaussian + exponential Double_t norm=par[0]; Double_t mu=par[1]; Double_t sigma=par[2]; Double_t expmax=par[3]; Double_t tau=par[4]; Double_t x1=x[0]; char string[256]; Double_t amplitude = norm * exp(-(x1-mu)*(x1-mu)/(2*sigma*sigma)) + expmax*exp(-x1/tau); /*sprintf (string,"amplitude=%f mu=%f sigma=%f arg=%f\n",amplitude,mu,sigma,arg); printf ("string=%s",string);*/ return amplitude; }