17#include "GaudiKernel/MsgStream.h"
18#include "CLHEP/Vector/ThreeVector.h"
19#include "CLHEP/Units/SystemOfUnits.h"
32(
const std::string& t,
const std::string& n,
const IInterface* p)
35 declareInterface<ITRT_SeededSpacePointFinder>(
this);
61 msg(MSG::FATAL) <<
"Failed to retrieve RegionSelector Service";
68 msg(MSG::ERROR) <<
"Could not get SCT_ID helper !" <<
endmsg;
69 return StatusCode::FAILURE;
75 msg(MSG::ERROR) <<
"Could not get TRT_ID helper !" <<
endmsg;
76 return StatusCode::FAILURE;
93 StatusCode
sc = AthAlgTool::finalize();
103(
const std::vector<IdentifierHash>& ,
const std::vector<IdentifierHash>& )
const
108std::list<std::pair<const Trk::SpacePoint*, const Trk::SpacePoint*> >
133 msg(MSG::VERBOSE) <<
"Enter getListOfSpacePointPairs, TrackParameter given is: " <<
endmsg;
134 msg(MSG::VERBOSE) << directionTRT <<
endmsg;
138 std::list<std::pair<const Trk::SpacePoint*, const Trk::SpacePoint*> > listOfSpacePointPairsBuffer;
141 std::set<IdentifierHash> setOfSCT_Hashes;
147 msg(MSG::VERBOSE) <<
"Retrieved " << setOfSCT_Hashes.size() <<
" potentially interesting detector elements." <<
endmsg;
150 if ( !
m_useROI || !setOfSCT_Hashes.empty())
153 std::multimap<int,const Trk::SpacePoint*> relevantSpacePoints;
159 msg(MSG::VERBOSE) <<
"Retrieved " << relevantSpacePoints.size() <<
" potentially interesting SpacePoints" <<
endmsg;
162 combineSpacePoints(relevantSpacePoints, directionTRT, modulTRT, listOfSpacePointPairsBuffer);
168 msg(MSG::VERBOSE) <<
"------------------------------------------------------------------------------------------" <<
endmsg;
169 msg(MSG::VERBOSE) <<
"Final SpacePoint pairs: " << listOfSpacePointPairsBuffer.size() <<
endmsg;
170 msg(MSG::VERBOSE) <<
" Position of initial vector: ( " << r0.x() <<
", " << r0.y() <<
", "<< r0.z() <<
" ) " <<
endmsg;
171 msg(MSG::VERBOSE) <<
" Direction of initial vector: ( " << v0.unit().x() <<
", " << v0.unit().y() <<
", "<< v0.unit().z() <<
" ) , phi = "
172 << v0.phi() <<
" theta = " << v0.theta() <<
" eta = "<< v0.eta() <<
endmsg;
173 msg(MSG::VERBOSE) <<
"------------------------------------------------------------------------------------------" <<
endmsg;
174 msg(MSG::VERBOSE) <<
" Direction of space Point vectors: "<<
endmsg;
175 msg(MSG::VERBOSE) <<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " <<
endmsg;
176 for (
auto & it : listOfSpacePointPairsBuffer)
181 msg(MSG::VERBOSE) <<
" Positions: ( " << s1.x() <<
" , "<< s1.y() <<
" , "<< s1.z() <<
" ) " <<
endmsg;
182 msg(MSG::VERBOSE) <<
" ( " << s2.x() <<
" , "<< s2.y() <<
" , "<< s2.z() <<
" ) " <<
endmsg;
183 msg(MSG::VERBOSE) <<
" direction: ( "
184 << s1s2.unit().x() <<
", " << s1s2.unit().y() <<
", " << s1s2.unit().z() <<
" ) , phi = "
185 << s1s2.phi() <<
" theta = " << s1s2.theta() <<
" eta = "<< s1s2.eta() <<
endmsg;
186 msg(MSG::VERBOSE) <<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " <<
endmsg;
188 msg(MSG::VERBOSE) <<
"------------------------------------------------------------------------------------------" <<
endmsg;
191 return listOfSpacePointPairsBuffer;
209 double deltaEta = 0.;
216 std::vector<IdentifierHash> listOfSCT_Hashes;
224 for (
auto listOfSCT_Hashe : listOfSCT_Hashes)
225 setOfSCT_Hashes.insert(listOfSCT_Hashe);
231 std::set<IdentifierHash>& setOfSCT_Hashes,
232 int modulTRT, std::multimap<
int,
252 const std::set<IdentifierHash>::const_iterator endSCT_Hashes = setOfSCT_Hashes.end();
258 if (!prd_to_track_map.
isValid()) {
261 prd_to_track_map_cptr = prd_to_track_map.
cptr();
271 for(; itCont != endCont; ++itCont)
273 bool acceptCollection =
true;
279 acceptCollection = ( idHash.
is_valid() && setOfSCT_Hashes.find( idHash ) != endSCT_Hashes );
282 int SCT_LayerNumber = -99;
283 if (acceptCollection)
287 int detRegionIndex =
m_sctId->barrel_ec(
id) ;
288 if ( detRegionIndex == -2 || detRegionIndex == 0 || detRegionIndex == 2 )
291 int detLayerOffset = 1;
292 int detLayerSign = 1;
293 if (detRegionIndex == 0) detLayerOffset = 10;
294 if (detRegionIndex == -2) detLayerSign = -1;
297 int detLayerIndex =
m_sctId->layer_disk(
id);
298 SCT_LayerNumber = detLayerSign*(detLayerIndex+detLayerOffset);
302 msg(MSG::VERBOSE) <<
"detRegionIndex " << detRegionIndex <<
" recieved. " <<
endmsg;
303 acceptCollection =
false;
307 if (acceptCollection)
309 if (modulTRT > -14 && modulTRT < 15 )
316 msg(MSG::WARNING) <<
"Received TRTmodul number " << modulTRT <<
endmsg;
317 acceptCollection =
false;
321 if (acceptCollection)
326 for(; itColl != endColl; ++itColl)
327 if ( !prd_to_track_map_cptr
328 || !( prd_to_track_map_cptr->
isUsed(*((*itColl)->clusterList().first))
329 || prd_to_track_map_cptr->
isUsed(*((*itColl)->clusterList().second)) ) )
331 relevantSpacePoints.insert(std::make_pair( SCT_LayerNumber ,*itColl));
332 msg(MSG::VERBOSE) <<
"Added SpacePoint for layer " << SCT_LayerNumber <<
" at ( "
333 << (*itColl)->globalPosition().x() <<
" , "
334 << (*itColl)->globalPosition().y() <<
" , "
335 << (*itColl)->globalPosition().z() <<
" ) " <<
endmsg;
343 if(spacepointsOverlap.
isValid())
349 for (; itColl != endColl; ++itColl)
352 std::pair<IdentifierHash, IdentifierHash> idHashPair = (*itColl)->elementIdList();
354 || (idHashPair.first.is_valid() && setOfSCT_Hashes.find( idHashPair.first ) != endSCT_Hashes)
355 || (idHashPair.second.is_valid() && setOfSCT_Hashes.find( idHashPair.second ) != endSCT_Hashes) )
359 if(prd_to_track_map_cptr)
364 u1=prd_to_track_map->isUsed(*p1);
366 u2=prd_to_track_map->isUsed(*p2);
367 if(u1 || u2)
continue;
371 Identifier id = (*itColl)->associatedSurface().associatedDetectorElementIdentifier();
374 int detRegionIndex =
m_sctId->barrel_ec(
id) ;
375 if ( detRegionIndex == -2 || detRegionIndex == 0 || detRegionIndex == 2 )
377 int detLayerOffset = 1;
378 int detLayerSign = 1;
379 if (detRegionIndex == 0) detLayerOffset = 10;
380 if (detRegionIndex == -2) detLayerSign = -1;
381 int detLayerIndex =
m_sctId->layer_disk(
id);
383 relevantSpacePoints.insert(std::make_pair(detLayerSign*(detLayerIndex+detLayerOffset),*itColl));
384 msg(MSG::VERBOSE) <<
"Added OverlapSpacePoint for layer " << detLayerSign*(detLayerIndex+detLayerOffset) <<
" at ( "
385 << (*itColl)->globalPosition().x() <<
" , "
386 << (*itColl)->globalPosition().y() <<
" , "
387 << (*itColl)->globalPosition().z() <<
" ) " <<
endmsg;
390 msg(MSG::VERBOSE) <<
"detRegionIndex " << detRegionIndex <<
" recieved. " <<
endmsg;
393 msg(MSG::DEBUG) <<
"Invalid Id from OverlapCollection recieved. " <<
endmsg;
419 std::list<std::pair<const Trk::SpacePoint*, const Trk::SpacePoint*> > &listOfSpacePointPairsBuffer)
const
437 for ( ; itTable != endTable ; ++itTable)
439 msg(MSG::VERBOSE) <<
" Combining Space Poinst from modules " << itTable->first <<
" and " << itTable->second <<
endmsg;
441 std::pair< std::multimap<int,const Trk::SpacePoint*>::const_iterator,
442 std::multimap<int,const Trk::SpacePoint*>::const_iterator >
443 range1 = relevantSpacePoints.equal_range(itTable->first);
447 std::pair< std::multimap<int,const Trk::SpacePoint*>::const_iterator,
448 std::multimap<int,const Trk::SpacePoint*>::const_iterator >
449 range2 = relevantSpacePoints.equal_range(itTable->second);
453 for ( std::multimap<int,const Trk::SpacePoint*>::const_iterator it1 = range1.first;
454 it1 != range1.second ; ++it1 )
455 for ( std::multimap<int,const Trk::SpacePoint*>::const_iterator it2 = range2.first;
456 it2 != range2.second ; ++it2 )
457 if (
pairIsOk(it1->second,it2->second,directionTRT) )
458 listOfSpacePointPairsBuffer.emplace_back(it2->second,it1->second);
463 msg(MSG::WARNING) <<
"TRT module not in look-up table --> no SP pairs formed" <<
endmsg;
485 msg(MSG::VERBOSE) <<
"Checking Space Point Pair at ( "<< s1.x() <<
", " << s1.y() <<
", " << s1.z()
486 <<
" ) and ( "<< s2.x() <<
", " << s2.y() <<
", " << s2.z() <<
" )" <<
endmsg;
489 double t = ( s1.x()-s2.x() )*( s1.x()-s2.x() ) + ( s1.y()-s2.y() )*( s1.y()-s2.y() ) ;
492 t = ( s1.x()*(s2.x()-s1.x()) + s1.y()*(s2.y()-s1.y()) ) / t;
494 msg(MSG::VERBOSE) <<
" closest approach to beam-pipe at ( "<< perigee.x() <<
", " << perigee.y() <<
", " << perigee.z() <<
" ) transversal: " << perigee.perp()<<
endmsg;
497 msg(MSG::VERBOSE) <<
" Passed cut on r-phi impact parameter" <<
endmsg;
501 double diffPhi= std::abs(s1s2.phi()-v0.phi());
503 if (diffPhi > CLHEP::pi ) diffPhi = 2.*CLHEP::pi - diffPhi;
504 if (diffPhi > CLHEP::pi/2. ) diffPhi = CLHEP::pi - diffPhi;
505 msg(MSG::VERBOSE) <<
"Phi directions differ by "<< diffPhi <<
endmsg;
508 msg(MSG::VERBOSE) <<
" Passed cut on direction phi deviation" <<
endmsg;
586 for (
int i = 2; i<4 ; ++ i)
616 for (
int i = 4 ; i < 7 ; ++i )
652 for (
int i = 7 ; i < 10 ; ++i)
678 for (
int i = 10 ; i < 13 ; ++i )
702 for (
int i = 13 ; i < 15 ; ++i )
726 for (
int iTable = 1 ; iTable < 15 ; ++iTable )
730 for ( ; itList != endList ; ++itList )
732 int i = itList->first;
733 int j = itList->second;
741 for (
int iTable = -14 ; iTable < 15 ; ++iTable )
745 for ( ; itList != endList ; ++itList )
760 out <<
"to be implemented soon..." << std::endl;
768 out <<
"to be implemented soon..." << std::endl;
780 msg(MSG::VERBOSE) <<
"=====================================================================================================================" <<
endmsg;
781 msg(MSG::VERBOSE) <<
" Module Lookup table: " <<
endmsg;
782 msg(MSG::VERBOSE) <<
"---------------------------------------------------------------------------------------------------------------------" <<
endmsg;
783 for (
int i = -14; i<15 ; ++i)
785 msg(MSG::VERBOSE) <<
"Module "<< i <<
" : " <<
endmsg;
788 for ( ; itList != endList ; ++itList )
789 msg(MSG::VERBOSE) <<
" (" << itList->first <<
", " << itList->second <<
") " ;
793 msg(MSG::VERBOSE) <<
"Needs Layers: { " ;
794 for ( ; itIndex != endIndex ; ++ itIndex )
795 msg(MSG::VERBOSE) << *itIndex <<
", " ;
797 msg(MSG::VERBOSE) <<
"...................................................................................................................." <<
endmsg;
800 msg(MSG::VERBOSE) <<
"=====================================================================================================================" <<
endmsg;
819 msg(MSG::WARNING) <<
" Id not valid "<<
endmsg;
823 int detRegionIndex =
m_trtId->barrel_ec(
id) ;
824 if ( detRegionIndex == -1 || detRegionIndex == 1 )
826 else if ( detRegionIndex == -2 || detRegionIndex == 2 )
828 modulNumber =
m_trtId->layer_or_wheel(
id) + 1 ;
829 modulNumber *= (detRegionIndex/2) ;
833 msg(MSG::WARNING) <<
"TRT barrel-endcap id not in {-2;-1;1;2}" <<
endmsg;
Scalar eta() const
pseudorapidity method
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
This is an Identifier helper class for the SCT subdetector.
#define SIMPLE_TRT_INDEX_OFFSET
This is an Identifier helper class for the TRT subdetector.
const ServiceHandle< StoreGateSvc > & detStore() const
DataModel_detail::const_iterator< DataVector > const_iterator
This is a "hash" representation of an Identifier.
bool is_valid() const
Check if id is in a valid state.
void combineSpacePoints(const std::multimap< int, const Trk::SpacePoint * > &relevantSpacePoints, const Trk::TrackParameters &directionTRT, int modulTRT, std::list< std::pair< const Trk::SpacePoint *, const Trk::SpacePoint * > > &listOfSpacePointPairsBuffer) const
builds pairs of SP according to the kook-up table
SimpleTRT_SeededSpacePointFinder_ATL(const std::string &, const std::string &, const IInterface *)
ToolHandle< IRegSelTool > m_pRegionSelector
Region Selector.
static void getSearchRange(double &deltaPhi, double &deltaEta)
List with SP pairs as seed for the Si part of the back-track.
virtual StatusCode initialize() override
IntegerProperty m_maxHoles
controls how many not considered SCT layers are allowed between two SP in order to form a seed pair
void getSpacePointsInROI(const EventContext &ctx, std::set< IdentifierHash > &setOfSCT_Hashes, int modulTRT, std::multimap< int, const Trk::SpacePoint * > &relevantSpacePoints) const
retrieves SP Collections of modules in the ROI and sorts them by SCT layer
const SCT_ID * m_sctId
ID SCT helper.
bool pairIsOk(const Trk::SpacePoint *sp1, const Trk::SpacePoint *sp2, const Trk::TrackParameters &directionTRT) const
applies rough cuts on the quality of a SP pair
BooleanProperty m_useROI
Controls, if SP have to be checked with the AssociationTool of the forward tracking and to avoid doub...
void printLookupTable() const
std::set< int > m_modulLookupTableIndex[2 *SIMPLE_TRT_INDEX_OFFSET+1]
const TRT_ID * m_trtId
ID TRT helper.
std::list< std::pair< const Trk::SpacePoint *, const Trk::SpacePoint * > > find2Sp(const EventContext &ctx, const Trk::TrackParameters &, InDet::ITRT_SeededSpacePointFinder::IEventData &event_data) const override
main method, calls the private methods and returns a pointer to the list of SpacePointpairs.
SG::ReadHandleKey< SpacePointContainer > m_spacepointsSCTname
virtual std::unique_ptr< InDet::ITRT_SeededSpacePointFinder::IEventData > newRegion(const std::vector< IdentifierHash > &, const std::vector< IdentifierHash > &) const override
void setupLookUpTable()
the name says it
SG::ReadHandleKey< SpacePointOverlapCollection > m_spacepointsOverlapname
virtual ~SimpleTRT_SeededSpacePointFinder_ATL()
virtual StatusCode finalize() override
DoubleProperty m_perigeeCut
rough cuts on the quality of the suggested SP pair
void getHashesInROI(const EventContext &ctx, const Trk::TrackParameters &directionTRT, std::set< IdentifierHash > &setOfSCT_Hashes) const
obtains the hashes of modules in the ROI
int TRT_Module(const Trk::TrackParameters &directionTRT) const
returns the number of the TRT wheel or barrel where the TP belongs to
modulLookupTable m_modulLookupTable[2 *SIMPLE_TRT_INDEX_OFFSET+1]
Lookup table that contains the SCT Layers to be considered to provide SP for the pairing in dependenc...
SG::ReadHandleKey< Trk::PRDtoTrackMap > m_prdToTrackMap
DoubleProperty m_directionPhiCut
MsgStream & dump(MsgStream &out) const override
Describes the Region of Ineterest geometry It has basically 9 parameters.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
bool isUsed(const PrepRawData &prd) const
does this PRD belong to at least one track?
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
virtual const Amg::Vector3D & globalPosition() const override final
Interface method to get the global Position.
Identifier associatedDetectorElementIdentifier() const
return Identifier of the associated Detector Element
Eigen::Matrix< double, 3, 1 > Vector3D
ParametersBase< TrackParametersDim, Charged > TrackParameters