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)
 
   81      _position(l._position),
 
   83      _leftRight(l._leftRight),
 
   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 < 
_nL; i++)
 
  129    unsigned nLinks = links.size();
 
  130    for (
unsigned i = 0; i < nLinks; i++)
 
  137    for (
unsigned i = 0; i < 
_nSL; i++)
 
  139    const unsigned nLinks = links.size();
 
  140    for (
unsigned i = 0; i < nLinks; i++)
 
  151    bool pull = (msg.find(
"pull") != string::npos);
 
  152    bool flag = (msg.find(
"flag") != string::npos);
 
  153    bool stereo = (msg.find(
"stereo") != string::npos);
 
  154    bool pos = (msg.find(
"position") != string::npos);
 
  157    bool breif = (msg.find(
"breif") != string::npos);
 
  158    bool detail = (msg.find(
"detail") != string::npos);
 
  161      pull = flag = stereo = pos = 
true;
 
  170      cout << 
"No hit linked";
 
  186      cout << 
"[pul=" << this->
pull() << 
"]";
 
  193        if (
_hit->
state() & CellHitInvalidForFit)
 
  202      cout << 
",drift=" << 
drift(0) << 
"," << 
drift(1);
 
  218    vector<const TRGCDCLink*> clinks;
 
  219    for (
unsigned i = 0; i < links.size(); i++)
 
  220      clinks.push_back(links[i]);
 
  231    bool mc = (msg.find(
"mc") != string::npos);
 
  232    bool sort = (msg.find(
"sort") != string::npos);
 
  233    bool flag = (msg.find(
"flag") != string::npos);
 
  236    bool detail = (msg.find(
"detail") != string::npos);
 
  240    vector<const TRGCDCLink*> tmp = links;
 
  244    unsigned n = tmp.size();
 
  245    unsigned nForFit = 0;
 
  247    unsigned MCC0[MCC_MAX];
 
  248    unsigned MCC1[MCC_MAX];
 
  249    memset((
char*) MCC0, 0, 
sizeof(
unsigned) * MCC_MAX);
 
  250    memset((
char*) MCC1, 0, 
sizeof(
unsigned) * MCC_MAX);
 
  251    bool MCCOverFlow = 
false;
 
  254    for (
unsigned i = 0; i < n; i++) {
 
  277          if (l.
hit()->
state() & CellHitFittingValid) {
 
  278            if (!(l.
hit()->
state() & CellHitInvalidForFit))
 
  288      cout << 
",Total " << n << 
" links";
 
  291    if (flag) cout << 
",fv " << nForFit << 
" l(s)";
 
  295      for (
unsigned i = 0; i < MCC_MAX; i++) {
 
  298          cout << i << 
":" << MCC0[i] << 
",";
 
  301      cout << 
"total " << nMC << 
" mc contributions";
 
  305        for (
unsigned i = 0; i < MCC_MAX; i++) {
 
  308            cout << i << 
":" << MCC1[i] << 
",";
 
  311        cout << 
" total " << nMC << 
" mc fit valid contribution(s)";
 
  316        cout << 
"(counter overflow)";
 
  323      if (! list.size()) 
return;
 
  326      for (
unsigned i = 0; i < MCC_MAX; i++) {
 
  330          cout << 
", mc" << i << 
"(";
 
  332            cout << h->pType() << 
")";
 
  338              cout << 
"<-mc" << m->id();
 
  347        cout << 
"(counter overflow)";
 
  357    vector<const TRGCDCLink*> tmp;
 
  358    tmp.push_back(& 
link);
 
  365    unsigned nLinks = links.size();
 
  367    for (
unsigned i = 0; i < nLinks; i++)
 
  368      if (links[i]->
cell()->stereo())
 
  376    unsigned nLinks = links.size();
 
  378    for (
unsigned i = 0; i < nLinks; i++)
 
  379      if (links[i]->
cell()->axial())
 
  387    vector<TRGCDCLink*> a;
 
  388    unsigned n = links.size();
 
  389    for (
unsigned i = 0; i < n; i++) {
 
  390      if (links[i]->
cell()->axial())
 
  391        a.push_back(links[i]);
 
  399    vector<TRGCDCLink*> a;
 
  400    unsigned n = links.size();
 
  401    for (
unsigned i = 0; i < n; i++) {
 
  402      if (! links[i]->
cell()->axial())
 
  403        a.push_back(links[i]);
 
  411    unsigned n = a.size();
 
  412    unsigned minId = 19999;
 
  414    for (
unsigned i = 0; i < n; i++) {
 
  415      unsigned id = a[i]->cell()->id();
 
  427    unsigned n = a.size();
 
  430    for (
unsigned i = 0; i < n; i++) {
 
  431      unsigned id = a[i]->cell()->id();
 
  442                            vector<TRGCDCLink*>& cores,
 
  443                            vector<TRGCDCLink*>& nonCores)
 
  445    unsigned n = input.size();
 
  446    for (
unsigned i = 0; i < n; i++) {
 
  448      const Belle2::TCCHit& h = * t.hit();
 
  449      if (h.state() & CellHitFittingValid)
 
  450        cores.push_back(& t);
 
  452        nonCores.push_back(& t);
 
  459    vector<TRGCDCLink*> a;
 
  460    unsigned n = input.size();
 
  461    for (
unsigned i = 0; i < n; i++) {
 
  463      const Belle2::TCCHit& h = * t.hit();
 
  464      if (h.state() & CellHitFittingValid)
 
  473    return a->cell()->id() < b->cell()->id();
 
  479    return a->position().x() < b->position().x();
 
  485    const unsigned n = list.size();
 
  488    const TCCell* 
const w0 = list[0]->cell();
 
  490    unsigned nWires = w0->layer().nCells();
 
  491    unsigned center = w0->localId();
 
  500    for (
unsigned i = 1; i < n; i++) {
 
  501      const TCCell* 
const w = list[i]->cell();
 
  502      unsigned id = w->localId();
 
  507      unsigned distance0, distance1;
 
  509        distance0 = 
id - center;
 
  510        distance1 = nWires - distance0;
 
  512        distance1 = center - id;
 
  513        distance0 = nWires - distance1;
 
  516      if (distance0 < distance1) {
 
  517        if (distance0 > right) right = distance0;
 
  519        if (distance1 > left) left = distance1;
 
  523    return right + left + 1;
 
  529    vector<TRGCDCLink*> a;
 
  531    unsigned n = list.size();
 
  533    else if (n == 2) 
return list;
 
  535    const TCCell* w = list[0]->cell();
 
  536    unsigned nWires = w->layer().nCells();
 
  537    unsigned center = w->localId();
 
  543    for (
unsigned i = 1; i < n; i++) {
 
  545      unsigned id = w->localId();
 
  547      unsigned distance0, distance1;
 
  549        distance0 = 
id - center;
 
  550        distance1 = nWires - distance0;
 
  552        distance1 = center - id;
 
  553        distance0 = nWires - distance1;
 
  556      if (distance0 < distance1) {
 
  557        if (distance0 > right) {
 
  562        if (distance1 > left) {
 
  577    vector<TRGCDCLink*> same;
 
  578    unsigned id = a.cell()->layerId();
 
  579    unsigned n = list.size();
 
  580    for (
unsigned i = 0; i < n; i++) {
 
  581      if (list[i]->
cell()->layerId() == 
id) same.push_back(list[i]);
 
  589    vector<TRGCDCLink*> same;
 
  590    unsigned id = a.cell()->superLayerId();
 
  591    unsigned n = list.size();
 
  592    for (
unsigned i = 0; i < n; i++) {
 
  593      if (list[i]->
cell()->superLayerId() == 
id) same.push_back(list[i]);
 
  601    vector<TRGCDCLink*> same;
 
  602    unsigned n = list.size();
 
  603    for (
unsigned i = 0; i < n; i++) {
 
  604      if (list[i]->
cell()->layerId() == 
id) same.push_back(list[i]);
 
  612    vector<TRGCDCLink*> same;
 
  613    unsigned n = list.size();
 
  614    for (
unsigned i = 0; i < n; i++) {
 
  615      if (list[i]->
cell()->superLayerId() == 
id) same.push_back(list[i]);
 
  623    vector<TRGCDCLink*> inners;
 
  624    vector<TRGCDCLink*> outers;
 
  625    unsigned n = list.size();
 
  626    unsigned innerMostLayer = 999;
 
  627    unsigned outerMostLayer = 0;
 
  628    for (
unsigned i = 0; i < n; i++) {
 
  629      unsigned id = list[i]->cell()->layerId();
 
  630      if (
id < innerMostLayer) innerMostLayer = id;
 
  631      else if (
id > outerMostLayer) outerMostLayer = id;
 
  633    for (
unsigned i = 0; i < n; i++) {
 
  634      unsigned id = list[i]->cell()->layerId();
 
  635      if (
id == innerMostLayer) inners.push_back(list[i]);
 
  636      else if (
id == outerMostLayer) outers.push_back(list[i]);
 
  639    inners.insert(inners.end(), outers.begin(), outers.end());
 
  647    unsigned n = list.size();
 
  648    for (
unsigned i = 0; i < n; i++)
 
  649      sl |= (1 << (list[i]->
cell()->superLayerId()));
 
  657    unsigned n = links.size();
 
  658    for (
unsigned i = 0; i < n; i++)
 
  661    for (
unsigned i = 0; i < 
_nSL; i++)
 
  671    unsigned n = list.size();
 
  672    for (
unsigned i = 0; i < n; i++) {
 
  673      unsigned id = list[i]->cell()->superLayerId();
 
  678    for (
unsigned i = 0; i < 
_nSL; i++) {
 
  679      if (l0 & (1 << i)) ++l;
 
  688    unsigned n = links.size();
 
  689    for (
unsigned i = 0; i < n; i++)
 
  692    for (
unsigned i = 0; i < 
_nSL; i++)
 
  702    const unsigned n = links.size();
 
  704    for (
unsigned i = 0; i < n; i++)
 
  705      if (links[i]->
cell()->axial())
 
  706        ++
_nHitsSL[links[i]->cell()->axialStereoSuperLayerId()];
 
  710    unsigned nMissing = 0;
 
  712    for (
unsigned i = j; i < 
_nSLA; i++) {
 
  715        if (nMax < nMissing) nMax = nMissing;
 
  726    const vector<const Belle2::TRGCDCTrackMC*> list =
 
  728    unsigned nHep = list.size();
 
  730    if (! nHep) 
return * best;
 
  733    if (NULL == (N = (
unsigned*) malloc(nHep * 
sizeof(
unsigned)))) {
 
  737    for (
unsigned i = 0; i < nHep; i++) N[i] = 0;
 
  748    for (
unsigned i = 0; i < nHep; i++) {
 
  763    const unsigned nLinks = links.size();
 
  764    for (
unsigned i = 0; i < nLinks; i++)
 
  775    for (
unsigned i = 0; i < 
_nSL; i++) {
 
  776      nh += TRGUtil::itostring(n[i]);
 
  777      if (i % 2) nh += 
",";
 
  778      else if (i < 10) nh += 
"-";
 
  785                     const vector<TRGCDCLink*>& links)
 
  787    const unsigned n = list.size();
 
  788    const unsigned m = links.size();
 
  791    for (
unsigned i = 0; i < n; i++) {
 
  792      for (
unsigned j = 0; j < m; j++) {
 
  793        if (list[i]->
cell()->
id() == links[j]->
cell()->
id())
 
  796          cout << 
"TCLink::remove !!! not implemented yet" << endl;
 
  806    static bool first = 
true;
 
  810      _nSL = cdc.nSuperLayers();
 
  811      _nSLA = cdc.nAxialSuperLayers();
 
  820                       vector<TRGCDCLink*>* layers)
 
  822    for (
unsigned i = 0; i < links.size(); i++) {
 
  823      const TCCell* c = links[i]->cell();
 
  825        unsigned lid = c->layer().id();
 
  827          layers[lid].push_back(links[i]);
 
  856  TRGCDCLink::operator 
new (
size_t size)
 
  858    void* p = malloc(size);
 
  869  TRGCDCLink::operator 
delete (
void* t)
 
  871    for (vector<TRGCDCLink*>::iterator it = _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.
HepGeom::Point3D< double > _arcZ[4]
arcZ
HepGeom::Point3D< double > _onTrack
position on track
int _zStatus
z status of stereo
const TRGCDCCellHit * _hit
Cell hit object.
HepGeom::Point3D< double > _onWire
position on wire
float _drift[2]
drift distance
TRGCDCLink * _neighbor[7]
neighbor TRGCDCLink
float _dDrift[2]
drift distance error
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.
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 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 unsigned _nSL
...Buffers...
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 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)
static std::vector< TRGCDCLink * > _all
Keeps all TRGCDCLinks created by new().
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.
void dump_base(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
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
static unsigned _nL
...Buffers...
static unsigned * _nHitsSL
...Buffers...
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.
static unsigned _nSLA
...Buffers...
Abstract base class for different kinds of events.