BOSS 7.1.0
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 // momentum cut
137 double p = rectrk -> getP();
138 if((fabs(p) < m_param.pCut[0]) || (fabs(p) > m_param.pCut[1])) continue;
139
140 for(lay=0; lay<MdcCalNLayer; lay++) fgHitLay[lay] = false;
141 for(k=0; k<nhit; k++){
142 rechit = rectrk -> getRecHit(k);
143 lay = rechit -> getLayid();
144 fgHitLay[lay] = true;
145 }
146
147 int nhitlay = 0;
148 for(lay=0; lay<MdcCalNLayer; lay++) if(fgHitLay[lay]) nhitlay++;
149 if(nhitlay < m_param.nHitLayCut) continue;
150
151 bool fgNoise = rectrk->getFgNoiseRatio();
152 if(m_param.noiseCut && (!fgNoise)) continue;
153
154// log << MSG::DEBUG << "nhits: " << nhit << endreq;
155 for(k=0; k<nhit; k++){
156 rechit = rectrk -> getRecHit(k);
157 lay = rechit -> getLayid();
158 cel = rechit -> getCellid();
159 wir = m_mdcGeomSvc -> Wire(lay, cel) -> Id();
160 lr = rechit -> getLR();
161 doca = rechit -> getDocaExc();
162 dmeas = rechit -> getDmeas();
163 resi = rechit -> getResiExc();
164 stat = rechit -> getStat();
165
166 if(1 != stat) continue;
167
168 if( (fabs(doca) < m_docaMin[lay]) ||
169 (fabs(doca) > m_docaMax[lay]) ||
170 (fabs(resi) > m_param.resiCut[lay]) ){
171 continue;
172 }
173
174 if(0 == lay){
175 if( ! fgHitLay[1] ) continue;
176 } else if(42 == lay){
177 if( ! fgHitLay[41] ) continue;
178 } else{
179 if( (!fgHitLay[lay-1]) && (!fgHitLay[lay+1]) ) continue;
180 }
181
182 if(wir < (m_mdcGeomSvc->getWireSize()) ){
183 if( 0 == lr ){
184 m_hleft[wir] -> Fill(resi);
185 }else if( 1 == lr ){
186 m_hright[wir] -> Fill(resi);
187 }
188 }else{
189 std::cout << "wireid: " << wir << std::endl;
190 }
191 }
192 }
193 return 1;
194}
195
198}
199
201 IMessageSvc* msgSvc;
202 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
203 MsgStream log(msgSvc, "T0MdcCalib");
204 log << MSG::INFO << "T0MdcCalib::updateConst()" << endreq;
205
206 MdcCalib::updateConst(calconst);
207
208 int i;
209 int lay;
210 int nwire;
211 double t0;
212 double delt0;
213 double resiLrSum;
214 double resiLrSub;
215
216 Stat_t entry_l;
217 double mean_l;
218// double gmean_l; // mean of fit with the gaussian distribution
219// double sigma_l;
220// double rms_l;
221
222 Stat_t entry_r;
223 double mean_r;
224// double gmean_r;
225// double sigma_r;
226// double rms_r;
227
228 nwire = m_mdcGeomSvc -> getWireSize();
229 std::cout << "totwire: " << nwire << std::endl;
230 for(i=0; i<nwire; i++){
231 lay = m_mdcGeomSvc -> Wire(i) -> Layer();
232
233 if(1 == m_param.fgCalib[lay]){
234 entry_l = m_hleft[i] -> GetEntries();
235 mean_l = m_hleft[i] -> GetMean();
236// m_hleft[i] -> Fit("gaus", "Q");
237// gmean_l = m_hleft[i] -> GetFunction("gaus") -> GetParameter(1);
238
239 entry_r = m_hright[i] -> GetEntries();
240 mean_r = m_hright[i] -> GetMean();
241// m_hright[i] -> Fit("gaus", "Q");
242// gmean_r = m_hright[i] -> GetFunction("gaus") -> GetParameter(1);
243
244 delt0 = 0.5 * (mean_l + mean_r) / m_vdr;
245 } else{
246 delt0 = 0.0;
247 }
248 if(0 == m_param.fgWireCal[i]) delt0 = 0.0;
249
250 resiLrSum = 0.5 * (mean_l + mean_r);
251 resiLrSub = 0.5 * (mean_l - mean_r);
252 m_hLrResiSum->Fill(resiLrSum);
253 m_hLrResiSub->Fill(resiLrSub);
254
255 t0 = calconst -> getT0(i);
256 t0 += delt0;
257
258 calconst -> resetT0(i, t0);
259 calconst -> resetDelT0(i, delt0);
260 }
261 return 1;
262}
263
curve Fill()
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)
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:65
int fgCalib[MdcCalNLayer]
Definition: MdcCalParams.h:80
double pCut[2]
Definition: MdcCalParams.h:75
double dzCut
Definition: MdcCalParams.h:74
double drCut
Definition: MdcCalParams.h:73
double resiCut[MdcCalNLayer]
Definition: MdcCalParams.h:84
int fgWireCal[MdcCalTotCell]
Definition: MdcCalParams.h:88
double getDz() const
Definition: MdcCalRecTrk.h:33
bool getFgNoiseRatio() const
Definition: MdcCalRecTrk.h:46
double getDr() const
Definition: MdcCalRecTrk.h:30
virtual void printCut() const =0
Definition: MdcCalib.cxx:1407
virtual void clear()=0
Definition: MdcCalib.cxx:80
virtual void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)=0
Definition: MdcCalib.cxx:214
virtual int updateConst(MdcCalibConst *calconst)=0
Definition: MdcCalib.cxx:1417
virtual int fillHist(MdcCalEvent *event)=0
Definition: MdcCalib.cxx:730
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:200
void printCut() const
Definition: T0MdcCalib.cxx:196