BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcPrintSvc.cxx
Go to the documentation of this file.
1#include "MdcPrintSvc.h"
2
3#include "GaudiKernel/Bootstrap.h"
4#include "GaudiKernel/DataSvc.h"
5#include "GaudiKernel/IDataProviderSvc.h"
6#include "GaudiKernel/IInterface.h"
7#include "GaudiKernel/ISvcLocator.h"
8#include "GaudiKernel/Kernel.h"
9#include "GaudiKernel/MsgStream.h"
10#include "GaudiKernel/SmartDataPtr.h"
11#include "GaudiKernel/StatusCode.h"
12
13#include "EvTimeEvent/RecEsTime.h"
14#include "EventModel/EventHeader.h"
15#include "EventModel/EventModel.h"
16#include "Identifier/MdcID.h"
17#include "McTruth/McParticle.h"
18#include "McTruth/MdcMcHit.h"
19#include "MdcRawEvent/MdcDigi.h"
20#include "MdcRecEvent/RecMdcHit.h"
21#include "MdcRecEvent/RecMdcTrack.h"
22#include "RawEvent/RawDataUtil.h"
23
24#include <iomanip>
25#include <iostream>
26
27using namespace std;
28using namespace Event;
30MdcPrintSvc::MdcPrintSvc( const string& name, ISvcLocator* svcloc )
31 : base_class( name, svcloc ) {
32
33 // declare properties
34 declareProperty( "printHit", m_printHit = 1 );
35 declareProperty( "printTrackDetail", m_printTrackDetail = 1 );
36 declareProperty( "printErrMat", m_printErrMat = 0 );
37 declareProperty( "printTdcAdc", m_printTdcAdc = 0 );
38 declareProperty( "printMcTk", m_printMcTk = 0 );
39}
40
42
44 MsgStream log( msgSvc(), name() );
45 log << MSG::INFO << "MdcPrintSvc::initialize()" << endmsg;
46
47 StatusCode sc = Service::initialize();
48 if ( sc.isFailure() ) return sc;
49
50 ISvcLocator* svcLocator = Gaudi::svcLocator();
51 svcLocator->service( "EventDataSvc", eventSvc, true );
52 if ( NULL == eventSvc )
53 {
54 std::cout << "ERROR Could not load service DataSvc" << std::endl;
55 return StatusCode::FAILURE;
56 }
57
58 IRawDataProviderSvc* irawDataProviderSvc;
59 sc = service( "RawDataProviderSvc", irawDataProviderSvc );
60 m_rawDataProviderSvc = irawDataProviderSvc;
61 if ( sc.isFailure() )
62 {
63 log << MSG::FATAL << "Could not load RawDataProviderSvc!" << endmsg;
64 return StatusCode::FAILURE;
65 }
66
67 return StatusCode::SUCCESS;
68}
69
71 MsgStream log( msgSvc(), name() );
72 log << MSG::INFO << "MdcPrintSvc::finalize()" << endmsg;
73
74 return StatusCode::SUCCESS;
75}
76
77/*StatusCode MdcPrintSvc::queryInterface(const InterfaceID& riid, void** ppvInterface){
78 if( IID_IMdcPrintSvc.versionMatch(riid) ){
79 *ppvInterface = static_cast<IMdcPrintSvc*> (this);
80 } else{
81 return Service::queryInterface(riid, ppvInterface);
82 }
83 return StatusCode::SUCCESS;
84}*/
85
86void MdcPrintSvc::printDigi( uint32_t getDigiFlag ) const {
87 MdcDigiVec mdcDigiVec = m_rawDataProviderSvc->getMdcDigiVec( getDigiFlag );
88 MdcDigiCol::iterator iter = mdcDigiVec.begin();
89 std::cout << "//==== " << name() << " print MdcDigiVec, nDigi=" << mdcDigiVec.size() << " :"
90 << std::endl;
91 for ( int iDigi = 0; iter != mdcDigiVec.end(); iter++, iDigi++ )
92 {
93 long l = MdcID::layer( ( *iter )->identify() );
94 long w = MdcID::wire( ( *iter )->identify() );
95 cout << "(" << l << "," << w;
96 if ( m_printMcTk )
97 {
98 int tkTruth = ( *iter )->getTrackIndex();
99 cout << ";" << tkTruth;
100 }
101 if ( m_printTdcAdc )
102 {
103 double tdc = RawDataUtil::MdcTime( ( *iter )->getTimeChannel() );
104 double adc = RawDataUtil::MdcCharge( ( *iter )->getChargeChannel() );
105 cout << ",t " << tdc << ",c " << adc;
106 }
107 cout << ")";
108 if ( iDigi % 4 == 0 ) std::cout << std::endl;
109 }
110 std::cout << std::endl;
111}
112
114 MsgStream log( msgSvc(), name() );
115
116 SmartDataPtr<RecMdcTrackCol> recMdcTrackCol( eventSvc, "/Event/Recon/RecMdcTrackCol" );
117 if ( !recMdcTrackCol )
118 {
119 log << MSG::WARNING << "Could not find RecMdcTrackCol" << endmsg;
120 return;
121 }
122
123 std::cout << "//======= " << name() << " RecMdcTrackCol size = " << recMdcTrackCol->size()
124 << std::endl;
125 RecMdcTrackCol::iterator it = recMdcTrackCol->begin();
126 for ( ; it != recMdcTrackCol->end(); it++ ) { printRecMdcTrack( *it ); }
127}
128
130 std::cout << "//==== " << name() << " print RecMdcTrack No." << tk->trackId() << " :"
131 << std::endl;
132 cout << " dr " << tk->helix( 0 ) << " phi0 " << tk->helix( 1 ) << " cpa " << tk->helix( 2 )
133 << " z0 " << tk->helix( 3 ) << " tanl " << tk->helix( 4 ) << endl;
134 if ( m_printTrackDetail )
135 {
136 std::cout << " q " << tk->charge() << " theta " << tk->theta() << " phi " << tk->phi()
137 << " x0 " << tk->x() << " y0 " << tk->y() << " z0 " << tk->z() << " r0 "
138 << tk->r() << endl;
139 std::cout << " p " << tk->p() << " pt " << tk->pxy() << " pxyz(" << tk->px() << ","
140 << tk->py() << "," << tk->pz() << ")" << endl;
141 std::cout << " tkStat " << tk->stat() << " chi2 " << tk->chi2() << " ndof " << tk->ndof()
142 << " nhit " << tk->getNhits() << " nst " << tk->nster() << endl;
143 if ( m_printErrMat )
144 {
145 std::cout << "errmat " << std::endl;
146 for ( int i = 0; i < 15; i++ ) { std::cout << " " << tk->err( i ); }
147 std::cout << " " << std::endl;
148 }
149 }
150
151 if ( m_printHit )
152 {
153 int haveDigi[43][288];
154 if ( m_printMcTk )
155 {
156 for ( int ii = 0; ii < 43; ii++ )
157 {
158 for ( int jj = 0; jj < 43; jj++ ) { haveDigi[ii][jj] = -9999; }
159 }
160 MdcDigiVec mdcDigiVec = m_rawDataProviderSvc->getMdcDigiVec();
161 MdcDigiCol::iterator iter = mdcDigiVec.begin();
162 std::cout << name() << "//==== " << name()
163 << " print MdcDigiVec, nDigi=" << mdcDigiVec.size() << " :" << std::endl;
164 for ( int iDigi = 0; iter != mdcDigiVec.end(); iter++, iDigi++ )
165 {
166 long l = MdcID::layer( ( *iter )->identify() );
167 long w = MdcID::wire( ( *iter )->identify() );
168 haveDigi[l][w] = ( *iter )->getTrackIndex();
169 }
170 }
171
172 int nhits = tk->getVecHits().size();
173 std::cout << "nHits=" << nhits << std::endl;
174 cout << "No. ";
175 if ( m_printMcTk ) cout << "mcTkId ";
176 cout << "(layer,wire,lr) stat z" << endl;
177 for ( int ii = 0; ii < nhits; ii++ )
178 {
179 Identifier id( tk->getVecHits()[ii]->getMdcId() );
180 int layer = MdcID::layer( id );
181 int wire = MdcID::wire( id );
182 cout << ii << ":";
183 if ( m_printMcTk ) { cout << haveDigi[layer][wire]; }
184 cout << " (" << layer << "," << wire << "," << tk->getVecHits()[ii]->getFlagLR() << ") "
185 << tk->getVecHits()[ii]->getStat() << " " << tk->getVecHits()[ii]->getZhit() << " "
186 << std::endl;
187 } // end of hit list
188 std::cout << " " << std::endl;
189 }
190}
191
193 MsgStream log( msgSvc(), name() );
194
195 SmartDataPtr<MdcMcHitCol> mdcMcHitCol( eventSvc, "/Event/MC/MdcMcHitCol" );
196 if ( !mdcMcHitCol )
197 {
198 log << MSG::WARNING << "Could not find MdcMcHitCol" << endmsg;
199 return;
200 }
201
202 int ihit = 0;
203 cout << "//==== " << name() << " print MdcMcHitCol nMcHit=" << mdcMcHitCol->size() << endl;
204 if ( mdcMcHitCol->size() > 0 )
205 { cout << "No. (layer,wire) mcTk (x,y,z) lr driftdist(cm) energy" << endl; }
206 MdcMcHitCol::iterator iter_mchit = mdcMcHitCol->begin();
207 for ( ; iter_mchit != mdcMcHitCol->end(); iter_mchit++, ihit++ )
208 {
209 const Identifier id = ( *iter_mchit )->identify();
210 int layer = MdcID::layer( id );
211 int wire = MdcID::wire( id );
212 int iMcTk = ( *iter_mchit )->getTrackIndex();
213 double mcX = ( *iter_mchit )->getPositionX() / 10.;
214 double mcY = ( *iter_mchit )->getPositionY() / 10.;
215 double mcZ = ( *iter_mchit )->getPositionZ() / 10.;
216 double mcLR = ( *iter_mchit )->getPositionFlag();
217 double mcDrift = ( *iter_mchit )->getDriftDistance() / 10.;
218 double mcEnergy = ( *iter_mchit )->getDepositEnergy() / 10.;
219 if ( mcLR == 0 ) mcLR = -1;
220 cout << ihit << " (" << layer << "," << wire << ") " << iMcTk << " (" << mcX << "," << mcY
221 << "," << mcZ << ") " << mcLR << " " << mcDrift << " " << mcEnergy << endl;
222 }
223}
DECLARE_COMPONENT(BesBdkRc)
double w
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
IMessageSvc * msgSvc()
const HepSymMatrix err() const
const HepVector helix() const
......
static int layer(const Identifier &id)
Values of different levels (failure returns 0).
Definition MdcID.cxx:47
static int wire(const Identifier &id)
Definition MdcID.cxx:52
StatusCode finalize()
StatusCode initialize()
void printDigi(uint32_t getDigiFlag=0) const
void printRecMdcTrack(const RecMdcTrack *tk) const
MdcPrintSvc(const std::string &name, ISvcLocator *svcloc)
void printMdcMcHitCol() const
void printRecMdcTrackCol() const
static double MdcTime(int timeChannel)
static double MdcCharge(int chargeChannel)