{ gROOT->Reset(); #include "Riostream.h"; // opening the txt file ifstream in; in.open("ThresholdScan.txt"); // reading Vin & run number (<-- useless) Double_t Vin; Int_t Runn; Double_t Vins[21]; Int_t iVin = 0; while ( 1 ) { in >> Vin >> Runn; if ( !in.good() ) break; printf("Vin: %3.2f; Runn: %d\n",Vin,Runn); Vins[iVin] = Vin; cout << Vins[iVin] << "\n"; iVin++; } in.close(); cout << "Done with Voltage values\n"; // reading the list of root files ifstream iList; iList.open("ThresholdScan.list"); // tfile TFile *f; // tstring for runtime TString* s; // ttree for pomoneDATA TTree *t; // array of histos TObjArray hlist(128*21); TH1F ***hAdc = new TH1F[21][128]; // reading data cout << "Reading File names\n"; char fileName[20]; Int_t nObjs = 0; while ( 1 ) { // reading a file name iList.getline( fileName, 20 ); if ( !iList.good() ) break; printf("File: %s\n",fileName); // the TFile f = new TFile(fileName,"READ"); // getting the string s = (TString*)f->Get("runtime"); Double_t rT = s->Atof(); // runtime cout << "runtime: " << rT << "\n"; // getting the tree t = (TTree*)f->Get("PomoneDATA"); // getting the histo TString hName; for ( Int_t iCh = 0; iCh < 128; iCh++ ) { hName.Form("Adc;Run%d;Ch%d",nObjs,iCh); cout << hName.Data() << "\n"; hAdc[nObjs][iCh] = new TH1F(hName.Data(),"Adc spectrum;Threshold;Entries",8,-0.5,7.5); cout << "hAdc has been initialized!\n"; Int_t iRow = iCh % 8; Int_t iCol = iCh / 8; TString aSel; aSel.Form("Col == %d && Row == %d",iCol,iRow); cout << aSel.Data() << "\n"; const char* hname= hAdc[nObjs][iCh]->GetName(); cout << "hname: " << hname << "\n"; t->Project(hAdc[nObjs][iCh]->GetName(),"Adc",aSel.Data()); cout << "Prjocetion has been done!\n"; Double_t n = hAdc[nObjs][iCh]->GetEntries(); hAdc[nObjs][iCh]->SetNormFactor( n/rT ); hlist.Add(hAdc[nObjs][iCh]); } nObjs++; } iList.close(); cout << "A total of " << nObjs << " have been read!\n"; cout << "Creating the file... \n"; TFile *g = new TFile("ThresholdScan.root","RECREATE"); g->cd(); cout << "Created the file... \n"; // saving histos hlist->Write(); g->Close(); }