FairRoot/PandaRoot
Functions
combine_ana.C File Reference
#include "TFile.h"
#include "TH1D.h"
#include "TCanvas.h"
#include "TStopwatch.h"
#include "TROOT.h"
#include "TSystem.h"
#include "TTree.h"
#include "TString.h"

Go to the source code of this file.

Functions

void SaveAndUpdateHisto (TH1D *currenthisto, TFile &storagefile)
 
int combine_ana (TString infilename, TString outfilename="combined_psi3770.root")
 

Function Documentation

int combine_ana ( TString  infilename,
TString  outfilename = "combined_psi3770.root" 
)

Definition at line 19 of file combine_ana.C.

References SaveAndUpdateHisto(), and TString.

20 {
21 
22 //TStopwatch timer;
23 //timer.Start();
24 
25 //gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C");rootlogon();
26 
27 TFile inputfile(infilename, "READ");
28 TList* mylist = inputfile.GetListOfKeys();
29 TListIter myiter(mylist);
30 TFile outputstorage(outfilename, "UPDATE");
31 TKey* mykey;
32 
33 //cout << mylist->GetEntries() << endl;
34 
35 int nHistos = 149;
36 TString histoClassName = "TH1D";
37 
38 if (mylist->GetEntries() != nHistos) {
39  cout << "Fatal Entry Mismatch: " << mylist->GetEntries() << endl;
40  return 1;
41 }
42 
43 outputstorage->cd();
44 
45 while (mykey = (TKey*)myiter()) {
46  if (histoClassName == TString(mykey->GetClassName())) {
47  TH1D* myhisto = (TH1D*)mykey->ReadObj();
48  SaveAndUpdateHisto(myhisto, outputstorage);
49  } else {
50  cout << "Ignored, not a histogram: " << mykey->GetName() << ", " << mykey->GetClassName() << endl;
51  }
52 }
53 
54 return 0;
55 
56 //timer.Stop();
57 //Double_t rtime = timer.RealTime();
58 //Double_t ctime = timer.CpuTime();
59 
60 //printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
61 
62 } // end macro
void SaveAndUpdateHisto(TH1D *currenthisto, TFile &storagefile)
Definition: combine_ana.C:10
void SaveAndUpdateHisto ( TH1D *  currenthisto,
TFile &  storagefile 
)

Definition at line 10 of file combine_ana.C.

Referenced by combine_ana().

11 {
12  if (storagefile.Get(currenthisto->GetName()) != 0) {
13  currenthisto->Add((TH1D*)storagefile.Get(currenthisto->GetName()));
14  }
15  //cout << currenthisto->GetName() << ": " << currenthisto->GetEntries() << endl;
16  currenthisto->Write();
17 }