CGEM BOSS 6.6.5.h
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
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 sc = m_svcLocator->service("MdcCalibFunSvc", m_mdcCalibFunSvc);
87 if ( sc.isFailure() ){
88 log << MSG::FATAL << "Could not load MdcCalibFunSvc!" << endreq;
89 return digiRef;
90 }
91
92 //get event start time t0
93 SmartDataPtr<RecEsTimeCol> esTimeCol(evtSvc,"/Event/Recon/RecEsTimeCol");
94 if (!esTimeCol){
95 log << MSG::INFO<< " Could not retrieve RecEsTimeCol"<< endreq;
96 keepBadTdc = false;
97 }else if( (esTimeCol->size()==0)) {
98 log << MSG::INFO<< " Could not retrieve RecEsTimeCol"<< endreq;
99 keepBadTdc = false;
100 }else{
101 RecEsTimeCol::iterator iter= esTimeCol->begin();
102 for(; iter!=esTimeCol->end(); iter++){
103 t0 = (*iter)->getTest();
104 }
105 }//end esTimeCol
106 }
107
108 //----- mark hit on track
109 bool m_hitInUse[43][288];
110 for (int i=0; i<43; i++){
111 for (int j=0; j<288; j++) m_hitInUse[i][j]=false;
112 }
113 bool dropHot = ((control&b_dropHot)==0x4000);
114 if (dropHot){
115 SmartDataPtr<RecMdcHitCol> recHitCol(evtSvc, "/Event/Recon/RecMdcHitCol");
116 if (!recHitCol) {
117 log << MSG::INFO << "Could not retrieve RecMdcHitCol" << endreq;
118 dropHot = false;
119 }else{
120 RecMdcHitCol::iterator iter = recHitCol->begin();
121 for ( ; iter != recHitCol->end(); iter++) {
122 Identifier id = (*iter)->getMdcId();
123 m_hitInUse[MdcID::layer(id)][MdcID::wire(id)] = true;
124 }
125 }
126 }
127
128 //----- mark skipped layers
129 bool isSkipLayers = ((control&b_keepSkipped)!=0x8000) && (m_skipLayers.size()>0);
130
131 bool skipLayer[43];
132 for (int i=0; i<43; i++){skipLayer[i]= false;}
133 for(unsigned iSkip =0; iSkip < m_skipLayers.size(); iSkip++){
134 skipLayer[m_skipLayers[iSkip]]=true;
135 }
136
137 //----- loop MdcDigiCol to select------------------
138 int iDigi=0;
139 int nMatchedDigi=0;
140
141 SmartDataPtr<MdcDigiCol> mdcDigiCol(evtSvc,"/Event/Digi/MdcDigiCol");
142 if (sc!=StatusCode::SUCCESS) {
143 log << MSG::FATAL << "Could not find MdcDigiCol!" << endreq;
144 return digiRef;
145 }
146 MdcDigiCol::iterator iter = mdcDigiCol->begin();
147 for (;iter != mdcDigiCol->end(); iter++,iDigi++ ) {
148 MdcDigi *aDigi = (*iter);
149 Identifier id = aDigi->identify();
150 int layer = MdcID::layer(id);
151 int wire = MdcID::wire(id);
152 unsigned tdc = aDigi->getTimeChannel();
153 unsigned adc = aDigi->getChargeChannel();
154 unsigned overflow = aDigi->getOverflow();
155
156 //--0. skip dead channel
157 if ( ((control&b_keepAllChannel)!=0x40000) && m_mdcCalibFunSvc
158 && m_mdcCalibFunSvc->getWireEff(layer,wire) < m_effThreshold) continue;
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 getWireEff(int layid, int cellid) const =0
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)
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