# include "TFile.h" # include "TH1F.h" # include "TChain.h" # include "Riostream.h" void addspecs2() { //Create the calibrated histograms //Int_t ADCmax = 2700; //maximum value for calibrated ADC2&3 //Int_t ADCmax1 = 8192; //maximum value for calibrated ADC1 Int_t nbins = 8192; // or whatever you want, eg ADCmax TFile *fout = new TFile("/Users/ew/AProg/ROOT1/Data/s00074/SUMhistos74.root","recreate"); TH1F *hADC1 = new TH1F("hADC1","calibrated ADC1",nbins, 0, nbins); TH1F *hADC2 = new TH1F("hADC2","calibrated ADC2",nbins, 0, nbins); TH1F *hADC3 = new TH1F("hADC3","calibrated ADC3",nbins, 0, nbins); //TH1F *hADC4 = new TH1F("hADC4","calibrated ADC4",nbins,0,ADCmax); //set your calibration constants 1=ADC1, 2=ADC2, 3=ADC3 //Double_t konst1 = //Double_t M1 = Double_t konst2 = 0.3298; Double_t M2 = -14.046; Double_t konst3 = 0.3348; Double_t M3 = 30.086; // Chain all the data files. TChain *chain = new TChain("data"); //data is the name of the TTree object in the files added with Add chain->Add("/Users/ew/AProg/ROOT1/Data/s00074/s00074_001.root"); chain->Add("/Users/ew/AProg/ROOT1/Data/s00074/s00074_002.root"); chain->Add("/Users/ew/AProg/ROOT1/Data/s00074/s00074_003.root"); chain->Add("/Users/ew/AProg/ROOT1/Data/s00074/s00074_004.root"); Int_t TimeStamp; Short_t ADC1, ADC2, ADC3, ADC4; //chain->SetBranchAddress("TimeStamp",&TimeStamp); chain->SetBranchAddress("ADC1",&ADC1); chain->SetBranchAddress("ADC2",&ADC2); chain->SetBranchAddress("ADC3",&ADC3); //loop on all entries and fill the calibrated histograms Long64_t nentries = chain->GetEntries(); for (Long64_t i=0;iGetEntry(i); hADC1->Fill(ADC1); hADC2->Fill(konst2*ADC2+M2); hADC3->Fill(konst3*ADC3+M3); //hADC4->Fill(konst4*ADC4+M4); } //save in memory histograms to their host file fout->Write(); delete fout; }