13#define TRG_SHORT_NAMES
14#define TRGCDC_SHORT_NAMES
19#include "trg/trg/Utilities.h"
20#include "trg/cdc/Wire.h"
21#include "trg/cdc/WireHit.h"
22#include "trg/cdc/WireHitMC.h"
23#include "trg/cdc/TRGCDCTrack.h"
24#include "trg/cdc/TrackMC.h"
25#include "trg/cdc/Segment.h"
26#include "trg/cdc/Link.h"
68 for (
unsigned i = 0; i < 7; ++i)
79 m_onTrack(l.m_onTrack),
81 m_position(l.m_position),
83 m_leftRight(l.m_leftRight),
84 m_zStatus(l.m_zStatus),
94 for (
unsigned i = 0; i < 7; ++i)
96 for (
unsigned i = 0; i < 4; ++i)
109 unsigned n = list.size();
110 for (
unsigned i = 0; i < n; i++) {
111 unsigned id = list[i]->cell()->layerId();
112 if (
id < 32) l0 |= (1u << id);
113 else l1 |= (1 << (
id - 32));
117 for (
unsigned i = 0; i < 32; i++) {
118 if (l0 & (1u << i)) ++l;
119 if (l1 & (1u << i)) ++l;
127 for (
unsigned i = 0; i <
m_nL; i++)
129 unsigned nLinks = links.size();
130 for (
unsigned i = 0; i < nLinks; i++)
137 const unsigned nLinks = links.size();
138 for (
unsigned i = 0; i < nLinks; i++)
149 bool pull = (msg.find(
"pull") != string::npos);
150 bool flag = (msg.find(
"flag") != string::npos);
151 bool stereo = (msg.find(
"stereo") != string::npos);
152 bool pos = (msg.find(
"position") != string::npos);
155 bool breif = (msg.find(
"breif") != string::npos);
156 bool detail = (msg.find(
"detail") != string::npos);
159 pull = flag = stereo = pos =
true;
168 cout <<
"No hit linked";
184 cout <<
"[pul=" << this->
pull() <<
"]";
200 cout <<
",drift=" <<
drift(0) <<
"," <<
drift(1);
216 vector<const TRGCDCLink*> clinks;
217 for (
unsigned i = 0; i < links.size(); i++)
218 clinks.push_back(links[i]);
229 bool mc = (msg.find(
"mc") != string::npos);
230 bool sort = (msg.find(
"sort") != string::npos);
231 bool flag = (msg.find(
"flag") != string::npos);
234 bool detail = (msg.find(
"detail") != string::npos);
238 vector<const TRGCDCLink*> tmp = links;
242 unsigned n = tmp.size();
243 unsigned nForFit = 0;
245 unsigned MCC0[MCC_MAX];
246 unsigned MCC1[MCC_MAX];
247 memset((
char*) MCC0, 0,
sizeof(
unsigned) * MCC_MAX);
248 memset((
char*) MCC1, 0,
sizeof(
unsigned) * MCC_MAX);
249 bool MCCOverFlow =
false;
252 for (
unsigned i = 0; i < n; i++) {
275 if (l.
hit()->
state() & CellHitFittingValid) {
276 if (!(l.
hit()->
state() & CellHitInvalidForFit))
286 cout <<
",Total " << n <<
" links";
289 if (flag) cout <<
",fv " << nForFit <<
" l(s)";
293 for (
unsigned i = 0; i < MCC_MAX; i++) {
296 cout << i <<
":" << MCC0[i] <<
",";
299 cout <<
"total " << nMC <<
" mc contributions";
303 for (
unsigned i = 0; i < MCC_MAX; i++) {
306 cout << i <<
":" << MCC1[i] <<
",";
309 cout <<
" total " << nMC <<
" mc fit valid contribution(s)";
314 cout <<
"(counter overflow)";
321 if (! list.size())
return;
324 for (
unsigned i = 0; i < MCC_MAX; i++) {
328 cout <<
", mc" << i <<
"(";
330 cout << h->pType() <<
")";
336 cout <<
"<-mc" << m->id();
345 cout <<
"(counter overflow)";
355 vector<const TRGCDCLink*> tmp;
356 tmp.push_back(&
link);
363 unsigned nLinks = links.size();
365 for (
unsigned i = 0; i < nLinks; i++)
366 if (links[i]->
cell()->stereo())
374 unsigned nLinks = links.size();
376 for (
unsigned i = 0; i < nLinks; i++)
377 if (links[i]->
cell()->axial())
385 vector<TRGCDCLink*> a;
386 unsigned n = links.size();
387 for (
unsigned i = 0; i < n; i++) {
388 if (links[i]->
cell()->axial())
389 a.push_back(links[i]);
397 vector<TRGCDCLink*> a;
398 unsigned n = links.size();
399 for (
unsigned i = 0; i < n; i++) {
400 if (! links[i]->
cell()->axial())
401 a.push_back(links[i]);
409 unsigned n = a.size();
410 unsigned minId = 19999;
412 for (
unsigned i = 0; i < n; i++) {
413 unsigned id = a[i]->cell()->id();
425 unsigned n = a.size();
428 for (
unsigned i = 0; i < n; i++) {
429 unsigned id = a[i]->cell()->id();
440 vector<TRGCDCLink*>& cores,
441 vector<TRGCDCLink*>& nonCores)
443 unsigned n = input.size();
444 for (
unsigned i = 0; i < n; i++) {
446 const Belle2::TCCHit& h = * t.hit();
447 if (h.state() & CellHitFittingValid)
448 cores.push_back(& t);
450 nonCores.push_back(& t);
457 vector<TRGCDCLink*> a;
458 unsigned n = input.size();
459 for (
unsigned i = 0; i < n; i++) {
461 const Belle2::TCCHit& h = * t.hit();
462 if (h.state() & CellHitFittingValid)
471 return a->cell()->id() < b->cell()->id();
477 return a->position().x() < b->position().x();
483 const unsigned n = list.size();
486 const TCCell*
const w0 = list[0]->cell();
488 unsigned nWires = w0->layer().nCells();
489 unsigned center = w0->localId();
498 for (
unsigned i = 1; i < n; i++) {
499 const TCCell*
const w = list[i]->cell();
500 unsigned id = w->localId();
505 unsigned distance0, distance1;
507 distance0 =
id - center;
508 distance1 = nWires - distance0;
510 distance1 = center - id;
511 distance0 = nWires - distance1;
514 if (distance0 < distance1) {
515 if (distance0 > right) right = distance0;
517 if (distance1 > left) left = distance1;
521 return right + left + 1;
527 vector<TRGCDCLink*> a;
529 unsigned n = list.size();
531 else if (n == 2)
return list;
533 const TCCell* w = list[0]->cell();
534 unsigned nWires = w->layer().nCells();
535 unsigned center = w->localId();
541 for (
unsigned i = 1; i < n; i++) {
543 unsigned id = w->localId();
545 unsigned distance0, distance1;
547 distance0 =
id - center;
548 distance1 = nWires - distance0;
550 distance1 = center - id;
551 distance0 = nWires - distance1;
554 if (distance0 < distance1) {
555 if (distance0 > right) {
560 if (distance1 > left) {
575 vector<TRGCDCLink*> same;
576 unsigned id = a.cell()->layerId();
577 unsigned n = list.size();
578 for (
unsigned i = 0; i < n; i++) {
579 if (list[i]->
cell()->layerId() ==
id) same.push_back(list[i]);
587 vector<TRGCDCLink*> same;
588 unsigned id = a.cell()->superLayerId();
589 unsigned n = list.size();
590 for (
unsigned i = 0; i < n; i++) {
591 if (list[i]->
cell()->superLayerId() ==
id) same.push_back(list[i]);
599 vector<TRGCDCLink*> same;
600 unsigned n = list.size();
601 for (
unsigned i = 0; i < n; i++) {
602 if (list[i]->
cell()->layerId() ==
id) same.push_back(list[i]);
610 vector<TRGCDCLink*> same;
611 unsigned n = list.size();
612 for (
unsigned i = 0; i < n; i++) {
613 if (list[i]->
cell()->superLayerId() ==
id) same.push_back(list[i]);
621 vector<TRGCDCLink*> inners;
622 vector<TRGCDCLink*> outers;
623 unsigned n = list.size();
624 unsigned innerMostLayer = 999;
625 unsigned outerMostLayer = 0;
626 for (
unsigned i = 0; i < n; i++) {
627 unsigned id = list[i]->cell()->layerId();
628 if (
id < innerMostLayer) innerMostLayer = id;
629 else if (
id > outerMostLayer) outerMostLayer = id;
631 for (
unsigned i = 0; i < n; i++) {
632 unsigned id = list[i]->cell()->layerId();
633 if (
id == innerMostLayer) inners.push_back(list[i]);
634 else if (
id == outerMostLayer) outers.push_back(list[i]);
637 inners.insert(inners.end(), outers.begin(), outers.end());
645 unsigned n = list.size();
646 for (
unsigned i = 0; i < n; i++)
647 sl |= (1 << (list[i]->
cell()->superLayerId()));
655 unsigned n = links.size();
656 for (
unsigned i = 0; i < n; i++)
659 for (
unsigned i = 0; i <
m_nSL; i++)
669 unsigned n = list.size();
670 for (
unsigned i = 0; i < n; i++) {
671 unsigned id = list[i]->cell()->superLayerId();
676 for (
unsigned i = 0; i <
m_nSL; i++) {
677 if (l0 & (1 << i)) ++l;
686 unsigned n = links.size();
687 for (
unsigned i = 0; i < n; i++)
690 for (
unsigned i = 0; i <
m_nSL; i++)
700 const unsigned n = links.size();
702 for (
unsigned i = 0; i < n; i++)
703 if (links[i]->
cell()->axial())
704 ++
m_nHitsSL[links[i]->cell()->axialStereoSuperLayerId()];
708 unsigned nMissing = 0;
710 for (
unsigned i = j; i <
m_nSLA; i++) {
713 if (nMax < nMissing) nMax = nMissing;
724 const vector<const Belle2::TRGCDCTrackMC*> list =
726 unsigned nHep = list.size();
728 if (! nHep)
return * best;
731 if (NULL == (N = (
unsigned*) malloc(nHep *
sizeof(
unsigned)))) {
735 for (
unsigned i = 0; i < nHep; i++) N[i] = 0;
746 for (
unsigned i = 0; i < nHep; i++) {
761 const unsigned nLinks = links.size();
762 for (
unsigned i = 0; i < nLinks; i++)
771 for (
unsigned i = 0; i <
m_nSL; i++) {
776 for (
unsigned i = 0; i <
m_nSL; i++) {
777 nh += TRGUtil::itostring(n[i]);
778 if (i % 2) nh +=
",";
779 else if (i < 10) nh +=
"-";
786 const vector<TRGCDCLink*>& links)
788 const unsigned n = list.size();
789 const unsigned m = links.size();
792 for (
unsigned i = 0; i < n; i++) {
793 for (
unsigned j = 0; j < m; j++) {
794 if (list[i]->
cell()->
id() == links[j]->
cell()->
id())
797 cout <<
"TCLink::remove !!! not implemented yet" << endl;
807 static bool first =
true;
810 m_nL = cdc.nLayers();
811 m_nSL = cdc.nSuperLayers();
812 m_nSLA = cdc.nAxialSuperLayers();
821 vector<TRGCDCLink*>* layers)
823 for (
unsigned i = 0; i < links.size(); i++) {
824 const TCCell* c = links[i]->cell();
826 unsigned lid = c->layer().id();
828 layers[lid].push_back(links[i]);
857 TRGCDCLink::operator
new (
size_t size)
859 void* p = malloc(size);
870 TRGCDCLink::operator
delete (
void* t)
872 for (vector<TRGCDCLink*>::iterator it = m_all.begin();
A class to represent a wire hit in CDC.
virtual std::string name(void) const =0
returns name.
A class to relate TRGCDCCellHit and TRGCDCTrack objects.
int m_zStatus
z status of stereo
HepGeom::Point3D< double > m_arcZ[4]
arcZ
HepGeom::Point3D< double > m_onTrack
position on track
TRGCDCLink * m_neighbor[7]
neighbor TRGCDCLink
float m_drift[2]
drift distance
const TRGCDCCellHit * m_hit
Cell hit object.
float m_dDrift[2]
drift distance error
HepGeom::Point3D< double > m_onWire
position on wire
A class to represent a GEN_HEPEVT particle in tracking.
A class to represent a reconstructed charged track in TRGCDC.
A class to represent a wire in CDC.
The instance of TRGCDC is a singleton.
const TRGCDCWire * wire(void) const
returns a pointer to a wire.
float drift(void) const
returns drift distance.
static std::vector< TRGCDCLink * > sameLayer(const std::vector< TRGCDCLink * > &list, const TRGCDCLink &a)
returns links which are in the same layer as 'a' or 'id'.
static const TRGCDCTrackMC & links2HEP(const std::vector< TRGCDCLink * > &links)
returns TRGCDCTrackMC
static TRGCDC * getTRGCDC(void)
returns TRGCDC object.
static unsigned m_nSLA
...Buffers...
virtual const TRGCDCCell & cell(void) const
returns a pointer to a TRGCDCWire.
virtual ~TRGCDCLink()
Destructor.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
const TRGCDCCell * cell(void) const
returns a pointer to a cell.
static std::vector< TRGCDCLink * > inOut(const std::vector< TRGCDCLink * > &)
returns links which are in the inner most and outer most layer.
static std::vector< TRGCDCLink * > edges(const std::vector< TRGCDCLink * > &)
returns links which are edges.
TRGCDCLink(TRGCDCTrack *track=0, const TRGCDCCellHit *hit=0, const HepGeom::Point3D< double > &position=Point3D())
Constructor.
static TRGCDCLink * outerMost(const std::vector< TRGCDCLink * > &links)
returns the outer-most link.
const HepGeom::Point3D< double > & position(void) const
returns position.
unsigned layerId(void) const
returns layer id.
static std::vector< TRGCDCLink * > m_all
Keeps all TRGCDCLinks created by new().
static unsigned width(const std::vector< TRGCDCLink * > &)
returns width(wire cell unit) of given std::vector<TRGCDCLink *>.
static TRGCDCLink * innerMost(const std::vector< TRGCDCLink * > &links)
returns the inner-most link.
static std::vector< TRGCDCLink * > sameSuperLayer(const std::vector< TRGCDCLink * > &list, const TRGCDCLink &a)
returns links which are in the same super layer as 'a' or 'id'.
static unsigned superLayer(const std::vector< TRGCDCLink * > &list)
returns super layer pattern.
unsigned superLayerId(void) const
returns super layer id.
static void clearBufferSL(void)
clear buffers
const TRGCDCCellHit * hit(void) const
returns a pointer to a hit.
static int sortByX(const TRGCDCLink *a, const TRGCDCLink *b)
sorts by X position.
static void separateCores(const std::vector< TRGCDCLink * > &input, std::vector< TRGCDCLink * > &cores, std::vector< TRGCDCLink * > &nonCores)
separate cores and non-cores.
static bool sortById(const TRGCDCLink *a, const TRGCDCLink *b)
sorts by ID.
static unsigned m_nSL
...Buffers...
static TRGCDCTrackMC * _undefined
returns a pointer to gen_hepevt.
static unsigned nMissingAxialSuperLayers(const std::vector< TRGCDCLink * > &links)
returns # of missing axial super layers.
static void removeAll(void)
destructs all TRGCDCLink objects. (Called by TRGCDC)
TRGCDCLink * link(void) const
returns a pointer to a TRGCDCLink.
unsigned nSuperLayers(void) const
returns # of super layers.
static void remove(std::vector< TRGCDCLink * > &list, const std::vector< TRGCDCLink * > &links)
removes links from list if wire is same
static bool ms_superb
ms_superb
static unsigned nSuperLayers(const std::vector< TRGCDCLink * > &links)
returns # of layers.
static void nHits(const std::vector< TRGCDCLink * > &links, unsigned *nHits)
returns # of hits per layer.
static std::vector< TRGCDCLink * > stereoHits(const std::vector< TRGCDCLink * > &links)
returns stereo hits.
double pull(void) const
returns pull.
static std::vector< TRGCDCLink * > axialHits(const std::vector< TRGCDCLink * > &links)
returns axial hits.
static unsigned * m_nHitsSL
...Buffers...
void dump_base(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
static unsigned m_nL
...Buffers...
static std::string layerUsage(const std::vector< TRGCDCLink * > &links)
usage of each layer
static unsigned nLayers(const std::vector< TRGCDCLink * > &links)
returns # of layers.
static bool ms_smallcell
ms_smallcell
static std::vector< TRGCDCLink * > cores(const std::vector< TRGCDCLink * > &input)
separate cores and non-cores.
static void initializeBuffers(void)
initialize the Buffers
static unsigned nAxialHits(const std::vector< TRGCDCLink * > &links)
returns # of axial hits.
unsigned leftRight(void) const
returns left-right. 0:left, 1:right, 2:wire
unsigned state(void) const
returns state.
static unsigned nStereoHits(const std::vector< TRGCDCLink * > &links)
returns # of stereo hits.
static void nHitsSuperLayer(const std::vector< TRGCDCLink * > &links, unsigned *nHits)
returns # of hits per super layer.
static void separate(const std::vector< TRGCDCLink * > &links, unsigned nLayers, std::vector< TRGCDCLink * > *layers)
separates into layers.
static std::vector< const TRGCDCTrackMC * > list(void)
returns a list of TRGCDCTrackMC's.
Abstract base class for different kinds of events.