BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
digiRootWriterAlg Class Reference

Writes Digi TDS data to a persistent ROOT file. @Based on the digiRootWriterAlg of GLAST. More...

#include <digiRootWriterAlg.h>

Inheritance diagram for digiRootWriterAlg:

Public Member Functions

 digiRootWriterAlg (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize ()
 Handles setup by opening ROOT file in write mode and creating a new TTree.
StatusCode execute ()
 Orchastrates reading from TDS and writing to ROOT for each event.
StatusCode finalize ()
 Closes the ROOT file and cleans up.

Detailed Description

Writes Digi TDS data to a persistent ROOT file. @Based on the digiRootWriterAlg of GLAST.

Definition at line 31 of file digiRootWriterAlg.h.

Constructor & Destructor Documentation

◆ digiRootWriterAlg()

digiRootWriterAlg::digiRootWriterAlg ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 83 of file digiRootWriterAlg.h.

84 : Algorithm( name, pSvcLocator ) {
85 // Input parameters available to be set via the jobOptions file
86 declareProperty( "digiRootFile", m_fileName = "digi.root" );
87 declareProperty( "splitMode", m_splitMode = 1 );
88 declareProperty( "bufferSize", m_bufSize = 64000 );
89 declareProperty( "compressionLevel", m_compressionLevel = 1 );
90 // declareProperty("treeName", m_treeName="Digi");
91 declareProperty( "treeName", m_treeName = "Rec" ); // wensp modified on 20050515 for test
92 declareProperty( "autoSave", m_autoSaveEvents = 1000 );
93}

Member Function Documentation

◆ execute()

StatusCode digiRootWriterAlg::execute ( )

Orchastrates reading from TDS and writing to ROOT for each event.

Definition at line 135 of file digiRootWriterAlg.h.

135 {
136 // Purpose and Method: Called once per event. This method calls
137 // the appropriate methods to read data from the TDS and write data
138 // to the ROOT file.
139
140 MsgStream log( msgSvc(), name() );
141
142 StatusCode sc = StatusCode::SUCCESS;
143
144 if ( !m_digiFile->IsOpen() )
145 {
146 log << MSG::ERROR << "ROOT file " << m_fileName << " could not be opened for writing."
147 << endmsg;
148 return StatusCode::FAILURE;
149 }
150
151 m_digiEvt->Clear();
152
153 sc = writeDigiEvent();
154 if ( sc.isFailure() )
155 {
156 log << MSG::ERROR << "Failed to write DigiEvent" << endmsg;
157 return sc;
158 }
159
160 sc = writeMdcDigi();
161 if ( sc.isFailure() )
162 {
163 log << MSG::ERROR << "Failed to write Tkr Digi Collection" << endmsg;
164 return sc;
165 }
166
167 writeEvent();
168 return sc;
169}
IMessageSvc * msgSvc()

◆ finalize()

StatusCode digiRootWriterAlg::finalize ( )

Closes the ROOT file and cleans up.

Definition at line 257 of file digiRootWriterAlg.h.

257 {
258 close();
259
260 StatusCode sc = StatusCode::SUCCESS;
261 return sc;
262}

◆ initialize()

StatusCode digiRootWriterAlg::initialize ( )

Handles setup by opening ROOT file in write mode and creating a new TTree.

Definition at line 95 of file digiRootWriterAlg.h.

95 {
96 // Purpose and Method: Called once before the run begins. This method
97 // opens a new ROOT file and prepares for writing.
98
99 StatusCode sc = StatusCode::SUCCESS;
100 MsgStream log( msgSvc(), name() );
101
102 // Use the Job options service to set the Algorithm's parameters
103 // This will retrieve parameters set in the job options file
104 setProperties();
105
106 if ( service( "RootIoSvc", m_rootIoSvc, true ).isFailure() )
107 {
108 log << MSG::INFO << "Couldn't find the RootIoSvc!" << endmsg;
109 log << MSG::INFO << "No Auto Saving" << endmsg;
110 m_rootIoSvc = 0;
111 }
112
113 facilities::Util::expandEnvVar( &m_fileName );
114
115 // Save the current directory for the ntuple writer service
116 TDirectory* saveDir = gDirectory;
117 // Create the new ROOT file
118 m_digiFile = new TFile( m_fileName.c_str(), "RECREATE" );
119 if ( !m_digiFile->IsOpen() )
120 {
121 log << MSG::ERROR << "ROOT file " << m_fileName << " could not be opened for writing."
122 << endmsg;
123 return StatusCode::FAILURE;
124 }
125 m_digiFile->cd();
126 m_digiFile->SetCompressionLevel( m_compressionLevel );
127 m_digiTree = new TTree( m_treeName.c_str(), "Bes Digitization Data" );
128 m_digiEvt = new DigiEvent();
129 m_common.m_digiEvt = m_digiEvt;
130 m_digiTree->Branch( "DigiEvent", "DigiEvent", &m_digiEvt, m_bufSize, m_splitMode );
131 saveDir->cd();
132 return sc;
133}
static int expandEnvVar(std::string *toExpand, const std::string &openDel=std::string("$("), const std::string &closeDel=std::string(")"))

The documentation for this class was generated from the following file: