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"
9#include "GaudiKernel/SmartDataPtr.h"
10#include "GaudiKernel/IDataProviderSvc.h"
11#include "GaudiKernel/PropertyMgr.h"
50 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
51 MsgStream log(
msgSvc,
"PreXtMdcCalib");
52 log << MSG::INFO <<
"PreXtMdcCalib::initialize()" << endreq;
55 m_mdcGeomSvc = mdcGeomSvc;
56 m_mdcFunSvc = mdcFunSvc;
57 m_mdcUtilitySvc = mdcUtilitySvc;
61 m_nWire = m_mdcGeomSvc -> getWireSize();
62 m_nLayer = m_mdcGeomSvc -> getLayerSize();
64 m_fdPreXt =
new TFolder(
"PreXt",
"PreXt");
65 m_hlist->Add(m_fdPreXt);
67 m_fdNhit =
new TFolder(
"XtNhit",
"XtNhit");
68 m_hlist->Add(m_fdNhit);
70 m_haxis =
new TH2F(
"axis",
"", 50, 0, 300, 50, 0, 9);
71 m_haxis -> SetStats(0);
72 m_fdPreXt -> Add(m_haxis);
76 sprintf(hname,
"trec%02d", lay);
77 m_htrec[lay] =
new TH1F(hname,
"", 310, -20, 600);
78 m_fdPreXt -> Add(m_htrec[lay]);
81 m_nhitTot =
new TH1F(
"nhitTot",
"", 43, -0.5, 42.5);
82 m_fdNhit -> Add(m_nhitTot);
85 sprintf(hname,
"nhitBin%02d", lay);
86 m_nhitBin[lay] =
new TH1F(hname,
"", 40, 5.0, 405.0);
87 m_fdNhit -> Add(m_nhitBin[lay]);
99 m_nEntries[lay][
bin] = 0;
106 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
107 MsgStream log(
msgSvc,
"PreXtMdcCalib");
108 log << MSG::DEBUG <<
"PreXtMdcCalib::fillHist()" << endreq;
120 IDataProviderSvc* eventSvc = NULL;
121 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
126 m_t0[lay] = m_mdcFunSvc -> getT0(lay, 0);
127 m_mdcFunSvc->
getXtpar(lay, 0, 0, xtpar);
128 m_tm[lay] = xtpar[6];
134 double tes = -9999.0;
136 SmartDataPtr<RecEsTimeCol> aevtimeCol(eventSvc,
"/Event/Recon/RecEsTimeCol");
137 if( (!aevtimeCol) || (aevtimeCol->size()==0) ){
141 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
142 for(; iter_evt!=aevtimeCol->end(); iter_evt++){
143 tes = (*iter_evt)->getTest();
144 esTimeflag = (*iter_evt)->getStat();
147 bool flagTes =
false;
148 for(
int iEs=0; iEs<m_param.
nEsFlag; iEs++){
149 if(esTimeflag == m_param.
esFlag[iEs]){
154 if( (!flagTes) || (tes < m_param.
tesMin) || (tes > m_param.
tesMax) )
return -1;
157 SmartDataPtr<MdcDigiCol> mdcDigiCol(eventSvc,
"/Event/Digi/MdcDigiCol");
159 log << MSG::FATAL <<
"Could not find event" << endreq;
162 MdcDigiCol::iterator
iter = mdcDigiCol->begin();
164 for(;
iter != mdcDigiCol->end();
iter++, digiId++) {
166 id = (aDigi)->identify();
170 tdc = (aDigi) -> getTimeChannel();
171 adc = (aDigi) -> getChargeChannel();
172 fgOverFlow = (aDigi) -> getOverflow();
174 trec = traw - tes - m_t0[lay];
179 if ( ((fgOverFlow & 1) !=0 ) || ((fgOverFlow & 12) != 0) ||
186 if(trec < m_tm[lay]){
188 m_htrec[lay]->Fill(trec);
189 m_nhitTot->Fill(lay);
192 if(trec < m_tbin[
bin]){
193 m_nEntries[lay][
bin]++;
194 m_nhitBin[lay]->Fill(m_tbin[
bin]);
204 Gaudi::svcLocator() -> service(
"MessageSvc",
msgSvc);
205 MsgStream log(
msgSvc,
"PreXtMdcCalib");
206 log << MSG::DEBUG <<
"PreXtMdcCalib::updateConst()" << endreq;
216 double pi = 3.141592653;
223 TF1* funXt =
new TF1(
"funXt", xtfun, 0, 300, 6);
224 funXt -> FixParameter(0, 0.0);
225 funXt -> SetParameter(1, 0.03);
226 funXt -> SetParameter(2, 0.0);
227 funXt -> SetParameter(3, 0.0);
228 funXt -> SetParameter(4, 0.0);
229 funXt -> SetParameter(5, 0.0);
231 ofstream fxtlog(
"preXtpar.dat");
233 sprintf(hname,
"grPreXt%02d", lay);
234 m_grXt[lay] =
new TGraph();
235 m_grXt[lay] -> SetName(hname);
237 m_fdPreXt -> Add(m_grXt[lay]);
239 layRad = m_mdcGeomSvc -> Layer(lay) -> Radius();
240 ncel = m_mdcGeomSvc -> Layer(lay) -> NCell();
241 dm =
pi * layRad / ncel;
243 fxtlog <<
"layer " << lay << endl;
245 dist[
bin] = dm * m_nEntries[lay][
bin] / m_nTot[lay];
246 m_grXt[lay] -> SetPoint(
bin, m_tbin[
bin], dist[
bin]);
247 fxtlog << setw(4) <<
bin << setw(15) << m_tbin[
bin]
248 << setw(15) << dist[
bin] << setw(15) << dm
249 << setw(10) << m_nEntries[lay][
bin]
250 << setw(10) << m_nTot[lay] << endl;
252 if(m_tbin[
bin] >= m_tm[lay])
break;
256 m_grXt[lay] ->
Fit(funXt,
"Q",
"", 0.0, m_tm[lay]);
257 for(ord=0; ord<6; ord++){
258 xtpar[ord] = funXt -> GetParameter(ord);
263 for(ord=0; ord<6; ord++){
264 calconst -> resetXtpar(lay, iEntr, iLR, ord, xtpar[ord]);
269 for(ord=0; ord<6; ord++) xtpar[ord] = calconst->
getXtpar(lay, 0, 0, ord);
272 for(ord=0; ord<6; ord++) fxtlog << setw(14) << xtpar[ord];
273 fxtlog << setw(10) << m_tm[lay] <<
" 0" << endl;
276 cout <<
"preXt.dat was written." << endl;
282Double_t PreXtMdcCalib::xtfun(Double_t *x, Double_t *par){
284 for(Int_t ord=0; ord<6; ord++){
285 val += par[ord] * pow(x[0], ord);
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per bin
const double MdcCalTdcCnv
virtual void getXtpar(int layid, int entr, int lr, double par[]) const =0
int fgCalib[MdcCalNLayer]
double getXtpar(int lay, int entr, int lr, int order)
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
int updateConst(MdcCalibConst *calconst)
int fillHist(MdcCalEvent *event)
void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)
unsigned int getChargeChannel() const
unsigned int getTimeChannel() const