Hello ROOTers,
I’m trying to linear rebin and rescale the yellow histogram in order to match the green spectrum. The code that we wrote is the following:
int Double_TH1F() {
FILE *file = fopen("./Run0_PHA_HG_0_44.txt", "r");
FILE *file2 = fopen("./conv_s13_63.txt", "r");
TCanvas* c1 = new TCanvas("c1","HG Multiphoton Spectrum",10,10,1920,1980);
c1->SetGridx();
c1->SetGridy();
TH1F* htmp = new TH1F("htemp","htemp",2048,0,2048);
TH1F *hsipm = new TH1F("HG Multiphoton Spectrum","",2048,0,2048);
//TH1F *hsipm = new TH1F("HG Multiphoton Spectrum","",630,0,21);
Int_t bins = 0;
Float_t x= 0;
Int_t i = 0;
Double_t gain_verde = 33.3085;
Double_t gain_giallo = 32.5152;
Double_t ped_verde = 74.9209;
Double_t ped_giallo = 121.278;
Double_t spe_verde = 101.996;
Double_t spe_giallo = 144.391;
while(!feof(file)){
fscanf(file,"%g\n",&x);
for(i=0;i<x; ++i){
htmp->Fill(bins);
hsipm->Fill(bins);
}
++bins;
}
hsipm->SetFillColorAlpha(kGreen, 0.85);
hsipm->GetXaxis()->SetRangeUser(0, 550);
hsipm->GetXaxis()->SetTitle("ADC Channels");
hsipm->GetYaxis()->SetTitle("Counts");
TH1F* htmp2 = new TH1F("htemp2","htemp2",2048,0,2048);
TH1F *hsipm2 = new TH1F("HG Multiphoton Spectrum 2","",2048,0,2048);
Int_t bins2 = 0;
Float_t y= 0;
while(!feof(file2)){
fscanf(file2,"%g\n",&y);
for(i=0;i<y; ++i){
htmp2->Fill(bins2);
hsipm2->Fill((bins2-ped_giallo+ped_verde)*(gain_giallo/gain_verde));
}
++bins2;
}
hsipm2->SetFillColorAlpha(kYellow, 0.85);
Float_t eventi_dt5202 = hsipm->Integral();
cout << "Eventi DT5202 = " << eventi_dt5202 << endl;
Float_t eventi_dt5550w = hsipm2->Integral();
cout << "Eventi DT5550W = " << eventi_dt5550w << endl;
// hsipm->SetBins(hsipm->GetNbinsX(),0.,20.);
hsipm->Draw();
// hsipm2->SetBins(hsipm2->GetNbinsX(),0.,1999.22331);
hsipm2->Draw("same");
auto legend = new TLegend(0.1, 0.6, 0.25, 0.9);
legend->AddEntry(hsipm, "CAEN DT5202", "f");
legend->AddEntry(hsipm2,"CAEN DT5550W", "f");
legend->Draw();
c1->SaveAs("Confronto_Schede_CAEN.pdf");
return 0;
}
We obtain the following output:
As you can see, the yellow peaks are not superimposed on the green peaks, as you might expect since we scaled the second histogram for the ratio of the two gains. And we notice, also, a problem in the yellow spectra bins (see the extra event in some bins).
The reseult that we want to reproduce is the following that we simply obtained using the same logic with Python.
Data file of the code:
conv_s13_63.txt (9,5 KB)
Run0_PHA_HG_0_44.txt (7,5 KB)