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 80 of file HanUtils.cxx.

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

◆ getObjKey()

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

Definition at line 36 of file HanUtils.cxx.

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

◆ newTList()

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

Definition at line 18 of file HanUtils.cxx.

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

◆ newTObjArray()

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

Definition at line 27 of file HanUtils.cxx.

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

◆ 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 539 of file HanOutput.cxx.

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

Variable Documentation

◆ root_mutex

std::mutex dqi::root_mutex

Definition at line 16 of file HanUtils.cxx.

AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
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:80
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
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:85
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:228
dq_make_web_display.rv
def rv
Definition: dq_make_web_display.py:219
a
TList * a
Definition: liststreamerinfos.cxx:10
h
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
python.PyAthena.obj
obj
Definition: PyAthena.py:132
beamspotman.fullpath
string fullpath
Definition: beamspotman.py:1039
dqi::getObjKey
TKey * getObjKey(TDirectory *dir, const std::string &path)
Definition: HanUtils.cxx:36
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37