11#include <tracking/dataobjects/FullSecID.h>
13#include <tracking/spacePointCreation/SpacePoint.h>
15#include <tracking/trackFindingVXD/filterMap/twoHitVariables/Distance1DZ.h>
16#include <tracking/trackFindingVXD/filterMap/twoHitVariables/Distance3DNormed.h>
17#include <tracking/trackFindingVXD/filterMap/twoHitVariables/DistanceInTimeUside.h>
18#include <tracking/trackFindingVXD/filterMap/twoHitVariables/DistanceInTimeVside.h>
19#include <tracking/trackFindingVXD/filterMap/twoHitVariables/SlopeRZ.h>
20#include <tracking/trackFindingVXD/filterMap/twoHitVariables/Distance1DZSquared.h>
21#include <tracking/trackFindingVXD/filterMap/twoHitVariables/Distance2DXYSquared.h>
22#include <tracking/trackFindingVXD/filterMap/twoHitVariables/Distance3DSquared.h>
24#include <tracking/trackFindingVXD/filterMap/threeHitVariables/DistanceInTime.h>
25#include <tracking/trackFindingVXD/filterMap/threeHitVariables/Angle3DSimple.h>
26#include <tracking/trackFindingVXD/filterMap/threeHitVariables/CosAngleXY.h>
27#include <tracking/trackFindingVXD/filterMap/threeHitVariables/AngleRZSimple.h>
28#include <tracking/trackFindingVXD/filterMap/threeHitVariables/CircleDist2IP.h>
29#include <tracking/trackFindingVXD/filterMap/threeHitVariables/DeltaSlopeRZ.h>
30#include <tracking/trackFindingVXD/filterMap/threeHitVariables/DeltaSlopeZoverS.h>
31#include <tracking/trackFindingVXD/filterMap/threeHitVariables/DeltaSoverZ.h>
32#include <tracking/trackFindingVXD/filterMap/threeHitVariables/HelixParameterFit.h>
33#include <tracking/trackFindingVXD/filterMap/threeHitVariables/Pt.h>
34#include <tracking/trackFindingVXD/filterMap/threeHitVariables/CircleRadius.h>
36#include <tracking/trackFindingVXD/filterMap/filterFramework/Shortcuts.h>
37#include <tracking/trackFindingVXD/filterTools/ObserverPrintResults.h>
38#include <tracking/trackFindingVXD/filterMap/filterFramework/VoidObserver.h>
40#include <tracking/dataobjects/SectorMapConfig.h>
42#include <framework/logging/Logger.h>
44#include <vxd/dataobjects/VxdID.h>
45#include <tracking/trackFindingVXD/filterMap/map/CompactSecIDs.h>
46#include <tracking/trackFindingVXD/segmentNetwork/StaticSector.h>
62 template<
class po
int_t>
74 0. <= DistanceInTimeUside<point_t>() <= 0. &&
75 0. <= DistanceInTimeVside<point_t>() <= 0. &&
76 0. <= Distance3DSquared<point_t>() <= 0.&&
77 0. <= Distance2DXYSquared<point_t>() <= 0.&&
78 0. <= Distance1DZ<point_t>() <= 0.&&
79 0. <= SlopeRZ<point_t>() <= 0.&&
80 0. <= Distance3DNormed<point_t>() <= 0.
100 0. <= DistanceInTime<point_t>() <= 0. &&
101 0. <= Angle3DSimple<point_t>() <= 0.&&
102 0. <= CosAngleXY<point_t>() <= 0.&&
103 0. <= AngleRZSimple<point_t>() <= 0.&&
104 CircleDist2IP<point_t>() <= 0.&&
105 0. <= DeltaSlopeRZ<point_t>() <= 0.&&
106 0. <= DeltaSlopeZoverS<point_t>() <= 0.&&
107 0. <= DeltaSoverZ<point_t>() <= 0.&&
108 0. <= HelixParameterFit<point_t>() <= 0.&&
109 0. <= Pt<point_t>() <= 0.&&
110 0. <= CircleRadius<point_t>() <= 0.
143 const std::vector<double>& normalizedVsup,
144 const std::vector< std::vector<FullSecID> >& sectorIds)
151 if ((
int) addedSectors != ((
int) normalizedVsup.size() + 1) *
152 ((
int) normalizedUsup.size() + 1))
153 return addedSectors ;
157 for (
auto secIDrow : sectorIds)
158 for (
auto secID : secIDrow) {
169 }
catch (...) {
return addedSectors ; }
223 if (sectorPosition == 0)
return nullptr;
238 if (staticSector ==
nullptr)
240 const auto* filterPtr = staticSector->getFilter2sp(inner);
241 if (filterPtr ==
nullptr)
249 double normalizedU,
double normalizedV)
const
252 normalizedU, normalizedV);
311 B2FATAL(
"Trying to modify a locked filter! A locked filter is not supposed to be changed anymore!");
333 B2FATAL(
"Trying to modify a locked filter! A locked filter is not supposed to be changed anymore!");
339 if (sectorPosition == 0)
return false;
341 if (!staticsector)
return false;
361 B2FATAL(
"Trying to modify a locked filter! A locked filter is not supposed to be changed anymore!");
365 if (staticSector ==
nullptr)
continue;
366 staticSector->modify2SPFilters(adjustFunctions);
378 B2FATAL(
"Trying to modify a locked filter! A locked filter is not supposed to be changed anymore!");
382 if (staticSector ==
nullptr)
continue;
383 staticSector->modify3SPFilters(adjustFunctions);
393 UInt_t layer, ladder, sensor;
394 tree->Branch(
"layer", & layer,
"layer/i");
395 tree->Branch(
"ladder", & ladder,
"ladder/i");
396 tree->Branch(
"sensor", & sensor,
"sensor/i");
398 std::vector< double >* normalizedUsup =
new std::vector< double> ();
399 tree->Branch(
"normalizedUsup", & normalizedUsup);
401 std::vector< double >* normalizedVsup =
new std::vector< double> ({1., 2., 3., 4.});
402 tree->Branch(
"normalizedVsup", & normalizedVsup);
404 std::vector< std::vector< unsigned int > >* fullSecIDs =
405 new std::vector< std::vector< unsigned int > > ();
406 tree->Branch(
"fullSecID", & fullSecIDs);
409 for (layer = 0 ; layer < nOfLayers ; layer ++) {
411 for (ladder = 0; ladder < nOfLadders ; ladder ++) {
413 for (sensor = 0; sensor < nOfSensors ; sensor ++) {
414 normalizedUsup->clear();
415 normalizedVsup->clear();
417 auto sectorsOnSensor =
419 sectorsOnSensor.get(normalizedUsup, normalizedVsup, fullSecIDs);
424 delete normalizedVsup;
425 delete normalizedUsup;
433 TString treeName = *dirName;
434 treeName.Append(
"/");
436 TTree* tree = (TTree*) gFile->Get(treeName);
437 UInt_t layer, ladder, sensor;
438 if (tree->SetBranchAddress(
"layer", & layer) < 0) B2FATAL(
"VXDTFFilters: invalid branch address");
439 if (tree->SetBranchAddress(
"ladder", & ladder) < 0) B2FATAL(
"VXDTFFilters: invalid branch address");
440 if (tree->SetBranchAddress(
"sensor", & sensor) < 0) B2FATAL(
"VXDTFFilters: invalid branch address");
442 std::vector< double >* normalizedUsup =
new std::vector< double> ();
443 if (tree->SetBranchAddress(
"normalizedUsup", & normalizedUsup) < 0) B2FATAL(
"VXDTFFilters: invalid branch address");
445 std::vector< double >* normalizedVsup =
new std::vector< double> ({1., 2., 3., 4.});
446 if (tree->SetBranchAddress(
"normalizedVsup", & normalizedVsup) < 0) B2FATAL(
"VXDTFFilters: invalid branch address");
448 std::vector< std::vector< unsigned int > >* fullSecIDs =
449 new std::vector< std::vector< unsigned int > > ();
450 if (tree->SetBranchAddress(
"fullSecID", & fullSecIDs) < 0) B2FATAL(
"VXDTFFilters: invalid branch address");
453 for (Long64_t i = 0; i < tree->GetEntries() ; i++) {
460 delete normalizedVsup;
461 delete normalizedUsup;
470 TTree* sp2tree =
new TTree(
"SegmentFilters",
"SegmentFilters");
472 twoHitFilter.persist(sp2tree,
"filter");
474 unsigned int outerFullSecID2sp, innerFullSecID2sp;
475 sp2tree->Branch(
"outerFullSecID", & outerFullSecID2sp);
476 sp2tree->Branch(
"innerFullSecID", & innerFullSecID2sp);
479 TTree* sp3tree =
new TTree(
"TripletsFilters",
"TripletFilters");
481 threeHitFilter.persist(sp3tree,
"filter");
483 unsigned int outerFullSecID3sp, centerFullSecID3sp,
485 sp3tree->Branch(
"outerFullSecID", & outerFullSecID3sp);
486 sp3tree->Branch(
"centerFullSecID", & centerFullSecID3sp);
487 sp3tree->Branch(
"innerFullSecID", & innerFullSecID3sp);
490 if (staticSector ==
nullptr)
495 outerFullSecID3sp = outerFullSecID2sp = staticSector->getFullSecID();
496 auto segmentFilters = staticSector->getAllFilters2sp();
497 for (
auto compactIdFilterPair : segmentFilters) {
498 auto innerCompactId = compactIdFilterPair.first;
499 innerFullSecID2sp =
getFullID(innerCompactId);
500 twoHitFilter = compactIdFilterPair.second;
504 auto tripletFilters = staticSector->getAllFilters3sp();
505 for (
auto compactIdFilterPair : tripletFilters) {
508 centerFullSecID3sp =
getFullID(id_center);
510 threeHitFilter = compactIdFilterPair.second;
523 TString sp2treeName = *dirName;
524 sp2treeName.Append(
"/SegmentFilters");
525 TTree* sp2tree = (TTree*) gFile->Get(sp2treeName);
530 twoHitFilter.setBranchAddress(sp2tree,
"filter");
532 unsigned int outerFullSecID2sp, innerFullSecID2sp;
533 if (sp2tree->SetBranchAddress(
"outerFullSecID", & outerFullSecID2sp) < 0) B2FATAL(
"VXDTFFilters: invalid branch address");
534 if (sp2tree->SetBranchAddress(
"innerFullSecID", & innerFullSecID2sp) < 0) B2FATAL(
"VXDTFFilters: invalid branch address");
536 for (Long64_t i = 0 ; i < sp2tree->GetEntries() ; i++) {
537 sp2tree->GetEntry(i);
540 FullSecID outer_secid_2sp(outerFullSecID2sp);
541 FullSecID inner_secid_2sp(innerFullSecID2sp);
544 B2WARNING(
"Outer sector is not on outer layer! Not adding this filter. \"Outer\" layer number: "
556 TString sp3treeName = *dirName;
557 sp3treeName.Append(
"/TripletsFilters");
558 TTree* sp3tree = (TTree*) gFile->Get(sp3treeName);
562 threeHitFilter.setBranchAddress(sp3tree,
"filter");
564 unsigned int outerFullSecID3sp, centerFullSecID3sp,
566 if (sp3tree->SetBranchAddress(
"outerFullSecID", & outerFullSecID3sp) < 0) B2FATAL(
"VXDTFFilters: invalid branch address");
567 if (sp3tree->SetBranchAddress(
"centerFullSecID", & centerFullSecID3sp) < 0) B2FATAL(
"VXDTFFilters: invalid branch address");
568 if (sp3tree->SetBranchAddress(
"innerFullSecID", & innerFullSecID3sp) < 0) B2FATAL(
"VXDTFFilters: invalid branch address");
570 for (Long64_t i = 0 ; i < sp3tree->GetEntries() ; i++) {
571 sp3tree->GetEntry(i);
574 FullSecID outer_secid_3sp(outerFullSecID3sp);
575 FullSecID center_secid_3sp(centerFullSecID3sp);
576 FullSecID inner_secid_3sp(innerFullSecID3sp);
580 B2WARNING(
"Layers not in the correct order for Triplet filter! Will not add filter! Outer layer number: " <<
601 const std::vector< double>& normalizedVsup,
602 const std::vector< std::vector< unsigned int >>&
605 std::vector< std::vector< FullSecID >> fullSecIDs;
607 for (
auto col : fullSecIDsBaseType) {
608 std::vector< FullSecID > tmp_col;
611 fullSecIDs.push_back(tmp_col);
This class provides a computer convenient numbering scheme for the sectors in the sector map and for ...
int nOfSensors(int layer, int ladder) const
get the number of sensors on
FullSecID getFullSecID(VxdID aSensorID, double normalizedU, double normalizedV) const
Returns a fullSecID for given sensor and pair of coordinates.
bool areCoordinatesValid(VxdID aSensorID, double normalizedU, double normalizedV) const
JKL: returns true if operator() will not throw an exception.
int nOfLadders(int layer) const
get the number of ladders on
uint16_t sectorID_t
Typedef of the compact Id for a single sector.
sectorID_t getCompactID(const FullSecID &fullID) const
Returns the compact id of the FullSecID It does not throw exceptions (at least it should not).
static void extractCompactID(secPairID_t pair_id, sectorID_t &id1, sectorID_t &id2)
Uses the values coded by the Sector Pair ID pair_id and sets the two compact Sector ids id1 and id2.
int getSize() const
Returns the number of sectors defined so far.
bool setSubLayerID(FullSecID §or, int sublayer)
set the SublayerID of the sector
int nOfLayers(void) const
get the number of layers in this CompactSecIDs
SectorsOnSensor< sectorID_t > getSectorsOnSensor(unsigned layer, unsigned ladder, unsigned sensor) const
Getter for IDs of all sectors on a sensor.
int addSectors(const std::vector< double > &normalizedUsup, const std::vector< double > &normalizedVsup, const std::vector< std::vector< FullSecID > > &fullSecIDs)
This method defines all the sectors on a given sensor.
Class to identify a sector inside of the VXD.
short int getLayerNumber() const
returns LayerID compatible with basf2 standards.
class to describe a static sector of the sector map.
void setSubLayerID(int sublayer)
set sublayer ID, needed as it is updated in the trainings phase
Class that contains all the static sectors to which the filters are attached.
FullSecID getFullID(VxdID aSensorID, double normalizedU, double normalizedV) const
returns fullSecID for given sensorID and local coordinates.
const std::vector< staticSector_t * > & getStaticSectors() const
JKL: intended for some checks only - returns CompactIDsMap storing the static sectors.
CompactSecIDs m_compactSecIDsMap
This member takes care of converting the [layer][ladder] [sensor][sector] multi index into a linear i...
int addSectorsOnSensor(const std::vector< double > &normalizedUsup, const std::vector< double > &normalizedVsup, const std::vector< std::vector< FullSecID > > §orIds)
To add an array of sectors on a sensor.
unsigned size() const
returns number of compact secIDs stored for this filter-container.
bool retrieveSectors(const TString *dirName)
Read the whole CompactSecIDs from the current TDirectory.
bool areCoordinatesValid(VxdID aSensorID, double normalizedU, double normalizedV) const
check if using getFullID() would be safe (true if it is safe):
const twoHitFilter_t getTwoHitFilters(const FullSecID &outer, const FullSecID &inner) const
retrieves a two hit filter:
bool retrieveFromRootFile(const TString *dirName)
Retrieves from the current TDirectory all the VXDTFFilters.
FullSecID getFullID(CompactSecIDs::sectorID_t compactSecID) const
returns the FullSecId of
SectorMapConfig m_testConfig
Configuration: i.e.
bool persistSectors(void) const
Persists all the sectors on the current TDirectory.
bool persistOnRootFile(void) const
Persists (i.e.: writes) on the current TDirectory the whole object.
decltype((0.<=DistanceInTimeUside< point_t >()<=0. &&0.<=DistanceInTimeVside< point_t >()<=0. &&0.<=Distance3DSquared< point_t >()<=0.&&0.<=Distance2DXYSquared< point_t >()<=0.&&0.<=Distance1DZ< point_t >()<=0.&&0.<=SlopeRZ< point_t >()<=0.&&0.<=Distance3DNormed< point_t >()<=0.)) twoHitFilter_t
minimal working 2-hits-example used for redesign of VXDTF.
bool setSubLayerIDs(FullSecID sector, int sublayer)
during the trainings phase the sublayer ids have to be updated
CompactSecIDs::sectorID_t getCompactID(FullSecID outer) const
returns compactSecID for given FullSecID, == 0 if not found.
void modify2SPFilters(const std::vector< std::tuple< int, std::string > > &adjustFunctions)
modifies the 2SP-filters according to the functions given
const SectorMapConfig & getConfig(void) const
returns the configuration settings for this VXDTFFilters.
std::vector< staticSector_t * > m_staticSectors
This vector contains all the static sectors on a sector map.
void lockFilters()
This function should be called only AFTER all adjustments to the filters have been performed.
const CompactSecIDs & getCompactIDsMap() const
JKL: intended for some checks only - returns CompactIDsMap storing the static sectors.
bool retrieveFilters(const TString *dirName)
Retrieves from the current TDirectory the StaticSectors.
int addThreeHitFilter(FullSecID outer, FullSecID center, FullSecID inner, const threeHitFilter_t &filter)
adds a three hit filter
void setConfig(const SectorMapConfig &config)
set the configuration which is used to create this filter
int addTwoHitFilter(FullSecID outer, FullSecID inner, const twoHitFilter_t &filter)
adds a two hit filter
decltype((0.<=DistanceInTime< point_t >()<=0. &&0.<=Angle3DSimple< point_t >()<=0.&&0.<=CosAngleXY< point_t >()<=0.&&0.<=AngleRZSimple< point_t >()<=0.&&CircleDist2IP< point_t >()<=0.&&0.<=DeltaSlopeRZ< point_t >()<=0.&&0.<=DeltaSlopeZoverS< point_t >()<=0.&&0.<=DeltaSoverZ< point_t >()<=0.&&0.<=HelixParameterFit< point_t >()<=0.&&0.<=Pt< point_t >()<=0.&&0.<=CircleRadius< point_t >()<=0.)) threeHitFilter_t
minimal working example for 3-hits:
int addSectorsOnSensor(const std::vector< double > &normalizedUsup, const std::vector< double > &normalizedVsup, const std::vector< std::vector< unsigned int > > &fullSecIDsBaseType)
Adds the static sector: TODO: need documentation for the parameters.
bool persistFilters(void) const
Persists on the current TDirectory the StaticSectors.
const char * c_CompactSecIDstreeName
name of the tree the SecIDs are stored in when persisted
void modify3SPFilters(const std::vector< std::tuple< int, std::string > > &adjustFunctions)
modifies the 3SP-filters according to the functions given
const staticSector_t * getStaticSector(const FullSecID secID) const
returns pointer to static sector for given fullSecID.
bool m_preventModification
The filters are not supposed to be altered after initialization (typically in the Module::initialize(...
~VXDTFFilters()
Destructor.
StaticSector< point_t, twoHitFilter_t, threeHitFilter_t, int > staticSector_t
typedef to make a static sector type more readable.
Class to uniquely identify a any structure of the PXD and SVD.
std::map< ExpRun, std::pair< double, double > > filter(const std::map< ExpRun, std::pair< double, double > > &runs, double cut, std::map< ExpRun, std::pair< double, double > > &runsRemoved)
filter events to remove runs shorter than cut, it stores removed runs in runsRemoved
Abstract base class for different kinds of events.
simple struct containing all the configuration data needed for the SecMapTrainer.