10#include "tracking/dataobjects/FullSecID.h"
11#include <tracking/trackFindingVXD/filterMap/map/SectorsOnSensor.h>
12#include <framework/core/FrameworkExceptions.h>
13#include <framework/logging/Logger.h>
58 return UINT16_MAX - (
getSize());
69 int addSectors(
const std::vector< double>& normalizedUsup,
70 const std::vector< double>& normalizedVsup,
71 const std::vector< std::vector< FullSecID >>& fullSecIDs)
75 (normalizedVsup.size() + 1))
80 if (fullSecIDs.size() != normalizedUsup.size() + 1 ||
81 fullSecIDs[0].size() != normalizedVsup.size() + 1)
86 auto layer = fullSecIDs[0][0].getLayerID();
87 auto ladder = fullSecIDs[0][0].getLadderID();
88 auto sensor = fullSecIDs[0][0].getVxdID().getSensorNumber();
90 for (
auto fullSecIDrow : fullSecIDs) {
92 if (fullSecIDrow.size() != normalizedVsup.size() + 1)
96 for (
auto fullSecID : fullSecIDrow)
97 if (layer != fullSecID.getLayerID() ||
98 ladder != fullSecID.getLadderID() ||
99 sensor != fullSecID.getVxdID().getSensorNumber())
104 normalizedUsup, normalizedVsup,
106 layer, ladder, sensor);
145 "On layer:%1% ladder:%2% sensor:%3% abnormal U=%4$");
149 "On layer:%1% ladder:%2% sensor:%3% abnormal V=%4$");
154 double normalizedU,
double normalizedV)
const
161 auto sectorsOnSensor =
165 if (normalizedU < 0. || 1. < normalizedU)
166 B2WARNING(
"CompactSecIDs: U not normalized! This may lead to undefined behavior!");
167 if (normalizedV < 0. || 1. < normalizedV)
168 B2WARNING(
"CompactSecIDs: V not normalized! This may lead to undefined behavior!");
170 return sectorsOnSensor(normalizedU, normalizedV);
199 return i1 + (i2 << 16);
210 id1 = pair_id & 0xffff;
211 id2 = (pair_id >> 16) & 0xffff;
237 return i1 + (i2 << 16) + (i3 << 32);
248 id1 = triplet_id & 0xffff;
249 id2 = (triplet_id >> 16) & 0xffff;
250 id3 = (triplet_id >> 32) & 0xffff;
276 return i1 + (i2 << 16) + (i3 << 32) + (i4 << 48) ;
345 if (ladder < 0 || ladder >=
nOfLadders(layer))
359 if (compactID == 0)
return false;
363 [sector.getVxdID().getSensorNumber()].updateSubLayerID(sector, sublayer);
377 template<
class TContainer,
380 const std::vector< double >& normalizedUsup,
381 const std::vector< double >& normalizedVsup,
382 const std::vector< std::vector< FullSecID > >& fullSecIDs,
383 short unsigned int index, Indexes ... indexes)
386 if ((
int) container.size() < (
int)index + 1)
387 container.resize(index + 1);
388 }
catch (...) {
return 0; }
390 normalizedUsup, normalizedVsup,
391 fullSecIDs, indexes...);
399 const std::vector< double>& normalizedUsup,
400 const std::vector< double>& normalizedVsup,
401 const std::vector< std::vector< FullSecID > >& fullSecIDs)
403 if (sectors.
size() != 0)
407 normalizedVsup, fullSecIDs);
409 int addedSectors = 0;
411 for (
auto sectorRow : fullSecIDs)
412 for (
auto sector : sectorRow) {
413 auto secID = sector.getSecID();
415 if ((
int) sectors.
size() < (
int) secID + 1)
416 sectors.
resize(secID + 1);
417 }
catch (...) {
return addedSectors; }
430 template<
class TContainer,
433 short unsigned int index, Indexes ... indexes)
const
435 if ((
int) container.size() < (
int) index + 1)
445 template<
class TContainer >
447 short unsigned int index)
const
449 if ((
int) container.size() < (
int) index + 1)
452 return container[ index ];
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
sectorID_t operator[](const FullSecID &fullID) const
Returns the compact id of the FullSecID fullID.
secTripletID_t getCompactID(const FullSecID &id1, const FullSecID &id2, const FullSecID &id3) const
Returns the compact id of the triplet of FullSecID id1 id2 id3.
std::vector< SensorsOnLadder_t > LaddersOnLayer_t
Typedef for vector of vector of IDs of sectors on a Ladder.
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.
uint32_t secPairID_t
Typedef of the compact Id for a 2 sectors combination.
int nOfLadders(int layer) const
get the number of ladders on
BELLE2_DEFINE_EXCEPTION(unboundedNormalizedU, "On layer:%1% ladder:%2% sensor:%3% abnormal U=%4$")
Exception for normalized coordinate U out of bound [0,1].
~CompactSecIDs()
The destructor is quite trivial: nothing special to delete.
int privateAddSectors(TContainer &container, const std::vector< double > &normalizedUsup, const std::vector< double > &normalizedVsup, const std::vector< std::vector< FullSecID > > &fullSecIDs, short unsigned int index, Indexes ... indexes)
The hidden private method that recursively manage the size of everything.
uint64_t secTripletID_t
Typedef of the compact Id for a 3 sectors combination.
sectorID_t privateGetCompactID(const TContainer &container, short unsigned int index, Indexes ... indexes) const
The hidden private method that recursively descend the layer, ladder, sensor stack and returns the co...
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.
sectorID_t m_sectorCounter
Counter for sectors.
std::vector< LaddersOnLayer_t > LayersLookUpTable_t
Typedef for vector of vector of vector of IDs of sectors on a layer.
const LayersLookUpTable_t & getCompactSectorsIDMap() const
Get access to the whole map.
int getSize() const
Returns the number of sectors defined so far.
CompactSecIDs()
The constructor have just to set the internal counter to 0.
bool setSubLayerID(FullSecID §or, int sublayer)
set the SublayerID of the sector
std::vector< SectorsOnSensor< sectorID_t > > SensorsOnLadder_t
Typedef for vector of IDs of sectors on a sensors.
LayersLookUpTable_t m_compactSectorsIDMap
Lookup table containing all sectorIDs.
int nOfLayers(void) const
get the number of layers in this CompactSecIDs
secPairID_t getCompactID(const FullSecID &id1, const FullSecID &id2) const
Returns the compact id of the pair of FullSecID id1 id2.
static void extractCompactID(secTripletID_t triplet_id, sectorID_t &id1, sectorID_t &id2, sectorID_t &id3)
Uses the values coded by the Sector Pair ID to set the three compact sector ids.
sectorID_t getCompactIDFastAndDangerous(const FullSecID &fullID) const
Fast (and potentially dangerous) equivalent of getCompactID.
SectorsOnSensor< sectorID_t > getSectorsOnSensor(unsigned layer, unsigned ladder, unsigned sensor) const
Getter for IDs of all sectors on a sensor.
unsigned int getAvailableSlots() const
Returns the available number of sector that can be defined now.
secQuadrupletID_t getCompactID(const FullSecID &id1, const FullSecID &id2, const FullSecID &id3, const FullSecID &id4) const
Returns the compact id of the quadruplet of FullSecID id1 id2 id3 id4 If any of the id1,...
sectorID_t privateGetCompactID(const TContainer &container, short unsigned int index) const
The hidden private method that close the recursion.
uint64_t secQuadrupletID_t
Typedef of the compact Id for a 4 sectors combination.
BELLE2_DEFINE_EXCEPTION(unboundedNormalizedV, "On layer:%1% ladder:%2% sensor:%3% abnormal V=%4$")
Exception for normalized coordinate V out of bound [0,1].
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.
int privateAddSectors(SectorsOnSensor< sectorID_t > §ors, const std::vector< double > &normalizedUsup, const std::vector< double > &normalizedVsup, const std::vector< std::vector< FullSecID > > &fullSecIDs)
The hidden private method that end the recursion.
Class to identify a sector inside of the VXD.
int getLadderID() const
returns LadderID compatible with basf2 standards
VxdID getVxdID() const
returns VxdID of sensor.
short int getLayerID() const
returns LayerID compatible with basf2 standards.
short int getSecID() const
returns SecID of current FullSecID (only unique for each sensor).
This class associates to an ordered pairs of normalized local coordinates a compact sector id.
size_t size() const
minimal vector semantics to get the size of the compactSecIDs vector
void resize(size_t n)
minimal vector semantics to resize the compactSecIDs vector
Class to uniquely identify a any structure of the PXD and SVD.
baseType getSensorNumber() const
Get the sensor id.
baseType getLadderNumber() const
Get the ladder id.
baseType getLayerNumber() const
Get the layer id.
Abstract base class for different kinds of events.