Hello, I’ve this root file WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free (a tree)
I’ve to produce histograms saving them in root file and plotting them in png files.
In particular, I’ve to produce, plot and save 7 histograms, that because I defined the energy vector
std::vector<int> Epeak={1824,4028,5014,5045,5060,6414,6997};
then, depending on the peak energy, I define the energy window and I’ve to make an histogram for each energy window ie:
for (int i=0; i<Epeak.size();i++){
Epeaki=Epeak.at(i);
cout << "Start processing Epeak= " << Epeaki << endl;
if (Epeaki==1824){
x1=1816;
x2=1832;
}
else if (Epeaki==4028){
x1=4015;
x2=4032;
}
etc
and I produce the histogram corresponding to the energy window by the TCut i.e.
TString string = TString::Format("e0 >> htemp(7500, 0, 7500)");
TCut pulser0 = TString::Format("e2==0").Data();
TCut pulser1 = TString::Format("e3==0").Data();
TCut detection = TString::Format("e0>0").Data();
TCut winsx = TString::Format("e1>%d",x1).Data();
TCut windx= TString::Format("e1<%d",x2).Data();
te->Draw(string, detection && winsx && windx && pulser0 && pulser1);
te->GetHistogram()->SetTitle("");
te->SetScanField(0);
TH1F *hGe[i]= (TH1F*)gPad->GetPrimitive("htemp");
hGe[i]->GetXaxis()->SetTitle("Energy (keV)");
etc.
then, for example, hGe[0] should be the histogram when Epeak==1824 (i.e. x1=1816 and x2=1832), similarly, hGe[1] should be the histogram when Epeak==4028 (i.e. x1==4015 and x2==4032), etc
then I’ve to store the 7 histograms in the root file (i.e. in the Root file I should have hGe[0], hGe[1]… hGe[6]) and I’ve to plot them in png files, ie. I should get the 7 png files given by
TString outfile = TString::Format("%s_Spectrum_when_%s=[%d,%d]_Run0%d.png",det,detfixed,x1,x2,run).Data();
i.e.
GePD_Spectrum_when_GeDD=[1816,1832]_Run0610.png
GePD_Spectrum_when_GeDD=[4015,4032]_Run0610.png
etc
I wrote the macro, but I get this error
Processing edepcoincroot.cpp...
In file included from input_line_8:1:
edepcoincroot.cpp:104:14: error: variable-sized object may not be initialized
TH1F *hGe[i]= (TH1F*)gPad->GetPrimitive("htemp");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
edepcoincroot.cpp:108:11: error: source file is not valid UTF-8
hGe[<EC>]->GetYaxis()->SetTitleFont(43);
^
edepcoincroot.cpp:108:12: error: expected expression
hGe[<EC>]->GetYaxis()->SetTitleFont(43);
edepcoincroot.cpp (4.6 KB)
Thank you
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided