ATLAS Offline Software
Loading...
Searching...
No Matches
IShowerLib.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6// header file
8#include "TTree.h"
9#include "G4Track.hh"
11
12#include <sstream>
13
14namespace ShowerLib {
15
16 bool IShowerLib::readMeta(TTree* source) {
17 char detector[40];
18 char release[40];
19 char geometry[40];
20 char geant[40];
21 char physics[40];
22 char comment[100];
23 source->SetBranchAddress("detector",&detector);
24 source->SetBranchAddress("particle",&m_particle);
25 source->SetBranchAddress("release",&release);
26 source->SetBranchAddress("geometry",&geometry);
27 source->SetBranchAddress("geantVersion",&geant);
28 source->SetBranchAddress("physicsList",&physics);
29 source->SetBranchAddress("comment",&comment);
30 source->GetEntry(0);
34 m_geantVersion = geant;
35 m_physicsList = physics;
37 return true;
38 }
39
40 bool IShowerLib::writeMeta(TTree* source) const {
41 char detector[40];
42 char release[40];
43 char geometry[40];
44 char geant[40];
45 char physics[40];
46 char comment[100];
47 int particle(m_particle);
48 m_detector.copy(detector,39,0);
49 detector[m_detector.length()] = '\0';
50 m_release.copy(release,39,0);
51 release[m_release.length()] = '\0';
52 m_geometry.copy(geometry,39,0);
53 geometry[m_geometry.length()] = '\0';
54 m_geantVersion.copy(geant,39,0);
55 geant[m_geantVersion.length()] = '\0';
56 m_physicsList.copy(physics,39,0);
57 physics[m_physicsList.length()] = '\0';
58 m_comment.copy(comment,99,0);
59 comment[m_comment.length()] = '\0';
60 source->Branch("detector",&detector,"detector/C");
61 source->Branch("particle",&particle,"particle/I");
62 source->Branch("release",&release,"release/C");
63 source->Branch("geometry",&geometry,"geometry/C");
64 source->Branch("geantVersion",&geant,"geantVersion/C");
65 source->Branch("physicsList",&physics,"physicsList/C");
66 source->Branch("comment",&comment,"comment/C");
67 source->Fill();
68 return true;
69 }
70
71 const std::string IShowerLib::statistics() const {
72
73 if (m_filled) {
74 std::stringstream out;
75
76 out << "======================================================" << std::endl;
77 out << " Statistics of the shower library " << std::endl;
78 out << "======================================================" << std::endl;
79 out << "Library Type: "<< getName() <<" PARTICLE: " << m_particle << " DETECTOR: "<< m_detector << std::endl;
80 out << m_release << " " << m_geometry << " " << m_geantVersion << " " << m_physicsList << std::endl;
81 if (printParameters().length() > 0)
82 out << printParameters() << std::endl;
83 out << m_comment << std::endl;
84 return out.str();
85 } else { //statistics for the genlib, shorter version
86 std::stringstream out;
87 out << getName() <<" PARTICLE: " << m_particle << " DETECTOR: "<< m_detector << ", ";
88 out << m_release << " " << m_geometry << " " << m_geantVersion << " " << m_physicsList << std::endl;
89 if (printParameters().length() > 0)
90 out << printParameters() << std::endl;
91 out << m_comment << std::endl;
92 return out.str();
93 }
94 }
95
96} // namespace IShowerLib
double length(const pvec &v)
bool readMeta(TTree *source)
read metadata from the given TTree
std::string m_geantVersion
geant 4 version
Definition IShowerLib.h:110
virtual const std::string geometry() const
get Geometry tag
Definition IShowerLib.h:130
virtual const std::string release() const
get Release tag
Definition IShowerLib.h:127
const std::string statistics() const
print library statistics
std::string m_release
atlas software release
Definition IShowerLib.h:108
int m_particle
ID of the generated particles.
Definition IShowerLib.h:107
virtual const std::string printParameters() const =0
virtual const std::string comment() const
get comment
Definition IShowerLib.h:139
bool writeMeta(TTree *dest) const
write metadata to the given TTree
std::string m_detector
name of the detector
Definition IShowerLib.h:106
std::string m_comment
comment
Definition IShowerLib.h:112
virtual const std::string detector() const
get detector tag
Definition IShowerLib.h:121
bool m_filled
is the library read from ROOT or from structure file
Definition IShowerLib.h:114
std::string m_physicsList
used geant 4 physics list
Definition IShowerLib.h:111
virtual const std::string getName() const
Definition IShowerLib.h:93
std::string m_geometry
atlas geometry version
Definition IShowerLib.h:109
Namespace for the ShowerLib related classes.
Definition StepInfo.h:17