141 #include "StFtpcSlowSimMaker.h"
142 #include "StFtpcSlowSimulator.hh"
143 #include "StFtpcRawWriter.hh"
146 #include "StDAQMaker/StFTPCReader.h"
147 #include "PhysicalConstants.h"
149 #include "StFtpcClusterMaker/StFtpcParamReader.hh"
150 #include "StFtpcClusterMaker/StFtpcDbReader.hh"
151 #include "StFtpcClusterMaker/StFtpcGeantReader.hh"
152 #include "StFtpcClusterMaker/StFtpcGasUtilities.hh"
155 #include "StFtpcTrackMaker/StFtpcTrackingParams.hh"
157 #include "StDetectorDbMaker/StDetectorDbFTPCGas.h"
158 #include "St_db_Maker/St_db_Maker.h"
160 #include "StMessMgr.h"
161 #include "St_DataSetIter.h"
165 #include "tables/St_g2t_track_Table.h"
166 #include "tables/St_g2t_ftp_hit_Table.h"
167 #include "tables/St_fcl_ftpcndx_Table.h"
168 #include "tables/St_fcl_ftpcsqndx_Table.h"
169 #include "tables/St_fcl_ftpcadc_Table.h"
171 #include "StDetectorDbMaker/StDetectorDbClock.h"
199 StFtpcSlowSimMaker::~StFtpcSlowSimMaker(){
202 Int_t StFtpcSlowSimMaker::InitRun(
int runnumber){
203 Float_t x[3] = {0,0,0};
205 StarMagField::Instance()->BField(x,b);
206 Double_t gFactor = b[2]/4.980;
209 Int_t dbDate = mDbMaker->GetDateTime().GetDate();
210 LOG_INFO<<
"dbDate = "<<dbDate<<endm;
212 LOG_INFO <<
"StFtpcSlowSimMaker::InitRun("<<runnumber<<
") - 'flavor' FTPC drift maps for gFactor = "<<gFactor<<endm;
217 if ( gFactor > 0.8 ) {
218 SetFlavor(
"ffp10kv",
"ftpcVDrift");
219 SetFlavor(
"ffp10kv",
"ftpcdVDriftdP");
220 SetFlavor(
"ffp10kv",
"ftpcDeflection");
221 SetFlavor(
"ffp10kv",
"ftpcdDeflectiondP");
222 LOG_INFO <<
"StFtpcSlowSimMaker::InitRun: flavor set to ffp10kv"<<endm;
224 else if ( gFactor > 0.2 ) {
225 SetFlavor(
"hfp10kv",
"ftpcVDrift");
226 SetFlavor(
"hfp10kv",
"ftpcdVDriftdP");
227 SetFlavor(
"hfp10kv",
"ftpcDeflection");
228 SetFlavor(
"hfp10kv",
"ftpcdDeflectiondP");
229 LOG_INFO <<
"StFtpcSlowSimMaker::InitRun: flavor set to hfp10kv"<<endm;
231 else if ( gFactor > -0.2 ) {
232 SetFlavor(
"zf10kv",
"ftpcVDrift");
233 SetFlavor(
"zf10kv",
"ftpcdVDriftdP");
234 SetFlavor(
"zf10kv",
"ftpcDeflection");
235 SetFlavor(
"zf10kv",
"ftpcdDeflectiondP");
236 LOG_INFO <<
"StFtpcSlowSimMaker::InitRun: flavor set to zf10kv"<<endm;
238 else if ( gFactor > -0.8 ) {
239 SetFlavor(
"hfn10kv",
"ftpcVDrift");
240 SetFlavor(
"hfn10kv",
"ftpcdVDriftdP");
241 SetFlavor(
"hfn10kv",
"ftpcDeflection");
242 SetFlavor(
"hfn10kv",
"ftpcdDeflectiondP");
243 LOG_INFO <<
"StFtpcSlowSimMaker::InitRun: flavor set to hfn10kv"<<endm;
246 SetFlavor(
"ffn10kv",
"ftpcVDrift");
247 SetFlavor(
"ffn10kv",
"ftpcdVDriftdP");
248 SetFlavor(
"ffn10kv",
"ftpcDeflection");
249 SetFlavor(
"ffn10kv",
"ftpcdDeflectiondP");
250 LOG_INFO <<
"StFtpcSlowSimMaker::InitRun: flavor set to ffn10kv"<<endm;
257 double freq = dbclock->getCurrentFrequency()/1000000.0;
263 St_DataSet *ftpc_geometry_db = GetDataBase(
"Geometry/ftpc");
264 if ( !ftpc_geometry_db ){
265 LOG_WARN <<
"StFtpcSlowSimMaker::Error Getting FTPC database: Geometry"<<endm;
270 m_dimensions = (St_ftpcDimensions *)dblocal_geometry(
"ftpcDimensions");
271 m_asicmap = (St_ftpcAsicMap *)dblocal_geometry(
"ftpcAsicMap");
273 m_cathode = (St_ftpcInnerCathode *)dblocal_geometry(
"ftpcInnerCathode");
275 St_DataSet *ftpc_calibrations_db = GetDataBase(
"Calibrations/ftpc");
276 if ( !ftpc_calibrations_db ){
277 LOG_WARN <<
"StFtpcSlowSimMaker::Error Getting FTPC database: Calibrations"<<endm;
283 m_efield = (St_ftpcEField *)dblocal_calibrations(
"ftpcEField" );
284 m_vdrift = (St_ftpcVDrift *)dblocal_calibrations(
"ftpcVDrift" );
285 m_deflection = (St_ftpcDeflection *)dblocal_calibrations(
"ftpcDeflection" );
286 m_dvdriftdp = (St_ftpcdVDriftdP *)dblocal_calibrations(
"ftpcdVDriftdP" );
287 m_ddeflectiondp = (St_ftpcdDeflectiondP *)dblocal_calibrations(
"ftpcdDeflectiondP" );
288 m_gas = (St_ftpcGas *)dblocal_calibrations(
"ftpcGas");
289 m_driftfield = (St_ftpcDriftField *)dblocal_calibrations(
"ftpcDriftField");
290 m_electronics = (St_ftpcElectronics *)dblocal_calibrations(
"ftpcElectronics");
291 m_temps = (St_ftpcTemps *)dblocal_calibrations(
"ftpcTemps");
294 m_ampslope = (St_ftpcAmpSlope *)dblocal_calibrations(
"ftpcAmpSlope" );
295 m_ampoffset = (St_ftpcAmpOffset *)dblocal_calibrations(
"ftpcAmpOffset");
297 m_timeoffset = (St_ftpcTimeOffset *)dblocal_calibrations(
"ftpcTimeOffset");
301 TDataSet *ftpcParsDb = GetInputDB(
"ftpc");
306 StFtpcTrackingParams::Instance(Debug(),
307 (St_ftpcTrackingPars *)ftpcPars(
"ftpcTrackingPars"),
308 (St_ftpcdEdxPars *)ftpcPars(
"ftpcdEdxPars"),
309 (St_ftpcDimensions *)dblocal_geometry(
"ftpcDimensions"),
310 (St_ftpcPadrowZ *)dblocal_geometry(
"ftpcPadrowZ"));
312 StFtpcTrackingParams::Instance(kTRUE,
313 (St_ftpcCoordTrans *)dblocal_calibrations(
"ftpcCoordTrans"));
317 LOG_WARN <<
"StFtpcSlowSimMaker::Error Getting local FTPC database: Calibrations"<<endm;
325 m_clusterpars = (St_ftpcClusterPars *)local(
"ftpcClusterPars");
326 m_slowsimgas = (St_ftpcSlowSimGas *)local(
"ftpcSlowSimGas");
327 m_slowsimpars = (St_ftpcSlowSimPars *)local(
"ftpcSlowSimPars");
332 Int_t StFtpcSlowSimMaker::Init(){
336 m_nadc =
new TH1F(
"fss_total_adc",
"Total number of adcs in both FTPCs",1000,0.,2000000.);
337 m_nsqndx =
new TH1F(
"fss_sqndx",
"FTPC raw data sequence index",100,0.,100000.);
338 m_nadc_index1 =
new TH2F(
"fss_nadc_index1",
"Total number of adcs vs. number of adcs in FTPC East",100,0.,2000000.,100,0.,1000000.);
340 return StMaker::Init();
344 LOG_INFO <<
"Event number "<<(int) GetEventNumber()<<endm;
347 St_g2t_vertex *g2t_vertex = (St_g2t_vertex *) geant(
"g2t_vertex");
348 St_g2t_track *g2t_track = (St_g2t_track *) geant(
"g2t_track");
349 St_g2t_ftp_hit *g2t_ftp_hit = (St_g2t_ftp_hit *) geant(
"g2t_ftp_hit");
350 if (g2t_vertex && g2t_track && g2t_ftp_hit){
353 St_fcl_ftpcndx *fcl_ftpcndx =
new St_fcl_ftpcndx(
"fcl_ftpcndx",2);
354 local.Add(fcl_ftpcndx);
355 St_fcl_ftpcsqndx *fcl_ftpcsqndx =
new St_fcl_ftpcsqndx(
"fcl_ftpcsqndx",500000);
356 local.Add(fcl_ftpcsqndx);
357 St_fcl_ftpcadc *fcl_ftpcadc =
new St_fcl_ftpcadc(
"fcl_ftpcadc",2000000);
358 local.Add(fcl_ftpcadc);
360 if (Debug()) {LOG_DEBUG <<
"create data reader" << endm;}
366 if (Debug()) {LOG_DEBUG <<
"create FTPC database reader" << endm;}
383 if ( dbReader->returnCode != 0 ) {
384 LOG_WARN <<
"StFtpcSlowSimMaker::Error Constructing StFtpcDbReader "<<endm;
388 if (Debug()) { LOG_DEBUG <<
"create parameter reader" << endm;}
397 if ( paramReader->gasTemperatureWest() == 0 && paramReader->gasTemperatureEast() == 0) {
398 LOG_INFO <<
"Using the following values from database:" << endm;
401 LOG_INFO<<
" microsecondsPerTimebin = "<<dbReader->microsecondsPerTimebin()<<
" (calculated from RHIC Clock Frequency)"<<endm;
403 LOG_INFO<<
" microsecondsPerTimebin = "<<dbReader->microsecondsPerTimebin()<<
" (default value from database)"<<endm;
405 LOG_INFO <<
" EastIsInverted = "<<dbReader->EastIsInverted()<<endm;
406 LOG_INFO <<
" Asic2EastNotInverted = "<<dbReader->Asic2EastNotInverted()<<endm;
407 LOG_INFO <<
" tzero = "<<dbReader->tZero()<<endm;
408 LOG_INFO <<
" temperatureDifference = "<<dbReader->temperatureDifference()<<endm;
409 LOG_INFO <<
" defaultTemperatureWest = "<<dbReader->defaultTemperatureWest()<<endm;
410 LOG_INFO <<
" defaultTemperatureEast = "<<dbReader->defaultTemperatureEast()<<endm;
411 LOG_INFO <<
" magboltzVDrift(0,0) = "<<dbReader->magboltzVDrift(0,0)<<endm;
412 LOG_INFO <<
" magboltzDeflection(0,0) = "<<dbReader->magboltzDeflection(0,0)<<endm;
414 LOG_INFO <<
" offsetCathodeWest = " << dbReader->offsetCathodeWest() << endm;
415 LOG_INFO <<
" angleOffsetWest = " << dbReader->angleOffsetWest() << endm;
416 LOG_INFO <<
" offsetCathodeEast = " << dbReader->offsetCathodeEast() << endm;
417 LOG_INFO <<
" angleOffsetEast = " << dbReader->angleOffsetEast() << endm;
419 LOG_DEBUG<<
" Using microsecondsPerTimebin = "<<dbReader->microsecondsPerTimebin()<<
" for this event"<<endm;
427 daqDataset=GetDataSet(
"StDAQReader");
430 LOG_INFO <<
"Using StDAQReader to get StFTPCReader in StFtpcSlowSimMaker for embedding" << endm;
434 ftpcReader=daqReader->getFTPCReader();
436 if (!ftpcReader || !ftpcReader->checkForData()) {
437 LOG_WARN <<
"No FTPC data available!" << endm;
447 LOG_WARN <<
"StFtpcSlowSimMaker::Error Getting FTPC Online database: Conditions"<<endm;
464 returnCode = gasUtils->barometricPressure();
468 Int_t dbDate = mDbMaker->GetDateTime().GetDate();
472 returnCode = gasUtils->averageTemperatureWest(dbDate,
GetRunNumber());
475 if (paramReader->gasTemperatureWest() == 0) {
481 LOG_INFO <<
"daqReader->SVTPresent() = " << daqReader->SVTPresent()<<endm;
482 returnCode = gasUtils->defaultTemperatureWest(dbDate,daqReader->SVTPresent());
487 returnCode = gasUtils->averageTemperatureEast(dbDate,
GetRunNumber());
490 if (paramReader->gasTemperatureEast() == 0 ) {
496 LOG_INFO <<
"daqReader->SVTPresent() = " << daqReader->SVTPresent()<<endm;
497 returnCode = gasUtils->defaultTemperatureEast(dbDate,daqReader->SVTPresent());
500 LOG_INFO <<
" Using normalizedNowPressure = "<<paramReader->normalizedNowPressure()<<
" gasTemperatureWest = "<<paramReader->gasTemperatureWest()<<
" gasTemperatureEast = "<<paramReader->gasTemperatureEast()<<endm;
501 paramReader->setAdjustedAirPressureWest(paramReader->normalizedNowPressure()*((dbReader->baseTemperature()+STP_Temperature)/(paramReader->gasTemperatureWest()+STP_Temperature)));
502 LOG_INFO <<
" paramReader->setAdjustedAirPressureWest = "<<paramReader->adjustedAirPressureWest()<<endm;
503 paramReader->setAdjustedAirPressureEast(paramReader->normalizedNowPressure()*((dbReader->baseTemperature()+STP_Temperature)/(paramReader->gasTemperatureEast()+STP_Temperature)));
504 LOG_INFO <<
" paramReader->setAdjustedAirPressureEast = "<<paramReader->adjustedAirPressureEast()<<endm;
510 if (Debug()) {LOG_DEBUG <<
" create data writer"<<endm;}
516 dbReader->Asic2EastNotInverted());
519 if (Debug()) {LOG_DEBUG <<
"Create SlowSimulator"<<endm;}
527 LOG_INFO <<
"FTPC SlowSimulator starting... " <<endm;
528 Int_t Res_fss = slowsim->simulate();
537 if(Debug()) {LOG_INFO <<
"finished fss" << endm;}
542 LOG_INFO <<
"FTPC SlowSimulator done... " <<endm;
546 void StFtpcSlowSimMaker::MakeHistograms() {
548 if(Debug()) {LOG_INFO <<
"*** NOW MAKING HISTOGRAMS FOR FtpcSlowSim ***" << endm;}
554 St_fcl_ftpcadc *adc = 0;
555 St_fcl_ftpcndx *ndx = 0;
556 St_fcl_ftpcsqndx *sqndx = 0;
557 adc = (St_fcl_ftpcadc *) ftpc_raw.Find(
"fcl_ftpcadc");
558 ndx = (St_fcl_ftpcndx *) ftpc_raw.Find(
"fcl_ftpcndx");
559 sqndx = (St_fcl_ftpcsqndx *) ftpc_raw.Find(
"fcl_ftpcsqndx");
562 Float_t nadc = adc->GetNRows();
563 LOG_INFO <<
"total # adcs = " << adc->GetNRows() <<
", nadc = " << nadc << endm;
567 fcl_ftpcndx_st *r = ndx->GetTable();
568 Float_t index1 = ++r->index;
575 fcl_ftpcsqndx_st *r = sqndx->GetTable();
576 for (Int_t i=0; i<sqndx->GetNRows();i++,r++) {
virtual TDataSet * Cd(const Char_t *dirname)
TH2F * m_nadc_index1
FTPC raw data sequence index.
TH1F * m_nsqndx
FTPC raw data adc output.
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
virtual Int_t GetRunNumber() const
Returns the current RunNumber.
Float_t microsecondsPerTimebin
FTPC # of total adcs vs. # in FTPC East.