BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcRawDataProvider.cxx
Go to the documentation of this file.
3#include "GaudiKernel/Kernel.h"
4#include "GaudiKernel/IInterface.h"
5#include "GaudiKernel/IIncidentSvc.h"
6#include "GaudiKernel/Incident.h"
7#include "GaudiKernel/IIncidentListener.h"
8#include "GaudiKernel/StatusCode.h"
9#include "GaudiKernel/SvcFactory.h"
10#include "GaudiKernel/MsgStream.h"
11#include "GaudiKernel/IDataProviderSvc.h"
12#include "GaudiKernel/SmartDataPtr.h"
13#include "GaudiKernel/DataSvc.h"
15#include "Identifier/MdcID.h"
19
20// tianhl for mt
21#include "GaudiKernel/ThreadGaudi.h"
22// tianhl for mt
23#include <stdint.h>
24#include <vector>
25
26using namespace std;
27
30 digiRef(0),
31 m_mdcCalibFunSvc(0)
32{}
33
34
36 RawDataProviderBase( name ),
37 digiRef(0),
38 m_mdcCalibFunSvc(0)
39{}
40
42}
43
44StatusCode MdcRawDataProvider::initialize( ISvcLocator* pSvcLoc, IMessageSvc* pMsg ) {
45 RawDataProviderBase::initialize( pSvcLoc,pMsg );
46 return StatusCode::SUCCESS;
47}
48
49void MdcRawDataProvider::handle(const Incident& inc){
50 MsgStream log( m_msgSvc, m_name );
51 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
52 if ( inc.type() == "BeginEvent" ){
53 digiRef.clear();
54 }
55 return;
56}
57
59 MsgStream log(m_msgSvc, m_name);
60 StatusCode sc;
61 bool unRedo = ((control&b_unRedo)==b_unRedo);
62 if(!unRedo) digiRef.clear();
63 else if(digiRef.size()>0) return digiRef;
64 //---- get event service
65 IDataProviderSvc* evtSvc;
66 // tianhl for mt
67 std::string evtDataSvc_name("EventDataSvc");
68 if(isGaudiThreaded(m_name)){
69 evtDataSvc_name += getGaudiThreadIDfromName(m_name);
70 }
71 // tianhl for mt
72 sc = m_svcLocator->service(evtDataSvc_name.c_str(),evtSvc,true);
73 if (!sc.isSuccess()){
74 log << MSG::FATAL << "Could not load EventDataSvc" << endreq;
75 return digiRef;
76 }
77
78 //---- get max MdcDigi
79 int maxMdcDigi = control&i_maxMdcDigi;
80
81 //---- prepare for drop Bad TDC
82 bool keepBadTdc = ((control&b_keepBadTdc)!=0x10000);
83 double t0 = 0.;
84 if (keepBadTdc){
85 //get MdcCalibFunSvc
86 IMdcCalibFunSvc* imdcCalibSvc;
87 sc = m_svcLocator->service("MdcCalibFunSvc", m_mdcCalibFunSvc);
88 if ( sc.isFailure() ){
89 log << MSG::FATAL << "Could not load MdcCalibFunSvc!" << endreq;
90 return digiRef;
91 }
92
93 //get event start time t0
94 SmartDataPtr<RecEsTimeCol> esTimeCol(evtSvc,"/Event/Recon/RecEsTimeCol");
95 if (!esTimeCol){
96 log << MSG::INFO<< " Could not retrieve RecEsTimeCol"<< endreq;
97 keepBadTdc = false;
98 }else if( (esTimeCol->size()==0)) {
99 log << MSG::INFO<< " Could not retrieve RecEsTimeCol"<< endreq;
100 keepBadTdc = false;
101 }else{
102 RecEsTimeCol::iterator iter= esTimeCol->begin();
103 for(; iter!=esTimeCol->end(); iter++){
104 t0 = (*iter)->getTest();
105 }
106 }//end esTimeCol
107 }
108
109 //----- mark hit on track
110 bool m_hitInUse[43][288];
111 for (int i=0; i<43; i++){
112 for (int j=0; j<288; j++) m_hitInUse[i][j]=false;
113 }
114 bool dropHot = ((control&b_dropHot)==0x4000);
115 if (dropHot){
116 SmartDataPtr<RecMdcHitCol> recHitCol(evtSvc, "/Event/Recon/RecMdcHitCol");
117 if (!recHitCol) {
118 log << MSG::INFO << "Could not retrieve RecMdcHitCol" << endreq;
119 dropHot = false;
120 }else{
121 RecMdcHitCol::iterator iter = recHitCol->begin();
122 for ( ; iter != recHitCol->end(); iter++) {
123 Identifier id = (*iter)->getMdcId();
124 m_hitInUse[MdcID::layer(id)][MdcID::wire(id)] = true;
125 }
126 }
127 }
128
129 //----- mark skipped layers
130 bool isSkipLayers = ((control&b_keepSkipped)!=0x8000) && (m_skipLayers.size()>0);
131
132 bool skipLayer[43];
133 for (int i=0; i<43; i++){skipLayer[i]= false;}
134 for(unsigned iSkip =0; iSkip < m_skipLayers.size(); iSkip++){
135 skipLayer[m_skipLayers[iSkip]]=true;
136 }
137
138 //----- loop MdcDigiCol to select------------------
139 int iDigi=0;
140 int nMatchedDigi=0;
141
142 SmartDataPtr<MdcDigiCol> mdcDigiCol(evtSvc,"/Event/Digi/MdcDigiCol");
143 if (sc!=StatusCode::SUCCESS) {
144 log << MSG::FATAL << "Could not find MdcDigiCol!" << endreq;
145 return digiRef;
146 }
147 MdcDigiCol::iterator iter = mdcDigiCol->begin();
148 for (;iter != mdcDigiCol->end(); iter++,iDigi++ ) {
149 MdcDigi *aDigi = (*iter);
150 Identifier id = aDigi->identify();
151 int layer = MdcID::layer(id);
152 int wire = MdcID::wire(id);
153 unsigned tdc = aDigi->getTimeChannel();
154 unsigned adc = aDigi->getChargeChannel();
155 unsigned overflow = aDigi->getOverflow();
156
157 //--0. skip dead channel w.o. sense wire
158 if((layer==18)&&(wire==27||wire==42)) continue;//yzhang add 2011-01-06
159
160 //--1. drop Mdc layer hits
161 if( isSkipLayers && skipLayer[layer] ) continue;
162
163 //--2. drop hit on track
164 if ( dropHot && m_hitInUse[layer][wire]) continue;
165
166 //--3. drop unmatched, overflow and multi TDC
167 //overflow :
168 // 1, T overflow
169 // 2, Q overflow
170 // 4, multi TDC
171 // 8, multi TDC, earliest
172 if ( ((control&b_keepUnmatch)!=0x2000) &&
173 (((overflow & 1)>0) ||
174 (((overflow&12)!=12)&&((overflow&12)!=0)) ||
175 (tdc==0x7FFFFFFF) || (adc== 0x7FFFFFFF) ) ) { continue; }
176
177
178
179 //--4. drop bad hit(Tdc - t0 < -10 ns)
180 if(keepBadTdc){
181 // Get T0
182 double T0Walk = 0.;
183 if (m_mdcCalibFunSvc) { T0Walk = m_mdcCalibFunSvc->getT0(layer,wire)
184 + m_mdcCalibFunSvc->getTimeWalk(layer,adc); }
185 if((RawDataUtil::MdcTime(tdc) - T0Walk - t0)<-10.) continue;
186 }
187
188 //--5. skip by max limit of digi number
189 nMatchedDigi++;
190 if ((maxMdcDigi>0) && (nMatchedDigi > maxMdcDigi)){
191 digiRef.clear();
192 return digiRef;
193 }
194
195 digiRef.push_back(aDigi);
196 }//end loop of MdcDigiCol
197 return digiRef;
198}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
std::vector< MdcDigi * > MdcDigiVec
virtual double getT0(int layid, int cellid) const =0
virtual double getTimeWalk(int layid, double Q) const =0
unsigned int getOverflow() const
Definition: MdcDigi.h:26
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
Definition: MdcID.cxx:49
static int wire(const Identifier &id)
Definition: MdcID.cxx:54
void handle(const Incident &)
MdcDigiVec & getMdcDigiVec(uint32_t control=0)
StatusCode initialize(ISvcLocator *svcLoc=0, IMessageSvc *pMsg=0)
StatusCode initialize(ISvcLocator *svcLoc=0, IMessageSvc *pMsg=0)
ISvcLocator * m_svcLocator
static double MdcTime(int timeChannel)
Definition: RawDataUtil.h:8
virtual Identifier identify() const
Definition: RawData.cxx:15
unsigned int getChargeChannel() const
Definition: RawData.cxx:45
unsigned int getTimeChannel() const
Definition: RawData.cxx:40