26 #include "StFtpcMixerMaker.h"
29 #include "StMessMgr.h"
32 #include "St_DataSetIter.h"
33 #include "St_ObjectSet.h"
36 #include "StFtpcClusterMaker/StFtpcDbReader.hh"
40 #include "StSequence.hh"
42 #include "StDAQMaker/StDAQReader.h"
45 #include "StFtpcSequencer.hh"
50 #include "tables/St_fcl_ftpcsqndx_Table.h"
51 #include "tables/St_fcl_ftpcadc_Table.h"
63 LOG_INFO <<
"StFtpcMixerMaker constructed" <<endm;
78 St_DataSet *ftpc_geometry_db = GetDataBase(
"Geometry/ftpc");
79 if ( !ftpc_geometry_db ){
80 LOG_WARN <<
"StFtpcMixerMaker::Error Getting FTPC database: Geometry"<<endm;
85 m_dimensions = (St_ftpcDimensions *)dblocal_geometry(
"ftpcDimensions");
86 m_padrow_z = (St_ftpcPadrowZ *)dblocal_geometry(
"ftpcPadrowZ");
87 m_asicmap = (St_ftpcAsicMap *)dblocal_geometry(
"ftpcAsicMap");
90 St_DataSet *ftpc_calibrations_db = GetDataBase(
"Calibrations/ftpc");
91 if ( !ftpc_calibrations_db ){
92 LOG_WARN <<
"StFtpcMixerMaker::Error Getting FTPC database: Calibrations"<<endm;
97 m_efield = (St_ftpcEField *)dblocal_calibrations(
"ftpcEField" );
98 m_vdrift = (St_ftpcVDrift *)dblocal_calibrations(
"ftpcVDrift" );
99 m_deflection = (St_ftpcDeflection *)dblocal_calibrations(
"ftpcDeflection" );
100 m_dvdriftdp = (St_ftpcdVDriftdP *)dblocal_calibrations(
"ftpcdVDriftdP" );
101 m_ddeflectiondp = (St_ftpcdDeflectiondP *)dblocal_calibrations(
"ftpcdDeflectiondP" );
102 m_ampslope = (St_ftpcAmpSlope *)dblocal_calibrations(
"ftpcAmpSlope" );
103 m_ampoffset = (St_ftpcAmpOffset *)dblocal_calibrations(
"ftpcAmpOffset");
104 m_timeoffset = (St_ftpcTimeOffset *)dblocal_calibrations(
"ftpcTimeOffset");
105 m_driftfield = (St_ftpcDriftField *)dblocal_calibrations(
"ftpcDriftField");
106 m_gas = (St_ftpcGas *)dblocal_calibrations(
"ftpcGas");
107 m_electronics = (St_ftpcElectronics *)dblocal_calibrations(
"ftpcElectronics");
123 Int_t reader1Created = 0;
124 Int_t reader2Created = 0;
126 LOG_INFO <<
"StFtpcMixerMaker starting..." <<endm;
135 if(!strcmp(getConfig1(),
"daq")) {
137 LOG_INFO <<
"StFtpcMixerMaker: Getting dataset 1 (DAQ)" << endm;
139 dataset1=GetDataSet(
"Input1");
141 LOG_WARN <<
"StFtpcMixerMaker: Missing Data! Bailing out..." <<endm;
146 LOG_WARN <<
"StFtpcMixerMaker: Missing Data! Bailing out..." <<endm;
149 ftpcr1=daqr1->getFTPCReader();
151 LOG_WARN <<
"StFtpcMixerMaker: Missing Data! Bailing out..." <<endm;
155 if (!ftpcr1->checkForData()) {
156 LOG_WARN <<
"No FTPC DAQ data available!" << endm;
160 LOG_INFO <<
"FTPC DAQ Dataset found!" <<endm;
166 LOG_INFO <<
"StFtpcMixerMaker: Getting dataset 1 (SlowSimulator)" << endm;
168 dataset1=GetDataSet(
"Input1");
170 LOG_WARN <<
"StFtpcMixerMaker: Missing Data! Bailing out..." <<endm;
175 LOG_INFO <<
"FTPC SlowSimulator Dataset found!"<<endm;
179 St_fcl_ftpcsqndx *fcl_ftpcsqndx = (St_fcl_ftpcsqndx*)
get(
"fcl_ftpcsqndx");
180 St_fcl_ftpcadc *fcl_ftpcadc = (St_fcl_ftpcadc* )
get(
"fcl_ftpcadc");
182 if (fcl_ftpcsqndx&&fcl_ftpcadc) {
184 ftpcr1=
new StFTPCReader((
short unsigned int *) fcl_ftpcsqndx->GetTable(),
185 fcl_ftpcsqndx->GetNRows(),
186 (
char *) fcl_ftpcadc->GetTable(),
187 fcl_ftpcadc->GetNRows());
190 LOG_INFO <<
"created StFTPCReader from tables" << endm;
194 LOG_INFO <<
"StFtpcMixerMaker: Tables are not found:"
195 <<
" fcl_ftpcsqndx = " << fcl_ftpcsqndx
196 <<
" fcl_ftpcadc = " << fcl_ftpcadc << endm;
197 LOG_WARN <<
"StFtpcMixerMaker exiting... "<<endm;
202 LOG_WARN <<
"Error getting FTPC SlowSimulator Dataset!" << endm;
207 if(!strcmp(getConfig2(),
"daq")) {
209 LOG_INFO <<
"StFtpcMixerMaker: Getting dataset 2 (DAQ)" << endm;
211 dataset2=GetDataSet(
"Input2");
213 LOG_WARN <<
"StFtpcMixerMaker: Missing Data! Bailing out..." <<endm;
218 LOG_WARN <<
"StFtpcMixerMaker: Missing Data! Bailing out..." <<endm;
221 ftpcr2=daqr2->getFTPCReader();
223 LOG_WARN <<
"StFtpcMixerMaker: Missing Data! Bailing out..." <<endm;
227 if (!ftpcr2->checkForData()) {
228 LOG_WARN <<
"No FTPC DAQ data available!" << endm;
232 LOG_INFO <<
"FTPC DAQ Dataset found!" <<endm;
237 LOG_INFO <<
"StFtpcMixerMaker: Getting dataset 2 (SlowSimulator)" << endm;
239 dataset2=GetDataSet(
"Input2");
241 LOG_WARN <<
"StFtpcMixerMaker: Missing Data! Bailing out..." <<endm;
246 LOG_INFO <<
"FTPC SlowSimulator Dataset found!" << endm;
250 St_fcl_ftpcsqndx *fcl_ftpcsqndx = (St_fcl_ftpcsqndx*)
get(
"fcl_ftpcsqndx");
251 St_fcl_ftpcadc *fcl_ftpcadc = (St_fcl_ftpcadc* )
get(
"fcl_ftpcadc");
255 if (fcl_ftpcsqndx&&fcl_ftpcadc) {
257 ftpcr2=
new StFTPCReader((
short unsigned int *) fcl_ftpcsqndx->GetTable(),
258 fcl_ftpcsqndx->GetNRows(),
259 (
char *) fcl_ftpcadc->GetTable(),
260 fcl_ftpcadc->GetNRows());
263 LOG_INFO <<
"created StFTPCReader from tables" << endm;
267 LOG_INFO <<
"StFtpcMixerMaker: Tables are not found:"
268 <<
" fcl_ftpcsqndx = " << fcl_ftpcsqndx
269 <<
" fcl_ftpcadc = " << fcl_ftpcadc << endm;
270 LOG_WARN <<
"StFtpcMixerMaker exiting... " << endm;
275 LOG_WARN <<
"Error getting FTPC SlowSimulator Dataset!" << endm;
285 int *iADC =
new int[dbReader->numberOfPadrows()
286 *dbReader->numberOfSectors()
287 *dbReader->numberOfPads()
288 *dbReader->numberOfTimebins()];
290 for (Int_t i = 0; i < dbReader->numberOfPadrows() *dbReader->numberOfSectors() *dbReader->numberOfPads() *dbReader->numberOfTimebins(); i++)
294 int iRow, iSec, iPad, iHardSec, iHardRow;
295 int firstPadrowToSearch = dbReader->firstPadrowToSearch() - 1;
301 for (iRow = firstPadrowToSearch; iRow < dbReader->numberOfPadrows(); iRow++)
303 for (iSec = dbReader->firstSectorToSearch()-1; iSec < dbReader->lastSectorToSearch(); iSec++)
306 iHardSec = dbReader->numberOfSectors() * (int)(iRow/2) + iSec + 1;
307 iHardRow = iRow%2 + 1;
310 unsigned char *(padlist[2]);
311 int iOccPads = ftpcr1->getPadList(iHardSec, iHardRow, padlist[iHardRow-1]);
313 int numberOfSequences;
316 for (
int iPadCounter = 0; iPadCounter < iOccPads; iPadCounter++)
318 iPad = padlist[iHardRow-1][iPadCounter];
320 ftpcr1->getSequences(iHardSec, iHardRow, iPad, &numberOfSequences, CurrentSequence);
324 for (
int iSeqCounter = 0; iSeqCounter < numberOfSequences; iSeqCounter++)
326 for (
int iEntry = 0; iEntry < CurrentSequence[iSeqCounter].Length; iEntry++)
328 iADC[iRow*dbReader->numberOfSectors() *dbReader->numberOfPads() *dbReader->numberOfTimebins()
329 + iSec*dbReader->numberOfPads() *dbReader->numberOfTimebins()
330 + iPad * dbReader->numberOfTimebins() + CurrentSequence[iSeqCounter].startTimeBin + iEntry]
331 += (int)CurrentSequence[iSeqCounter].FirstAdc[iEntry];
336 iOccPads = ftpcr2->getPadList(iHardSec, iHardRow, padlist[iHardRow-1]);
338 for (
int iPadCounter = 0; iPadCounter < iOccPads; iPadCounter++)
340 iPad = padlist[iHardRow-1][iPadCounter];
342 ftpcr2->getSequences(iHardSec, iHardRow, iPad, &numberOfSequences, CurrentSequence);
346 for (
int iSeqCounter = 0; iSeqCounter < numberOfSequences; iSeqCounter++)
348 for (
int iEntry = 0; iEntry < CurrentSequence[iSeqCounter].Length; iEntry++)
350 iADC[iRow*dbReader->numberOfSectors() *dbReader->numberOfPads() *dbReader->numberOfTimebins()
351 + iSec*dbReader->numberOfPads() *dbReader->numberOfTimebins()
352 + iPad * dbReader->numberOfTimebins() + CurrentSequence[iSeqCounter].startTimeBin + iEntry]
353 += (int)CurrentSequence[iSeqCounter].FirstAdc[iEntry];
366 LOG_INFO <<
"FTPC Embedding done... "<< endm;
370 St_fcl_ftpcndx *fcl_ftpcndx_out =
new St_fcl_ftpcndx(
"fcl_ftpcndx", 2);
371 local.Add(fcl_ftpcndx_out);
372 St_fcl_ftpcsqndx *fcl_ftpcsqndx_out =
new St_fcl_ftpcsqndx(
"fcl_ftpcsqndx", 500000);
373 local.Add(fcl_ftpcsqndx_out);
374 St_fcl_ftpcadc *fcl_ftpcadc_out =
new St_fcl_ftpcadc(
"fcl_ftpcadc", 2000000);
375 local.Add(fcl_ftpcadc_out);
377 LOG_INFO <<
"Output sequences created..." << endm;
382 ftpcSequencer->
writeArray(iADC, dbReader->numberOfPadrows(), dbReader->numberOfSectors(), dbReader->numberOfPads(), dbReader->numberOfTimebins());
385 delete ftpcSequencer;
387 if (reader1Created)
delete ftpcr1;
388 if (reader2Created)
delete ftpcr2;
391 LOG_INFO <<
"FtpcMixerMaker done..." << endm;
Int_t InitRun(int)
InitRun method, reads in the database (FTPC geometry and calibration)
~StFtpcMixerMaker()
Destructor.
int writeArray(const int *cArray, const int numberPadrows, const int numberSectors, const int numberPads, const int numberTimebins)
writeArray method, fills zero-suppressed sequences from ADC array
Int_t Make()
Make method, does all the work.
virtual void Clear(Option_t *option="")
User defined functions.
FTPC Sequencer, creates Simulator sequences from ADC values.
FTPC Mixer Maker, main part of FTPC embedding Framework.
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
void Clear(Option_t *option="")
Clear method.
Int_t Finish()
Finish method.