Belle II Software light-2411-aldebaran
VariablesToNtupleModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <analysis/modules/VariablesToNtuple/VariablesToNtupleModule.h>
10
11// analysis
12#include <analysis/dataobjects/ParticleList.h>
13#include <analysis/VariableManager/Manager.h>
14#include <analysis/VariableManager/Utility.h>
15#include <analysis/dataobjects/StringWrapper.h>
16
17// framework
18#include <framework/logging/Logger.h>
19#include <framework/pcore/ProcHandler.h>
20#include <framework/core/ModuleParam.templateDetails.h>
21#include <framework/core/Environment.h>
22#include <framework/core/RandomNumbers.h>
23#include <framework/database/Database.h>
24
25// framework - root utilities
26#include <framework/utilities/MakeROOTCompatible.h>
27#include <framework/utilities/RootFileCreationManager.h>
28#include <framework/io/RootIOUtilities.h>
29#include <framework/io/RootFileInfo.h>
30
31
32#include <cmath>
33#include <filesystem>
34
35using namespace std;
36using namespace Belle2;
37using namespace RootIOUtilities;
38
39// Register module in the framework
40REG_MODULE(VariablesToNtuple);
41
42
44 Module(), m_tree("", DataStore::c_Persistent), m_outputFileMetaData("", DataStore::c_Persistent)
45{
46 //Set module properties
47 setDescription("Calculate variables specified by the user for a given ParticleList and save them into a TNtuple. The TNtuple is candidate-based, meaning that the variables of each candidate are saved into separate rows.");
49
50 vector<string> emptylist;
51 addParam("particleList", m_particleList,
52 "Name of particle list with reconstructed particles. If no list is provided the variables are saved once per event (only possible for event-type variables)",
53 std::string(""));
54 addParam("variables", m_variables,
55 "List of variables (or collections) to save. Variables are taken from Variable::Manager, and are identical to those available to e.g. ParticleSelector.",
56 emptylist);
57
58 addParam("fileName", m_fileName, "Name of ROOT file for output. Can be overridden using the -o argument of basf2.",
59 string("VariablesToNtuple.root"));
60 addParam("treeName", m_treeName, "Name of the NTuple in the saved file.", string("ntuple"));
61 addParam("basketSize", m_basketsize, "Size of baskets in Output NTuple in bytes.", 1600);
62
63 std::tuple<std::string, std::map<int, unsigned int>> default_sampling{"", {}};
64 addParam("sampling", m_sampling,
65 "Tuple of variable name and a map of integer values and inverse sampling rate. E.g. (signal, {1: 0, 0:10}) selects all signal candidates and every 10th background candidate.",
66 default_sampling);
67
68 addParam("signalSideParticleList", m_signalSideParticleList,
69 "Name of signal-side particle list to store the index of the signal-side particle when one calls the module in a for_each loop over the RestOfEvent",
70 std::string(""));
71
72 addParam("fileNameSuffix", m_fileNameSuffix, "The suffix of the output ROOT file to be appended before ``.root``.",
73 string(""));
74
75 addParam("useFloat", m_useFloat,
76 "Use float type for floating-point numbers.", false);
77
78 addParam("storeEventType", m_storeEventType,
79 "If true, the branch __eventType__ is added. The eventType information is available from MC16 on.", true);
80
81 addParam("dataDescription", m_dataDescription,
82 "Additional dictionary of "
83 "name->value pairs to be added to the file metadata to describe the data",
85
86 addParam("ignoreCommandLineOverride", m_ignoreCommandLineOverride,
87 "Ignore override of file name via command line argument -o. Useful if you have multiple output modules in one path.", false);
88
89}
90
92{
93 m_eventMetaData.isRequired();
94 if (not m_particleList.empty())
96
97 // Initializing the output root file
98
99 // override the output file name with what's been provided with the -o option
101 const std::string& outputFileArgument = Environment::Instance().getOutputFileOverride();
102 if (!outputFileArgument.empty())
103 m_fileName = outputFileArgument;
104 }
105
106 if (!m_fileNameSuffix.empty())
107 m_fileName = m_fileName.insert(m_fileName.rfind(".root"), m_fileNameSuffix);
108
109 if (m_fileName.empty()) {
110 B2FATAL("Output root file name is not set. Please set a valid root output file name (\"fileName\" module parameter).");
111 }
112 // See if there is already a file in which case add a new tree to it ...
113 // otherwise create a new file (all handled by framework)
115 if (!m_file) {
116 B2ERROR("Could not create file \"" << m_fileName <<
117 "\". Please set a valid root output file name (\"fileName\" module parameter).");
118 return;
119 }
120
121 TDirectory::TContext directoryGuard(m_file.get());
122
123 // check if TTree with that name already exists
124 if (m_file->Get(m_treeName.c_str()) || m_treeName == "persistent") {
125 B2FATAL("Tree with the name \"" << m_treeName
126 << "\" already exists in the file \"" << m_fileName << "\"\n"
127 << "or is reserved for FileMetaData.\n"
128 << "\nYou probably want to either set the output fileName or the treeName to something else:\n\n"
129 << " from modularAnalysis import variablesToNtuple\n"
130 << " variablesToNtuple('pi+:all', ['p'], treename='pions', filename='variablesToNtuple.root')\n"
131 << " variablesToNtuple('gamma:all', ['p'], treename='photons', filename='variablesToNtuple.root') # two trees, same file\n"
132 << "\n == Or ==\n"
133 << " from modularAnalysis import variablesToNtuple\n"
134 << " variablesToNtuple('pi+:all', ['p'], filename='pions.root')\n"
135 << " variablesToNtuple('gamma:all', ['p'], filename='photons.root') # two files\n"
136 );
137 return;
138 }
139
140 // set up tree and register it in the datastore
142 m_tree.construct(m_treeName.c_str(), "");
143 m_tree->get().SetCacheSize(100000);
144
147 m_outputFileMetaData.create();
148 }
150
151 // declare counter branches - pass through variable list, remove counters added by user
152 m_tree->get().Branch("__experiment__", &m_experiment, "__experiment__/I");
153 m_tree->get().Branch("__run__", &m_run, "__run__/I");
154 m_tree->get().Branch("__event__", &m_event, "__event__/i");
155 m_tree->get().Branch("__production__", &m_production, "__production__/I");
156 if (not m_particleList.empty()) {
157 m_tree->get().Branch("__candidate__", &m_candidate, "__candidate__/I");
158 m_tree->get().Branch("__ncandidates__", &m_ncandidates, "__ncandidates__/I");
159 }
160
161 if (not m_signalSideParticleList.empty()) {
163 m_tree->get().Branch("__signalSideCandidate__", &m_signalSideCandidate, "__signalSideCandidate__/I");
164 m_tree->get().Branch("__nSignalSideCandidates__", &m_nSignalSideCandidates, "__nSignalSideCandidates__/I");
165 if (not m_roe.isOptional("RestOfEvent")) {
166 B2WARNING("The signalSideParticleList is set outside of a for_each loop over the RestOfEvent. "
167 << "__signalSideCandidates__ and __nSignalSideCandidate__ will be always -1 and 0, respectively.");
168 }
169 }
170
171 if (m_stringWrapper.isOptional("MCDecayString"))
172 m_tree->get().Branch("__MCDecayString__", &m_MCDecayString);
173
174 if (m_storeEventType) {
175 m_tree->get().Branch("__eventType__", &m_eventType);
176 if (not m_eventExtraInfo.isOptional())
177 B2INFO("EventExtraInfo is not registered. __eventType__ will be empty. The eventType is available from MC16 on.");
178 }
179
180 for (const auto& variable : m_variables)
181 if (Variable::isCounterVariable(variable)) {
182 B2WARNING("The counter '" << variable
183 << "' is handled automatically by VariablesToNtuple, you don't need to add it.");
184 }
185
186 // declare branches and get the variable strings
188 // remove duplicates from list of variables but keep the previous order
189 unordered_set<string> seen;
190 auto newEnd = remove_if(m_variables.begin(), m_variables.end(), [&seen](const string & varStr) {
191 if (seen.find(varStr) != std::end(seen)) return true;
192 seen.insert(varStr);
193 return false;
194 });
195 m_variables.erase(newEnd, m_variables.end());
196
197 if (m_useFloat)
198 m_branchAddressesFloat.resize(m_variables.size() + 1);
199 else
200 m_branchAddressesDouble.resize(m_variables.size() + 1);
201 m_branchAddressesInt.resize(m_variables.size() + 1);
202 if (m_useFloat) {
203 m_tree->get().Branch("__weight__", &m_branchAddressesFloat[0], "__weight__/F");
204 } else {
205 m_tree->get().Branch("__weight__", &m_branchAddressesDouble[0], "__weight__/D");
206 }
207 size_t enumerate = 1;
208 for (const string& varStr : m_variables) {
209 string branchName = MakeROOTCompatible::makeROOTCompatible(varStr);
210
211 // Check for deprecated variables
213
214 // also collection function pointers
216 if (!var) {
217 B2ERROR("Variable '" << varStr << "' is not available in Variable::Manager!");
218 } else {
219 if (m_particleList.empty() && var->description.find("[Eventbased]") == string::npos) {
220 B2ERROR("Variable '" << varStr << "' is not an event-based variable, "
221 "but you are using VariablesToNtuple without a decay string, i.e. in the event-wise mode.\n"
222 "If you have created an event-based alias you can wrap your alias with `eventCached` to "
223 "declare it as event based, which avoids this error.\n\n"
224 "vm.addAlias('myAliasName', 'eventCached(myAlias)')");
225 continue;
226 }
227 if (var->variabletype == Variable::Manager::VariableDataType::c_double) {
228 if (m_useFloat) {
229 m_tree->get().Branch(branchName.c_str(), &m_branchAddressesFloat[enumerate], (branchName + "/F").c_str());
230 } else {
231 m_tree->get().Branch(branchName.c_str(), &m_branchAddressesDouble[enumerate], (branchName + "/D").c_str());
232 }
233 } else if (var->variabletype == Variable::Manager::VariableDataType::c_int) {
234 m_tree->get().Branch(branchName.c_str(), &m_branchAddressesInt[enumerate], (branchName + "/I").c_str());
235 } else if (var->variabletype == Variable::Manager::VariableDataType::c_bool) {
236 m_tree->get().Branch(branchName.c_str(), &m_branchAddressesInt[enumerate], (branchName + "/O").c_str());
237 }
238 m_functions.push_back(std::make_pair(var->function, var->variabletype));
239 }
240 enumerate++;
241 }
242 m_tree->get().SetBasketSize("*", m_basketsize);
243
244 m_sampling_name = std::get<0>(m_sampling);
245 m_sampling_rates = std::get<1>(m_sampling);
246
247 if (m_sampling_name != "") {
249 if (m_sampling_variable == nullptr) {
250 B2FATAL("Couldn't find sample variable " << m_sampling_name << " via the Variable::Manager. Check the name!");
251 }
252 for (const auto& pair : m_sampling_rates)
253 m_sampling_counts[pair.first] = 0;
254 } else {
255 m_sampling_variable = nullptr;
256 }
257
258}
259
260
262{
263 if (m_sampling_variable == nullptr)
264 return 1.0;
265
266 long target = 0;
267 if (m_sampling_variable->variabletype == Variable::Manager::VariableDataType::c_double) {
268 target = std::lround(std::get<double>(m_sampling_variable->function(particle)));
269 } else if (m_sampling_variable->variabletype == Variable::Manager::VariableDataType::c_int) {
270 target = std::lround(std::get<int>(m_sampling_variable->function(particle)));
271 } else if (m_sampling_variable->variabletype == Variable::Manager::VariableDataType::c_bool) {
272 target = std::lround(std::get<bool>(m_sampling_variable->function(particle)));
273 }
274 if (m_sampling_rates.find(target) != m_sampling_rates.end() and m_sampling_rates[target] > 0) {
275 m_sampling_counts[target]++;
276 if (m_sampling_counts[target] % m_sampling_rates[target] != 0)
277 return 0;
278 else {
279 m_sampling_counts[target] = 0;
280 return m_sampling_rates[target];
281 }
282 }
283 return 1.0;
284}
285
287{
288 m_event = m_eventMetaData->getEvent();
289 m_run = m_eventMetaData->getRun();
290 m_experiment = m_eventMetaData->getExperiment();
291 m_production = m_eventMetaData->getProduction();
292
293 if (m_experimentLow > m_experimentHigh) { //starting condition
297 } else {
299 ((m_experiment == m_experimentLow) && ((m_run < m_runLow) || ((m_run == m_runLow) && (m_event < m_eventLow))))) {
301 m_runLow = m_run;
303 }
309 }
310 }
311
312 if (m_inputFileMetaData.isValid()) {
313 std::string lfn = m_inputFileMetaData->getLfn();
314 if (not lfn.empty() and (m_parentLfns.empty() or (m_parentLfns.back() != lfn))) {
315 m_parentLfns.push_back(lfn);
316 }
317 }
318
319 // check if the event is a full event or not: if yes, increase the counter
320 if (m_eventMetaData->getErrorFlag() == 0) // no error flag -> this is a full event
321 m_eventCount++;
322
323 if (m_stringWrapper.isValid())
324 m_MCDecayString = m_stringWrapper->getString();
325 else
326 m_MCDecayString = "";
327
328 if (m_storeEventType and m_eventExtraInfo.isValid())
329 m_eventType = m_eventExtraInfo->getEventType();
330 else
331 m_eventType = "";
332
333 if (not m_signalSideParticleList.empty()) {
334 if (m_roe.isValid()) {
336 auto signal = m_roe->getRelatedFrom<Particle>();
337 m_signalSideCandidate = signaSideParticleList->getIndex(signal);
338 m_nSignalSideCandidates = signaSideParticleList->getListSize();
339 } else {
342 }
343 }
344
345 if (m_particleList.empty()) {
346 double weight = getInverseSamplingRateWeight(nullptr);
347 if (m_useFloat) {
348 m_branchAddressesFloat[0] = weight;
349 } else {
350 m_branchAddressesDouble[0] = weight;
351 }
352 if (weight > 0) {
353 for (unsigned int iVar = 0; iVar < m_variables.size(); iVar++) {
354 auto var_result = std::get<0>(m_functions[iVar])(nullptr);
355 auto var_type = std::get<1>(m_functions[iVar]);
356 if (std::holds_alternative<double>(var_result)) {
357 if (var_type != Variable::Manager::VariableDataType::c_double)
358 B2WARNING("Wrong registered data type for variable '" + m_variables[iVar] +
359 "'. Expected Variable::Manager::VariableDataType::c_double. Exported data for this variable might be incorrect.");
360 if (m_useFloat) {
361 m_branchAddressesFloat[iVar + 1] = std::get<double>(var_result);
362 } else {
363 m_branchAddressesDouble[iVar + 1] = std::get<double>(var_result);
364 }
365 } else if (std::holds_alternative<int>(var_result)) {
366 if (var_type != Variable::Manager::VariableDataType::c_int)
367 B2WARNING("Wrong registered data type for variable '" + m_variables[iVar] +
368 "'. Expected Variable::Manager::VariableDataType::c_int. Exported data for this variable might be incorrect.");
369 m_branchAddressesInt[iVar + 1] = std::get<int>(var_result);
370 } else if (std::holds_alternative<bool>(var_result)) {
371 if (var_type != Variable::Manager::VariableDataType::c_bool)
372 B2WARNING("Wrong registered data type for variable '" + m_variables[iVar] +
373 "'. Expected Variable::Manager::VariableDataType::c_bool. Exported data for this variable might be incorrect.");
374 m_branchAddressesInt[iVar + 1] = std::get<bool>(var_result);
375 }
376 }
377 m_tree->get().Fill();
378 }
379
380 } else {
382 m_ncandidates = particlelist->getListSize();
383 for (unsigned int iPart = 0; iPart < m_ncandidates; iPart++) {
384 m_candidate = iPart;
385 const Particle* particle = particlelist->getParticle(iPart);
386 double weight = getInverseSamplingRateWeight(particle);
387 if (m_useFloat) {
388 m_branchAddressesFloat[0] = weight;
389 } else {
390 m_branchAddressesDouble[0] = weight;
391 }
392 if (weight > 0) {
393 for (unsigned int iVar = 0; iVar < m_variables.size(); iVar++) {
394 auto var_result = std::get<0>(m_functions[iVar])(particle);
395 auto var_type = std::get<1>(m_functions[iVar]);
396 if (std::holds_alternative<double>(var_result)) {
397 if (var_type != Variable::Manager::VariableDataType::c_double)
398 B2WARNING("Wrong registered data type for variable '" + m_variables[iVar] +
399 "'. Expected Variable::Manager::VariableDataType::c_double. Exported data for this variable might be incorrect.");
400 if (m_useFloat) {
401 m_branchAddressesFloat[iVar + 1] = std::get<double>(var_result);
402 } else {
403 m_branchAddressesDouble[iVar + 1] = std::get<double>(var_result);
404 }
405 } else if (std::holds_alternative<int>(var_result)) {
406 if (var_type != Variable::Manager::VariableDataType::c_int)
407 B2WARNING("Wrong registered data type for variable '" + m_variables[iVar] +
408 "'. Expected Variable::Manager::VariableDataType::c_int. Exported data for this variable might be incorrect.");
409 m_branchAddressesInt[iVar + 1] = std::get<int>(var_result);
410 } else if (std::holds_alternative<bool>(var_result)) {
411 if (var_type != Variable::Manager::VariableDataType::c_bool)
412 B2WARNING("Wrong registered data type for variable '" + m_variables[iVar] +
413 "'. Expected Variable::Manager::VariableDataType::c_bool. Exported data for this variable might be incorrect.");
414 m_branchAddressesInt[iVar + 1] = std::get<bool>(var_result);
415 }
416 }
417 m_tree->get().Fill();
418 }
419 }
420 }
421}
422
424{
425
426 FileMetaData outputFileMetaData;
427 bool isMC = (m_inputFileMetaData) ? m_inputFileMetaData->isMC() : true;
428 if (!isMC) outputFileMetaData.declareRealData();
429
430 outputFileMetaData.setLow(m_experimentLow, m_runLow, m_eventLow);
431 outputFileMetaData.setHigh(m_experimentHigh, m_runHigh, m_eventHigh);
432 outputFileMetaData.setNEvents(m_tree->get().GetEntries());
433 outputFileMetaData.setNFullEvents(m_eventCount);
434
435 //fill more file level metadata
436 RootIOUtilities::setCreationData(outputFileMetaData);
437 outputFileMetaData.setRandomSeed(RandomNumbers::getSeed());
438 outputFileMetaData.setSteering(Environment::Instance().getSteering());
439 auto mcEvents = Environment::Instance().getNumberOfMCEvents();
440 outputFileMetaData.setMcEvents(mcEvents);
441 outputFileMetaData.setDatabaseGlobalTag(Database::Instance().getGlobalTags());
442 for (const auto& item : m_dataDescription) {
443 m_outputFileMetaData->setDataDescription(item.first, item.second);
444 }
445 for (const auto& item : m_outputFileMetaData->getDataDescription()) {
446 outputFileMetaData.setDataDescription(item.first, item.second);
447 }
448 outputFileMetaData.setDataDescription("isNtupleMetaData", "True");
449 std::sort(m_parentLfns.begin(), m_parentLfns.end());
450 m_parentLfns.erase(std::unique(m_parentLfns.begin(), m_parentLfns.end()), m_parentLfns.end());
451 outputFileMetaData.setParents(m_parentLfns);
452 outputFileMetaData.setLfn(m_file->GetName());
453
454 TTree* persistent = new TTree(c_treeNames[DataStore::c_Persistent].c_str(), c_treeNames[DataStore::c_Persistent].c_str());
455 persistent->Branch("FileMetaData", &outputFileMetaData);
456 persistent->Fill();
457 persistent->Write("persistent", TObject::kWriteDelete);
458}
459
461{
463
464 TDirectory::TContext directoryGuard(m_file.get());
466
467 B2INFO("Writing NTuple " << m_treeName);
468 m_tree->write(m_file.get());
469
470 const bool writeError = m_file->TestBit(TFile::kWriteError);
471 m_file.reset();
472 if (writeError) {
473 B2FATAL("A write error occurred while saving '" << m_fileName << "', please check if enough disk space is available.");
474 }
475 }
476}
In the store you can park objects that have to be accessed by various modules.
Definition: DataStore.h:51
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
Definition: DataStore.h:71
@ c_Persistent
Object is available during entire execution time.
Definition: DataStore.h:60
unsigned int getNumberOfMCEvents() const
Number of generated events (from EventInfoSetter).
Definition: Environment.h:106
const std::string & getOutputFileOverride() const
Return overriden output file name, or "" if none was set.
Definition: Environment.h:127
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28
Metadata information about a file.
Definition: FileMetaData.h:29
void setLow(int experiment, int run, unsigned int event)
Lowest experiment, run and event number setter.
Definition: FileMetaData.h:159
void setHigh(int experiment, int run, unsigned int event)
Highest experiment, run and event number setter.
Definition: FileMetaData.h:167
void setRandomSeed(const std::string &seed)
Random seed setter.
Definition: FileMetaData.h:189
void setSteering(const std::string &steering)
Steering file content setter.
Definition: FileMetaData.h:195
void declareRealData()
Declare that this is not generated, but real data.
Definition: FileMetaData.h:294
void setNFullEvents(unsigned int nEvents)
Number of full events setter.
Definition: FileMetaData.h:151
void setDatabaseGlobalTag(const std::string &globalTag)
Set the database global tag used when creating this file.
Definition: FileMetaData.h:208
void setLfn(const std::string &lfn)
Setter for LFN.
Definition: FileMetaData.h:139
void setDataDescription(const std::string &key, const std::string &value)
describe the data, if the key exists contents will be overwritten.
Definition: FileMetaData.h:214
void setNEvents(unsigned int nEvents)
Number of events setter.
Definition: FileMetaData.h:145
void setMcEvents(unsigned int nEvents)
Number of generated events setter.
Definition: FileMetaData.h:201
void setParents(const std::vector< std::string > &parents)
Parents setter.
Definition: FileMetaData.h:173
static std::string makeROOTCompatible(std::string str)
Remove special characters that ROOT dislikes in branch names, e.g.
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
@ c_TerminateInAllProcesses
When using parallel processing, call this module's terminate() function in all processes().
Definition: Module.h:83
Class to store reconstructed particles.
Definition: Particle.h:75
static bool isOutputProcess()
Return true if the process is an output process.
Definition: ProcHandler.cc:232
static bool parallelProcessingUsed()
Returns true if multiple processes have been spawned, false in single-core mode.
Definition: ProcHandler.cc:226
static std::string getSeed()
Get the random number generator seed.
Definition: RandomNumbers.h:92
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
std::vector< std::string > resolveCollections(const std::vector< std::string > &variables)
Resolve Collection Returns variable names corresponding to the given collection or if it is not a col...
Definition: Manager.cc:179
const Var * getVariable(std::string name)
Get the variable belonging to the given key.
Definition: Manager.cc:57
static Manager & Instance()
get singleton instance.
Definition: Manager.cc:25
void checkDeprecatedVariable(const std::string &name)
Check if a variable is deprecated.
Definition: Manager.cc:443
StoreObjPtr< RestOfEvent > m_roe
ROE object.
StoreObjPtr< FileMetaData > m_inputFileMetaData
Pointer to the input file meta data.
bool m_useFloat
Use float type for floating-point numbers.
void fillFileMetaData()
Create and fill FileMetaData object.
std::vector< std::string > m_variables
List of variables to save.
std::vector< float > m_branchAddressesFloat
Branch addresses of variables of type float.
virtual void initialize() override
Initialises the module.
std::map< int, unsigned int > m_sampling_rates
Inverse sampling rates.
virtual void event() override
Method called for each event.
unsigned int m_ncandidates
total n candidates
virtual void terminate() override
Write TTree to file, and close file if necessary.
StoreObjPtr< EventMetaData > m_eventMetaData
the event information
std::map< std::string, std::string > m_dataDescription
Additional metadata description.
std::map< int, unsigned long int > m_sampling_counts
Current number of samples with this value.
std::string m_fileName
Name of ROOT file for output.
std::vector< std::pair< Variable::Manager::FunctionPtr, Variable::Manager::VariableDataType > > m_functions
List of pairs of function pointers and respective data type corresponding to given variables.
std::tuple< std::string, std::map< int, unsigned int > > m_sampling
Tuple of variable name and a map of integer values and inverse sampling rate.
std::vector< int > m_branchAddressesInt
Branch addresses of variables of type int (or bool)
int m_basketsize
Size of TBaskets in the output ROOT file in bytes.
int m_production
production ID (to distinguish MC samples)
unsigned int m_nSignalSideCandidates
total n signal-side candidates
unsigned int m_eventCount
event counter
StoreObjPtr< StringWrapper > m_stringWrapper
string wrapper storing the MCDecayString
bool m_storeEventType
If true, the branch eventType is added.
std::string m_particleList
Name of particle list with reconstructed particles.
bool m_ignoreCommandLineOverride
if true, ignore override of filename
std::string m_eventType
EventType to be filled.
StoreObjPtr< FileMetaData > m_outputFileMetaData
File meta data to be stored in the output ntuple file.
StoreObjPtr< RootMergeable< TTree > > m_tree
The ROOT TNtuple for output.
std::shared_ptr< TFile > m_file
ROOT file for output.
std::vector< double > m_branchAddressesDouble
Branch addresses of variables of type double.
std::string m_sampling_name
Variable name of sampling variable.
float getInverseSamplingRateWeight(const Particle *particle)
Calculate inverse sampling rate weight.
int m_experimentLow
lowest experiment number
StoreObjPtr< EventExtraInfo > m_eventExtraInfo
pointer to EventExtraInfo
std::string m_treeName
Name of the TTree.
std::string m_signalSideParticleList
Name of signal-side particle list
const Variable::Manager::Var * m_sampling_variable
Variable Pointer to target variable.
int m_experimentHigh
highest experiment number
int m_signalSideCandidate
signal-side candidate counter
std::vector< std::string > m_parentLfns
Vector of parent file LFNs.
std::string m_fileNameSuffix
Suffix to be appended to the output file name.
std::string m_MCDecayString
MC decay string to be filled.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
std::shared_ptr< TFile > getFile(std::string, bool ignoreErrors=false)
Get a file with a specific name, if is does not exist it will be created.
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:42
static RootFileCreationManager & getInstance()
Interface for the FileManager.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
const std::string c_treeNames[]
Names of trees.
void setCreationData(FileMetaData &metadata)
Fill the creation info of a file meta data: site, user, data.
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24
STL namespace.
VariableDataType variabletype
data type of variable
Definition: Manager.h:133
A variable returning a floating-point value for a given Particle.
Definition: Manager.h:146
FunctionPtr function
Pointer to function.
Definition: Manager.h:147