BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcMakeHits.cxx
Go to the documentation of this file.
1#include "MdcMakeHits.h"
2#include "EventModel/Event.h"
3#include "GaudiKernel/IDataManagerSvc.h"
4#include "GaudiKernel/IDataProviderSvc.h"
5#include "GaudiKernel/INTupleSvc.h"
6#include "GaudiKernel/ISvcLocator.h"
7#include "GaudiKernel/MsgStream.h"
8#include "GaudiKernel/PropertyMgr.h"
9#include "GaudiKernel/SmartDataPtr.h"
10#include "Identifier/MdcID.h"
11#include "MdcCalibFunSvc/IMdcCalibFunSvc.h"
12#include "MdcData/MdcHit.h"
13#include "MdcData/MdcHitMap.h"
14#include "MdcGeom/MdcDetector.h"
15#include "MdcGeom/MdcLayer.h"
16#include "MdcGeom/MdcSWire.h"
17#include "MdcRawEvent/MdcDigi.h"
18#include "RawDataProviderSvc/IRawDataProviderSvc.h"
19#include "RawDataProviderSvc/MdcRawDataProvider.h"
20#include <CLHEP/Geometry/Point3D.h>
21#include <CLHEP/Units/PhysicalConstants.h>
22
23#include <iostream>
24#include <vector>
25using namespace std;
26using namespace Event;
27
28extern const CLID& CLID_MdcHitCol;
29
30/////////////////////////////////////////////////////////////////////////////
32MdcMakeHits::MdcMakeHits( const std::string& name, ISvcLocator* pSvcLocator )
33 : Algorithm( name, pSvcLocator ) {
34 // Declare the properties
35 declareProperty( "cosmicFit", m_cosmicFit = false );
36 declareProperty( "doSag", m_doSag = false );
37 declareProperty( "countPropTime", m_countPropTime = true );
38
39 declareProperty( "getDigiFlag", m_getDigiFlag = 0 );
40 declareProperty( "maxMdcDigi", m_maxMdcDigi = 0 );
41 declareProperty( "keepBadTdc", m_keepBadTdc = 0 );
42 declareProperty( "dropHot", m_dropHot = 0 );
43 declareProperty( "keepUnmatch", m_keepUnmatch = 0 );
44 declareProperty( "minMdcDigi", m_minMdcDigi = 0 );
45 declareProperty( "combineTracking", m_combineTracking = false ); // yzhang 2010-05-28
46
47#ifdef MDCPATREC_RESLAYER
48 declareProperty( "resLayer", m_resLayer = -1 );
49#endif
50}
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
54 _gm = MdcDetector::instance( m_doSag );
55 if ( NULL == _gm ) return StatusCode::FAILURE;
56 return StatusCode::SUCCESS;
57}
58// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
60
61 MsgStream log( msgSvc(), name() );
62 log << MSG::INFO << "in initialize()" << endmsg;
63
64 StatusCode sc;
65
66 sc = service( "MdcCalibFunSvc", m_mdcCalibFunSvc );
67 if ( sc.isFailure() ) { log << MSG::FATAL << "Could not load MdcCalibFunSvc!" << endmsg; }
68
69 sc = service( "RawDataProviderSvc", m_rawDataProviderSvc );
70 if ( sc.isFailure() )
71 {
72 log << MSG::FATAL << "Could not load RawDataProviderSvc!" << endmsg;
73 return StatusCode::FAILURE;
74 }
75
76 return StatusCode::SUCCESS;
77}
78
79// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
81 if ( !m_beginRun )
82 {
83 StatusCode sc = beginRun();
84 if ( sc.isFailure() )
85 {
86 error() << "beginRun failed" << endmsg;
87 return StatusCode::FAILURE;
88 }
89 m_beginRun = true;
90 }
91
92 MsgStream log( msgSvc(), name() );
93 log << MSG::INFO << "in execute()" << endmsg;
94 StatusCode sc;
95
96 DataObject* pnode = 0;
97 sc = eventSvc()->retrieveObject( "/Event/Hit", pnode );
98 if ( !sc.isSuccess() )
99 {
100 pnode = new DataObject;
101 sc = eventSvc()->registerObject( "/Event/Hit", pnode );
102 if ( !sc.isSuccess() )
103 {
104 log << MSG::FATAL << " Could not register hit branch" << endmsg;
105 return StatusCode::FAILURE;
106 }
107 }
108
109 SmartIF<IDataManagerSvc> dataManSvc( eventSvc() );
110 DataObject* hitCol;
111 eventSvc()->findObject( "/Event/Hit/MdcHitCol", hitCol );
112 if ( hitCol != NULL )
113 {
114 dataManSvc->clearSubTree( "/Event/Hit/MdcHitCol" );
115 eventSvc()->unregisterObject( "/Event/Hit/MdcHitCol" );
116 }
117 MdcHitCol* mdcHitCol = new MdcHitCol;
118 sc = eventSvc()->registerObject( "/Event/Hit/MdcHitCol", mdcHitCol );
119 if ( !sc.isSuccess() )
120 {
121 log << MSG::FATAL << " Could not register hit collection" << endmsg;
122 return StatusCode::FAILURE;
123 }
124
125 DataObject* hitMap;
126 eventSvc()->findObject( "/Event/Hit/MdcHitMap", hitMap );
127 if ( hitMap != NULL )
128 {
129 dataManSvc->clearSubTree( "/Event/Hit/MdcHitMap" );
130 eventSvc()->unregisterObject( "/Event/Hit/MdcHitMap" );
131 }
132 MdcHitMap* mdcHitMap = new MdcHitMap( *_gm );
133 sc = eventSvc()->registerObject( "/Event/Hit/MdcHitMap", mdcHitMap );
134 if ( !sc.isSuccess() )
135 {
136 log << MSG::FATAL << " Could not register hit map" << endmsg;
137 return StatusCode::FAILURE;
138 }
139
140 // retrieve Mdc digi vector form RawDataProviderSvc
141 uint32_t getDigiFlag = 0;
142 getDigiFlag += m_maxMdcDigi;
143 if ( m_dropHot || m_combineTracking ) getDigiFlag |= MdcRawDataProvider::b_dropHot;
144 if ( m_keepBadTdc ) getDigiFlag |= MdcRawDataProvider::b_keepBadTdc;
145 if ( m_keepUnmatch ) getDigiFlag |= MdcRawDataProvider::b_keepUnmatch;
146 MdcDigiVec mdcDigiVec = m_rawDataProviderSvc->getMdcDigiVec( getDigiFlag );
147
148 // std::cout<<__FILE__<<" nDigi = "<<mdcDigiVec.size()<< std::endl;
149 if ( (int)mdcDigiVec.size() < m_minMdcDigi )
150 {
151 log << MSG::WARNING << " Skip this event for MdcDigiVec.size() < " << m_minMdcDigi
152 << endmsg;
153 return StatusCode::SUCCESS;
154 }
155
156 MdcDigiVec::iterator iter = mdcDigiVec.begin();
157 for ( ; iter != mdcDigiVec.end(); iter++ )
158 {
159 const MdcDigi* aDigi = *iter;
160 MdcHit* hit = new MdcHit( aDigi, _gm );
161 hit->setCalibSvc( m_mdcCalibFunSvc );
162 hit->setCosmicFit( m_cosmicFit );
163 hit->setCountPropTime( m_countPropTime );
164#ifdef MDCPATREC_RESLAYER
165 hit->setResLayer( m_resLayer );
166#endif
167 mdcHitCol->push_back( hit );
168 mdcHitMap->addHit( *hit );
169 }
170 return StatusCode::SUCCESS;
171}
172
173// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
175
176 MsgStream log( msgSvc(), name() );
177 log << MSG::INFO << "in finalize()" << endmsg;
178
179 return StatusCode::SUCCESS;
180}
DECLARE_COMPONENT(BesBdkRc)
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
const CLID & CLID_MdcHitCol
IMessageSvc * msgSvc()
static MdcDetector * instance()
void setCalibSvc(const IMdcCalibFunSvc *calibSvc)
Definition MdcHit.cxx:136
StatusCode beginRun()
StatusCode initialize()
StatusCode execute()
StatusCode finalize()
MdcMakeHits(const std::string &name, ISvcLocator *pSvcLocator)