3 #include "TObjString.h"
7 void addhistoEmc(const char* list="list.txt", char *newname=0)
9 // Add histograms from a set of files listed in file list
10 // and write the result into a new file.
15 sprintf(SumName,"Sum_All_Emc.root");
17 printf("\n === Default output file name is %s ===\n",newname);
23 char hnam[80]; char htit[80];
30 for(Int_t iMod=0; iMod<5; iMod++) {
31 for(Int_t iX=0; iX<64; iX++) {
32 for(Int_t iZ=0; iZ<56; iZ++) {
33 sprintf(hnam,"%d_%d_%d",iMod,iX,iZ);
34 sprintf(htit,"Two-gamma inv. mass for mod %d, cell (%d,%d)",iMod,iX,iZ);
35 hst[iMod][iX][iZ] = new TH1F(hnam,htit,100,0.,300.);
40 TH1F* hmgg = new TH1F("hmgg","2-cluster invariant mass",100,0.,300.);
42 FILE* fd = fopen(list,"r");
43 while( ifscanf = fscanf(fd,"%s",fpath) != EOF) {
45 hlist = (TList*)f->Get("histos");
47 for(Int_t iList=0; iList<hlist->GetEntries(); iList++) {
48 hadd = (TH1F*)hlist->At(iList);
49 const char* str = hadd->GetName();
51 if (sscanf(str,"%d_%d_%d",&md,&X,&Z)) {
52 hst[md][X][Z]->Add(hadd);
53 //printf("Added hst[%d][%d][%d]\n",md,X,Z);
56 printf("Trying to add histogram %s to hmgg.\n",hadd->GetName());
61 printf("Deleting list..\n");
66 printf("File %s processed.\n",fpath);
70 printf("%d processed.\n",ifile);
72 TFile outfile(newname,"recreate");
74 for(Int_t iMod=0; iMod<5; iMod++) {
75 for(Int_t iX=0; iX<64; iX++) {
76 for(Int_t iZ=0; iZ<56; iZ++) {
77 if(hst[iMod][iX][iZ]->GetEntries()) hst[iMod][iX][iZ]->Print();
78 hst[iMod][iX][iZ]->Write();