ATLAS Offline Software
Classes | Functions | Variables
dqi Namespace Reference

Classes

class  CompositeAlgorithm
 
class  ConditionsSingleton
 
class  CorrelationYX
 
class  CountsBinsGreaterThan
 
class  DatabaseConfig
 
class  DisableMustClean
 
class  HanAlgorithmConfig
 
class  HanApp
 
class  HanConfig
 
class  HanConfigAlgLimit
 
class  HanConfigAlgPar
 
class  HanConfigAssessor
 
class  HanConfigCompAlg
 
class  HanConfigGroup
 
class  HanConfigMetadata
 
class  HanConfigParMap
 
class  HanHistogramLink
 
class  HanInputRootFile
 
class  HanOutput
 
class  HanRuntimeConfigSingleton
 
class  MiniConfig
 description More...
 
class  MiniConfigTreeNode
 A node of a tree structure holding a configuration, where each node may be given attributes, and a node inherits the attributes of parent nodes if those attributes are not redefined. More...
 

Functions

nlohmann::ordered_json to_JSON (TSeqCollection *tseq)
 Converts sequense, containing TDirectories and strings to JSON file. More...
 
TSeqCollection * newTList (const char *name, TObject *obj=0)
 
TSeqCollection * newTObjArray (const char *name, TObject *obj=0, Int_t size=TCollection::kInitCapacity)
 
TKey * getObjKey (TDirectory *dir, const std::string &path)
 
void dolsr (const TDirectory *dir, std::vector< std::string > &hists, const TDirectory *topdir=nullptr)
 
bool setNameGeneral (TObject *obj, const std::string &name)
 

Variables

std::mutex root_mutex
 

Function Documentation

◆ dolsr()

void dqi::dolsr ( const TDirectory *  dir,
std::vector< std::string > &  hists,
const TDirectory *  topdir = nullptr 
)

Definition at line 81 of file HanUtils.cxx.

82 {
83  // permit calling with two arguments
84  if (topdir == NULL) {
85  topdir = dir;
86  }
87  TIter keys(dir->GetListOfKeys());
88  TKey* key;
89  std::string fullpath(dir->GetPath());
90  std::string toppath(topdir->GetPath());
91  std::string::size_type toppathlen = toppath.length();
92  while ((key = dynamic_cast<TKey*>(keys())) != NULL) {
93  if (CxxUtils::starts_with(key->GetClassName(), "TDirectory")) {
94  TDirectory* newdir = dynamic_cast<TDirectory*>(key->ReadObj());
95  if (!newdir) {
96  std::cerr << "WARNING: cannot read directory "
97  << fullpath << "/" << key->GetName()
98  << "; skipping" << std::endl;
99  } else {
100  dolsr(newdir, hists, topdir);
101  }
102  delete newdir;
103  } else {
104  if (std::string(key->GetName()) == "metadata") {
105  continue;
106  }
107  std::string path;
108  if (fullpath.substr(0, toppathlen) == toppath) {
109  int extra = 1;
110  if (toppath[toppathlen-1] == '/') extra = 0;
111  path = fullpath.substr(toppathlen + extra, std::string::npos);
112  } else {
113  path = fullpath;
114  }
115  hists.push_back(path+"/"+std::string(key->GetName()));
116  }
117  }
118 }

◆ getObjKey()

TKey * dqi::getObjKey ( TDirectory *  dir,
const std::string &  path 
)

Definition at line 37 of file HanUtils.cxx.

38 {
39  if( dir == 0 )
40  return 0;
41 
42  std::string::size_type i = path.find_first_of('/');
43  if( i != std::string::npos ) {
44  std::string dName( path, 0, i );
45  std::string pName( path, i+1, std::string::npos );
46  if( dName != "" ) {
47  TDirectory* subDir = dir->GetDirectory(dName.c_str());
48  if (subDir != 0) {
49  TKey* rv = getObjKey( subDir, pName );
50  //delete subDir;
51  return rv;
52  }
53  // TKey* key = dir->FindKey( dName.c_str() );
54  // if( key != 0 ) {
55  // TDirectory* subDir = dynamic_cast<TDirectory*>( key->ReadObj() );
56  // TKey* rv = getObjKey( subDir, pName );
57  // // delete subDir;
58  // return rv;
59  // }
60  return 0;
61  }
62  return getObjKey( dir, pName );
63  }
64 
65  return dir->FindKey( path.c_str() );
66 }

◆ newTList()

TSeqCollection * dqi::newTList ( const char *  name,
TObject *  obj = 0 
)

Definition at line 19 of file HanUtils.cxx.

20 {
21  TList *ret = new TList();
22  ret->SetName(name);
23  if (obj != 0)
24  ret->Add(obj);
25  return ret;
26 }

◆ newTObjArray()

TSeqCollection * dqi::newTObjArray ( const char *  name,
TObject *  obj = 0,
Int_t  size = TCollection::kInitCapacity 
)

Definition at line 28 of file HanUtils.cxx.

29 {
30  TObjArray *ret = new TObjArray(size);
31  ret->SetName(name);
32  if (obj != NULL)
33  ret->Add(obj);
34  return ret;
35 }

◆ setNameGeneral()

bool dqi::setNameGeneral ( TObject *  obj,
const std::string &  name 
)

Definition at line 44 of file HanOutput.cxx.

45  {
46  if (obj != 0)
47  {
48  // some special cases, to avoid interpreter
49  if (TH1* h = dynamic_cast<TH1*>(obj))
50  {
51  h->SetName(name.c_str());
52  return true;
53  }
54  else if (TObjArray* a = dynamic_cast<TObjArray*>(obj))
55  {
56  a->SetName(name.c_str());
57  return true;
58  }
59  else if (TGraph* g = dynamic_cast<TGraph*>(obj))
60  {
61  g->SetName(name.c_str());
62  return true;
63  }
64  else if (TEfficiency* e = dynamic_cast<TEfficiency*>(obj))
65  {
66  e->SetName(name.c_str());
67  return true;
68  }
69  else
70  {
71  TClass* kl = obj->IsA();
72  TMethod* klm = kl->GetMethod("SetName", "\"Reference\"");
73  if (!klm)
74  {
75  std::cerr << "Error: attempt to change object name to " << name << " failed as its name is not settable"
76  << std::endl;
77  }
78  else
79  {
80  std::cout << "Manually doing cast for " << name << " of class " << kl->GetName() << std::endl;
81  obj->Execute("SetName", ("\"" + name + "\"").c_str());
82  return true;
83  }
84  }
85  }
86  return false;
87  }

◆ to_JSON()

nlohmann::ordered_json dqi::to_JSON ( TSeqCollection *  tseq)

Converts sequense, containing TDirectories and strings to JSON file.

Definition at line 535 of file HanOutput.cxx.

536  {
537  using json = nlohmann::ordered_json;
538  json j;
539 
540  TIter nextElem(tseq);
541  TObject* obj;
542  while ((obj = nextElem()) != 0)
543  {
544  // If Results (or Config) directory contatins hist - ignore it (do not write in to the file), it
545  // should to be writen to the outer level before
546  if ((strncmp(obj->ClassName(), "TH", 2) == 0) || (strncmp(obj->ClassName(), "TGraph", 6) == 0) ||
547  (strncmp(obj->ClassName(), "TProfile", 8) == 0) || (strncmp(obj->ClassName(), "TEfficiency", 11) == 0) ||
548  (strncmp(obj->GetName(), "Reference", 9) == 0))
549 
550  {
551  continue;
552  }
553  TSeqCollection* tmpList = dynamic_cast<TSeqCollection*>(obj);
554  if (tmpList != 0)
555  { // Nested object
556  // Write TSeqCollection_names as keys and content of them as a values
557  // Convert TString to string
558  std::string key_name_string(obj->GetName());
559  j.emplace(key_name_string, to_JSON(tmpList));
560  }
561  else
562  { // leaf
563  j = obj->GetName();
564  }
565  }
566  return j;
567  }

Variable Documentation

◆ root_mutex

std::mutex dqi::root_mutex

Definition at line 17 of file HanUtils.cxx.

to_JSON
nlohmann::ordered_json to_JSON(TObject *obj)
Definition: HanOutputFile_translation.cxx:281
dqi::dolsr
void dolsr(const TDirectory *dir, std::vector< std::string > &hists, const TDirectory *topdir=nullptr)
Definition: HanUtils.cxx:81
CxxUtils::starts_with
bool starts_with(const char *s, const char *prefix)
Test whether one null-terminated byte string starts with another.
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
json
nlohmann::json json
Definition: HistogramDef.cxx:9
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
keylayer_zslicemap.kl
kl
Definition: keylayer_zslicemap.py:109
lumiFormat.i
int i
Definition: lumiFormat.py:92
ret
T ret(T t)
Definition: rootspy.cxx:260
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
MakeTH3DFromTH2Ds.hists
hists
Definition: MakeTH3DFromTH2Ds.py:72
beamspotman.dir
string dir
Definition: beamspotman.py:623
python.handimod.extra
int extra
Definition: handimod.py:522
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
dq_make_web_display.rv
def rv
Definition: dq_make_web_display.py:219
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
a
TList * a
Definition: liststreamerinfos.cxx:10
h
TH1
Definition: rootspy.cxx:268
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
python.PyAthena.obj
obj
Definition: PyAthena.py:135
beamspotman.fullpath
string fullpath
Definition: beamspotman.py:1039
dqi::getObjKey
TKey * getObjKey(TDirectory *dir, const std::string &path)
Definition: HanUtils.cxx:37
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37