CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Attributes
VariablePlotter Class Reference

#include <Plotter.h>

Inheritance diagram for VariablePlotter:
Plotter

Classes

class  Directory
 
class  SubDirectory
 

Public Member Functions

void complete ()
 
void fill (std::string subDir, const edm::Event &iEvent)
 
void setDir (std::string dir)
 
 VariablePlotter (edm::ParameterSet iConfig)
 
 ~VariablePlotter ()
 
- Public Member Functions inherited from Plotter
 Plotter ()
 
 Plotter (edm::ParameterSet iConfig)
 
virtual ~Plotter ()
 

Private Types

typedef std::map< std::string,
Directory
Directories
 
typedef std::map< std::string,
ConfigurableHisto * > 
DirectoryHistos
 
typedef std::map< std::string,
SubDirectory
SubDirectories
 

Private Attributes

std::string currentDir_
 
Directories directories_
 
DirectoryHistos master_
 

Detailed Description

Definition at line 31 of file Plotter.h.

Member Typedef Documentation

typedef std::map<std::string, Directory> VariablePlotter::Directories
private

Definition at line 209 of file Plotter.h.

typedef std::map<std::string, ConfigurableHisto *> VariablePlotter::DirectoryHistos
private

Definition at line 190 of file Plotter.h.

typedef std::map<std::string, SubDirectory> VariablePlotter::SubDirectories
private

Definition at line 200 of file Plotter.h.

Constructor & Destructor Documentation

VariablePlotter::VariablePlotter ( edm::ParameterSet  iConfig)
inline

Definition at line 33 of file Plotter.h.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSetNames(), ConfigurableHisto::h1, ConfigurableHisto::h2, master_, ConfigurableHisto::prof, and split.

33  : currentDir_("youDidNotSetDirectoryFirst") {
34  //create the master copy, never filled, just to make copies
35 
36  // make TH1
38  std::vector<std::string> th1Names;
39  th1.getParameterSetNames(th1Names);
40  for (unsigned int iH=0;iH!=th1Names.size();++iH){
41  std::string hname = th1Names[iH];
43  bool split=hPset.exists("splitter") || hPset.exists("splitters");
44  if (split)
46  else
47  master_[hname]=new ConfigurableHisto(ConfigurableHisto::h1, hname, hPset);
48  }
49 
50  // make profiles
51  edm::ParameterSet tprof=iConfig.getParameter<edm::ParameterSet>("TProfiles");
52  std::vector<std::string> tprofNames;
53  tprof.getParameterSetNames(tprofNames);
54  for (unsigned int iH=0;iH!=tprofNames.size();++iH){
55  std::string hname = tprofNames[iH];
57  bool split=hPset.exists("splitter") || hPset.exists("splitters");
58  if (split)
60  else
61  master_[hname]=new ConfigurableHisto(ConfigurableHisto::prof, hname, hPset);
62  }
63 
64  // make TH2
66  std::vector<std::string> th2Names;
67  th2.getParameterSetNames(th2Names);
68  for (unsigned int iH=0;iH!=th2Names.size();++iH){
69  std::string hname = th2Names[iH];
71  bool split=hPset.exists("splitter") || hPset.exists("splitters");
72  if (split)
74  else
75  master_[hname]=new ConfigurableHisto(ConfigurableHisto::h2, hname, hPset);
76  }
77  }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
DirectoryHistos master_
Definition: Plotter.h:191
std::string currentDir_
Definition: Plotter.h:211
size_t getParameterSetNames(std::vector< std::string > &output, bool trackiness=true) const
double split
Definition: MVATrainer.cc:139
VariablePlotter::~VariablePlotter ( )
inline

Definition at line 142 of file Plotter.h.

142  {
143  // CANNOT DO THAT because of TFileService holding the histograms
144  /* //loop over all subdirectories and delete all ConfigurableHistograms
145  Directories::iterator dir_It = directories_.begin();
146  Directories::iterator dir_It_end = directories_.end();
147  // loop directories
148  for (;dir_It!=dir_It_end;++dir_It){
149  Directory & currentDirectory=dir_It->second;
150  SubDirectories & currentSetOfSubDirectories=currentDirectory.subDir;
151  SubDirectories::iterator subDir_It = currentSetOfSubDirectories.begin();
152  SubDirectories::iterator subDir_It_end = currentSetOfSubDirectories.end();
153  //loop subdirectories
154  for (;subDir_It!=subDir_It_end;++subDir_It){
155  DirectoryHistos::iterator histogramIterator=subDir_It->second.histos.begin();
156  DirectoryHistos::iterator histogramIterator_end=subDir_It->second.histos.end();
157  //loop configurable histograms
158  for(; histogramIterator!=histogramIterator_end;++histogramIterator){
159  // by doing that you are removing the histogram from the TFileService too. and this will crash
160  // delete histogramIterator->second;
161  }
162  }
163  }
164  */
165  }

Member Function Documentation

void VariablePlotter::complete ( )
inlinevirtual

Implements Plotter.

Definition at line 166 of file Plotter.h.

References directories_, and VariablePlotter::Directory::subDir.

166  {
167 
168  //loop over all subdirectories and call complete() on all ConfigurableHistograms
169 
170  Directories::iterator dir_It = directories_.begin();
171  Directories::iterator dir_It_end = directories_.end();
172  // loop directories
173  for (;dir_It!=dir_It_end;++dir_It){
174  Directory & currentDirectory=dir_It->second;
175  SubDirectories & currentSetOfSubDirectories=currentDirectory.subDir;
176  SubDirectories::iterator subDir_It = currentSetOfSubDirectories.begin();
177  SubDirectories::iterator subDir_It_end = currentSetOfSubDirectories.end();
178  //loop subdirectories
179  for (;subDir_It!=subDir_It_end;++subDir_It){
180  DirectoryHistos::iterator histogramIterator=subDir_It->second.histos.begin();
181  DirectoryHistos::iterator histogramIterator_end=subDir_It->second.histos.end();
182  //loop configurable histograms
183  for(; histogramIterator!=histogramIterator_end;++histogramIterator)
184  { histogramIterator->second->complete(); }
185  }
186  }
187  }
Directories directories_
Definition: Plotter.h:212
std::map< std::string, SubDirectory > SubDirectories
Definition: Plotter.h:200
void VariablePlotter::fill ( std::string  subDir,
const edm::Event iEvent 
)
inlinevirtual

Implements Plotter.

Definition at line 93 of file Plotter.h.

References currentDir_, VariablePlotter::SubDirectory::dir, VariablePlotter::Directory::dir, directories_, VariablePlotter::SubDirectory::dirName, VariablePlotter::SubDirectory::histos, master_, TFileDirectory::mkdir(), and VariablePlotter::Directory::subDir.

93  {
94  //what is the current directory
95  Directory & currentDirectory= directories_[currentDir_];
96 
97  //what is the current set of sub directories for this
98  SubDirectories & currentSetOfSubDirectories=currentDirectory.subDir;
99 
100  //find the subDirectory requested:
101  SubDirectory * subDirectoryToUse=0;
102  SubDirectories::iterator subDirectoryFindIterator=currentSetOfSubDirectories.find(subDir);
103 
104  //not found? insert a new directory with this name
105  if (subDirectoryFindIterator==currentSetOfSubDirectories.end()){
106  edm::LogInfo("VariablePlotter")<<" gonna clone histograms for :"<<subDir<<" in "<<currentDir_;
107  SubDirectory & insertedDir = currentSetOfSubDirectories[subDir];
108  subDirectoryToUse = &insertedDir;
109  if (!insertedDir.dir){
110  insertedDir.dir=new TFileDirectory(currentDirectory.dir->mkdir(subDir));
111  insertedDir.dirName=subDir;
112  }
113 
114  //create a copy from the master copy
115  DirectoryHistos::iterator masterHistogramIterator=master_.begin();
116  DirectoryHistos::iterator masterHistogramIterator_end=master_.end();
117  for (; masterHistogramIterator!=masterHistogramIterator_end;++masterHistogramIterator)
118  {
119  //clone does not book histogram
120  insertedDir.histos[masterHistogramIterator->first]=masterHistogramIterator->second->clone();
121  }
122 
123  //book all copies of the histos
124  DirectoryHistos::iterator clonedHistogramIterator=insertedDir.histos.begin();
125  DirectoryHistos::iterator clonedHistogramIterator_end=insertedDir.histos.end();
126  for (; clonedHistogramIterator!=clonedHistogramIterator_end;++clonedHistogramIterator)
127  {
128  clonedHistogramIterator->second->book(insertedDir.dir);
129  }
130  }
131  else{
132  subDirectoryToUse=&subDirectoryFindIterator->second;
133  }
134 
135  //now that you have the subdirectory: fill histograms for this sub directory
136  DirectoryHistos::iterator histogramIterator=subDirectoryToUse->histos.begin();
137  DirectoryHistos::iterator histogramIterator_end=subDirectoryToUse->histos.end();
138  for(; histogramIterator!=histogramIterator_end;++histogramIterator)
139  { histogramIterator->second->fill(iEvent); }
140  }
Directories directories_
Definition: Plotter.h:212
DirectoryHistos master_
Definition: Plotter.h:191
std::string currentDir_
Definition: Plotter.h:211
std::map< std::string, SubDirectory > SubDirectories
Definition: Plotter.h:200
void VariablePlotter::setDir ( std::string  dir)
inlinevirtual

Implements Plotter.

Definition at line 79 of file Plotter.h.

References currentDir_, dir, VariablePlotter::Directory::dir, directories_, and VariablePlotter::Directory::dirName.

79  {
80  //insert a new one
81  Directory & insertedDirectory = directories_[dir];
82 
83  //create the actual directory in TFile: name is <dir>
84  if (!insertedDirectory.dir){
85  insertedDirectory.dir=new TFileDirectory(edm::Service<TFileService>()->mkdir(dir));
86  insertedDirectory.dirName=dir;
87  }
88 
89  //remember which directory name this is
91  }
Directories directories_
Definition: Plotter.h:212
std::string currentDir_
Definition: Plotter.h:211
dbl *** dir
Definition: mlp_gen.cc:35

Member Data Documentation

std::string VariablePlotter::currentDir_
private

Definition at line 211 of file Plotter.h.

Referenced by fill(), and setDir().

Directories VariablePlotter::directories_
private

Definition at line 212 of file Plotter.h.

Referenced by complete(), fill(), and setDir().

DirectoryHistos VariablePlotter::master_
private

Definition at line 191 of file Plotter.h.

Referenced by fill(), and VariablePlotter().