36 #include "StTofMaker.h"
38 #include "StMessMgr.h"
39 #include "StEventTypes.h"
40 #include "StEvent/StTofData.h"
41 #include "StEvent/StTofRawData.h"
42 #include "StTofUtil/StTofGeometry.h"
43 #include "StTofUtil/StTofDataCollection.h"
44 #include "StTofUtil/StTofRawDataCollection.h"
45 #include "StDaqLib/GENERIC/EventReader.hh"
46 #include "StDaqLib/TOF/TOF_Reader.hh"
47 #include "StDAQMaker/StDAQReader.h"
48 #include "tables/St_TofTag_Table.h"
68 nAdcHitHisto =
new TH1S(
"tof_nadchit",
"Crude No. ADC Hits/Event",181,-0.5,180.5);
69 nTdcHitHisto =
new TH1S(
"tof_ntdchit",
"Crude No. TDC Hits/Event",185,-0.5,184.5);
70 return StMaker::Init();
76 LOG_INFO <<
"StTofMaker::InitRun -- initializing TofGeometry --" << endm;
86 LOG_INFO <<
"StTofMaker::FinishRun -- cleaning up TofGeometry --" << endm;
87 if (mTofGeom)
delete mTofGeom;
98 LOG_INFO <<
"StTofMaker::Make() -- All Your Base Are Belong To Us --" << endm;
100 mDataCollection = &myDataCollection;
101 mTofCollectionPresent = 0;
102 mDataCollectionPresent = 0;
106 mRawDataCollection = &myRawDataCollection;
107 mRawDataCollectionPresent = 0;
112 mEvent = (
StEvent *) GetInputDS(
"StEvent");
114 LOG_INFO <<
"StTofMaker Checking for Tof and TofData collections ..." << endm;
115 mTheTofCollection = mEvent->tofCollection();
116 if(mTheTofCollection) {
117 mTofCollectionPresent = 1;
118 LOG_INFO <<
" + tofCollection Exists" << endm;
120 if(mTheTofCollection->dataPresent()) {
121 LOG_INFO <<
" + tofDataCollection Exists" << endm;
122 mDataCollectionPresent = 1;
123 }
else if(mTheTofCollection->rawdataPresent()) {
124 mRawDataCollectionPresent = 1;
126 else LOG_INFO <<
" - tofDataCollection & tofRawDataCollection does not exist" << endm;
129 LOG_INFO <<
" - tofCollection does not exist" << endm;
130 LOG_INFO <<
" - tofDataCollection & tofRawDataCollection does not exist" << endm;
133 if (!mTheTofCollection){
134 LOG_INFO <<
"StTofMaker Creating tofCollection in StEvent ... ";
136 mEvent->setTofCollection(mTheTofCollection);
137 mTheTofCollection = mEvent->tofCollection();
138 if (mTheTofCollection) LOG_INFO <<
"OK"<< endm;
139 else LOG_INFO <<
"FAILED" << endm;
142 else LOG_INFO <<
"StTofMaker No StEvent structures detected ... not good!" << endm;
147 if(!mDataCollectionPresent) {
149 LOG_INFO <<
"StTofMaker Will get real data from TOFpDAQ Reader ... " << endm;
150 mTheTofData = GetDataSet(
"StDAQReader");
152 LOG_INFO <<
"StTofMaker No StDAQReader dataset. Event skipped" << endm;
156 if (!mTheDataReader) {
157 LOG_INFO <<
"StTofMaker No StDAQReader object. Event skipped" << endm;
160 if (!(mTheDataReader->TOFPresent())) {
161 LOG_INFO <<
"StTofMaker TOF is not in datastream. Event skipped" << endm;
165 mTheTofReader = mTheDataReader->getTOFReader();
166 if (!mTheTofReader) {
167 LOG_INFO <<
"StTofMaker Failed to getTofReader()...." << endm;
175 if (MyTest) MyTest->printRawData();
176 if (MyTest->year2Data()) LOG_INFO <<
"StTofMaker: year2 data - TOFp+pVPD" << endm;
177 if (MyTest->year3Data()) LOG_INFO <<
"StTofMaker: year3 data - TOFp+pVPD+TOFr" << endm;
178 if (MyTest->year4Data()) LOG_INFO <<
"StTofMaker: year4 data - TOFp+pVPD+TOFrprime" << endm;
179 if (MyTest->year5Data()) LOG_INFO <<
"StTofMaker: year5 data - TOFr5+pVPD " << endm;
185 if (mTheTofReader->year2Data()||mTheTofReader->year3Data()||mTheTofReader->year4Data()){
192 int pvpdStrobeMin=1500;
193 if (mTheTofReader->year3Data()||mTheTofReader->year4Data()){
198 for (
int i=0;i<48;i++){
199 unsigned short slatid = mTofGeom->daqToSlatId(i);
200 unsigned short rawAdc = mTheTofReader->GetAdcFromSlat(i);
201 unsigned short rawTdc = mTheTofReader->GetTdcFromSlat(i);
203 if (i<32) rawTc = mTheTofReader->GetTc(i);
204 unsigned short rawSc = 0;
205 if (i<12) rawSc = mTheTofReader->GetSc(i);
208 mDataCollection->push_back(rawTofData);
210 if (rawAdc> 50) nadchit++;
211 if (rawTdc<tdcHitMax) ntdchit++;
214 if (rawTdc>pvpdStrobeMin) iStrobe++;
217 if (mTheTofReader->year3Data()){
218 for (
int i=48;i<132;i++){
220 unsigned short id = (100-48)+i;
221 unsigned short rawAdc = mTheTofReader->GetAdc(i);
222 unsigned short rawTdc = 0;
223 if (i<120) rawTdc = mTheTofReader->GetTdc(i);
226 mDataCollection->push_back(rawTofData);
227 if ((i>59) && (rawAdc>50)) nadchit++;
228 if ((i<120) && (rawTdc<tdcHitMax)) ntdchit++;
232 if (mTheTofReader->year4Data()){
233 for (
int i=48;i<184;i++){
235 unsigned short id = (100-48)+i;
236 unsigned short rawAdc = 0;
238 rawAdc = mTheTofReader->GetAdc(i);
241 unsigned short rawTdc = 0;
242 rawTdc = mTheTofReader->GetTdc(i);
245 mDataCollection->push_back(rawTofData);
246 if ((i>59) && (rawAdc>50)) nadchit++;
247 if ((rawTdc<tdcHitMax)) ntdchit++;
255 LOG_INFO <<
"StTofMaker ... Strobe Event:" << iStrobe << endm;
258 nTdcHitHisto->Fill(-1.);
260 LOG_INFO <<
"StTofMaker ... Beam Event: ~" << nadchit <<
" ADC and ~"
261 << ntdchit <<
" TDC Raw Hits in TRAY" << endm;
264 nTdcHitHisto->Fill(ntdchit);
271 if (mTheTofReader->year5Data()){
272 for (
int i=0;i<(int)mTheTofReader->GetNLeadingHits();i++){
274 unsigned short chn=mTheTofReader->GetLeadingGlobalTdcChan(i);
275 unsigned int tdc=mTheTofReader->GetLeadingTdc(i);
277 unsigned short quality = 1;
279 mRawDataCollection->push_back(rawTofData1);
281 for (
int i=0;i<(int)mTheTofReader->GetNTrailingHits();i++){
283 unsigned short chn=mTheTofReader->GetTrailingGlobalTdcChan(i);
284 unsigned int tdc=mTheTofReader->GetTrailingTdc(i);
286 unsigned short quality = 1;
288 mRawDataCollection->push_back(rawTofData1);
290 for (
int i=0;i<TOF_MAX_TDC_CHANNELS;i++){
291 unsigned int rawLdTdc=mTheTofReader->GetLdTdc(i);
292 unsigned int rawTrTdc=mTheTofReader->GetTrTdc(i);
294 mDataCollection->push_back(rawTofData);
300 LOG_INFO <<
"StTofMaker No special action required for DataCollection"<<endm;
302 LOG_INFO <<
"WRONG SetMode (" <<
m_Mode <<
")! "
303 <<
"... should be either 0 (DAQ reader) or 1(no action, SIM)" << endm;
312 LOG_INFO <<
"StTofMaker tofTag = " << tofTag << endm;
313 if (mEvent) storeTag();
317 if (mEvent) this->fillStEvent();
319 LOG_INFO <<
"StTofMaker::Make() -- see you next event --" << endm;
327 void StTofMaker::fillStEvent() {
329 LOG_INFO <<
"StTofMaker::fillStEvent() Starting..." << endm;
332 if(!mTheTofCollection){
334 mEvent->setTofCollection(mTheTofCollection);
338 if(mDataCollectionPresent != 1) {
339 LOG_INFO <<
"StTofMaker::fillStEvent() Size of mDataCollection = " << mDataCollection->size() << endm;
340 for(
size_t jj = 0; jj < mDataCollection->size(); jj++)
341 mTheTofCollection->addData(mDataCollection->getData(jj));
343 if(mRawDataCollectionPresent != 1) {
344 LOG_INFO <<
"StTofMaker::fillStEvent() Size of mRawDataCollection = " << mRawDataCollection->size() << endm;
345 for(
size_t jj = 0; jj < mRawDataCollection->size(); jj++)
346 mTheTofCollection->addRawData(mRawDataCollection->getRawData(jj));
356 LOG_INFO <<
"StTofMaker::fillStEvent() Verifying TOF StEvent data ..." << endm;
358 if(mmTheTofCollection){
359 LOG_INFO <<
" + StEvent tofCollection Exists" << endm;
360 if(mmTheTofCollection->dataPresent()) {
361 LOG_INFO <<
" + StEvent TofDataCollection Exists" << endm;
362 StSPtrVecTofData& rawTofVec = mmTheTofCollection->tofData();
364 for (
size_t i = 0; i < rawTofVec.size(); i++) {
369 LOG_INFO <<
" StEvent TofDataCollection has " << rawTofVec.size() <<
" entries..." << endm;
371 else LOG_INFO <<
" - StEvent TofDataCollection does not Exist" << endm;
374 LOG_INFO <<
" - StEvent tofCollection does not Exist" << endm;
375 LOG_INFO <<
" - StEvent tofDataCollection does not Exist" << endm;
381 void StTofMaker::storeTag(){
383 St_TofTag *tagTable =
new St_TofTag(
"TofTag",1);
384 if (!tagTable)
return;
385 tagTable->SetNRows(1);
389 TofTag_st *pTofTag = tagTable->GetTable();
392 pTofTag->tofEventType = tofTag;
393 LOG_INFO <<
"StTofMaker::storeTag() tofTag stored" << endm;
396 LOG_INFO <<
"StTofMaker::storeTag() unable to store tofTag" << endm;
virtual Int_t Make()
Make method, check for collections; create and fill them according to m_Mode.
TH1S * nAdcHitHisto
method for testing classes of StTofPidMaker
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
virtual Int_t Finish()
default Finish method (empty)
virtual ~StTofMaker()
default empty destructor
Int_t InitRun(int)
InitRun method, (re)initialize TOFp data from STAR dBase.
Int_t FinishRun(int)
FinishRun method, clean up TOFp dBase entries.
Time-of-Flight Geometry Utilities.
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
StTofMaker(const char *name="tof")
default constructor
virtual Int_t Init()
Init method, book histograms.
void init()
initialize geometry class from XDF file and set-up DAQ/Slat mappings