Classes | Functions | Variables
NearlineSummariser.cxx File Reference
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include "TFile.h"
#include "TTree.h"
#include "TList.h"
#include "TKey.h"
#include "TH1.h"

Go to the source code of this file.

Classes

struct  NearlineFileInfo
 
struct  NearlineRunPlotSet
 

Functions

bool checkFileHasDir (TFile *fp, std::string dirName)
 
TH1 * getHistogram (TFile *fp, std::string histName, std::string newHistName)
 
int main (int argc, char **argv)
 

Variables

const int NearlineMinorVersion =1
 
const int NearlineMajorVersion =0
 
const std::string NearlineInstanceLabel = "nearlineana"
 

Function Documentation

bool checkFileHasDir ( TFile *  fp,
std::string  dirName 
)

Definition at line 260 of file NearlineSummariser.cxx.

260  {
261 
262  TList* listOfKeys = fp->GetListOfKeys();
263  TIter next(listOfKeys);
264  TKey* key;
265  while(( key = (TKey*)next() )){
266  std::string thisKeyName(key->GetName());
267  if(thisKeyName == dirName){
268  // std::cout << "NearlineSummariser: INFO: Got dirName: " << dirName << std::endl;
269  return true;
270  }
271  }
272  std::cout << "NearlineSummariser: ERROR: " << fp->GetName() << " doesn't contain a dir: " << dirName << std::endl;
273  return false;
274 }
std::string string
Definition: nybbler.cc:12
def key(type, name=None)
Definition: graph.py:13
QTextStream & endl(QTextStream &s)
TH1 * getHistogram ( TFile *  fp,
std::string  histName,
std::string  newHistName 
)

Definition at line 279 of file NearlineSummariser.cxx.

279  {
280 
281  TH1* hist;
282  TH1* outhist;
283 
284  // std::cout << "NearlineSummariser: INFO: Getting: " << histName << std::endl;
285 
286  fp->GetObject(histName.c_str(), hist);
287 
288  if(!hist){
289  std::cout << "NearlineSummariser: ERROR: Failed to get histogram: " << histName << "\n";
290  return NULL;
291  }
292 
293  // std::cout << "NearlineSummariser: INFO: Got: " << hist->GetName() << std::endl;
294 
295  outhist = (TH1*) hist->Clone(newHistName.c_str());
296  outhist->SetDirectory(0);
297 
298  // std::cout << "NearlineSummariser: INFO: Returning: " << outhist->GetName() << std::endl;
299 
300  return outhist;
301 }
int main ( int  argc,
char **  argv 
)

Definition at line 153 of file NearlineSummariser.cxx.

153  {
154 
155  std::vector<std::string> vecFileNames;
156  for(int i=1;i<argc;i++){
157  std::string thisFileName(argv[i]);
158  vecFileNames.push_back(thisFileName);
159  }
160 
161  std::vector<NearlineRunPlotSet> VecRunPlotSet;
162  std::vector<std::string> VecPlotNames;
163  VecPlotNames.push_back("hped_per_event_chan_0");
164  VecPlotNames.push_back("hped_per_event_chan_128");
165  VecPlotNames.push_back("hped_per_event_chan_256");
166  VecPlotNames.push_back("hped_per_event_chan_384");
167  VecPlotNames.push_back("hped_per_event_chan_512");
168  VecPlotNames.push_back("hped_per_event_chan_640");
169  VecPlotNames.push_back("hped_per_event_chan_768");
170  VecPlotNames.push_back("hped_per_event_chan_896");
171  VecPlotNames.push_back("hped_per_event_chan_1024");
172  VecPlotNames.push_back("hped_per_event_chan_1152");
173  VecPlotNames.push_back("hped_per_event_chan_1280");
174  VecPlotNames.push_back("hped_per_event_chan_1408");
175  VecPlotNames.push_back("hped_per_event_chan_1536");
176  VecPlotNames.push_back("hped_per_event_chan_1664");
177  VecPlotNames.push_back("hped_per_event_chan_1792");
178  VecPlotNames.push_back("hped_per_event_chan_1920");
179 
180 
181 
182  for(auto thisFileName: vecFileNames){
183  TFile *fp = TFile::Open(thisFileName.c_str());
184  if(fp){
185  if(!checkFileHasDir(fp, NearlineInstanceLabel)) continue;
186  }
187 
188  NearlineRunPlotSet thisRunPlotSet(fp);
189 
190  //DEBUG
191  std::cout << "NearlineSummariser: INFO: "
192  << thisRunPlotSet.FileInfo
193  // << thisRunPlotSet.FileInfo.StartYear
194  // << " " << thisRunPlotSet.FileInfo.StartMonth
195  // << " " << thisRunPlotSet.FileInfo.StartDay
196  // << " " << thisRunPlotSet.FileInfo.StartHour
197  // << " " << thisRunPlotSet.FileInfo.StartTime
198  << "\n";
199 
200  std::cout << "NearlineSummariser: INFO: ThisNearlineVersion: "
201  << thisRunPlotSet.FileInfo.ThisNearlineMajorVersion
202  << "." << thisRunPlotSet.FileInfo.ThisNearlineMinorVersion
203  << " NearlineVersion (Summariser): "
205  << "." << NearlineMinorVersion
206  << std::endl;
207 
208  for(auto thisPlotName: VecPlotNames){
209  thisRunPlotSet.loadHistogram(NearlineInstanceLabel, thisPlotName);
210  }//VecPlotNames
211 
212  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_0");
213  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_128");
214  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_256");
215  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_384");
216  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_512");
217  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_640");
218  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_768");
219  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_896");
220  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_1024");
221  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_1152");
222  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_1280");
223  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_1408");
224  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_1536");
225  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_1664");
226  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_1792");
227  // thisRunPlotSet.loadHistogram(NearlineInstanceLabel , "hped_per_event_chan_1920");
228 
229  VecRunPlotSet.push_back(thisRunPlotSet);
230 
231  // if(fp) checkFileHasDir(fp, "foo");
232  // listHistogramsInFile(thisFileName);
233 
234  }//vecFileNames
235 
236  for(auto thisRunPlotSet: VecRunPlotSet){
237  std::cout << "NearlineSummariser: INFO: " << thisRunPlotSet.FileInfo << std::endl;
238 
239  // for(auto thisPlotName: VecPlotNames){
240  // auto thisHist =thisRunPlotSet.MapNameHists.at(thisPlotName);
241  // double mean = (thisHist)->GetMean();
242  // double rms = (thisHist)->GetRMS();
243  // std::cout << "NearlineSummariser: INFO: Name " << thisPlotName << " count " << thisHist.use_count() << " mean " << mean << " rms " << rms << std::endl;
244  // }//thisPlotName
245 
246  // for(auto thisNameHistPair: thisRunPlotSet.MapNameHists){
247  // double mean = (thisNameHistPair.second)->GetMean();
248  // double rms = (thisNameHistPair.second)->GetRMS();
249  // std::cout << "NearlineSummariser: INFO: Name " << thisNameHistPair.first << " mean " << mean << " rms " << rms << std::endl;
250  // }//MapNameHists
251 
252  }//VecRunPlotSet
253 
254 
255  return 0;
256 }
const int NearlineMajorVersion
std::string string
Definition: nybbler.cc:12
const int NearlineMinorVersion
const std::string NearlineInstanceLabel
bool checkFileHasDir(TFile *fp, std::string dirName)
QTextStream & endl(QTextStream &s)

Variable Documentation

const std::string NearlineInstanceLabel = "nearlineana"

Definition at line 17 of file NearlineSummariser.cxx.

const int NearlineMajorVersion =0

Definition at line 15 of file NearlineSummariser.cxx.

const int NearlineMinorVersion =1

Definition at line 14 of file NearlineSummariser.cxx.