1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/AlgFactory.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/SmartDataPtr.h"
5#include "GaudiKernel/IDataProviderSvc.h"
6#include "EventModel/EventModel.h"
7#include "EventModel/Event.h"
9#include "EvtRecEvent/EvtRecEvent.h"
10#include "EvtRecEvent/EvtRecTrack.h"
11#include "EvtRecEvent/EvtRecDTag.h"
13#include "DstReformAlg/DstReformAlg.h"
15#include "GaudiKernel/SmartIF.h"
16#include "GaudiKernel/IJobOptionsSvc.h"
17#include "VertexFit/IVertexDbSvc.h"
18#include "GaudiKernel/Bootstrap.h"
19#include "GaudiKernel/ISvcLocator.h"
20#include "CLHEP/Vector/ThreeVector.h"
21#include "CLHEP/Vector/LorentzVector.h"
22#include "CLHEP/Vector/TwoVector.h"
23using CLHEP::Hep3Vector;
24using CLHEP::Hep2Vector;
25using CLHEP::HepLorentzVector;
26#include "CLHEP/Geometry/Point3D.h"
27#ifndef ENABLE_BACKWARDS_COMPATIBILITY
30#include "CLHEP/Matrix/SymMatrix.h"
31#include "VertexFit/Helix.h"
33#include "RootCnvSvc/RootCnvSvc.h"
34#include "RootEventData/TEvtRecObject.h"
35#include "RootEventData/TDstEvent.h"
36#include "RootEventData/TMdcTrack.h"
37#include "RootEventData/TEvtHeader.h"
49 Algorithm(name, pSvcLocator) {
51 declareProperty(
"OutputDstFile", m_outputFile);
56 MsgStream log(
msgSvc(), name());
58 log << MSG::INFO <<
"in initialize()" << endmsg;
60 Gaudi::svcLocator()->service(
"TagFilterSvc", m_tagFilterSvc);
63 std::cout<<
"init DstReformAlg, m_dstDataType: "<< m_dstDataType <<std::endl;
65 return StatusCode::SUCCESS;
74 cmap[tagData0].push_back(m_evtNum);
76 if (m_dstDataType==1) {
77 evtmap[m_evtNum].push_back(tagData0);
78 evtmap[m_evtNum].push_back(tagData1);
79 evtmap[m_evtNum].push_back(tagData2);
80 evtmap[m_evtNum].push_back(tagData3);
81 evtmap[m_evtNum].push_back(tagData4);
82 }
else if (m_dstDataType==2) {
87 evtmap[m_evtNum].push_back(tagData1);
88 evtmap[m_evtNum].push_back(tagData2);
89 evtmap[m_evtNum].push_back(tagData3);
90 evtmap[m_evtNum].push_back(tagData4);
91 evtmap[m_evtNum].push_back(tagData5);
92 evtmap[m_evtNum].push_back(tagData6);
93 evtmap[m_evtNum].push_back(tagData7);
94 evtmap[m_evtNum].push_back(tagData8);
95 }
else if (m_dstDataType==3) {
101 evtmap[m_evtNum].push_back(tagData1);
102 evtmap[m_evtNum].push_back(tagData2);
103 evtmap[m_evtNum].push_back(tagData3);
104 evtmap[m_evtNum].push_back(tagData4);
105 evtmap[m_evtNum].push_back(tagData5);
106 evtmap[m_evtNum].push_back(tagData6);
107 evtmap[m_evtNum].push_back(tagData7);
108 evtmap[m_evtNum].push_back(tagData8);
109 evtmap[m_evtNum].push_back(tagData9);
117 MsgStream log(
msgSvc(), name());
120 SmartIF<IJobOptionsSvc> iSvc(Gaudi::svcLocator()->service(
"JobOptionsSvc"));
121 if ( iSvc.isValid() ) {
122 const std::vector<const Property*>* ps = iSvc->getProperties(
"EventCnvSvc");
123 std::vector<const Property*>::const_iterator it, end = ps->end();
124 for ( it = ps->begin(); it != end; ++it ) {
125 if ( (*it)->name() ==
"digiRootInputFile" ) {
126 std::string flist=(*it)->toString();
127 std::string::size_type p1 = flist.find(
'"') + 1;
128 std::string::size_type p2 = flist.find(
'"', p1);
129 fn = flist.substr(p1, p2-p1);
130 std::cout<<
"input dst file name: "<<fn<<std::endl;
134 TFile*
f1 = TFile::Open(fn.c_str(),
"READ");
135 TFile* f2 = TFile::Open(m_outputFile.c_str(),
"RECREATE");
136 TTree* t1 = (TTree*)
f1->Get(
"Event");
138 log << MSG::INFO <<
"in finalize()" << endmsg;
139 TTree* jt1 = (TTree*)(
f1->Get(
"JobInfoTree"));
140 TTree* jt2 = jt1->CloneTree();
141 TTree* t0 =
new TTree(
"Metadata",
"");
143 Int_t mode = -1, begin = 0, end = 0;
144 t0->Branch(
"mode", &mode,
"mode/I");
145 t0->Branch(
"begin", &begin,
"begin/I");
146 t0->Branch(
"end", &end,
"end/I");
148 for ( std::map<
int, std::vector<long int> >::iterator it = cmap.begin(); it != cmap.end(); ++it ) {
151 end += (it->second).size();
152 std::cout<<
"mode: "<<mode<<
" begin: "<<begin<<
" end: "<<end<<std::endl;
156 TTree* t2 = t1->CloneTree(0);
157 Int_t nEvents = t1->GetEntries();
158 std::cout<<
"Total nEvents: "<<nEvents<<std::endl;
159 Int_t origEntry=0, currEntry=0;
160 UInt_t tagData0, tagData1, tagData2, tagData3, tagData4;
161 UInt_t tagData5, tagData6, tagData7, tagData8;
162 TTree* t3 =
new TTree(
"Entries",
"");
163 t3->Branch(
"origEntry", &origEntry,
"origEntry/I");
164 t3->Branch(
"currEntry", &currEntry,
"currEntry/I");
165 t3->Branch(
"tagData0", &tagData0,
"tagData0/i");
166 t3->Branch(
"tagData1", &tagData1,
"tagData1/i");
167 t3->Branch(
"tagData2", &tagData2,
"tagData2/i");
168 t3->Branch(
"tagData3", &tagData3,
"tagData3/i");
169 t3->Branch(
"tagData4", &tagData4,
"tagData4/i");
170 if (m_dstDataType==2) {
171 t3->Branch(
"tagData5", &tagData5,
"tagData5/i");
172 t3->Branch(
"tagData6", &tagData6,
"tagData6/i");
173 t3->Branch(
"tagData7", &tagData7,
"tagData7/i");
175 if (m_dstDataType==3) {
176 t3->Branch(
"tagData5", &tagData5,
"tagData5/i");
177 t3->Branch(
"tagData6", &tagData6,
"tagData6/i");
178 t3->Branch(
"tagData7", &tagData7,
"tagData7/i");
179 t3->Branch(
"tagData8", &tagData8,
"tagData8/i");
182 for ( std::map<
int, std::vector<long int> >::iterator it = cmap.begin(); it != cmap.end(); ++it ) {
183 int nNt = it->second.size();
184 std::cout <<
"Writing " << nNt <<
"\t events with " << it->first <<
" TagData0..." << std::endl;
185 for (
int i = 0; i < nNt; ++i ) {
186 origEntry=(it->second)[i];
187 t1->GetEntry(origEntry);
188 tagData0=(evtmap[origEntry])[0];
189 tagData1=(evtmap[origEntry])[1];
190 tagData2=(evtmap[origEntry])[2];
191 tagData3=(evtmap[origEntry])[3];
192 tagData4=(evtmap[origEntry])[4];
193 if (m_dstDataType==2) {
194 tagData5=(evtmap[origEntry])[5];
195 tagData6=(evtmap[origEntry])[6];
196 tagData7=(evtmap[origEntry])[7];
198 if (m_dstDataType==3) {
199 tagData5=(evtmap[origEntry])[5];
200 tagData6=(evtmap[origEntry])[6];
201 tagData7=(evtmap[origEntry])[7];
202 tagData8=(evtmap[origEntry])[8];
208 (it->second).clear();
213 return StatusCode::SUCCESS;
virtual unsigned int getTagData1()=0
virtual unsigned int getTagData2()=0
virtual int getDstDataType()=0
virtual unsigned int getTagData8()=0
virtual unsigned int getTagData9()=0
virtual unsigned int getTagData6()=0
virtual unsigned int getTagData4()=0
virtual unsigned int getTagData5()=0
virtual unsigned int getTagData7()=0
virtual unsigned int getTagData3()=0
virtual unsigned int getTagData0()=0