BOSS 6.6.4.p03
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 88 of file digiRootWriterAlg.h.

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

Member Function Documentation

◆ execute()

StatusCode digiRootWriterAlg::execute ( )

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

Definition at line 143 of file digiRootWriterAlg.h.

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

◆ finalize()

StatusCode digiRootWriterAlg::finalize ( )

Closes the ROOT file and cleans up.

Definition at line 267 of file digiRootWriterAlg.h.

268{
269 close();
270
271 StatusCode sc = StatusCode::SUCCESS;
272 return sc;
273}

◆ initialize()

StatusCode digiRootWriterAlg::initialize ( )

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

Definition at line 103 of file digiRootWriterAlg.h.

104{
105 // Purpose and Method: Called once before the run begins. This method
106 // opens a new ROOT file and prepares for writing.
107
108 StatusCode sc = StatusCode::SUCCESS;
109 MsgStream log(msgSvc(), name());
110
111 // Use the Job options service to set the Algorithm's parameters
112 // This will retrieve parameters set in the job options file
113 setProperties();
114
115 if ( service("RootIoSvc", m_rootIoSvc, true).isFailure() ){
116 log << MSG::INFO << "Couldn't find the RootIoSvc!" << endreq;
117 log << MSG::INFO << "No Auto Saving" << endreq;
118 m_rootIoSvc = 0;
119 }
120
122
123 // Save the current directory for the ntuple writer service
124 TDirectory *saveDir = gDirectory;
125 // Create the new ROOT file
126 m_digiFile = new TFile(m_fileName.c_str(), "RECREATE");
127 if (!m_digiFile->IsOpen()) {
128 log << MSG::ERROR << "ROOT file " << m_fileName
129 << " could not be opened for writing." << endreq;
130 return StatusCode::FAILURE;
131 }
132 m_digiFile->cd();
133 m_digiFile->SetCompressionLevel(m_compressionLevel);
134 m_digiTree = new TTree(m_treeName.c_str(), "Bes Digitization Data");
135 m_digiEvt = new DigiEvent();
136 m_common.m_digiEvt = m_digiEvt;
137 m_digiTree->Branch("DigiEvent","DigiEvent", &m_digiEvt, m_bufSize, m_splitMode);
138 saveDir->cd();
139 return sc;
140
141}
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: