13#define TRG_SHORT_NAMES
14#define TRGCDC_SHORT_NAMES
17#include "cdc/dataobjects/CDCSimHit.h"
18#include "trg/trg/Debug.h"
19#include "trg/trg/Utilities.h"
20#include "trg/cdc/TRGCDC.h"
21#include "trg/cdc/Layer.h"
22#include "trg/cdc/Cell.h"
23#include "trg/cdc/Wire.h"
24#include "trg/cdc/WireHit.h"
25#include "trg/cdc/PerfectFinder.h"
26#include "trg/cdc/Segment.h"
27#include "trg/cdc/SegmentHit.h"
28#include "trg/cdc/Circle.h"
29#include "trg/cdc/TRGCDCTrack.h"
30#include "trg/cdc/Link.h"
33#include "trg/cdc/DisplayRphi.h"
34namespace Belle2_TRGCDC {
35 extern Belle2::TRGCDCDisplayRphi* D;
37using namespace Belle2_TRGCDC;
51 return string(
"TRGCDCPerfectFinder 5.24");
56 : _name(name), _cdc(
TRGCDC)
68 trackListClone = trackList;
80 map<int, vector<const TCSegment*> *> trackMap;
82 for (
unsigned i = 0; i < hits.size(); i++) {
83 const TCSHit& ts = * hits[i];
84 if (! ts.signal().active())
continue;
85 if (ts.segment().stereo())
continue;
87 const TCWHit* wh = ts.segment().priority().hit();
91 if (! trackMap[trackId]) {
92 trackMap[trackId] =
new vector<const TCSegment*>();
95 trackMap[trackId]->push_back(& ts.segment());
99 cout <<
TRGDebug::tab() <<
"#tracksInMC=" << trackMap.size() << endl;
100 map<int, vector<const TCSegment*> *>::iterator it = trackMap.begin();
101 while (it != trackMap.end()) {
103 const vector<const TCSegment*>& l = * it->second;
104 for (
unsigned i = 0; i < l.size(); i++)
105 cout << l[i]->
name() <<
",";
112 map<int, vector<const TCSegment*> *>::iterator it = trackMap.begin();
114 while (it != trackMap.end()) {
117 const vector<const TCSegment*>& l = * it->second;
118 vector<TCLink*> links;
119 for (
unsigned i = 0; i < l.size(); i++) {
120 TCLink* link =
new TCLink(0,
122 l[i]->hit()->cell().xyPosition());
123 links.push_back(link);
127 const unsigned nSuperLayers = TCLink::nSuperLayers(links);
128 if (nSuperLayers < 5) {
134 vector<TCLink*> layers[9];
135 vector<TCLink*> forCircle;
136 TCLink::separate(links, 9, layers);
137 for (
unsigned i = 0; i < 9; i++) {
138 if (layers[i].size() < 1)
continue;
139 if (layers[i].size() < 2) {
140 forCircle.push_back(layers[i][0]);
145 float timeMin = 99999;
146 bool bestCenterHit = 0;
147 for (
unsigned j = 0; j < layers[i].size(); j++) {
149 const float tsDrift = layers[i][j]->cell()->hit()->drift();
155 if (centerHit == 1 && bestCenterHit == 0) {
159 }
else if (centerHit == 0 && bestCenterHit == 1) {
161 if (tsDrift < timeMin) {
167 forCircle.push_back(best);
171 TCLink::dump(forCircle,
176 TCCircle c = TCCircle(forCircle);
178 c.name(
"CircleFitted_" + TRGUtil::itostring(n));
181 TCTrack& t = *
new TCTrack(c);
182 t.name(
"Track_" + TRGUtil::itostring(n));
183 trackList.push_back(& t);
194#ifdef TRGCDC_DISPLAY_HOUGH
195 vector<const TCCircle*> cc;
197 vector<const TCTrack*> tt;
199 string stg =
"2D : Perfect Finder circle fit";
204 D->area().append(cc, Gdk::Color(
"#FF0066009900"));
215 cout <<
TRGDebug::tab() <<
"#tracksMade=" << trackList.size() << endl;
int getTrackId() const
The method to get track id.
const TRGCDC & _cdc
CDCTRG.
std::vector< int > _mcList
MC track ID list.
A class to represent a wire in CDC.
The instance of TRGCDC is a singleton.
std::vector< const TRGCDCSegmentHit * > segmentHits(void) const
returns a list of TRGCDCSegmentHit.
static std::string tab(void)
returns tab spaces.
int priorityPosition(void) const
return priority cell position in TSHit. 0: no hit, 3: 1st priority, 1: 2nd right, 2: 2nd left
int doit(std::vector< TRGCDCTrack * > &trackListClone, std::vector< TRGCDCTrack * > &trackList)
do track finding.
virtual ~TRGCDCPerfectFinder()
Destructor.
static void enterStage(const std::string &stageName)
Declare that you enter new stage.
TRGCDCPerfectFinder(const std::string &name, const TRGCDC &)
Contructor.
std::string name(void) const
returns name.
static int level(void)
returns the debug level.
std::vector< const TRGCDCWireHit * > hits(void) const
returns a list of TRGCDCWireHit.
static void leaveStage(const std::string &stageName)
Declare that you leave a stage.
std::string version(void) const
returns version.
int doitPerfectly(std::vector< TRGCDCTrack * > &trackList)
do perfect finding.
Abstract base class for different kinds of events.