What is wrong with my script ?
I use THStack for colouring two histograms in one histogram.
While THStack draws a histogram by doing a superimposed one histogram for hv==0 && db==0 and hv==1 && db==0 and they are blue colours, outfile.root perceives just hv==0 && db==1 and hv==1 && db==1 and they are red colours. So, there is no hv==0 && db==0 and hv==1 && db==0, being in THStack histogram, in outfile.root !
Problem is that THStack and *_outfile.root didn’t perceive all of data(48bins) in one histogram.Why ?
I want to be coloured different colours with respect to the first 24 data and the last 24 ones !
Could you,please, help me for this problem, I appreciate you .
PS:
My script runs as root -b -q ‘Analysis.C(3104)’
map.txt and an example of rootfile is in the attachment!
My script is :
#include <iostream>
#include <fstream>
using namespace std;
char rootfile[200];
int qie,depth,ieta;
int runno;
void Analysis(runno){
sprintf(rootfile,"Run_%d.root",runno);
TFile *f = new TFile(rootfile);
stringstream outfile;
outfile<<runno<<"_outfile.root";
TFile *f1 = new TFile(outfile.str().c_str(),"RECREATE");
outfile.str("");
int HV[] = {650,700};
// TH2F *HistGain[2];
TH2F *HistGain_0[2];
TH2F *HistGain_1[2];
THStack *hs = new THStack ("hs","db0 and db1 in one histogram");
stringstream voltage;
for(const int hv=0;hv<2;hv++) {
voltage<<HV[hv]<<"GainVsChannel";
HistGain_0[hv] = new TH2F(voltage.str().c_str(),voltage.str().c_str(),55,0,50,1000,0,2700000);
HistGain_1[hv] = new TH2F(voltage.str().c_str(),voltage.str().c_str(),55,0,50,1000,0,2700000);
// HistGain[hv]= new TH2F(voltage.str().c_str(),voltage.str().c_str(),48,0,50,1000,0,2700000);
voltage.str("");
}
ifstream input("map.txt");
if (input.fail()){
cout<<"map.txt is not available"<<endl;
}
int count = 0;
while( input>>qie>>ieta>>depth ){
for(int hv=0;hv<2;hv++){
for(int db=0;db<2;db++) {
// count++;
// cout<<count;
TString histnameLED,histnamePED;
stringstream ledname,pedname;
histnameLED.Form("/Analyzer/QIEsSumLED%d_QiECh_%d_DBOX_%d_eta_%d_D_%d",HV[hv],qie,db,ieta,depth);
histnamePED.Form("/Analyzer/QIEsSumPED%d_QiECh_%d_DBOX_%d_eta_%d_D_%d",HV[hv],qie,db,ieta,depth);
pedname<<histnamePED;
ledname<<histnameLED;
TH1F *HistLED = (TH1F*)f->Get(ledname.str().c_str());
TH1F *HistPED = (TH1F*)f->Get(pedname.str().c_str());
ledname.str("");
pedname.str("");
// cout<<ledname.str().c_str()<<endl;
if(HistLED && HistPED) {
LEDMEAN = HistLED->GetMean();
PEDMEAN = HistPED->GetMean();
LEDRMS = HistLED->GetRMS();
PEDRMS = HistPED->GetRMS();
double TRUEMEAN = LEDMEAN - PEDMEAN;
double TRUERMS = sqrt(pow(LEDRMS,2)+pow(PEDRMS,2));
double NPE = 1.15*pow(TRUEMEAN,2)/pow(TRUERMS,2);
double GAIN = TRUEMEAN*2.6*10000/NPE/1.6;
cout<<GAIN<<endl;
if (GAIN>0) {
if (db==0) {
HistGain_0[hv]->Fill(qie+(db*24),GAIN);
HistGain_0[hv]->GetXaxis()->SetTitle("Channel");
HistGain_0[hv]->GetYaxis()->SetTitle("Gain");
HistGain_0[hv]->SetMarkerStyle(8);
HistGain_0[hv]->SetMarkerColor(kBlue);
hs->Add(HistGain_0[hv]); }
if (db==1) {
HistGain_1[hv]->Fill(qie+(db*24),GAIN);
HistGain_1[hv]->GetXaxis()->SetTitle("Channel");
HistGain_1[hv]->GetYaxis()->SetTitle("Gain");
HistGain_1[hv]->SetMarkerStyle(8);
HistGain_1[hv]->SetMarkerColor(kRed);
hs->Add(HistGain_1[hv]); }
}
}
}
}
hs->Draw("NOSTACK P");
}
f1->Write();
input.close();
f1->Close();
f->Close();
}
Thanks for your help,
Cheers,
Ersel
map.txt (241 Bytes)
Run_3104.root (709 KB)