81 #include "St_db_Maker/St_db_Maker.h"
82 #include "StFtpcDriftMapMaker.h"
83 #include "StFtpcMagboltz1.hh"
84 #include "StFtpcClusterMaker/StFtpcDbReader.hh"
86 #include "StMessMgr.h"
87 #include "St_DataSetIter.h"
97 StFtpcDriftMapMaker::StFtpcDriftMapMaker(
const StarMagField::EBField map,
const Float_t factor,
const Float_t deltaAr):
110 mDbMaker->SetDateTime(20330101,0);
114 St_DataSet *ftpc_geometry_db = GetDataBase(
"Geometry/ftpc");
115 if ( !ftpc_geometry_db ){
116 *gMessMgr<<
"Could not locate MySQLDb:Geometry/ftpc"<<endm;
121 m_dimensions = (St_ftpcDimensions *)dblocal_geometry(
"ftpcDimensions");
122 m_padrow_z = (St_ftpcPadrowZ *)dblocal_geometry(
"ftpcPadrowZ" );
124 St_DataSet *ftpc_calibrations_db = GetDataBase(
"Calibrations/ftpc");
125 if ( !ftpc_calibrations_db ){
126 *gMessMgr<<
"Could not locate MySQLDb:Calibrations/ftpc"<<endm;
131 m_gas = (St_ftpcGas *)dblocal_calibrations(
"ftpcGas");
135 m_driftfield = (St_ftpcDriftField *)dblocal_calibrations(
"ftpcDriftField");
136 m_efield = (St_ftpcEField *)dblocal_calibrations(
"ftpcEField" );
137 m_vdrift = (St_ftpcVDrift *)dblocal_calibrations(
"ftpcVDrift" );
138 m_deflection = (St_ftpcDeflection *)dblocal_calibrations(
"ftpcDeflection" );
139 m_dvdriftdp = (St_ftpcdVDriftdP *)dblocal_calibrations(
"ftpcdVDriftdP" );
140 m_ddeflectiondp = (St_ftpcdDeflectiondP *)dblocal_calibrations(
"ftpcdDeflectiondP" );
142 if (!m_efield || !m_vdrift || !m_deflection || !m_dvdriftdp || !m_ddeflectiondp
143 || !m_gas || !m_driftfield) {
144 cout<<
"MySQLDb:Calibrations/ftpc not complete"<<endl;
158 if (dbReader->returnCode != 0) {
159 cout<<
"Error constructing StFtpcDbReader"<<endl;
163 ftpcEField_st *ftpcEField = m_efield->GetTable();
164 ftpcVDrift_st *ftpcVDrift = m_vdrift->GetTable();
165 ftpcDeflection_st *ftpcDeflection = m_deflection->GetTable();
166 ftpcdVDriftdP_st *ftpcdVDriftdP = m_dvdriftdp->GetTable();
167 ftpcdDeflectiondP_st *ftpcdDeflectiondP = m_ddeflectiondp->GetTable();
168 for ( Int_t iBin=0; iBin<dbReader->maximumNumberOfMagboltzBins(); iBin++)
170 ftpcEField->e[iBin] = 0.0;
171 for(Int_t iPadrow=0; iPadrow<dbReader->numberOfPadrowsPerSide(); iPadrow++) {
172 ftpcVDrift->v[iPadrow + dbReader->numberOfPadrowsPerSide()*iBin] = 0.0;
173 ftpcDeflection->psi[iPadrow + dbReader->numberOfPadrowsPerSide()*iBin] = 0.0;
174 ftpcdVDriftdP->dv_dp[iPadrow + dbReader->numberOfPadrowsPerSide()*iBin] = 0.0;
175 ftpcdDeflectiondP->dpsi_dp[iPadrow + dbReader->numberOfPadrowsPerSide()*iBin] = 0.0;
179 for ( Int_t iBin=0; iBin<dbReader->numberOfMagboltzBins(); iBin++)
181 dbReader->setMagboltzEField(iBin,dbReader->minimumDriftField() + iBin*dbReader->stepSizeDriftField());
193 float thisField, thisRadius;
194 float posVector[3], bVector[3];
195 float bMag, bTheta, bRadial;
196 float vDrift, psiAngle, pressure;
197 float upPressure, upDrift, upAngle, pOff;
204 for(i=0; i < dbReader->numberOfMagboltzBins(); i++)
207 thisField = dbReader->minimumDriftField()
208 + i*dbReader->stepSizeDriftField();
209 thisRadius = dbReader->radiusTimesField() / thisField;
211 posVector[1]=thisRadius;
212 for(j=0; j < dbReader->numberOfPadrowsPerSide(); j++)
214 posVector[2]=dbReader->padrowZPosition(j);
217 magField->BField(posVector, bVector);
218 printf(
"pos %f %f %f field %f %f %f\n", posVector[0], posVector[1], posVector[2], bVector[0], bVector[1], bVector[2]);
219 bMag=::sqrt(bVector[0]*bVector[0] + bVector[1]*bVector[1] +
220 bVector[2]*bVector[2]);
221 bRadial=::sqrt(bVector[0]*bVector[0] + bVector[1]*bVector[1]);
222 bTheta=acos(bRadial/bMag)*90/acos(0.0);
224 bTheta = (factor/fabs(factor)) * bTheta;
226 upPressure=760.0+dbReader->pressureOffset();
227 pOff=dbReader->pressureOffset()*1.3332;
233 printf(
"loop %d of %d\n", i, dbReader->numberOfMagboltzBins());
234 printf(
"calling magboltz with field %f bMag %f bTheta %f pressure %f vDrift %f psiAngle %f\n", thisField, bMag, bTheta, pressure, vDrift, psiAngle);
235 cout<<
"dbReader->percentAr() = "<<dbReader->percentAr()<<
" deltaAr = "<<deltaAr<<endl;
236 float gas1=dbReader->percentAr() + deltaAr;
237 float gas2=dbReader->percentCO2() - deltaAr;;
238 float gas3=dbReader->percentNe();
239 float gas4=dbReader->percentHe();
240 float temperature=dbReader->baseTemperature();
241 cout<<
"calling magboltz with "<<gas1<<
"% Ar and "<<gas2<<
"% CO2"<<endl;
242 magboltz->magboltz_(&thisField, &bMag, &bTheta, &pressure, &gas1, &gas2, &gas3, &gas4, &temperature, &vDrift, &psiAngle, &eFinal);
243 printf(
"called magboltz got field %f bMag %f bTheta %f pressure %f vDrift %f psiAngle %f\n", thisField, bMag, bTheta, pressure, vDrift, psiAngle);
244 magboltz->magboltz_(&thisField, &bMag, &bTheta, &upPressure, &gas1, &gas2, &gas3, &gas4, &temperature, &upDrift, &upAngle, &eFinal);
245 printf(
"changing magboltz values from %f %f %f %f\n",dbReader->magboltzVDrift(i,j), dbReader->magboltzDeflection(i,j),dbReader->magboltzdVDriftdP(i,j),dbReader->magboltzdDeflectiondP(i,j));
246 dbReader->setMagboltzEField(i,thisField);
247 dbReader->setMagboltzVDrift(i,j,vDrift);
248 dbReader->setMagboltzDeflection(i,j,psiAngle);
249 dbReader->setMagboltzdVDriftdP(i,j,(upDrift-vDrift)/pOff);
250 dbReader->setMagboltzdDeflectiondP(i,j,(upAngle-psiAngle)/pOff);
251 printf(
" to %f %f %f %f\n",dbReader->magboltzVDrift(i,j), dbReader->magboltzDeflection(i,j),dbReader->magboltzdVDriftdP(i,j),dbReader->magboltzdDeflectiondP(i,j));
259 void* cstruct = m_deflection -> GetTable();
260 Int_t nrows = m_deflection -> GetNRows();
262 fTableName =
new char[20];
263 strcpy(fTableName,
"ftpcDeflection");
267 fOutputFileName =
new char[100];
268 strcpy(fOutputFileName,
"./ftpcDeflection.C");
269 ofstream ofs_Deflection(fOutputFileName);
270 table -> SavePrimitive(ofs_Deflection,0);
271 ofs_Deflection.close();
275 cstruct = m_vdrift -> GetTable();
276 nrows = m_vdrift -> GetNRows();
278 strcpy(fTableName,
"ftpcVDrift");
280 table =
TTable::New(fTableName,fTableName,cstruct,nrows);
282 strcpy(fOutputFileName,
"./ftpcVDrift.C");
283 ofstream ofs_VDrift(fOutputFileName);
284 table -> SavePrimitive(ofs_VDrift,0);
289 cstruct = m_ddeflectiondp -> GetTable();
290 nrows = m_ddeflectiondp -> GetNRows();
292 strcpy(fTableName,
"ftpcdDeflectiondP");
294 table =
TTable::New(fTableName,fTableName,cstruct,nrows);
296 strcpy(fOutputFileName,
"./ftpcdDeflectiondP.C");
297 ofstream ofs_dDeflectiondP(fOutputFileName);
298 table -> SavePrimitive(ofs_dDeflectiondP,0);
299 ofs_dDeflectiondP.close();
303 cstruct = m_dvdriftdp -> GetTable();
304 nrows = m_dvdriftdp -> GetNRows();
306 strcpy(fTableName,
"ftpcdVDriftdP");
308 table =
TTable::New(fTableName,fTableName,cstruct,nrows);
310 strcpy(fOutputFileName,
"./ftpcdVDriftdP.C");
311 ofstream ofs_dVDriftdP(fOutputFileName);
312 table -> SavePrimitive(ofs_dVDriftdP,0);
313 ofs_dVDriftdP.close();
319 cstruct = m_efield -> GetTable();
320 nrows = m_efield -> GetNRows();
322 fTableName =
new char[20];
323 strcpy(fTableName,
"ftpcEField");
325 table =
TTable::New(fTableName,fTableName,cstruct,nrows);
327 fOutputFileName =
new char[100];
328 strcpy(fOutputFileName,
"./ftpcEField.C");
329 ofstream ofs_ftpcEField(fOutputFileName);
330 table -> SavePrimitive(ofs_ftpcEField,0);
331 ofs_ftpcEField.close();
336 cstruct = m_driftfield -> GetTable();
337 nrows = m_driftfield -> GetNRows();
339 fTableName =
new char[20];
340 strcpy(fTableName,
"ftpcDriftField");
342 table =
TTable::New(fTableName,fTableName,cstruct,nrows);
344 fOutputFileName =
new char[100];
345 strcpy(fOutputFileName,
"./ftpcDriftField.C");
346 ofstream ofs_ftpcDriftField(fOutputFileName);
347 table -> SavePrimitive(ofs_ftpcDriftField,0);
348 ofs_ftpcDriftField.close();
354 cout <<
"finished StFtpcDriftMapMaker" << endl;
static TTable * New(const Char_t *name, const Char_t *type, void *array, UInt_t size)
This static method creates a new TTable object if provided.