BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
T0MdcCalib.cxx
Go to the documentation of this file.
2
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/IMessageSvc.h"
5#include "GaudiKernel/StatusCode.h"
6#include "GaudiKernel/ISvcLocator.h"
7#include "GaudiKernel/Bootstrap.h"
8
9#include <iostream>
10#include <iomanip>
11#include <cstring>
12
14 for(int lay=0; lay<MdcCalNLayer; lay++){
15 if(lay < 8){
16 m_docaMin[lay] = 1.2; // mm
17 m_docaMax[lay] = 4.8; // mm
18 } else{
19 m_docaMin[lay] = 1.6; // mm
20 m_docaMax[lay] = 6.4; // mm
21 }
22 }
23}
24
26}
27
29 for(int i=0; i<MdcCalTotCell; i++){
30 delete m_hleft[i];
31 delete m_hright[i];
32 }
33 delete m_hLrResiSum;
34 delete m_hLrResiSub;
35 delete m_fdT0;
36 delete m_fdResiWire;
37
39}
40
41void T0MdcCalib::initialize(TObjArray* hlist, IMdcGeomSvc* mdcGeomSvc,
42 IMdcCalibFunSvc* mdcFunSvc, IMdcUtilitySvc* mdcUtilitySvc) {
43 IMessageSvc* msgSvc;
44 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
45 MsgStream log(msgSvc, "T0MdcCalib");
46 log << MSG::INFO << "T0MdcCalib::initialize()" << endreq;
47
48 m_hlist = hlist;
49 m_mdcGeomSvc = mdcGeomSvc;
50 m_mdcFunSvc = mdcFunSvc;
51 m_mdcUtilitySvc = mdcUtilitySvc;
52
53 m_vdr = 0.03;
54
55 MdcCalib::initialize(m_hlist, m_mdcGeomSvc, m_mdcFunSvc, m_mdcUtilitySvc);
56
57 int i;
58 int nwire;
59 int lay;
60 int cel;
61 char hname[200];
62
63 m_fdT0 = new TFolder("fdT0", "fdT0");
64 m_hlist -> Add(m_fdT0);
65
66 m_fdResiWire = new TFolder("ResiWire", "ResiWire");
67 m_hlist->Add(m_fdResiWire);
68
69 nwire = m_mdcGeomSvc -> getWireSize();
70 for(i=0; i<nwire; i++){
71 lay = m_mdcGeomSvc -> Wire(i) -> Layer();
72 cel = m_mdcGeomSvc -> Wire(i) -> Cell();
73
74 sprintf(hname, "Resi%04d_Lay%02d_Cell%03d_L", i, lay, cel);
75 m_hleft[i] = new TH1F(hname, "", 400, -2.0, 2.0);
76 m_fdT0 -> Add(m_hleft[i]);
77
78 sprintf(hname, "Resi%04d_Lay%02d_Cell%03d_R", i, lay, cel);
79 m_hright[i] = new TH1F(hname, "", 400, -2.0, 2.0);
80 m_fdT0 -> Add(m_hright[i]);
81 }
82
83 m_hLrResiSum = new TH1F("LrResiSum", "", 200, -0.5, 0.5);
84 m_fdResiWire->Add(m_hLrResiSum);
85
86 m_hLrResiSub = new TH1F("LrResiSub", "", 200, -0.5, 0.5);
87 m_fdResiWire->Add(m_hLrResiSub);
88}
89
91 IMessageSvc* msgSvc;
92 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
93 MsgStream log(msgSvc, "T0MdcCalib");
94 log << MSG::DEBUG << "T0MdcCalib::fillHist()" << endreq;
95
96 MdcCalib::fillHist(event);
97
98 // get EsTimeCol
99 bool esCutFg = event->getEsCutFlag();
100 if( ! esCutFg ) return -1;
101
102 int i;
103 int k;
104 int ntrk;
105 int nhit;
106 int stat;
107
108 int lay;
109 int cel;
110 int wir;
111 int lr;
112 double dmeas;
113 double doca;
114 double resi;
115
116 bool fgHitLay[MdcCalNLayer];
117
118 MdcCalRecTrk* rectrk;
119 MdcCalRecHit* rechit;
120
121 ntrk = event -> getNTrk();
122 if((ntrk < m_param.nTrkCut[0]) || (ntrk > m_param.nTrkCut[1])) return -1;
123
124 for(i=0; i<ntrk; i++){
125 rectrk = event -> getRecTrk(i);
126 nhit = rectrk -> getNHits();
127
128 // dr cut
129 double dr = rectrk->getDr();
130 if(fabs(dr) > m_param.drCut) continue;
131
132 // dz cut
133 double dz = rectrk->getDz();
134 if(fabs(dz) > m_param.dzCut) continue;
135
136 for(lay=0; lay<MdcCalNLayer; lay++) fgHitLay[lay] = false;
137 for(k=0; k<nhit; k++){
138 rechit = rectrk -> getRecHit(k);
139 lay = rechit -> getLayid();
140 fgHitLay[lay] = true;
141 }
142
143 int nhitlay = 0;
144 for(lay=0; lay<MdcCalNLayer; lay++) if(fgHitLay[lay]) nhitlay++;
145 if(nhitlay < m_param.nHitLayCut) continue;
146
147 bool fgNoise = rectrk->getFgNoiseRatio();
148 if(m_param.noiseCut && (!fgNoise)) continue;
149
150// log << MSG::DEBUG << "nhits: " << nhit << endreq;
151 for(k=0; k<nhit; k++){
152 rechit = rectrk -> getRecHit(k);
153 lay = rechit -> getLayid();
154 cel = rechit -> getCellid();
155 wir = m_mdcGeomSvc -> Wire(lay, cel) -> Id();
156 lr = rechit -> getLR();
157 doca = rechit -> getDocaExc();
158 dmeas = rechit -> getDmeas();
159 resi = rechit -> getResiExc();
160 stat = rechit -> getStat();
161
162 if(1 != stat) continue;
163
164 if( (fabs(doca) < m_docaMin[lay]) ||
165 (fabs(doca) > m_docaMax[lay]) ||
166 (fabs(resi) > m_param.resiCut[lay]) ){
167 continue;
168 }
169
170 if(0 == lay){
171 if( ! fgHitLay[1] ) continue;
172 } else if(42 == lay){
173 if( ! fgHitLay[41] ) continue;
174 } else{
175 if( (!fgHitLay[lay-1]) && (!fgHitLay[lay+1]) ) continue;
176 }
177
178 if(wir < (m_mdcGeomSvc->getWireSize()) ){
179 if( 0 == lr ){
180 m_hleft[wir] -> Fill(resi);
181 }else if( 1 == lr ){
182 m_hright[wir] -> Fill(resi);
183 }
184 }else{
185 std::cout << "wireid: " << wir << std::endl;
186 }
187 }
188 }
189 return 1;
190}
191
193 IMessageSvc* msgSvc;
194 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
195 MsgStream log(msgSvc, "T0MdcCalib");
196 log << MSG::INFO << "T0MdcCalib::updateConst()" << endreq;
197
198 MdcCalib::updateConst(calconst);
199
200 int i;
201 int lay;
202 int nwire;
203 double t0;
204 double delt0;
205 double resiLrSum;
206 double resiLrSub;
207
208 Stat_t entry_l;
209 double mean_l;
210// double gmean_l; // mean of fit with the gaussian distribution
211// double sigma_l;
212// double rms_l;
213
214 Stat_t entry_r;
215 double mean_r;
216// double gmean_r;
217// double sigma_r;
218// double rms_r;
219
220 nwire = m_mdcGeomSvc -> getWireSize();
221 std::cout << "totwire: " << nwire << std::endl;
222 for(i=0; i<nwire; i++){
223 lay = m_mdcGeomSvc -> Wire(i) -> Layer();
224
225 if(1 == m_param.fgCalib[lay]){
226 entry_l = m_hleft[i] -> GetEntries();
227 mean_l = m_hleft[i] -> GetMean();
228// m_hleft[i] -> Fit("gaus", "Q");
229// gmean_l = m_hleft[i] -> GetFunction("gaus") -> GetParameter(1);
230
231 entry_r = m_hright[i] -> GetEntries();
232 mean_r = m_hright[i] -> GetMean();
233// m_hright[i] -> Fit("gaus", "Q");
234// gmean_r = m_hright[i] -> GetFunction("gaus") -> GetParameter(1);
235
236 delt0 = 0.5 * (mean_l + mean_r) / m_vdr;
237 } else{
238 delt0 = 0.0;
239 }
240
241 resiLrSum = 0.5 * (mean_l + mean_r);
242 resiLrSub = 0.5 * (mean_l - mean_r);
243 m_hLrResiSum->Fill(resiLrSum);
244 m_hLrResiSub->Fill(resiLrSub);
245
246 t0 = calconst -> getT0(i);
247 t0 += delt0;
248
249 calconst -> resetT0(i, t0);
250 calconst -> resetDelT0(i, delt0);
251 }
252 return 1;
253}
254
curve Fill()
const int MdcCalNLayer
Definition: MdcCalParams.h:6
const int MdcCalTotCell
Definition: MdcCalParams.h:9
IMessageSvc * msgSvc()
virtual const int getWireSize()=0
int nTrkCut[2]
Definition: MdcCalParams.h:63
int fgCalib[MdcCalNLayer]
Definition: MdcCalParams.h:75
double dzCut
Definition: MdcCalParams.h:71
double drCut
Definition: MdcCalParams.h:70
double resiCut[MdcCalNLayer]
Definition: MdcCalParams.h:79
double getDz() const
Definition: MdcCalRecTrk.h:33
bool getFgNoiseRatio() const
Definition: MdcCalRecTrk.h:46
double getDr() const
Definition: MdcCalRecTrk.h:30
virtual void clear()=0
Definition: MdcCalib.cxx:76
virtual void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)=0
Definition: MdcCalib.cxx:202
virtual int updateConst(MdcCalibConst *calconst)=0
Definition: MdcCalib.cxx:1322
virtual int fillHist(MdcCalEvent *event)=0
Definition: MdcCalib.cxx:692
int fillHist(MdcCalEvent *event)
Definition: T0MdcCalib.cxx:90
void clear()
Definition: T0MdcCalib.cxx:28
void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)
Definition: T0MdcCalib.cxx:41
int updateConst(MdcCalibConst *calconst)
Definition: T0MdcCalib.cxx:192
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
mg Add(gr3)