11 #include "CLHEP/Vector/ThreeVector.h" 40 template <
class In,
class Out,
class Pred >
44 typedef typename Pred::hit_type
HitType ;
46 typedef std::vector< GenericCluster<HitType >* > ClusterList ;
53 while( first != last ) {
61 if( pred->mergeHits( (*first) , (*
other) ) ) {
63 if( (*first)->second == 0 && (*other)->second == 0 ) {
72 else if( (*first)->second != 0 && (*other)->second != 0 ) {
77 if( (*first)->second != (*other)->second )
78 (*first)->second->mergeClusters( (*other)->second ) ;
82 if( (*first)->second != 0 ) {
84 (*first)->second->addHit( (*
other) ) ;
88 (*other)->second->addHit( (*first) ) ;
104 if( (*i)->size() > 0 ) {
121 class GenericHit :
public std::pair< T*, GenericCluster<T>* >{
124 typedef std::pair< T*, GenericCluster<T>* >
Pair ;
183 (*it)->second = this ;
195 typedef std::vector< GenericHit<T>* >
Vector ;
207 template <
class T,
class Pred>
210 for(
unsigned int i=0 ; i < vec.size() ; i++ ){
212 T*
hit =
dynamic_cast<T*
>( vec.at(i) ) ;
225 template <
class T,
class Pred,
class Order>
228 for(
unsigned int i=0 ; i < vec.size() ; i++ ){
230 T*
hit =
dynamic_cast<T*
>( vec.at(i) ) ;
243 typedef std::list< GenericCluster<T>* >
List ;
255 template <
class HitClass,
typename PosType >
264 NNDistance(
float dCut) : _dCutSquared( dCut*dCut ) , _dCut(dCut) {}
272 const PosType* pos0 = h0->first->Position() ;
273 const PosType* pos1 = h1->first->Position() ;
276 ( pos0[0] - pos1[0] ) * ( pos0[0] - pos1[0] ) +
277 ( pos0[1] - pos1[1] ) * ( pos0[1] - pos1[1] ) +
278 ( pos0[2] - pos1[2] ) * ( pos0[2] - pos1[2] )
297 inline bool operator() (
T*
hit) {
return hit->Energy() > _eCut ; }
310 template <
class T,
int N>
314 XIndex(
float xmin ,
float xmax ) : _xmin( xmin ), _xmax( xmax ) {}
316 inline int operator() (
T*
hit) {
318 return (
int) std::floor( ( hit->Position()[0] - _xmin ) / ( _xmax - _xmin ) *
N ) ;
343 unsigned n = c->size() ;
347 std::vector<float> tmin;
348 std::vector<float> tmax;
350 std::vector<float>
a,
t,
x,
y,
z;
359 T*
hit = (*hi)->first ;
361 a[i] = hit->Energy() ;
362 t[i] = hit->Time().first ;
363 x[i] = hit->Position()[0] ;
364 y[i] = hit->Position()[1] ;
365 z[i] = hit->Position()[2] ;
367 clu->
addHit( hit , a[i] ) ;
370 float r = std::sqrt(y[i]*y[i] + z[i]*z[i]);
371 if( std::fabs(x[i]) < _xendcap ){
376 tmin.push_back(t[i]);
381 tmax.push_back(t[i]);
386 if( rmin >= std::fabs(x[i]) )
388 rmin = std::fabs(x[i]);
389 tmin.push_back(t[i]);
391 if( rmax <= std::fabs(x[i]) )
393 rmax = std::fabs(x[i]);
394 tmax.push_back(t[i]);
402 auto time_first = std::min_element( tmin.begin(), tmin.end() );
403 assert(time_first != tmin.end());
405 auto time_last = std::min_element( tmax.begin(), tmax.end() );
406 assert(time_last != tmax.end());
410 clu->
setEnergy( cs.getTotalAmplitude() ) ;
411 clu->
setTime( cs.getAverageTime(), *time_first - *time_last ) ;
415 float*
d = cs.getEigenVecInertia() ;
419 CLHEP::Hep3Vector v( d[0], d[1], d[2] ) ;
427 param[0] = cs.getElipsoid_r_forw();
428 param[1] = cs.getElipsoid_r_back();
429 param[2] = cs.getElipsoid_r2() ;
430 param[3] = cs.getElipsoid_r3() ;
431 param[4] = cs.getElipsoid_vol() ;
432 param[5] = cs.getWidth() ;
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
AlgCluster(float xendcap)
void cluster(In first, In last, Out result, Pred *pred)
GenericHit(T *hit, GenericCluster< T > *cl, int index0=0)
void setShape(const float *shape)
std::vector< gar::rec::CaloHit * > CaloHitVec
std::list< GenericCluster< T > * > List
void addToGenericHitVec(GenericHitVec< T > &v, CaloHitVec vec, Pred pred)
void addHit(GenericHit< T > *hit)
void setEigenVectors(const float *eigenvectors)
bool mergeHits(GenericHit< HitClass > *h0, GenericHit< HitClass > *h1)
GenericCluster(GenericHit< T > *hit)
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
void setEnergy(float energy)
std::pair< T *, GenericCluster< T > * > Pair
void setPosition(const float *position)
Detector simulation of raw signals on wires.
void addHit(gar::rec::CaloHit *hit, float contribution)
void mergeClusters(GenericCluster< T > *cl)
General GArSoft Utilities.
void setITheta(float theta)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
second_as<> second
Type of time stored in seconds, in double precision.
XIndex(float xmin, float xmax)
GenericHit(T *hit, int index0=0)
std::vector< GenericHit< T > * > Vector
void setTime(float time, float time_diff)