ATLAS Offline Software
HanApp.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // **********************************************************************
6 // $Id: HanApp.cxx,v 1.13 2008-12-07 03:25:37 ponyisi Exp $
7 // **********************************************************************
8 
10 
11 #include <TFile.h>
12 #include <TROOT.h>
13 
14 #include "dqm_core/LibraryManager.h"
15 #include "dqm_core/InputRootFile.h"
21 
22 #include <TCanvas.h>
23 
24 #include <utility>
25 
27 ATLAS_NO_CHECK_FILE_THREAD_SAFETY; // standalone application
28 
29 //Get rid of Root macros that confuse Doxygen
33 
34  /*
35 void HanApp_dummyMethod()
36 {
37  TCanvas* dummyCanvas = new TCanvas("dummyCanvas","dummyCanvas", 450, 450 );
38  dummyCanvas->cd();
39 }
40  */
41 
42 namespace {
43 
44  void RecursivelyDeleteCollection(TCollection* seq) {
45  TIter it(seq);
46  while (TObject* obj = it()) {
47  TCollection* coll = dynamic_cast<TCollection*>(obj);
48  if (coll) {
49  RecursivelyDeleteCollection(coll);
50  }
51  }
52  seq->Delete();
53  }
54 
55 } // end unnamed namespace
56 
57 
58 namespace dqi {
59 
60 // *********************************************************************
61 // Public Methods
62 // *********************************************************************
63 
65 HanApp()
66  : m_outputName("")
67 {
68 }
69 
70 
72 HanApp( const std::string& configName, const std::string& inputName, const std::string& outputName, const std::string& path )
73 {
74  HanApp::Analyze( configName, inputName, outputName, path );
75 }
76 
77 
79 ~HanApp()
80 {
81 }
82 
83 
84 int
86 Analyze( const std::string& configName_, const std::string& inputName_, const std::string& outputName_, const std::string& path_ )
87 {
89 
90  auto& runtimeConfig = HanRuntimeConfigSingleton::getInstance();
91  runtimeConfig.setPath( path_ );
92 
94  TSeqCollection *outputList = new TList();
95 
96  m_outputName = outputName_;
97 
98  //dqm_core::InputRootFile input( inputName_ );
99  HanInputRootFile input( inputName_, path_ ); // HanInputRootFile inherits from dqm_core::InputRootFile
100 
101  HanOutput output( outputName_, outputMap, outputList );
102  output.setInput(const_cast<TDirectory*>(input.getBasedir()));
103 
104  dqm_core::LibraryManager::instance().loadLibrary( "libdqm_algorithms.so" );
105  dqm_core::LibraryManager::instance().loadLibrary( "libdqm_summaries.so" );
106 
108  std::cout << "Reading configuration and input histograms...\n" << std::flush;
109  config.BuildMonitors( configName_, input, output );
110  std::cout << "Preparing output...\n" << std::flush;
111  config.BuildConfigOutput( configName_, input.file(), path_, outputMap, outputList );
112 
113  std::cout << "Analyzing histograms...\n" << std::flush;
114  output.activate();
115  input.activate();
116  output.publishMissingDQPars();
117 
118  std::cout << "Writing output file...\n" << std::flush;
119  output.deactivate(); // essential for the HanOutput object since it writes the output file
120 
121  std::cout << "Deleting objects from memory.\n" << std::flush;
122  RecursivelyDeleteCollection(outputList);
123  delete outputList;
124  delete outputMap;
125  return 0;
126 }
127 
128 
129 TFile*
131 OpenResultsFile() const
132 {
133  if( m_outputName == "" )
134  return 0;
135 
136  return TFile::Open( m_outputName.c_str() );
137 }
138 
139 } // namespace dqi
140 
test_athena_ntuple_filter.seq
seq
filter configuration ## -> we use the special sequence 'AthMasterSeq' which is run before any other a...
Definition: test_athena_ntuple_filter.py:18
HanApp.h
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
FullCPAlgorithmsTest_eljob.flush
flush
Definition: FullCPAlgorithmsTest_eljob.py:186
dqi::HanApp::Analyze
virtual int Analyze(const std::string &configName_, const std::string &inputName_, const std::string &outputName_, const std::string &path_="")
Definition: HanApp.cxx:86
dqi::HanApp::~HanApp
virtual ~HanApp()
Definition: HanApp.cxx:79
dqi::HanApp::HanApp
HanApp()
Definition: HanApp.cxx:65
dqi::HanApp::m_outputName
std::string m_outputName
Definition: HanApp.h:35
skel.it
it
Definition: skel.GENtoEVGEN.py:396
HanRuntimeConfigSingleton.h
dqi::HanOutput
Definition: HanOutput.h:39
dqi::DisableMustClean
Definition: HanUtils.h:30
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
ClassImp
ClassImp(xAOD::TFileChecker) namespace xAOD
Definition: TFileChecker.cxx:28
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
HanInputRootFile.h
HanUtils.h
HanOutput.h
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
SCT_Monitoring::disabled
@ disabled
Definition: SCT_MonitoringNumbers.h:60
merge.output
output
Definition: merge.py:17
dqi::HanInputRootFile
Definition: HanInputRootFile.h:19
dqi::HanApp
Definition: HanApp.h:21
lumiFormat.outputName
string outputName
Definition: lumiFormat.py:65
dqi::HanRuntimeConfigSingleton::getInstance
static HanRuntimeConfigSingleton & getInstance()
Definition: HanRuntimeConfigSingleton.cxx:15
dqi::HanApp::OpenResultsFile
virtual TFile * OpenResultsFile() const
Definition: HanApp.cxx:131
dqi::HanConfig
Definition: HanConfig.h:48
config
std::vector< std::string > config
Definition: fbtTestBasics.cxx:74
dqi::HanOutput::DQOutputMap_t
std::map< std::string, TSeqCollection * > DQOutputMap_t
Definition: HanOutput.h:45
checker_macros.h
Define macros for attributes used to control the static checker.
python.PyAthena.obj
obj
Definition: PyAthena.py:132
dqi
Definition: CompositeAlgorithm.h:16
HanConfig.h
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Definition: HanApp.cxx:27