/////////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////////// #include "TFile.h" #include "TTree.h" #include "TBranch.h" #include "OfflineMon/TFarmLosses.hh" ClassImp(TFarmLosses) //_____________________________________________________________________________ TFarmLosses::TFarmLosses() { } //_____________________________________________________________________________ int TFarmLosses::UpdateNtuple() { TFile* ntuple_file = new TFile(fNtupleFileName.Data(),"recreate"); TTree* tree = new TTree("farm_losses","Farm Losses"); TBranch* br = tree->Branch("FarmLosses","TFarmLosses", &fData); fData = new TFarmLosses::Data_t(); //----------------------------------------------------------------------------- // read the data file and fill the ntuple //----------------------------------------------------------------------------- FILE* f = fopen(fInputDirName.Data(),"r"); char c[200], buf1[50], buf2[50], buf3[50], name[20][50]; int nmax = 200; //----------------------------------------------------------------------------- // first line: names of the streams, first - input, the rest output //----------------------------------------------------------------------------- fgets(c,nmax,f); char* p; int i(0), n_streams, n_output_streams; p = strtok(c," "); while (p) { strcpy(name[i++],p); p = strtok(0," "); }; n_streams = i; n_output_streams = i-1; while (fgets(c,nmax,f) > 0) { if (c[0] != '#') { p = strtok(c," "); fData->fRunNumber = atoi(p); for (int i=0; ifRs1[i] = atoi(p); p = strtok(0," "); fData->fRs2[i] = atoi(p); p = strtok(0," "); fData->fNMisses[i] = atoi(p); p = strtok(0," "); fData->fNMissingRs[i] = atoi(p); } for (int i=0; ifStream[i] = name[i]; tree->Fill(); } } ntuple_file->Write(); delete ntuple_file; return 0; }