CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
PhysicsTools::TreeReader::Value Class Reference

#include <TreeReader.h>

Public Member Functions

void fill (AtomicId name, TreeReader *reader) const
 
void setBranchName (const TString &name)
 
void setOpt (bool opt, double optVal)
 
void setPtr (const void *ptr)
 
void update (TreeReader *reader) const
 
 Value ()
 
 Value (int index, bool multiple, bool optional, char type)
 
 ~Value ()
 

Private Attributes

int index
 
bool multiple
 
TString name
 
bool optional
 
double optVal
 
const void * ptr
 
char type
 

Detailed Description

Definition at line 62 of file TreeReader.h.

Constructor & Destructor Documentation

PhysicsTools::TreeReader::Value::Value ( )
inline

Definition at line 64 of file TreeReader.h.

64 {}
PhysicsTools::TreeReader::Value::Value ( int  index,
bool  multiple,
bool  optional,
char  type 
)
inline
PhysicsTools::TreeReader::Value::~Value ( )
inline

Definition at line 72 of file TreeReader.h.

72 {}

Member Function Documentation

void PhysicsTools::TreeReader::Value::fill ( AtomicId  name,
TreeReader reader 
) const

Definition at line 348 of file TreeReader.cc.

References PhysicsTools::Variable::ValueList::add(), PhysicsTools::TreeReader::multiBool, PhysicsTools::TreeReader::multiDouble, PhysicsTools::TreeReader::multiFloat, PhysicsTools::TreeReader::multiInt, Types::optional, PhysicsTools::TreeReader::singleBool, PhysicsTools::TreeReader::singleDouble, PhysicsTools::TreeReader::singleFloat, PhysicsTools::TreeReader::singleInt, relativeConstraints::value, and PhysicsTools::TreeReader::values.

348  {
349  if (multiple) {
350  switch (type) {
351  case 'D': {
352  const std::vector<Double_t> *values = static_cast<const std::vector<Double_t> *>(ptr);
353  if (!values)
354  values = &reader->multiDouble[index].second;
355  for (std::vector<Double_t>::const_iterator iter = values->begin(); iter != values->end(); iter++)
356  reader->values.add(name, *iter);
357  break;
358  }
359  case 'F': {
360  const std::vector<Float_t> *values = static_cast<const std::vector<Float_t> *>(ptr);
361  if (!values)
362  values = &reader->multiFloat[index].second;
363  for (std::vector<Float_t>::const_iterator iter = values->begin(); iter != values->end(); iter++)
364  reader->values.add(name, *iter);
365  break;
366  }
367  case 'I': {
368  const std::vector<Int_t> *values = static_cast<const std::vector<Int_t> *>(ptr);
369  if (!values)
370  values = &reader->multiInt[index].second;
371  for (std::vector<Int_t>::const_iterator iter = values->begin(); iter != values->end(); iter++)
372  reader->values.add(name, *iter);
373  break;
374  }
375  case 'B': {
376  const std::vector<Bool_t> *values = static_cast<const std::vector<Bool_t> *>(ptr);
377  if (!values)
378  values = &reader->multiBool[index].second;
379  for (std::vector<Bool_t>::const_iterator iter = values->begin(); iter != values->end(); iter++)
380  reader->values.add(name, *iter);
381  break;
382  }
383  }
384  } else {
385  double value = 0.0;
386 
387  switch (type) {
388  case 'D':
389  value = ptr ? *(const Double_t *)ptr : reader->singleDouble[index];
390  break;
391  case 'F':
392  value = ptr ? *(const Float_t *)ptr : reader->singleFloat[index];
393  break;
394  case 'I':
395  value = ptr ? *(const Int_t *)ptr : reader->singleInt[index];
396  break;
397  case 'B':
398  value = ptr ? *(const Bool_t *)ptr : reader->singleBool[index];
399  break;
400  }
401 
402  if (!optional || value != optVal)
403  reader->values.add(name, value);
404  }
405  }
Variable::ValueList values
Definition: TreeReader.h:107
tuple reader
Definition: DQM.py:105
void PhysicsTools::TreeReader::Value::setBranchName ( const TString &  name)
inline

Definition at line 75 of file TreeReader.h.

References name.

75 { this->name = name; }
void PhysicsTools::TreeReader::Value::setOpt ( bool  opt,
double  optVal 
)
inline

Definition at line 74 of file TreeReader.h.

References runTheMatrix::opt, optional, and optVal.

void PhysicsTools::TreeReader::Value::setPtr ( const void *  ptr)
inline

Definition at line 76 of file TreeReader.h.

References ptr.

76 { this->ptr = ptr; }
void PhysicsTools::TreeReader::Value::update ( TreeReader reader) const

Definition at line 304 of file TreeReader.cc.

References index, PhysicsTools::TreeReader::multiBool, PhysicsTools::TreeReader::multiDouble, PhysicsTools::TreeReader::multiFloat, PhysicsTools::TreeReader::multiInt, multiple, name, ptr, PhysicsTools::TreeReader::singleBool, PhysicsTools::TreeReader::singleDouble, PhysicsTools::TreeReader::singleFloat, PhysicsTools::TreeReader::singleInt, PhysicsTools::TreeReader::tree, and relativeConstraints::value.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

304  {
305  if (ptr)
306  return;
307 
308  void *value = nullptr;
309  if (multiple) {
310  switch (type) {
311  case 'D':
312  reader->multiDouble[index].first = &reader->multiDouble[index].second;
313  value = &reader->multiDouble[index].first;
314  break;
315  case 'F':
316  reader->multiFloat[index].first = &reader->multiFloat[index].second;
317  value = &reader->multiFloat[index].first;
318  break;
319  case 'I':
320  reader->multiInt[index].first = &reader->multiInt[index].second;
321  value = &reader->multiInt[index].first;
322  break;
323  case 'B':
324  reader->multiBool[index].first = value;
325  value = &reader->multiBool[index].first;
326  break;
327  }
328  } else {
329  switch (type) {
330  case 'D':
331  value = &reader->singleDouble[index];
332  break;
333  case 'F':
334  value = &reader->singleFloat[index];
335  break;
336  case 'I':
337  value = &reader->singleInt[index];
338  break;
339  case 'B':
340  value = &reader->singleBool[index];
341  break;
342  }
343  }
344 
345  reader->tree->SetBranchAddress(name, value);
346  }
tuple reader
Definition: DQM.py:105

Member Data Documentation

int PhysicsTools::TreeReader::Value::index
private

Definition at line 83 of file TreeReader.h.

Referenced by BeautifulSoup.PageElement::_invert(), and update().

bool PhysicsTools::TreeReader::Value::multiple
private

Definition at line 85 of file TreeReader.h.

Referenced by update().

TString PhysicsTools::TreeReader::Value::name
private
bool PhysicsTools::TreeReader::Value::optional
private

Definition at line 84 of file TreeReader.h.

Referenced by setOpt().

double PhysicsTools::TreeReader::Value::optVal
private

Definition at line 86 of file TreeReader.h.

Referenced by setOpt().

const void* PhysicsTools::TreeReader::Value::ptr
private

Definition at line 88 of file TreeReader.h.

Referenced by setPtr(), and update().

char PhysicsTools::TreeReader::Value::type
private

Definition at line 87 of file TreeReader.h.