18#include "CLHEP/Vector/ThreeVector.h"
19#include "TrkReco/TMDC.h"
20#include "TrkReco/TMDCLayer.h"
21#include "TrkReco/TMDCTsf.h"
22#include "TrkReco/TMDCWire.h"
23#include "TrkReco/TMDCWireHit.h"
25#include "CLHEP/Matrix/Vector.h"
28using CLHEP::HepVector;
32TMDC* TMDCTsf::_cdc = 0;
66void TMDCTsf::dump(
const std::string& msg,
const std::string& pre )
const {
68 std::cout <<
"tsf : " << _wires.length() <<
" : ";
69 for (
unsigned i = 0; i < _wires.length(); i++ )
72 std::cout <<
w->layerId() <<
"-" <<
w->localId() <<
", ";
74 std::cout << std::endl;
81 unsigned localId =
w->localLayerId();
82 unsigned superId =
w->superLayerId();
83 unsigned availableLayer =
GMDC->nLocalLayer( superId ) - localId;
86 std::cout <<
"TMDCTsf::create !!! can not create TSF for wire ";
87 std::cout << superId <<
"-" << localId <<
" because of ";
88 std::cout <<
"lack of layer(s)." << std::endl;
91 availableLayer = ( availableLayer > offset.length() ) ? offset.length() : availableLayer;
94 bool offsetLayer =
false;
95 if (
w->layer()->offset() != 0. ) offsetLayer =
true;
98 for (
unsigned l = 0; l < availableLayer; l++ )
100 unsigned absLayerId =
w->layerId() + l;
102 wireId[0] =
w->localId() + ( *offset[l] );
103 wireId[1] =
w->localId() + ( *offset[l] );
104 if ( offsetLayer ) ++wireId[1];
107 for (
unsigned j = 0; j < *( width[l] ); j++ )
108 { _wires.append( (TMDCWire*)
GMDC->
wire( absLayerId, wireId[l % 2] + j ) ); }
192 _all.append( links );
196 for (
int i = 0; i < _all.length(); ++i )
198 if ( _all[i]->wire()->localLayerId() == 0 ) seeds1.append( _all[i] );
199 else if ( _all[i]->wire()->localLayerId() == 1 ) seeds2.append( _all[i] );
203 unsigned n = list.length();
206 for (
unsigned i = 0; i <
n; ++i )
208 seedNeighbors.removeAll();
212 for (
int j = 0; j < c->
links().length(); ++j )
214 if ( c->
links()[j]->wire()->localLayerId() > 0 )
continue;
215 unsigned seedId = c->
links()[j]->wire()->localId();
216 for (
int k = 0; k < seeds1.length(); ++k )
218 if ( seeds1[k]->wire()->localIdForPlus() + 1 == seedId ||
219 seeds1[k]->wire()->localIdForMinus() - 1 == seedId )
220 seedNeighbors.append( seeds1[k] );
227 splitted.append( c );
228 if ( newClusters.length() == 0 )
continue;
229 list.append( newClusters );
231 list.remove( splitted );
232 HepAListDeleteAll( splitted );
239 for (
unsigned i = 0; i <
n; ++i )
241 seedNeighbors.removeAll();
245 for (
int j = 0; j < c->
links().length(); ++j )
247 if ( c->
links()[j]->wire()->localLayerId() != 1 )
continue;
248 unsigned seedId = c->
links()[j]->wire()->localId();
249 for (
int k = 0; k < seeds2.length(); ++k )
251 if ( seeds2[k]->wire()->localIdForPlus() + 1 == seedId ||
252 seeds2[k]->wire()->localIdForMinus() - 1 == seedId )
253 seedNeighbors.append( seeds2[k] );
260 splitted2.append( c );
261 if ( newClusters2.length() == 0 )
continue;
262 list2.append( newClusters2 );
264 list2.remove( splitted2 );
265 HepAListDeleteAll( splitted2 );
268 list.append( list2 );
272 for (
int i = 0; i < list.length(); ++i )
274 for (
int j = i + 1; j < list.length(); ++j )
278 for (
int k = 0; k < links.length(); ++k )
281 if ( list[i]->links().hasMember( l ) ) multiLinks.append( l );
283 if ( multiLinks.length() < 2 )
continue;
284 unsigned minLength = links.length();
285 if ( links.length() > list[i]->links().length() ) minLength = list[i]->links().length();
286 if ( minLength - multiLinks.length() > 1 )
continue;
287 int nHits[4] = { 0 };
289 for (
int k = 0; k < multiLinks.length(); ++k )
290 ++nHits[multiLinks[k]->hit()->wire()->localLayerId()];
291 for (
int k = 0; k < 4; ++k )
292 if ( nHits[k] > 0 ) ++multiLayers;
293 if ( multiLayers >= 2 && ( links.length() > list[i]->links().length() ) )
294 badList.append( list[i] );
295 else if ( multiLayers >= 2 ) badList.append( list[j] );
299 list.remove( badList );
302 for (
int i = 0; i < badList.length(); ++i )
305 for (
int j = 0; j < bads.length(); ++j )
307 unsigned n = bads[j]->tsfTag();
308 if (
n == 0 )
continue;
312 bads[j]->tsfTag(
n );
316 HepAListDeleteAll( badList );
328 unsigned n = _all.length();
329 if (
n < 3 )
return list;
330 if ( seedlayer == 1 && _sl == 10 )
return list;
332 for (
unsigned i = 0; i <
n; ++i )
340 for (
unsigned i = 0; i < seeds.length(); ++i )
347 float phi0 = _cdc->layer( lId )->offset();
348 int nWir = (int)_cdc->layer( lId )->nWires();
349 float phi = phi0 + local * 2 *
M_PI / nWir;
351 forSegment.append( seed );
354 int hitsOnLayer[3] = { 0, 0, 0 };
356 for (
unsigned m = 0; m < exhits.length(); ++m )
362 float phi0tmp = _cdc->layer( tmpId )->offset();
363 int nWirtmp = (int)_cdc->layer( tmpId )->nWires();
365 (int)( ( phi - phi0tmp ) / ( 2 *
M_PI / nWirtmp ) );
368 int diff =
abs( tmpLocal - localOffset );
370 if ( diff > nWirtmp / 2 ) diff = nWirtmp - diff;
374 if ( diff > lLayer + 2 )
continue;
386 .dot( -seed->
position().unit() ) ) ) < _angle )
388 forSegment.append( l );
389 ++hitsOnLayer[lLayer - 1 - seedlayer];
395 for (
unsigned j = 0; j < 3; ++j )
397 if ( hitsOnLayer[j] > 0 ) ++fireLayers;
399 if ( fireLayers < 2 ) {
continue; }
400 list.append(
new TSegment( forSegment ) );
405double TMDCTsf::alpha(
unsigned sl,
TMLink* seed )
const {
406 double radius[11] = { 11.525, 16.160, 24.555, 31.060, 37.455, 44.760,
407 51.370, 57.855, 64.165, 71.570, 76.345 };
410 if ( sl < 2 ) rcell = 0.6;
412 pa.set( 0, 2 / radius[sl], 0 );
413 pb.set( -2 * rcell / ( rcell * rcell + ( radius[sl] + rcell ) * ( radius[sl] + rcell ) ),
414 2 * ( radius[sl] + rcell ) /
415 ( rcell * rcell + ( radius[sl] + rcell ) * ( radius[sl] + rcell ) ),
417 pc.set( 2 * rcell / ( rcell * rcell + ( radius[sl] + rcell ) * ( radius[sl] + rcell ) ),
418 2 * ( radius[sl] + rcell ) /
419 ( rcell * rcell + ( radius[sl] + rcell ) * ( radius[sl] + rcell ) ),
421 cout <<
"sl = " << sl
422 <<
"alpha2 = " << acos( ( pb - pa ).
unit().dot( ( pc - pa ).
unit() ) ) / 2 << endl;
424 pa2.set( 0, 2 / radius[sl], 0 );
425 pb2.set( -6 * rcell /
426 ( 9 * rcell * rcell + ( radius[sl] + rcell ) * ( radius[sl] + rcell ) ),
427 2 * ( radius[sl] + rcell ) /
428 ( 9 * rcell * rcell + ( radius[sl] + rcell ) * ( radius[sl] + rcell ) ),
430 pc2.set( 6 * rcell / ( 9 * rcell * rcell + ( radius[sl] + rcell ) * ( radius[sl] + rcell ) ),
431 2 * ( radius[sl] + rcell ) /
432 ( 9 * rcell * rcell + ( radius[sl] + rcell ) * ( radius[sl] + rcell ) ),
434 cout <<
"alpha22 = " << acos( ( pb2 - pa2 ).
unit().dot( ( pc2 - pa2 ).
unit() ) ) / 2 << endl;
HepGeom::Point3D< double > HepPoint3D
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per saves r n generator level $ !Flag for chat level in !Latex Output unit
#define TMDCTSF_MIN_LAYERS
TMDCTsf(unsigned sl)
Constructor of fixed shape.
AList< TSegment > createTsf(unsigned) const
AList< TSegment > segments(const AList< TMLink > &links)
finds segments.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
void solveLeftRight(void)
solves left-right ambiguityies.
virtual ~TMDCTsf()
Destructor.
A class to represent a wire in MDC.
unsigned localLayerId(void) const
returns local layer id in a super layer.
unsigned localId(void) const
returns local id in a wire layer.
unsigned layerId(void) const
returns layer id.
const TMDCWire *const wire(unsigned wireId) const
returns a pointer to a wire. 0 will be returned if 'wireId' is invalid.
static TMDC * getTMDC(void)
A class to relate TMDCWireHit and TTrack objects.
const HepPoint3D & position(void) const
returns position.
const TMDCWire *const wire(void) const
returns a pointer to a wire.
A class to relate TMDCWireHit and TTrack objects.
AList< TSegment > splitTsf(AList< TMLink > &)
const AList< TMLink > & links(unsigned mask=0) const