HighLAND
Public Member Functions | Protected Attributes | List of all members
Experiment Class Reference

Public Member Functions

 Experiment (const std::string &name)
 
 Experiment (const std::string &name, const std::string &configfile)
 
 Experiment (const std::string &name, const std::string &file1, const std::string &file2)
 Create an experiment provided a data and a MC files.
 
bool HasSampleGroup (const std::string &name)
 Checks if the Experiment has a SampleGroup with a given name.
 
void AddSampleGroup (const std::string &name, SampleGroup &sampleGroup)
 
void AddSampleGroup (const std::string &name, const std::string &dataFile, std::map< std::string, std::string > &mcFiles)
 
void AddSampleGroup (const std::string &name, DataSample *dataFile, std::map< std::string, DataSample *> &mcSamples)
 Add group of samples (normally data and MC).
 
std::map< std::string, SampleGroup > & GetSampleGroups ()
 Returns all sample groups.
 
SampleGroupGetSampleGroup (const std::string &name)
 Get a single sample group by name.
 
DataSampleGetDataSample (const std::string &name)
 Returns the data sample in group.
 
DataSampleGetMCSample (const std::string &name, const std::string &name2)
 Returns the by name a MC sample in agroup.
 
std::map< std::string, DataSample * > & GetMCSamples (const std::string &name)
 Returns all MC samples in a group.
 
void DumpPOT (const std::string &name)
 Dump detailed POT information for a given sample pair.
 
void DumpPOTRatios ()
 Dump total good POT for all sample pairs, and the POT ratio for each pair.
 
Float_t GetOverallPOTRatio ()
 Get the overall POT ratio.
 
std::string GetFilePath ()
 
void SetCurrentTree (const std::string &name)
 Set the current configuration to all samples in all SampleGroups.
 
const std::string & GetCurrentTree () const
 Get the current configuration.
 
void Dump ()
 Dump info about the experiment.
 
std::vector< std::string > GetMCFileVector ()
 Return pointer to vector of mc files.
 
std::vector< std::string > GetDataFileVector ()
 Return pointer to vector of data files.
 
void AddSampleFilesToVector (SampleGroup &sampleGroup)
 Method to add file paths to the MC and Data vectors that store them.
 

Protected Attributes

std::string _name
 What the user called this Experiment.
 
std::map< std::string, SampleGroup_sampleGroups
 
std::string _filePath
 
std::string _tree
 The current tree from the tree manager.
 
std::vector< std::string > _mcFiles
 Vector holding all MC file paths associated with this experiment.
 
std::vector< std::string > _dataFiles
 Vector holding all data file paths associated with this experiment.
 

Detailed Description

Definition at line 73 of file Experiment.hxx.

Constructor & Destructor Documentation

§ Experiment() [1/2]

Experiment::Experiment ( const std::string &  name)

Default constructor - just set the name of the experiment. You can add sample groups using AddSampleGroup functions.

Definition at line 149 of file Experiment.cxx.

149  {
150 //********************************************************************
151 
152  _name = name;
153  _filePath = "";
154  _tree="default";
155 }
std::string _tree
The current tree from the tree manager.
Definition: Experiment.hxx:177
std::string _name
What the user called this Experiment.
Definition: Experiment.hxx:165
std::string _filePath
Definition: Experiment.hxx:174

§ Experiment() [2/2]

Experiment::Experiment ( const std::string &  name,
const std::string &  configfile 
)

Automatically add sampleGroups to the experiment, based on the contents of a configuration file.

Each line in this file should relate to one SampleGroup. The first entry on each line is the group name. The samples are then specified in "sampleName:fileName" pairs. The first pair on each line corresponds to the data, the others to MC.

NOTE THAT YOU CANNOT HAVE SPACES IN EITHER THE GROUP NAME OR SAMPLE NAMES.

Example: Run1 Data:run1_data.root MC:run1_mc.root Sand:run1_sand.root Run2 Data:run2_data.root MC:run2_mc.root

Definition at line 169 of file Experiment.cxx.

169  {
170 //**************************************************
171  _name = name;
172  _tree="default";
173 
174 
175  _dataFiles.clear();
176  _mcFiles.clear();
177 
178  std::ifstream infile(configfile.c_str());
179 
180  while (infile) {
181  std::string line;
182  if (!getline(infile, line))
183  break;
184 
185  std::istringstream ssline(line);
186  std::vector<std::string> record;
187 
188  while (ssline) {
189  std::string token;
190  if (!getline(ssline, token, ' ')) break;
191  record.push_back(token);
192  }
193 
194  if (record.size() < 3) {
195  std::cerr << "Invalid format (should be sampleName dataName:dataFile mcName:mcFile [mcName2:mcFile2])" << std::endl;
196  std::cerr << "Saw: " << line << std::endl;
197  continue;
198  }
199 
200  std::string groupName = record[0];
201  std::string dataFile = record[1].replace(0, record[1].find(":") + 1, "");
202  std::cout << "Adding group " << groupName << " with data file " << dataFile << " and MC files ";
203 
204  std::map<std::string, std::string> mcFiles;
205  for (unsigned int i = 2; i < record.size(); i++) {
206  std::string mcName = record[i];
207  std::string mcFile = record[i];
208  mcName = mcName.replace(mcName.find(":"), mcName.size(), "");
209  mcFile = mcFile.replace(0, mcFile.find(":") + 1, "");
210  mcFiles[mcName] = mcFile;
211  std::cout << mcFile << " ";
212  }
213 
214  std::cout << std::endl;
215 
216  _sampleGroups[groupName] = SampleGroup(groupName, dataFile, mcFiles);
217  _filePath = dataFile;
218  }
219 }
std::vector< std::string > _mcFiles
Vector holding all MC file paths associated with this experiment.
Definition: Experiment.hxx:180
std::string _tree
The current tree from the tree manager.
Definition: Experiment.hxx:177
std::string _name
What the user called this Experiment.
Definition: Experiment.hxx:165
std::map< std::string, SampleGroup > _sampleGroups
Definition: Experiment.hxx:169
std::string _filePath
Definition: Experiment.hxx:174
std::vector< std::string > _dataFiles
Vector holding all data file paths associated with this experiment.
Definition: Experiment.hxx:182

Member Function Documentation

§ AddSampleGroup() [1/2]

void Experiment::AddSampleGroup ( const std::string &  name,
SampleGroup sampleGroup 
)

Add a group of samples (normally data and MC). A DataSample object will be generated internally for each.

Definition at line 248 of file Experiment.cxx.

248  {
249 //**************************************************
250 
251  AddSampleFilesToVector(sampleGroup);
252  _sampleGroups[name] = sampleGroup;
253 
254 }
std::map< std::string, SampleGroup > _sampleGroups
Definition: Experiment.hxx:169
void AddSampleFilesToVector(SampleGroup &sampleGroup)
Method to add file paths to the MC and Data vectors that store them.
Definition: Experiment.cxx:233

§ AddSampleGroup() [2/2]

void Experiment::AddSampleGroup ( const std::string &  name,
const std::string &  dataFile,
std::map< std::string, std::string > &  mcFiles 
)

Add a group of samples (normally data and MC). A DataSample object will be generated internally for each.

Definition at line 257 of file Experiment.cxx.

257  {
258 //**************************************************
259 
260  _sampleGroups[name] = SampleGroup(name, dataFile, mcFiles);
262  _filePath = dataFile;
263 }
std::map< std::string, SampleGroup > _sampleGroups
Definition: Experiment.hxx:169
std::string _filePath
Definition: Experiment.hxx:174
void AddSampleFilesToVector(SampleGroup &sampleGroup)
Method to add file paths to the MC and Data vectors that store them.
Definition: Experiment.cxx:233

§ GetFilePath()

std::string Experiment::GetFilePath ( )
inline

If the Experiment was created by passing file paths in (rather than DataSample objects) then return the path to one of those files. This is mainly used in automated scripts where the Experiment(name, configfile) constructor was used and you later need an explicit file path to construct some other object.

Definition at line 142 of file Experiment.hxx.

142 { return _filePath; }
std::string _filePath
Definition: Experiment.hxx:174

Member Data Documentation

§ _filePath

std::string Experiment::_filePath
protected

we keep a record of one of the input files the user specified, so that they can access it later (for example, if they want to instantiate a DrawingTools object using an Experiment rather than specifying a file path directly).

Definition at line 174 of file Experiment.hxx.

§ _sampleGroups

std::map< std::string, SampleGroup > Experiment::_sampleGroups
protected

Configurations that have been added. Structure is name ==> [ sample1, sample2 ]

Definition at line 169 of file Experiment.hxx.


The documentation for this class was generated from the following files: