60 #include "PhysicalConstants.h"
62 #include "StMessMgr.h"
63 #include "StFtpcCalibMaker.h"
64 #include "StFtpcLaserCalib.hh"
65 #include "StFtpcLaserTrafo.hh"
67 #include "St_DataSetIter.h"
68 #include "St_DataSet.h"
69 #include "StMessMgr.h"
74 #include "TObjArray.h"
89 StFtpcCalibMaker::~StFtpcCalibMaker(){
95 void StFtpcCalibMaker::GetRunInfo(TString filename){
101 LOG_DEBUG<<
"StFtpcCalibMaker::GetRunInfo j->Run.run = "<<j->Run.run<<
" j->Run.date = "<<j->Run.date<<
" j->Run.time = "<<j->Run.time<<
" j->Run.micropertimebin = "<<j->Run.micropertimebin<<
" j->Run.normalizedNowPressure = "<<j->Run.normalizedNowPressure <<
" j->Run.standardPressure = "<<j->Run.standardPressure<<
" j->Run.baseTemperature = "<<j->Run.baseTemperature<<
" j->Run.gasTemperatureWest = "<<j->Run.gasTemperatureWest<<
" j->Run.gasTemperatureEast = "<<j->Run.gasTemperatureEast<<endm;
105 micropertime = j->Run.micropertimebin;
106 normalizedNowPressure = j->Run.normalizedNowPressure;
107 standardPressure = j->Run.standardPressure;
108 baseTemperature = j->Run.baseTemperature;
109 gasTemperatureWest = j->Run.gasTemperatureWest;
110 gasTemperatureEast = j->Run.gasTemperatureEast;
128 if ( mbfield > 0.8 ) {
129 SetFlavor(
"ffp10kv",
"ftpcVDrift");
130 SetFlavor(
"ffp10kv",
"ftpcdVDriftdP");
131 SetFlavor(
"ffp10kv",
"ftpcDeflection");
132 SetFlavor(
"ffp10kv",
"ftpcdDeflectiondP");
133 LOG_INFO <<
"StFtpcCalibMaker::DbInit - flavor set to ffp10kv"<<endm;
135 else if ( mbfield > 0.2 ) {
136 SetFlavor(
"hfp10kv",
"ftpcVDrift");
137 SetFlavor(
"hfp10kv",
"ftpcdVDriftdP");
138 SetFlavor(
"hfp10kv",
"ftpcDeflection");
139 SetFlavor(
"hfp10kv",
"ftpcdDeflectiondP");
140 LOG_INFO <<
"StFtpcCalibMaker::DbInit - flavor set to hfp10kv"<<endm;
142 else if ( mbfield > -0.2 ) {
143 SetFlavor(
"zf10kv",
"ftpcVDrift");
144 SetFlavor(
"zf10kv",
"ftpcdVDriftdP");
145 SetFlavor(
"zf10kv",
"ftpcDeflection");
146 SetFlavor(
"zf10kv",
"ftpcdDeflectiondP");
147 LOG_INFO <<
"StFtpcCalibMaker::DbInit - flavor set to zf10kv"<<endm;
149 else if ( mbfield > -0.8 ) {
150 SetFlavor(
"hfn10kv",
"ftpcVDrift");
151 SetFlavor(
"hfn10kv",
"ftpcdVDriftdP");
152 SetFlavor(
"hfn10kv",
"ftpcDeflection");
153 SetFlavor(
"hfn10kv",
"ftpcdDeflectiondP");
154 LOG_INFO <<
"StFtpcCalibMaker::DbInit - flavor set to hfn10kv"<<endm;
157 SetFlavor(
"ffn10kv",
"ftpcVDrift");
158 SetFlavor(
"ffn10kv",
"ftpcdVDriftdP");
159 SetFlavor(
"ffn10kv",
"ftpcDeflection");
160 SetFlavor(
"ffn10kv",
"ftpcdDeflectiondP");
161 LOG_INFO <<
"StFtpcCalibMaker::DbInit - flavor set to ffn10kv"<<endm;
164 ftpc_db = GetDataBase(
"ftpc");
166 LOG_WARN <<
"StFtpcCalibMaker::DbInit - run parameter database StarDb/ftpc not found"<<endm;
171 m_clusterpars = (St_ftpcClusterPars *)local(
"ftpcClusterPars");
181 St_DataSet *ftpc_geometry_db = GetDataBase(
"Geometry/ftpc");
184 m_dimensions = (St_ftpcDimensions *)dblocal_geometry(
"ftpcDimensions");
185 m_padrow_z = (St_ftpcPadrowZ *)dblocal_geometry(
"ftpcPadrowZ");
187 St_DataSet *ftpc_calibrations_db = GetDataBase(
"Calibrations/ftpc");
190 m_gas= (St_ftpcGas *)dblocal_calibrations(
"ftpcGas");
191 m_efield = (St_ftpcEField *)dblocal_calibrations(
"ftpcEField");
196 m_vdrift = (St_ftpcVDrift *)dblocal_calibrations(
"ftpcVDrift");
197 m_deflection = (St_ftpcDeflection *)dblocal_calibrations(
"ftpcDeflection");
198 m_dvdriftdp = (St_ftpcdVDriftdP *)dblocal_calibrations(
"ftpcdVDriftdP");
199 m_ddeflectiondp = (St_ftpcdDeflectiondP *)dblocal_calibrations(
"ftpcdDeflectiondP");
201 m_driftfield = (St_ftpcDriftField *)dblocal_calibrations(
"ftpcDriftField");
202 m_electronics = (St_ftpcElectronics *)dblocal_calibrations(
"ftpcElectronics");
234 void StFtpcCalibMaker::DoLaserCalib(TString filename,
int ftpc,
int lsec,
int straight,
int gfit,
int minz,
int maxz,
int minrad,
int maxrad,
char* t0,
char* gas,
float gastemp,
float mbfield)
236 if (ftpc == 1) LOG_INFO<<
"StFtpcCalibMaker::DoLaserCalib - entered for FTPC West"<<endm;
237 if (ftpc == 2) LOG_INFO<<
"StFtpcCalibMaker::DoLaserCalib - entered for FTPC East"<<endm;
243 Float_t adjustedAirPressureWest = normalizedNowPressure*((baseTemperature+STP_Temperature)/(gasTemperatureWest+gastemp+STP_Temperature));
244 deltap = adjustedAirPressureWest - standardPressure;
245 LOG_INFO <<
"d_TempWest = " << gastemp <<
" adjustedAirPressureWest = " << adjustedAirPressureWest <<
" deltap West = " << deltap << endm;
248 Float_t adjustedAirPressureEast = normalizedNowPressure*((baseTemperature+STP_Temperature)/(gasTemperatureEast+gastemp+STP_Temperature));
249 deltap = adjustedAirPressureEast - standardPressure;
250 LOG_INFO <<
"d_TempEast = " << gastemp <<
" adjustedAirPressureEast = " << adjustedAirPressureEast <<
" deltap East = " << deltap << endm;
253 Bool_t laserRun = kTRUE;
254 dbReader->setLaserRun(laserRun);
257 tZero = dbReader->laserTZero();
258 LOG_INFO<<
"StFtpcCalibMaker::DoLaserCalib() - laserTZero = "<<tZero<<endm;
260 LOG_INFO<<
"StFtpcCalibMaker::DoLaserCalib() ..."<<endm;
265 LOG_INFO<<
"StFtpcCalibMaker::DoLaserCalib() - Reading Magnetic-Field maps..."<<endm;
274 trafo=
new StFtpcLaserTrafo(dbReader,paramReader,atof(t0),atof(gas),micropertime,deltap,mbfield,tZero);
275 if (trafo->calcpadtrans()) {
276 LOG_INFO<<
"StFtpcCalibMaker::DoLaserCalib - calcpadtrans done !"<<endm;
279 LOG_FATAL<<
"StFtpcCalibMaker::DoLaserCalib - fatal error in calcpadtrans !"<<endm;
285 StFtpcLaserCalib *l=
new StFtpcLaserCalib(ftpc,lsec,straight,gfit,minz,maxz,minrad,maxrad,atof(t0),atof(gas),gastemp,trafo,m_magf);
288 l->MakeOutput(filename,t0,gas,gastemp);
290 Int_t maxentries=l->btcluster->GetEntries();
292 LOG_INFO<<
"StFtpcCalibMaker::DoLaserCalib() - processing Cluster-on-Track-Tree with "<<maxentries<<
" clusters... please be patient"<<endm;
295 for (
int k=0;k<=maxentries;k++)
297 if (k%(maxentries/10)==0 && k>0) {
303 int hardsec = 6*(int)((l->tcluster.row-1)/2) + l->tcluster.sec;
313 if (l->tevent.nevent==neventold)
315 if (l->tcluster.ntracks==ntracksold)
317 l->fillarray(l->thit.x,l->thit.y,l->thit.z,l->thit.ex,l->thit.ey,i,hardsec,l->tcluster.padpos,l->tcluster.padpossigma,l->tcluster.sec,l->tcluster.row,l->tcluster.timepos,l->tcluster.padlength,l->tcluster.timelength,l->tcluster.peakheight,l->tcluster.charge);
322 if (l->laser_straight(l->radius,i)==l->STRAIGHT || l->STRAIGHT==3)
323 if (l->laser_fit(i)==0) {}
326 l->fillarray(l->thit.x,l->thit.y,l->thit.z,l->thit.ex,l->thit.ey,i,hardsec,l->tcluster.padpos,l->tcluster.padpossigma,l->tcluster.sec,l->tcluster.row,l->tcluster.timepos,l->tcluster.padlength,l->tcluster.timelength,l->tcluster.peakheight,l->tcluster.charge);
332 if (l->laser_straight(l->radius,i)==l->STRAIGHT || l->STRAIGHT==3)
333 if (l->laser_fit(i)==0) {}
336 l->fillarray(l->thit.x,l->thit.y,l->thit.z,l->thit.ex,l->thit.ey,i,hardsec,l->tcluster.padpos,l->tcluster.padpossigma,l->tcluster.sec,l->tcluster.row,l->tcluster.timepos,l->tcluster.padlength,l->tcluster.timelength,l->tcluster.peakheight,l->tcluster.charge);
340 neventold=l->tevent.nevent;
341 ntracksold=l->tcluster.ntracks;
344 if (l->laser_straight(l->radius,i)==l->STRAIGHT || l->STRAIGHT==3)
345 if (l->laser_fit(i)==0) {}
360 LOG_INFO<<
"Laser calibration done :-) !"<<endm;
376 Bool_t laserRun = kFALSE;
377 dbReader->setLaserRun(laserRun);
379 tZero = dbReader->tZero();
380 LOG_INFO<<
"StFtpcCalibMaker::DoT0Calib entered with filename "<<filename<<
" t0 "<<t0<<
" gas "<<gas<<
" mbfield "<<mbfield<<
" and tZero = "<<tZero<<endm;
388 LOG_INFO<<
"StFtpcCalibMaker::DoT0Calib deltap = deltapW = "<<deltap<<endm;
391 trafo =
new StFtpcLaserTrafo(dbReader,paramReader,atof(t0),atof(gas),micropertime,deltap,mbfield,tZero);
393 if (trafo->calcpadtrans()) {
394 LOG_INFO<<
"StFtpcCalibMaker::DoT0Calib - calcpadtrans (west) done !"<<endm;
397 LOG_FATAL<<
"StFtpcCalibMaker::DoT0Calib - fatal error in calcpadtrans west !"<<endm;
405 LOG_INFO<<
"StFtpcCalibMaker::DoT0Calib deltap = deltapE = "<<deltap<<endm;
407 trafo2 =
new StFtpcLaserTrafo(dbReader,paramReader,atof(t0),atof(gas),micropertime,deltap,mbfield,tZero);
409 if (trafo2->calcpadtrans()) {
410 LOG_INFO<<
"StFtpcCalibMaker::DoT0Calib - calcpadtrans (east) done !"<<endm;
413 LOG_FATAL<<
"StFtpcCalibMaker::DoT0Calib - fatal error in calcpadtrans east !"<<endm;
421 LOG_INFO<<
"StFtpcCalibMaker::DoT0Calib() ..."<<endm;
429 Int_t maxentries=(int) l->bcluster->GetEntries();
432 LOG_INFO<<
"StFtpcCalibMaker::DoT0Calib() - processing Cluster-Tree with "<<maxentries<<
" clusters... please be patient"<<endm;
437 for (
int k=0;k<=maxentries;k++) {
439 if (k%(maxentries/10)==0 && k>0) {
443 l->GetClusterTreeEntry(k);
447 if (l->cluster.sec<31)
448 trafo->padtrans(l->cluster.row,l->cluster.sec,l->cluster.timepos,l->cluster.padpos,&x,&y);
450 trafo2->padtrans(l->cluster.row,l->cluster.sec,l->cluster.timepos,l->cluster.padpos,&x,&y);
459 if (l->cluster.sec<31) {
462 htimew->Fill(l->cluster.timepos);
467 htimee->Fill(l->cluster.timepos);
476 delete trafo;
delete trafo2;
486 LOG_INFO<<
"T0 calibration done :-) !"<<endm;
501 TString outname=fname;
506 outname +=
"_t0.root";
511 LOG_INFO<<
"StFtpcCalibMaker::HistInit - Store histograms in ROOT-file : "<<outname<<endm;
513 anaf=
new TFile(outname,
"RECREATE");
515 hradeall=
new TH1F(
"rad_east_all",
"radius FTPC East",nradbins*31,0.5,31.5);
516 hradwall=
new TH1F(
"rad_west_all",
"radius FTPC West",nradbins*31,0.5,31.5);
518 hrade=
new TH1F(
"rad_east",
"radius FTPC East",nradbins*7,5,12);
519 hradw=
new TH1F(
"rad_west",
"radius FTPC West",nradbins*7,5,12);
521 htimee=
new TH1F(
"time_east",
"Timepos. FTPC East",45,140,185);
522 htimew=
new TH1F(
"time_west",
"Timepos. FTPC West",45,140,185);
537 TString outname=psname;
545 LOG_INFO<<
"StFtpcCalibMaker::MakeT0Ps - make ps file "<<outname<<endm;
548 TCanvas *c1 =
new TCanvas(
"c1",
"ps",200,10,700,500);
550 TPostScript *fps=
new TPostScript(outname,112);
556 TLine *inner=
new TLine();
559 hradwall->Draw();inner=
new TLine(7.8,0,7.8,hradwall->GetMaximum());inner->SetLineColor(2);inner->Draw();
561 hradeall->Draw();inner=
new TLine(7.8,0,7.8,hradeall->GetMaximum());inner->SetLineColor(2);inner->Draw();
563 hradw->Draw();inner=
new TLine(7.8,0,7.8,hradw->GetMaximum());inner->SetLineColor(2);inner->Draw();
565 hrade->Draw();inner=
new TLine(7.8,0,7.8,hrade->GetMaximum());inner->SetLineColor(2);inner->Draw();
575 hradw->Scale(1/hradw->Integral(0,nradbins*7));
576 hrade->Scale(1/hrade->Integral(0,nradbins*7));
578 hrade->Draw();hradw->SetLineColor(3);hradw->Draw(
"same");
579 inner=
new TLine(7.8,0,7.8,hrade->GetMaximum());inner->SetLineColor(2);inner->Draw();
582 htimee->Scale(1/htimee->GetEntries());htimew->Scale(1/htimew->GetEntries());
583 htimee->DrawCopy();htimew->SetLineColor(3);htimew->DrawCopy(
"same");
virtual Int_t DbInit(float mbfield)
The FTPC calibration maker.
void HistInit(int nradbins, TString fname, char *t0, char *gas)
void DoLaserCalib(TString filename, int ftpc, int lsec, int straight, int gfit, int minz, int maxz, int minrad, int maxrad, char *t0, char *gas, float gastemp, float mbfield)
void DoT0Calib(TString filename, char *t0, char *gas, float mbfield)
void MakeT0Ps(int nradbins, TString psname, char *t0, char *gas)