128 {
129 MsgStream log(
msgSvc(), name());
130
131 std::string fn;
132 SmartIF<IJobOptionsSvc> iSvc(Gaudi::svcLocator()->service("JobOptionsSvc"));
133 if ( iSvc.isValid() ) {
134 const std::vector<const Property*>* ps = iSvc->getProperties("EventCnvSvc");
135 std::vector<const Property*>::const_iterator it, end = ps->end();
136 for ( it = ps->begin(); it != end; ++it ) {
137 if ( (*it)->name() == "digiRootInputFile" ) {
138 std::string flist=(*it)->toString();
139 std::string::size_type p1 = flist.find('"') + 1;
140 std::string::size_type p2 = flist.find('"', p1);
141 fn = flist.substr(p1, p2-p1);
142 std::cout<<"input dst file name: "<<fn<<std::endl;
143 }
144 }
145 }
146 TFile*
f1 = TFile::Open(fn.c_str(),
"READ");
147 TFile* f2 = TFile::Open(m_outputFile.c_str(), "RECREATE");
148 TTree* t1 = (TTree*)
f1->Get(
"Event");
149
150 log << MSG::INFO << "in finalize()" << endmsg;
151 TTree* jt1 = (TTree*)(
f1->Get(
"JobInfoTree"));
152 TTree* jt2 = jt1->CloneTree();
153 TTree* t0 = new TTree("Metadata", "");
154 Int_t mode = -1, begin = 0, end = 0;
155 t0->Branch("mode", &mode, "mode/I");
156 t0->Branch("begin", &begin, "begin/I");
157 t0->Branch("end", &end, "end/I");
158
159 for ( std::map<int, std::vector<long int> >::iterator it = cmap.begin(); it != cmap.end(); ++it ) {
160 mode = it->first;
161 begin = end;
162 end += (it->second).size();
163 std::cout<<"mode: "<<mode<< " begin: "<<begin<< " end: "<<end<<std::endl;
164 t0->Fill();
165 }
166
167 TTree* t2 = t1->CloneTree(0);
168 Int_t nEvents = t1->GetEntries();
169 std::cout<<"Total nEvents: "<<nEvents<<std::endl;
170 Int_t origEntry=0, currEntry=0;
171 UInt_t tagData0, tagData1, tagData2, tagData3, tagData4;
172 UInt_t tagData5, tagData6, tagData7, tagData8;
173 TTree* t3 = new TTree("Entries", "");
174 t3->Branch("origEntry", &origEntry, "origEntry/I");
175 t3->Branch("currEntry", &currEntry, "currEntry/I");
176 t3->Branch("tagData0", &tagData0, "tagData0/i");
177 t3->Branch("tagData1", &tagData1, "tagData1/i");
178 t3->Branch("tagData2", &tagData2, "tagData2/i");
179 t3->Branch("tagData3", &tagData3, "tagData3/i");
180 t3->Branch("tagData4", &tagData4, "tagData4/i");
181 if (m_dstDataType==2) {
182 t3->Branch("tagData5", &tagData5, "tagData5/i");
183 t3->Branch("tagData6", &tagData6, "tagData6/i");
184 t3->Branch("tagData7", &tagData7, "tagData7/i");
185 }
186 if ( (m_dstDataType==3) || (m_dstDataType==4) ) {
187 t3->Branch("tagData5", &tagData5, "tagData5/i");
188 t3->Branch("tagData6", &tagData6, "tagData6/i");
189 t3->Branch("tagData7", &tagData7, "tagData7/i");
190 t3->Branch("tagData8", &tagData8, "tagData8/i");
191 }
192
193 for ( std::map<int, std::vector<long int> >::iterator it = cmap.begin(); it != cmap.end(); ++it ) {
194 int nNt = it->second.size();
195 std::cout << "Writing " << nNt << "\t events with " << it->first << " TagData0..." << std::endl;
196 for ( int i = 0; i < nNt; ++i ) {
197 origEntry=(it->second)[i];
198 t1->GetEntry(origEntry);
199 tagData0=(evtmap[origEntry])[0];
200 tagData1=(evtmap[origEntry])[1];
201 tagData2=(evtmap[origEntry])[2];
202 tagData3=(evtmap[origEntry])[3];
203 tagData4=(evtmap[origEntry])[4];
204 if (m_dstDataType==2) {
205 tagData5=(evtmap[origEntry])[5];
206 tagData6=(evtmap[origEntry])[6];
207 tagData7=(evtmap[origEntry])[7];
208 }
209 if ( (m_dstDataType==3) || (m_dstDataType==4) ) {
210 tagData5=(evtmap[origEntry])[5];
211 tagData6=(evtmap[origEntry])[6];
212 tagData7=(evtmap[origEntry])[7];
213 tagData8=(evtmap[origEntry])[8];
214 }
215 t2->Fill();
216 t3->Fill();
217 currEntry++;
218 }
219 (it->second).clear();
220 }
221
222 f2->Write();
223 f2->Close();
224 return StatusCode::SUCCESS;
225}