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 (const edm::ParameterSet &iConfig)
 
 ~VariablePlotter ()
 
- Public Member Functions inherited from Plotter
 Plotter ()
 
 Plotter (const 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 212 of file Plotter.h.

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

Definition at line 193 of file Plotter.h.

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

Definition at line 203 of file Plotter.h.

Constructor & Destructor Documentation

VariablePlotter::VariablePlotter ( const 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, split, and AlCaHLTBitMon_QueryRunRegistry::string.

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  if (hPset.exists("name")) hname = hPset.getParameter<std::string>("name");
44  bool split=hPset.exists("splitter") || hPset.exists("splitters");
45  if (split)
47  else
48  master_[hname]=new ConfigurableHisto(ConfigurableHisto::h1, hname, hPset);
49  }
50 
51  // make profiles
52  edm::ParameterSet tprof=iConfig.getParameter<edm::ParameterSet>("TProfiles");
53  std::vector<std::string> tprofNames;
54  tprof.getParameterSetNames(tprofNames);
55  for (unsigned int iH=0;iH!=tprofNames.size();++iH){
56  std::string hname = tprofNames[iH];
58  bool split=hPset.exists("splitter") || hPset.exists("splitters");
59  if (hPset.exists("name")) hname = hPset.getParameter<std::string>("name");
60  if (split)
62  else
63  master_[hname]=new ConfigurableHisto(ConfigurableHisto::prof, hname, hPset);
64  }
65 
66  // make TH2
68  std::vector<std::string> th2Names;
69  th2.getParameterSetNames(th2Names);
70  for (unsigned int iH=0;iH!=th2Names.size();++iH){
71  std::string hname = th2Names[iH];
73  if (hPset.exists("name")) hname = hPset.getParameter<std::string>("name");
74  bool split=hPset.exists("splitter") || hPset.exists("splitters");
75  if (split)
77  else
78  master_[hname]=new ConfigurableHisto(ConfigurableHisto::h2, hname, hPset);
79  }
80  }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
DirectoryHistos master_
Definition: Plotter.h:194
std::string currentDir_
Definition: Plotter.h:214
size_t getParameterSetNames(std::vector< std::string > &output, bool trackiness=true) const
double split
Definition: MVATrainer.cc:139
VariablePlotter::~VariablePlotter ( )
inline

Definition at line 145 of file Plotter.h.

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

Member Function Documentation

void VariablePlotter::complete ( )
inlinevirtual

Implements Plotter.

Definition at line 169 of file Plotter.h.

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

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

Implements Plotter.

Definition at line 96 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.

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

Implements Plotter.

Definition at line 82 of file Plotter.h.

References currentDir_, dir, VariablePlotter::Directory::dir, directories_, VariablePlotter::Directory::dirName, and eostools::mkdir().

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

Member Data Documentation

std::string VariablePlotter::currentDir_
private

Definition at line 214 of file Plotter.h.

Referenced by fill(), and setDir().

Directories VariablePlotter::directories_
private

Definition at line 215 of file Plotter.h.

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

DirectoryHistos VariablePlotter::master_
private

Definition at line 194 of file Plotter.h.

Referenced by fill(), and VariablePlotter().