3 #include "StSortTofRawData.h"
5 #include "StTofCollection.h"
6 #include "StTofRawData.h"
7 #include "StTofrDaqMap.h"
9 StSortTofRawData::StSortTofRawData() {
29 StSortTofRawData::~StSortTofRawData() {
33 void StSortTofRawData::Reset() {
34 for(
unsigned int i=0;i<mNTRAY;i++) mRawHitVec[i].clear();
38 if(tofColl && tofColl->rawdataPresent()) {
39 StSPtrVecTofRawData &tofRawData = tofColl->tofRawData();
40 for(
size_t i=0; i<tofRawData.size(); i++) {
41 if(tofRawData[i]->leteFlag()!=1)
continue;
44 int ichan = tofRawData[i]->channel();
46 for(
size_t ii=0; ii<mRawHitVec[0].size(); ii++) {
47 if(itray==mRawHitVec[itray-1][ii].tray && ichan==mRawHitVec[itray-1][ii].channel) {
55 aRawHit.channel = ichan;
56 aRawHit.leadingTdc.push_back((
int)(tofRawData[i]->tdc()));
57 for(
size_t j=i+1;j<tofRawData.size();j++) {
58 if(tofRawData[j]->leteFlag()==1 &&
59 itray==93 && ichan==tofRawData[j]->channel()) {
60 aRawHit.leadingTdc.push_back((
int)(tofRawData[j]->tdc()));
65 for(
size_t j=0;j<tofRawData.size();j++) {
66 if(tofRawData[j]->leteFlag()==2 &&
67 itray==93 && ichan==tofRawData[j]->channel()) {
68 aRawHit.trailingTdc.push_back((
int)(tofRawData[j]->tdc()));
71 if(aRawHit.trailingTdc.size()) mRawHitVec[itray-1].push_back(aRawHit);
74 gMessMgr->Warning(
"",
"OS") <<
" No Tof Collection !!! " << endm;
79 if(tofColl && tofColl->rawdataPresent()) {
83 for(
unsigned int i=0;i<mNTRAY;i++){
84 for(
int j=0;j<2;j++) mTimeWindow[i][j] = 0.;
86 mTimeWindow[i][0] = 3270;
87 mTimeWindow[i][1] = 3390;
90 mTimeWindow[i][0] = 3230;
91 mTimeWindow[i][1] = 3340;
94 mTimeWindow[i][0] = 3290;
95 mTimeWindow[i][1] = 3400;
99 StSPtrVecTofRawData &tofRawData = tofColl->tofRawData();
100 for(
size_t i=0; i<tofRawData.size(); i++) {
101 if(tofRawData[i]->leteFlag()!=1)
continue;
102 int itray = tofRawData[i]->tray();
103 int ichan = tofRawData[i]->channel();
104 bool iexist = kFALSE;
105 for(
size_t ii=0; ii<mRawHitVec[itray-1].size(); ii++) {
106 if(itray==mRawHitVec[itray-1][ii].tray && ichan==mRawHitVec[itray-1][ii].channel) {
113 aRawHit.tray = itray;
114 aRawHit.channel = ichan;
115 aRawHit.triggertime = tofRawData[i]->triggertime();
116 aRawHit.leadingTdc.push_back((
int)(tofRawData[i]->tdc()));
117 for(
size_t j=i+1;j<tofRawData.size();j++) {
118 if(tofRawData[j]->leteFlag()==1 &&
119 itray==tofRawData[j]->tray() && ichan==tofRawData[j]->channel()) {
120 aRawHit.leadingTdc.push_back((
int)(tofRawData[j]->tdc()));
126 for(
size_t j=0;j<tofRawData.size();j++) {
127 if(tofRawData[j]->leteFlag()==2 &&
128 itray==tofRawData[j]->tray() && ichan==tofRawData[j]->channel()) {
129 aRawHit.trailingTdc.push_back((
int)(tofRawData[j]->tdc()));
133 int iTube = (itray==121) ? mTDIGLeChan2WestPMT[ichan] : mTDIGLeChan2EastPMT[ichan];
134 for(
size_t j=0;j<tofRawData.size();j++) {
135 if(tofRawData[j]->leteFlag()==2 && itray== tofRawData[j]->tray()) {
136 int jTube = (itray==121) ? mTDIGTeChan2WestPMT[tofRawData[j]->channel()] : mTDIGTeChan2EastPMT[tofRawData[j]->channel()];
138 aRawHit.trailingTdc.push_back((
int)(tofRawData[j]->tdc()));
143 if(aRawHit.trailingTdc.size()) mRawHitVec[itray-1].push_back(aRawHit);
146 gMessMgr->Warning(
"",
"OS") <<
" No Tof Collection !!! " << endm;
150 IntVec StSortTofRawData::GetValidChannel() {
152 for(
size_t k=0 ; k<mNTRAY; k++){
153 for(
size_t i=0 ; i<mRawHitVec[k].size() ; i++) {
154 chanVec.push_back(mRawHitVec[k][i].channel);
160 IntVec StSortTofRawData::GetLeadingTdc(
int channel) {
162 for(
size_t k=0 ; k<mNTRAY; k++){
163 for(
size_t i=0 ; i<mRawHitVec[k].size() ; i++) {
164 if(mRawHitVec[k][i].channel!=channel)
continue;
165 leTdc = mRawHitVec[k][i].leadingTdc;
171 IntVec StSortTofRawData::GetTrailingTdc(
int channel) {
173 for(
size_t k=0 ; k<mNTRAY; k++){
174 for(
size_t i=0 ; i<mRawHitVec[k].size() ; i++) {
175 if(mRawHitVec[k][i].channel!=channel)
continue;
176 teTdc = mRawHitVec[k][i].trailingTdc;
182 IntVec StSortTofRawData::GetValidChannel(
int tray) {
184 for(
size_t i=0 ; i<mRawHitVec[tray-1].size() ; i++) {
185 if( mRawHitVec[tray-1][i].tray == tray )
186 chanVec.push_back(mRawHitVec[tray-1][i].channel);
191 IntVec StSortTofRawData::GetLeadingTdc(
int tray,
int channel)
194 for(
size_t i=0 ; i<mRawHitVec[tray-1].size() ; i++) {
195 if(mRawHitVec[tray-1][i].tray!=tray)
continue;
196 if(mRawHitVec[tray-1][i].channel!=channel)
continue;
197 leTdc = mRawHitVec[tray-1][i].leadingTdc;
202 IntVec StSortTofRawData::GetLeadingTdc(
int tray,
int channel,
bool triggerevent)
205 for(
size_t i=0 ; i<mRawHitVec[tray-1].size() ; i++) {
206 if(mRawHitVec[tray-1][i].tray!=tray)
continue;
207 if(mRawHitVec[tray-1][i].channel!=channel)
continue;
209 for(
size_t j=0; j<mRawHitVec[tray-1][i].leadingTdc.size(); j++) {
210 float trgTime = 25.*(mRawHitVec[tray-1][i].triggertime & 0xfff) - 2775.;
211 float timeDiff = mRawHitVec[tray-1][i].leadingTdc[j]*25./1024 - trgTime;
212 while(timeDiff<0) timeDiff += 51200;
215 if(timeDiff>=mTimeWindow[tray-1][0]&&timeDiff<=mTimeWindow[tray-1][1])
216 leTdc.push_back(mRawHitVec[tray-1][i].leadingTdc[j]);
219 leTdc.push_back(mRawHitVec[tray-1][i].leadingTdc[j]);
224 double stime = timeDiff;
225 if(stime > ftime+300.){
226 if(timeDiff>=mTimeWindow[tray-1][0]&&timeDiff<=mTimeWindow[tray-1][1])
227 leTdc.push_back(mRawHitVec[tray-1][i].leadingTdc[j]);
232 leTdc.push_back(mRawHitVec[tray-1][i].leadingTdc[j]);
240 IntVec StSortTofRawData::GetTrailingTdc(
int tray,
int channel) {
242 for(
size_t i=0 ; i<mRawHitVec[tray-1].size() ; i++) {
243 if(mRawHitVec[tray-1][i].tray!=tray)
continue;
244 if(mRawHitVec[tray-1][i].channel!=channel)
continue;
245 teTdc = mRawHitVec[tray-1][i].trailingTdc;
250 IntVec StSortTofRawData::GetTrailingTdc(
int tray,
int channel,
bool triggerevent)
253 for(
size_t i=0 ; i<mRawHitVec[tray-1].size() ; i++) {
254 if(mRawHitVec[tray-1][i].tray!=tray)
continue;
255 if(mRawHitVec[tray-1][i].channel!=channel)
continue;
257 for(
size_t j=0; j<mRawHitVec[tray-1][i].trailingTdc.size(); j++) {
258 float trgTime = 25.*(mRawHitVec[tray-1][i].triggertime & 0xfff) - 2775.;
259 float timeDiff = mRawHitVec[tray-1][i].trailingTdc[j]*25./1024 - trgTime;
260 while(timeDiff<0) timeDiff += 51200;
263 if(timeDiff>=mTimeWindow[tray-1][0]&&timeDiff<=mTimeWindow[tray-1][1])
264 teTdc.push_back(mRawHitVec[tray-1][i].trailingTdc[j]);
267 teTdc.push_back(mRawHitVec[tray-1][i].trailingTdc[j]);
272 double stime = timeDiff;
273 if(stime > ftime+300.){
274 if(timeDiff>=mTimeWindow[tray-1][0]&&timeDiff<=mTimeWindow[tray-1][1])
275 teTdc.push_back(mRawHitVec[tray-1][i].trailingTdc[j]);
280 teTdc.push_back(mRawHitVec[tray-1][i].trailingTdc[j]);
288 Int_t StSortTofRawData::GetTriggerTime(
int tray,
int channel) {
290 for(
size_t i=0 ; i<mRawHitVec[tray-1].size() ; i++) {
291 if(mRawHitVec[tray-1][i].tray!=tray)
continue;
292 if(mRawHitVec[tray-1][i].channel!=channel)
continue;
293 triggertime = mRawHitVec[tray-1][i].triggertime;
298 void StSortTofRawData::SetVPDMap(
StTofrDaqMap* daqMap) {
299 for(
int i=0;i<mNTOF;i++) {
300 mTDIGLeChan2WestPMT[i] = daqMap->TDIGLeChan2WestPMT(i);
301 mTDIGTeChan2WestPMT[i] = daqMap->TDIGTeChan2WestPMT(i);
302 mTDIGLeChan2EastPMT[i] = daqMap->TDIGLeChan2EastPMT(i);
303 mTDIGTeChan2EastPMT[i] = daqMap->TDIGTeChan2EastPMT(i);
void Init(StTofCollection *)