167 #include "StTrackTopologyMap.h"
168 #include "StMessMgr.h"
173 #if !defined(ST_NO_NAMESPACES)
175 using std::adjacent_difference;
176 using std::max_element;
179 static const char rcsid[] =
"$Id: StTrackTopologyMap.cxx,v 2.22 2019/03/04 17:02:16 ullrich Exp $";
189 StTrackTopologyMap::StTrackTopologyMap(
unsigned int m1,
191 unsigned long long m3)
192 : mMap0(m1), mMap1(m2), mMap_iTpc(m3)
195 StTrackTopologyMap::StTrackTopologyMap(
const unsigned int* m,
196 unsigned long long k)
197 : mMap0(m[0]), mMap1(m[1]), mMap_iTpc(k)
200 StTrackTopologyMap::StTrackTopologyMap(
const unsigned long* m,
201 unsigned long long k)
202 : mMap0(m[0]), mMap1(m[1]), mMap_iTpc(k)
205 StTrackTopologyMap::~StTrackTopologyMap() { }
208 StTrackTopologyMap::bit(
int i)
const
210 return i>31 ? (mMap1>>(i-32) & 1U) : (mMap0>>i & 1U);
214 StTrackTopologyMap::iTpcBit(
int i)
const
216 return (i < 41 ? (mMap_iTpc>>i & 1ULL) : bit(i-20));
220 StTrackTopologyMap::ftpcFormat()
const
226 StTrackTopologyMap::hftFormat()
const
232 StTrackTopologyMap::data(
unsigned int i)
const
234 unsigned long long theData = 0;
237 theData =
static_cast<unsigned long long>(mMap0);
240 theData =
static_cast<unsigned long long>(mMap1);
252 StTrackTopologyMap::primaryVertexUsed()
const {
return bit(0); }
255 StTrackTopologyMap::turnAroundFlag()
const {
return bit(62); }
258 StTrackTopologyMap::hasHitInDetector(StDetectorId
id)
const
260 return ((numberOfHits(
id)) ?
true :
false);
265 StTrackTopologyMap::hasHitInDetector(StDetectorId d1, StDetectorId d2,
266 StDetectorId d3, StDetectorId d4,
267 StDetectorId d5, StDetectorId d6)
const
273 return (hasHitInDetector(d1) && hasHitInDetector(d2) &&
274 (d3 == kUnknownId ?
true : hasHitInDetector(d3)) &&
275 (d4 == kUnknownId ?
true : hasHitInDetector(d4)) &&
276 (d5 == kUnknownId ?
true : hasHitInDetector(d5)) &&
277 (d6 == kUnknownId ?
true : hasHitInDetector(d6)));
281 StTrackTopologyMap::hasHitInSvtLayer(
unsigned int layer)
const
290 StTrackTopologyMap::hasHitInPxlLayer(
unsigned int layer)
const
299 StTrackTopologyMap::hasHitInIstLayer(
unsigned int layer)
const
309 StTrackTopologyMap::hasHitInSsdLayer(
unsigned int layer)
const
322 StTrackTopologyMap::hasHitInRow(StDetectorId
id,
unsigned int row)
const
326 return !ftpcFormat() && bit(row+7);
329 return ftpcFormat() && bit(row);
332 return ftpcFormat() && bit(row+10);
335 return !ftpcFormat() && iTpcBit(row);
344 StTrackTopologyMap::numberOfHits(StDetectorId
id)
const
347 !(
id == kFtpcWestId ||
id == kFtpcEastId))
356 if (hasHitInSvtLayer(i)) n++;
363 for(
int i=1;i<=2;i++) {
364 if (hasHitInSsdLayer(i)) n++;
370 if(hasHitInPxlLayer(i)) n++;
375 if(hasHitInIstLayer(i)) n++;
380 if (hasHitInRow(
id, i)) n++;
384 if (hasHitInRow(
id, i)) n++;
388 if (hasHitInRow(
id, i)) n++;
403 case kBarrelEmcTowerId:
404 case kBarrelEmcPreShowerId:
405 case kBarrelSmdEtaStripId:
406 case kBarrelSmdPhiStripId:
409 case kEndcapEmcTowerId:
410 case kEndcapEmcPreShowerId:
411 case kEndcapSmdUStripId:
412 case kEndcapSmdVStripId:
423 StTrackTopologyMap::trackTpcOnly()
const
426 return ((hasHitInDetector(kTpcId) || hasHitInDetector(kiTpcId)) &&
427 !(hasHitInDetector(kPxlId) || hasHitInDetector(kIstId) || hasHitInDetector(kSsdId)));
430 return ((hasHitInDetector(kTpcId) || hasHitInDetector(kiTpcId)) &&
431 !(hasHitInDetector(kSvtId) || hasHitInDetector(kSsdId)));
435 StTrackTopologyMap::trackSvtOnly()
const
437 return (hasHitInDetector(kSvtId) && !(hasHitInDetector(kTpcId) || hasHitInDetector(kiTpcId)));
441 StTrackTopologyMap::trackTpcSvt()
const
443 return ((hasHitInDetector(kTpcId) || hasHitInDetector(kiTpcId)) && hasHitInDetector(kSvtId));
447 StTrackTopologyMap::trackFtpcEast()
const
449 return hasHitInDetector(kFtpcEastId);
453 StTrackTopologyMap::trackFtpcWest()
const
455 return hasHitInDetector(kFtpcWestId);
459 StTrackTopologyMap::trackFtpc()
const
461 return (hasHitInDetector(kFtpcWestId) || hasHitInDetector(kFtpcEastId));
465 StTrackTopologyMap::largestGap(StDetectorId
id)
const
467 if (
id == kTpcId && hasHitInDetector(kiTpcId)) {
468 gMessMgr->Warning() <<
"StTrackTopologyMap::largestGap():\n"
469 <<
"\tWas called for detector id=kTpcId but there\n"
470 <<
"\tare also hits in the iTPC present. The largest\n"
471 <<
"\tgap in the TPC cannot be derived reliably at\n"
472 <<
"\t this point. Results are unreliable.\n"
476 if (ftpcFormat() && !(
id == kFtpcWestId ||
id == kFtpcEastId))
485 if (hasHitInSvtLayer(i)) rows.push_back(i);
490 if (hasHitInRow(
id, i)) rows.push_back(i);
494 if (hasHitInRow(
id, i)) rows.push_back(i);
498 if (hasHitInRow(
id, i)) rows.push_back(i);
504 if (rows.size() < 2)
return -1;
506 vector<int> diffs(rows.size());
507 adjacent_difference(rows.begin(), rows.end(), diffs.begin());
508 return *max_element(diffs.begin()+1, diffs.end()) - 1;
513 auto word0 = m.data(0);
514 auto word1 = m.data(1);
515 auto word2 = m.data(2);
517 for (
int i=0; i<64; i++) {
519 os << ((word1>>(i-32) & 1U) ? 1 : 0);
521 os << ((word0>>i & 1U) ? 1 : 0);
526 for (
int i=0; i<64; i++) {
527 os << ((word2>>i & 1U) ? 1 : 0);