CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
TTStubAlgorithm_official< T > Class Template Reference

Class for "official" algorithm to be used in TTStubBuilder. More...

#include <TTStubAlgorithm_official.h>

Inheritance diagram for TTStubAlgorithm_official< T >:
TTStubAlgorithm< T >

Public Member Functions

float degradeBend (bool psModule, int window, int bend) const
 
template<>
float degradeBend (bool psModule, int window, int bend) const
 
template<>
float degradeBend (bool psModule, int window, int bend) const
 
template<>
void PatternHitCorrelation (bool &aConfirmation, int &aDisplacement, int &anOffset, float &anROffset, float &anHardBend, const TTStub< Ref_Phase2TrackerDigi_ > &aTTStub) const
 Implementation of methods of TTStubAlgorithm_official. More...
 
void PatternHitCorrelation (bool &aConfirmation, int &aDisplacement, int &anOffset, float &anROffset, float &anHardBend, const TTStub< T > &aTTStub) const override
 Matching operations. More...
 
template<>
void PatternHitCorrelation (bool &aConfirmation, int &aDisplacement, int &anOffset, float &anROffset, float &anHardBend, const TTStub< Ref_Phase2TrackerDigi_ > &aTTStub) const
 Close class. More...
 
 TTStubAlgorithm_official (const TrackerGeometry *const theTrackerGeom, const TrackerTopology *const theTrackerTopo, std::vector< double > setBarrelCut, std::vector< std::vector< double > > setRingCut, std::vector< std::vector< double > > setTiltedCut, std::vector< double > setBarrelNTilt, bool aPerformZMatchingPS, bool aPerformZMatching2S)
 Constructor. More...
 
 ~TTStubAlgorithm_official () override
 Destructor. More...
 
- Public Member Functions inherited from TTStubAlgorithm< T >
virtual std::string AlgorithmName () const
 Algorithm name. More...
 
 TTStubAlgorithm (const TrackerGeometry *const theTrackerGeom, const TrackerTopology *const theTrackerTopo, std::string fName)
 Constructors. More...
 
virtual ~TTStubAlgorithm ()
 Destructor. More...
 

Private Attributes

std::vector< double > barrelCut
 
std::vector< double > barrelNTilt
 
std::string className_
 
bool m_tilted
 
bool mPerformZMatching2S
 
bool mPerformZMatchingPS
 Data members. More...
 
std::vector< std::vector< double > > ringCut
 
std::vector< std::vector< double > > tiltedCut
 

Additional Inherited Members

- Protected Attributes inherited from TTStubAlgorithm< T >
std::string className_
 
const TrackerGeometry *const theTrackerGeom_
 Data members. More...
 
const TrackerTopology *const theTrackerTopo_
 

Detailed Description

template<typename T>
class TTStubAlgorithm_official< T >

Class for "official" algorithm to be used in TTStubBuilder.

HW-friendly algorithm: layer-wise LUT. After moving from SimDataFormats to DataFormats, the template structure of the class was maintained in order to accomodate any types other than PixelDigis in case there is such a need in the future.

Author
Nicola Pozzobon
Sebastien Viret
Date
2013, Jul 18

Definition at line 38 of file TTStubAlgorithm_official.h.

Constructor & Destructor Documentation

template<typename T>
TTStubAlgorithm_official< T >::TTStubAlgorithm_official ( const TrackerGeometry *const  theTrackerGeom,
const TrackerTopology *const  theTrackerTopo,
std::vector< double >  setBarrelCut,
std::vector< std::vector< double > >  setRingCut,
std::vector< std::vector< double > >  setTiltedCut,
std::vector< double >  setBarrelNTilt,
bool  aPerformZMatchingPS,
bool  aPerformZMatching2S 
)
inline

Constructor.

Definition at line 54 of file TTStubAlgorithm_official.h.

60  : TTStubAlgorithm< T >( theTrackerGeom, theTrackerTopo, __func__ )
61  {
62  barrelCut = setBarrelCut;
63  ringCut = setRingCut;
64  tiltedCut = setTiltedCut;
65  barrelNTilt = setBarrelNTilt;
66  mPerformZMatchingPS = aPerformZMatchingPS;
67  mPerformZMatching2S = aPerformZMatching2S;
68  }
Base class for any algorithm to be used in TTStubBuilder.
std::vector< double > barrelNTilt
bool mPerformZMatchingPS
Data members.
std::vector< std::vector< double > > ringCut
std::vector< std::vector< double > > tiltedCut
std::vector< double > barrelCut
template<typename T>
TTStubAlgorithm_official< T >::~TTStubAlgorithm_official ( )
inlineoverride

Member Function Documentation

template<typename T>
float TTStubAlgorithm_official< T >::degradeBend ( bool  psModule,
int  window,
int  bend 
) const
template<>
float TTStubAlgorithm_official< Ref_Phase2TrackerDigi_ >::degradeBend ( bool  psModule,
int  window,
int  bend 
) const
template<>
float TTStubAlgorithm_official< Ref_Phase2TrackerDigi_ >::degradeBend ( bool  psModule,
int  window,
int  bend 
) const

Definition at line 139 of file TTStubAlgorithm_official.cc.

References Exception, mps_fire::i, funct::pow(), and svgfig::window().

139  {
140 
141  // Number of bits used to encoded bend output by FE electronics.
142  const unsigned int bitsPS_ = 3;
143  const unsigned int bits2S_ = 4;
144 
145  // Number of degraded bend values should correspond to 3 bits (PS modules) or 4 bits (2S modules),
146  // so measuring everything in half-strip units, max integer "window" size that can be encoded without
147  // compression given by 2*window+1 <= pow(2,B), where B is number of bits.
148  // Hence no compression required if window cut is abs(b) <= 3 (PS) or 7 (2S). Must introduce one merge for
149  // each 1 unit increase in "window" beyond this.
150 
151  // Bend is measured with granularity of 0.5 strips.
152  // Convert it to integer measured in half-strip units for this calculation!
153 
154  float degradedB;
155  unsigned int numBends = 2*window + 1;
156  unsigned int numAllowed = (psModule) ? pow(2, bitsPS_) : pow(2, bits2S_);
157 
158  // Existance of bend = 0 means can only use an odd number of groups.
159  numAllowed -= 1; // NumAllowed can be only based on 3 or 4 bits encoded bends, so 7 or 15 possible values
160  if (numBends <= numAllowed)
161  {
162  // Can output uncompressed bend info. (So if window is lower or equal than 1.5 in PS, and 3.5 in 2S
163  degradedB = static_cast<double>(bend);
164  }
165  else // all other cases, need to compress
166  {
167  unsigned int inSmallGroup = numBends/numAllowed;
168  unsigned int numLargeGroups = numBends%numAllowed;
169  unsigned int inLargeGroup = inSmallGroup + 1;
170  unsigned int numSmallGroups = numAllowed - numLargeGroups;
171 
172  std::vector<unsigned int> groups;
173 
174  // At the end we have
175  //
176  // numBends=inSmallGroup*numSmallGroups+inLargeGroup*numLargeGroups
177  // and
178  // numAllowed= numSmallGroups+numLargeGroups;
179  //
180  // Then you alternate large-small-large-small....large. In the middle, you
181  // put either large or small, depending if group size is odd or not
182 
183 
184  for (unsigned int i = 0; i < numLargeGroups/2; i++) groups.push_back(inLargeGroup);
185  for (unsigned int i = 0; i < numSmallGroups/2; i++) groups.push_back(inSmallGroup);
186 
187  // Only one of numLargeGroups & numSmallGroups can be odd, since numAllowed is odd.
188  // And whichever one is odd is associated to a group with an odd number of elements since numBends is odd,
189  if (numLargeGroups%2 == 1 && inLargeGroup%2 == 1)
190  {
191  groups.push_back(inLargeGroup);
192  } else if (numSmallGroups%2 == 1 && inSmallGroup%2 == 1) {
193  groups.push_back(inSmallGroup);
194  } else {
195  throw cms::Exception("DegradeBend: logic error with odd numbers");
196  }
197 
198  for (unsigned int i = 0; i < numSmallGroups/2; i++) groups.push_back(inSmallGroup);
199  for (unsigned int i = 0; i < numLargeGroups/2; i++) groups.push_back(inLargeGroup);
200 
201  degradedB = 999;
202  int iUp = -static_cast<int>(window) - 1; // Start with the minimal possible bend -1
203  int iDown;
204 
205  for (unsigned int& inGroup: groups)
206  {
207  iUp += inGroup;
208  iDown = iUp - inGroup + 1;
209  if (bend <= iUp && bend >= iDown)
210  {
211  degradedB = 0.5*(iUp + iDown);
212  }
213  }
214  if (degradedB == 999) throw cms::Exception("DegradeStubResolution: error in the group creation, method has been called with wrong inputs");
215  }
216 
217  // This is degraded bend in full strip units (neglecting bend sign).
218  return static_cast<float>(degradedB)/2.;
219 
220 
221 }
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
Definition: svgfig.py:643
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
template<>
void TTStubAlgorithm_official< Ref_Phase2TrackerDigi_ >::PatternHitCorrelation ( bool &  aConfirmation,
int &  aDisplacement,
int &  anOffset,
float &  anROffset,
float &  anHardBend,
const TTStub< Ref_Phase2TrackerDigi_ > &  aTTStub 
) const

Implementation of methods of TTStubAlgorithm_official.

Here, in the source file, the methods which do depend on the specific type <T> that can fit the template.

Author
Nicola Pozzobon
Sebastien Viret
Date
2013, Jul 18Matching operations

Calculate average coordinates col/row for inner/outer Cluster

Get the module position in global coordinates

Find pixel pitch and topology related information

Stop if the clusters are not in the same z-segment

This assumes the ratio is integer!

PS Modules

Get the Stack radius and z and displacements

Scale factor is already present in double mPtScalingFactor = (floor(mMagneticFieldStrength*10.0 + 0.5))/10.0*0.0015/mPtThreshold; hence the formula iis something like displacement < Delta * 1 / sqrt( ( 1/(mPtScalingFactor*R) )** 2 - 1 )

POSITION IN TERMS OF PITCH MULTIPLES: 0 1 2 3 4 5 5 6 8 9 ... COORD: 0 1 2 3 4 5 6 7 8 9 ... OUT | | | | | |x| | | | | | | | | |

IN | | | |x|x| | | | | | | | | | | THIS is 3.5 (COORD) and 4.0 (POS) 1) disp is the difference between average row coordinates in inner and outer stack member, in terms of outer member pitch (in case they are the same, this is just a plain coordinate difference)

In HALF-STRIP units!

In HALF-STRIP units!

2) offset is the projection with a straight line of the innermost hit towards the ourermost stack member, still in terms of outer member pitch NOTE: in terms of coordinates, the center of the module is at NROWS/2-0.5 to be consistent with the definition given above

In HALF-STRIP units!

In HALF-STRIP units!

Accept the stub if the post-offset correction displacement is smaller than the half-window

In HALF-STRIP units!

In HALF-STRIP units!

In HALF-STRIP units!

In HALF-STRIP units!

End of stub is accepted

Definition at line 15 of file TTStubAlgorithm_official.cc.

References funct::abs(), alpha, egammaForCoreTracking_cff::barrelCut, corr, funct::cos(), delta, TTStub< T >::getClusterRef(), TTStub< T >::getDetId(), PVValHelper::ladder, PixelTopology::ncolumns(), PixelTopology::nrows(), PV3DBase< T, PVType, FrameType >::perp(), TrackerGeometry::Ph2PSP, PixelTopology::pitch(), GeomDet::position(), pfBoostedDoubleSVAK8TagInfos_cfi::R0, particleFlowDisplacedVertex_cfi::ratio, funct::sin(), PixelGeomDetUnit::specificTopology(), mathSSE::sqrt(), StripSubdetector::TID, StripSubdetector::TOB, svgfig::window(), PV2DBase< T, PVType, FrameType >::x(), PV2DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), and Z0.

21 {
23  // These are already corrected for being at the center of each pixel
24  MeasurementPoint mp0 = aTTStub.getClusterRef(0)->findAverageLocalCoordinates();
25  MeasurementPoint mp1 = aTTStub.getClusterRef(1)->findAverageLocalCoordinates();
26 
29  // TODO temporary: should use a method from the topology
30  DetId stDetId( aTTStub.getDetId() );
31  const GeomDetUnit* det0 = theTrackerGeom_->idToDetUnit( stDetId+1 );
32  const GeomDetUnit* det1 = theTrackerGeom_->idToDetUnit( stDetId+2 );
33 
35  const PixelGeomDetUnit* pix0 = dynamic_cast< const PixelGeomDetUnit* >( det0 );
36  const PixelGeomDetUnit* pix1 = dynamic_cast< const PixelGeomDetUnit* >( det1 );
37  const PixelTopology* top0 = dynamic_cast< const PixelTopology* >( &(pix0->specificTopology()) );
38  const PixelTopology* top1 = dynamic_cast< const PixelTopology* >( &(pix1->specificTopology()) );
39  std::pair< float, float > pitch0 = top0->pitch();
40  std::pair< float, float > pitch1 = top1->pitch();
41 
43  int cols0 = top0->ncolumns();
44  int cols1 = top1->ncolumns();
45  int ratio = cols0/cols1;
46  int segment0 = floor( mp0.y() / ratio );
47 
48 // if ( ratio == 1 ) /// 2S Modules
49  if (!isPS)
50  {
51  if ( mPerformZMatching2S && ( segment0 != floor( mp1.y() ) ) )
52  return;
53  }
54  else
55  {
56  if ( mPerformZMatchingPS && ( segment0 != floor( mp1.y() ) ) )
57  return;
58  }
59 
61  double R0 = det0->position().perp();
62  double R1 = det1->position().perp();
63  double Z0 = det0->position().z();
64  double Z1 = det1->position().z();
65 
66  double DR = R1-R0;
67  double DZ = Z1-Z0;
68 
69  double alpha = atan2(DR,DZ);
70  double delta = sqrt(DR*DR+DZ*DZ)/(R0*sin(alpha)+Z0*cos(alpha));
71 
72  int window=0;
73 
78 
79 
90  double dispD = 2 * (mp1.x() - mp0.x()) * (pitch0.first / pitch1.first);
91  int dispI = ((dispD>0)-(dispD<0))*floor(std::abs(dispD));
92 
97  double offsetD = 2 * delta * ( mp0.x() - (top0->nrows()/2 - 0.5) ) * (pitch0.first / pitch1.first);
98  int offsetI = ((offsetD>0)-(offsetD<0))*floor(std::abs(offsetD));
99 
100  if (stDetId.subdetId()==StripSubdetector::TOB)
101  {
102  int layer = theTrackerTopo_->layer(stDetId);
103  int ladder = theTrackerTopo_->tobRod(stDetId);
104  int type = 2*theTrackerTopo_->tobSide(stDetId)-3; // -1 for tilted-, 1 for tilted+, 3 for flat
105  double corr=0;
106 
107  if (type<3) // Only for tilted modules
108  {
109  corr = (barrelNTilt.at(layer)+1)/2.;
110  ladder = corr-(corr-ladder)*type; // Corrected ring number, bet 0 and barrelNTilt.at(layer), in ascending |z|
111  window = 2*(tiltedCut.at(layer)).at(ladder);
112  }
113  else // Classis barrel window otherwise
114  {
115  window = 2*barrelCut.at( layer );
116  }
117 
118  }
119  else if (stDetId.subdetId()==StripSubdetector::TID)
120  {
121  window = 2*(ringCut.at( theTrackerTopo_->tidWheel(stDetId))).at(theTrackerTopo_->tidRing(stDetId));
122  }
123 
125  if ( std::abs(dispI - offsetI) <= window )
126  {
127  aConfirmation = true;
128  aDisplacement = dispI;
129  anOffset = offsetI;
130  anROffset = static_cast<float>(offsetD);
131  anHardBend = this->degradeBend(isPS, window, (aDisplacement - anOffset)); // In strips units
132  }
133 
134 }
dbl * delta
Definition: mlp_gen.cc:36
type
Definition: HCALResponse.h:21
virtual int nrows() const =0
float alpha
Definition: AMPTWrapper.h:95
T y() const
Definition: PV2DBase.h:46
static const double Z0
T perp() const
Definition: PV3DBase.h:72
unsigned int tidRing(const DetId &id) const
const TrackerGeometry *const theTrackerGeom_
Data members.
float degradeBend(bool psModule, int window, int bend) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
virtual std::pair< float, float > pitch() const =0
unsigned int tidWheel(const DetId &id) const
DetId getDetId() const
Detector element.
Definition: TTStub.h:40
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:48
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
unsigned int tobSide(const DetId &id) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
Definition: svgfig.py:643
std::vector< double > barrelNTilt
ModuleType getDetectorType(DetId) const
JetCorrectorParameters corr
Definition: classes.h:5
bool mPerformZMatchingPS
Data members.
Definition: DetId.h:18
const TrackerTopology *const theTrackerTopo_
std::vector< std::vector< double > > ringCut
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
std::vector< std::vector< double > > tiltedCut
unsigned int layer(const DetId &id) const
virtual int ncolumns() const =0
std::vector< double > barrelCut
unsigned int tobRod(const DetId &id) const
T x() const
Definition: PV2DBase.h:45
const edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > & getClusterRef(unsigned int hitIdentifier) const
Clusters composing the Stub.
Definition: TTStub.h:116
template<typename T>
void TTStubAlgorithm_official< T >::PatternHitCorrelation ( bool &  aConfirmation,
int &  aDisplacement,
int &  anOffset,
float &  anROffset,
float &  anHardBend,
const TTStub< T > &  aTTStub 
) const
overridevirtual

Matching operations.

Reimplemented from TTStubAlgorithm< T >.

Referenced by TTStubAlgorithm_official< T >::~TTStubAlgorithm_official().

template<>
void TTStubAlgorithm_official< Ref_Phase2TrackerDigi_ >::PatternHitCorrelation ( bool &  aConfirmation,
int &  aDisplacement,
int &  anOffset,
float &  anROffset,
float &  anHardBend,
const TTStub< Ref_Phase2TrackerDigi_ > &  aTTStub 
) const

Close class.

Implementation of methods

Here, in the header file, the methods which do not depend on the specific type <T> that can fit the template. Other methods, with type-specific features, are implemented in the source file.Matching operations

Member Data Documentation

template<typename T>
std::vector< double > TTStubAlgorithm_official< T >::barrelCut
private

Definition at line 47 of file TTStubAlgorithm_official.h.

template<typename T>
std::vector< double > TTStubAlgorithm_official< T >::barrelNTilt
private

Definition at line 50 of file TTStubAlgorithm_official.h.

template<typename T>
std::string TTStubAlgorithm_official< T >::className_
private

Definition at line 45 of file TTStubAlgorithm_official.h.

template<typename T>
bool TTStubAlgorithm_official< T >::m_tilted
private

Definition at line 44 of file TTStubAlgorithm_official.h.

template<typename T>
bool TTStubAlgorithm_official< T >::mPerformZMatching2S
private
template<typename T>
bool TTStubAlgorithm_official< T >::mPerformZMatchingPS
private

Data members.

Definition at line 42 of file TTStubAlgorithm_official.h.

Referenced by ES_TTStubAlgorithm_official< T >::produce().

template<typename T>
std::vector< std::vector< double > > TTStubAlgorithm_official< T >::ringCut
private

Definition at line 48 of file TTStubAlgorithm_official.h.

template<typename T>
std::vector< std::vector< double > > TTStubAlgorithm_official< T >::tiltedCut
private

Definition at line 49 of file TTStubAlgorithm_official.h.