FairRoot/PandaRoot
PndMvdAnaRadDam.cxx
Go to the documentation of this file.
1 /*
2  * PndMvdAnaRadDam.cxx
3  *
4  * Created on: Feb 2, 2009
5  * Author: stockman
6  */
7 
8 #include "PndMvdAnaRadDam.h"
9 #include "TList.h"
10 #include "TCollection.h"
11 #include "TObject.h"
12 
13 #include<iostream>
14 
16  fCountGoodFiles(0),
17  fFileList(),
18  fHistoMap()
19 {
20  // TODO Auto-generated constructor stub
21 }
22 
24 {
25  // TODO Auto-generated destructor stub
26 }
27 
29 {
30  for (unsigned int i = 0; i < fFileList.size(); i++){
31  TFile* f = fFileList[i];
32  if (f != NULL){
33  TList* l = f->GetListOfKeys();
34  TIter iter(l);
35  TObject* ob;
37  while( (ob = iter()) ){
38  if (TString(ob->GetName()).Contains("ocave_1oMvd-2.1")){
39  TString newName = ob->GetName();
40  newName.Append("_sum");
41  TProfile2D* histo = (TProfile2D*)(f->Get(ob->GetName()));
42  AddHisto(histo);
43  }
44  }
45  }
46 // f->Close();
47  }
48 }
49 
50 void PndMvdAnaRadDam::AddHisto(TProfile2D* histo)
51 {
52  TString mapName = histo->GetName();
53  mapName.Append("_sum");
54  if(fHistoMap[mapName] == 0){
55  TProfile2D* newHisto = new TProfile2D(*histo);
56  newHisto->SetName(mapName);
57  fHistoMap[mapName] = newHisto;
58  }
59  else{
60  //std::cout << fHistoMap[histo->GetName()]->GetName() << " / " << histo->GetName() << std::endl;
61  fHistoMap[mapName]->Add(histo);
62  }
63  //std::cout << histo->GetName() << std::endl;
64 }
65 
67 {
68  std::map<TString, TProfile2D*>::iterator iter = fHistoMap.begin();
69  for (int j = 0; j < i; j++)iter++;
70  return iter->second;
71 }
72 
74 {
75  return fHistoMap[name];
76 }
77 
79 {
80  TFile f(fileName,"RECREATE");
81  //f.Dump();
82 // f.Write();
83 
84  for (std::map<TString, TProfile2D*>::const_iterator iter = fHistoMap.begin(); iter != fHistoMap.end(); iter++){
85  if (iter->second != 0){
86  iter->second->Write();
87  }
88  }
89  f.Close();
90 }
Int_t i
Definition: run_full.C:25
void SaveHistos(TString fileName)
virtual ~PndMvdAnaRadDam()
TFile * f
Definition: bump_analys.C:12
void AddHisto(TProfile2D *histo)
TString name
TH2 * GetHistoByName(TString name)
std::map< TString, TProfile2D * > fHistoMap
TH2 * GetHisto(int i)
std::vector< TFile * > fFileList