CGEM BOSS 6.6.5.g
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 32 of file digiRootWriterAlg.h.

Constructor & Destructor Documentation

◆ digiRootWriterAlg()

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

Definition at line 90 of file digiRootWriterAlg.h.

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

Member Function Documentation

◆ execute()

StatusCode digiRootWriterAlg::execute ( )

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

Definition at line 145 of file digiRootWriterAlg.h.

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

◆ finalize()

StatusCode digiRootWriterAlg::finalize ( )

Closes the ROOT file and cleans up.

Definition at line 304 of file digiRootWriterAlg.h.

305{
306 close();
307
308 StatusCode sc = StatusCode::SUCCESS;
309 return sc;
310}

◆ initialize()

StatusCode digiRootWriterAlg::initialize ( )

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

Definition at line 105 of file digiRootWriterAlg.h.

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