CMS 3D CMS Logo

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

Plugin to load the Stub finding algorithm and produce the collection of Stubs that goes in the event content. More...

#include <TTStubBuilder.h>

Inheritance diagram for TTStubBuilder< T >:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 TTStubBuilder (const edm::ParameterSet &iConfig)
 Constructor. More...
 
 ~TTStubBuilder () override
 Destructor;. More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginRun (const edm::Run &run, const edm::EventSetup &iSetup) override
 Mandatory methods. More...
 
void endRun (const edm::Run &run, const edm::EventSetup &iSetup) override
 End run. More...
 
template<>
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 Implementation of methods of TTClusterBuilder.h. More...
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
template<>
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 Implement the producer. More...
 

Static Private Member Functions

static bool SortStubBendPairs (const std::pair< unsigned int, double > &left, const std::pair< unsigned int, double > &right)
 Sort routine for stub ordering. More...
 
static bool SortStubsBend (const TTStub< T > &left, const TTStub< T > &right)
 Analogous sorting routine directly from stubs. More...
 

Private Attributes

bool applyFE
 
edm::EDGetTokenT< edmNew::DetSetVector< TTCluster< T > > > clustersToken
 
bool ForbidMultipleStubs
 
unsigned int high_rate_max_ring [5]
 
int ievt
 
unsigned int maxStubs_2S
 
unsigned int maxStubs_2S_CIC_5
 
unsigned int maxStubs_PS
 
unsigned int maxStubs_PS_CIC_10
 
unsigned int maxStubs_PS_CIC_5
 
std::unordered_map< int, int > moduleStubs_CBC
 
std::unordered_map< int, std::vector< TTStub< Ref_Phase2TrackerDigi_ > > > moduleStubs_CIC
 Temporary storage for stubs before max check. More...
 
std::unordered_map< int, int > moduleStubs_MPA
 
unsigned int tedd1_maxring
 
unsigned int tedd2_maxring
 
edm::ESHandle< TTStubAlgorithm< T > > theStubFindingAlgoHandle
 Data members. More...
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

template<typename T>
class TTStubBuilder< T >

Plugin to load the Stub finding algorithm and produce the collection of Stubs that goes in the event content.

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
Andrew W. Rose
Nicola Pozzobon
Ivan Reid
Date
2013, Jul 18

Definition at line 43 of file TTStubBuilder.h.

Constructor & Destructor Documentation

template<typename T >
TTStubBuilder< T >::TTStubBuilder ( const edm::ParameterSet iConfig)
explicit

Constructor.

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.Constructors

Definition at line 111 of file TTStubBuilder.h.

References TTStubBuilder< T >::applyFE, TTStubBuilder< T >::clustersToken, TTStubBuilder< T >::ForbidMultipleStubs, edm::ParameterSet::getParameter(), TTStubBuilder< T >::high_rate_max_ring, TTStubBuilder< T >::maxStubs_2S, TTStubBuilder< T >::maxStubs_2S_CIC_5, TTStubBuilder< T >::maxStubs_PS, TTStubBuilder< T >::maxStubs_PS_CIC_10, TTStubBuilder< T >::maxStubs_PS_CIC_5, TTStubBuilder< T >::tedd1_maxring, and TTStubBuilder< T >::tedd2_maxring.

112 {
113  clustersToken = consumes< edmNew::DetSetVector< TTCluster< T > > >(iConfig.getParameter< edm::InputTag >( "TTClusters" ));
114  ForbidMultipleStubs = iConfig.getParameter< bool >( "OnlyOnePerInputCluster" );
115  applyFE = iConfig.getParameter< bool >( "FEineffs" );
116  maxStubs_2S = iConfig.getParameter< uint32_t >( "CBClimit" );
117  maxStubs_PS = iConfig.getParameter< uint32_t >( "MPAlimit" );
118  maxStubs_2S_CIC_5 = iConfig.getParameter< uint32_t >( "SS5GCIClimit" );
119  maxStubs_PS_CIC_5 = iConfig.getParameter< uint32_t >( "PS5GCIClimit" );
120  maxStubs_PS_CIC_10 = iConfig.getParameter< uint32_t >( "PS10GCIClimit" );
121  tedd1_maxring = iConfig.getParameter< uint32_t >( "TEDD1Max10GRing" );
122  tedd2_maxring = iConfig.getParameter< uint32_t >( "TEDD2Max10GRing" );
123  produces< edmNew::DetSetVector< TTCluster< T > > >( "ClusterAccepted" );
124  produces< edmNew::DetSetVector< TTStub< T > > >( "StubAccepted" );
125  produces< edmNew::DetSetVector< TTStub< T > > >( "StubRejected" );
126 
132 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edmNew::DetSetVector< TTCluster< T > > > clustersToken
Definition: TTStubBuilder.h:55
unsigned int maxStubs_PS_CIC_10
Definition: TTStubBuilder.h:77
unsigned int high_rate_max_ring[5]
Definition: TTStubBuilder.h:96
bool ForbidMultipleStubs
Definition: TTStubBuilder.h:56
unsigned int maxStubs_2S_CIC_5
Definition: TTStubBuilder.h:75
unsigned int tedd2_maxring
Definition: TTStubBuilder.h:80
unsigned int maxStubs_2S
Definition: TTStubBuilder.h:73
unsigned int maxStubs_PS
Definition: TTStubBuilder.h:74
unsigned int maxStubs_PS_CIC_5
Definition: TTStubBuilder.h:76
unsigned int tedd1_maxring
Definition: TTStubBuilder.h:79
template<typename T >
TTStubBuilder< T >::~TTStubBuilder ( )
override

Destructor;.

Destructor.

Definition at line 136 of file TTStubBuilder.h.

136 {}

Member Function Documentation

template<typename T >
void TTStubBuilder< T >::beginRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
overrideprivate

Mandatory methods.

Begin run.

Get the stub finding algorithm

Definition at line 140 of file TTStubBuilder.h.

References edm::EventSetup::get(), TTStubBuilder< T >::ievt, TTStubBuilder< T >::moduleStubs_CBC, TTStubBuilder< T >::moduleStubs_CIC, TTStubBuilder< T >::moduleStubs_MPA, and TTStubBuilder< T >::theStubFindingAlgoHandle.

141 {
144  ievt=0;
145  moduleStubs_CIC.clear();
146  moduleStubs_MPA.clear();
147  moduleStubs_CBC.clear();
148 }
std::unordered_map< int, int > moduleStubs_MPA
Definition: TTStubBuilder.h:87
std::unordered_map< int, int > moduleStubs_CBC
Definition: TTStubBuilder.h:88
std::unordered_map< int, std::vector< TTStub< Ref_Phase2TrackerDigi_ > > > moduleStubs_CIC
Temporary storage for stubs before max check.
Definition: TTStubBuilder.h:86
Class to store the TTStubAlgorithm used in TTStubBuilder.
T get() const
Definition: EventSetup.h:63
edm::ESHandle< TTStubAlgorithm< T > > theStubFindingAlgoHandle
Data members.
Definition: TTStubBuilder.h:54
template<typename T >
void TTStubBuilder< T >::endRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
overrideprivate

End run.

Definition at line 152 of file TTStubBuilder.h.

152 {}
template<>
void TTStubBuilder< Ref_Phase2TrackerDigi_ >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
private

Implementation of methods of TTClusterBuilder.h.

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

Author
Andrew W. Rose
Nicola Pozzobon
Ivan Reid
Date
2013, Jul 18Implement the producer

Prepare output

Get the Clusters already stored away

Go on only if both detectors have Clusters

Get the DetSets of the Clusters

If there are Clusters in both sensors you can try and make a Stub This is ~redundant

Create the vectors of objects to be passed to the FastFillers

Get chip size information

SV 21/11/17: tracker topology method should be updated, currently provide wrong nums

Loop over pairs of Clusters

Temporary storage to allow only one stub per inner cluster if requested in cfi

Build a temporary Stub

Check for compatibility

If the Stub is above threshold

Stub accepted

End of loop over outer clusters

Here tempOutput stores all the stubs from this inner cluster Check if there is need to store only one (if only one already, skip this step)

If so, sort the stubs by bend and keep only the first one (smallest bend)

Get to the second element (the switch above ensures there are min 2)

tempIter points now to the second element

Delete all-but-the first one from tempOutput

Here, tempOutput is either of size 1 (if entering the switch) either of size N with all the valid combinations ...

Now loop over the accepted stubs (1 or N) for this inner cluster

Get the stub

Put in the output

This means that ALL stubs go into the output

This means that only some of them do

Put in the temporary output

Find out which MPA/CBC ASIC

Find out which CIC ASIC

Already a stub for this ASIC?

No, so new entry

Already a stub for this ASIC?

No, so new entry

Already a stub for this ASIC?

No, so new entry

Sort them by |bend| and pick up only the first N.

End of check on max number of stubs per module

End of nested loop

End of loop over pairs of Clusters

Create the FastFillers

End of loop over detector elements

Put output in the event (1) Get also the OrphanHandle of the accepted clusters

Now, correctly reset the output

Get the DetId and prepare the FastFiller

detid of the two components. This should be done via a TrackerTopology method that is not yet available.

Get the DetSets of the clusters

Get the DetSet of the stubs

Prepare the new DetSet to replace the current one Loop over the stubs

Create a temporary stub

Compare the clusters stored in the stub with the ones of this module

If no compatible clusters were found, skip to the next one

getter is in FULL-strip units, setter is in HALF-strip units

getter is in FULL-strip units, setter is in HALF-strip units

End of loop over stubs of this module

End of loop over stub DetSetVector

Put output in the event (2)

Definition at line 16 of file TTStubBuilder.cc.

References TTStub< T >::addClusterRef(), edmNew::DetSet< T >::begin(), edmNew::DetSetVector< T >::begin(), TrackerGeometry::dets(), edmNew::DetSet< T >::empty(), edmNew::DetSetVector< T >::empty(), edmNew::DetSet< T >::end(), edmNew::DetSetVector< T >::end(), plotBeamSpotDB::first, edm::EventSetup::get(), edm::Event::getByToken(), TTStub< T >::getClusterRef(), TrackerGeometry::getDetectorType(), TTStub< T >::getDetId(), TTStub< T >::getHardwareBend(), TTStub< T >::getRealTriggerOffset(), TTStub< T >::getTriggerDisplacement(), TTStub< T >::getTriggerOffset(), TTStub< T >::getTriggerPosition(), mps_fire::i, edmNew::DetSetVector< T >::id(), createfilelist::int, TrackerTopology::isLower(), TrackerTopology::layer(), funct::m, edmNew::makeRefTo(), eostools::move(), TrackerTopology::partnerDetId(), TrackerGeometry::Ph2PSP, edm::ESHandle< T >::product(), edmNew::DetSetVector< T >::push_back(), edm::Event::put(), TTStub< T >::setHardwareBend(), TTStub< T >::setRealTriggerOffset(), TTStub< T >::setTriggerDisplacement(), TTStub< T >::setTriggerOffset(), findQualityFiles::size, TrackerTopology::stack(), DetId::subdetId(), StripSubdetector::TID, TrackerTopology::tidRing(), TrackerTopology::tidWheel(), StripSubdetector::TOB, and PV2DBase< T, PVType, FrameType >::y().

17 {
18  //Retrieve tracker topology from geometry
20  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
21  const TrackerTopology* const tTopo = tTopoHandle.product();
23  iSetup.get< TrackerDigiGeometryRecord >().get( tGeomHandle );
24  const TrackerGeometry* const theTrackerGeom = tGeomHandle.product();
25 
27  auto ttClusterDSVForOutput = std::make_unique<edmNew::DetSetVector<TTCluster<Ref_Phase2TrackerDigi_>>>();
28  auto ttStubDSVForOutputTemp = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
29  auto ttStubDSVForOutputAccepted = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
30  auto ttStubDSVForOutputRejected = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
31 
34  iEvent.getByToken( clustersToken, clusterHandle );
35 
36  int nmod=-1;
37 
38  // Loop over all the tracker elements
39 
40  // for (auto gd=theTrackerGeom->dets().begin(); gd != theTrackerGeom->dets().end(); gd++)
41  for (const auto& gd : theTrackerGeom->dets())
42  {
43  DetId detid = (*gd).geographicalId();
44  if(detid.subdetId()!=StripSubdetector::TOB && detid.subdetId()!=StripSubdetector::TID ) continue; // only run on OT
45  if(!tTopo->isLower(detid) ) continue; // loop on the stacks: choose the lower arbitrarily
46  DetId lowerDetid = detid;
47  DetId upperDetid = tTopo->partnerDetId(detid);
48  DetId stackDetid = tTopo->stack(detid);
49  bool isPS = (theTrackerGeom->getDetectorType(stackDetid)==TrackerGeometry::ModuleType::Ph2PSP);
50 
51  bool is10G_PS = false;
52 
53  // Determine if this module is a 10G transmission scheme module
54  //
55  // sviret comment (221217): this info should be made available in conddb at some point
56  // not in TrackerTopology as some modules may switch between 10G and 5G transmission
57  // schemes during running period
58 
59  if (detid.subdetId()==StripSubdetector::TOB)
60  {
61  if (tTopo->layer(detid)==1) is10G_PS = true;
62  }
63  else if (detid.subdetId()==StripSubdetector::TID)
64  {
65  if (tTopo->tidRing(detid)<=high_rate_max_ring[tTopo->tidWheel(detid)-1]) is10G_PS = true;
66  }
67 
68 
69  ++nmod;
70 
71  unsigned int maxStubs;
72  std::vector< std::pair< unsigned int, double > > bendMap;
73 
75  if ( clusterHandle->find( lowerDetid ) == clusterHandle->end() ||
76  clusterHandle->find( upperDetid ) == clusterHandle->end() )
77  continue;
78 
80  edmNew::DetSet< TTCluster< Ref_Phase2TrackerDigi_ > > lowerClusters = (*clusterHandle)[ lowerDetid ];
81  edmNew::DetSet< TTCluster< Ref_Phase2TrackerDigi_ > > upperClusters = (*clusterHandle)[ upperDetid ];
82 
86  if ( lowerClusters.empty() || upperClusters.empty() )
87  continue;
88 
90  std::vector< TTCluster< Ref_Phase2TrackerDigi_ > > tempInner;
91  std::vector< TTCluster< Ref_Phase2TrackerDigi_ > > tempOuter;
92  std::vector< TTStub< Ref_Phase2TrackerDigi_ > > tempAccepted;
93  tempInner.clear();
94  tempOuter.clear();
95  tempAccepted.clear();
96 
98  int chipSize = 127;
99  if (isPS) chipSize = 120;
100 
102  for ( auto lowerClusterIter = lowerClusters.begin();
103  lowerClusterIter != lowerClusters.end();
104  ++lowerClusterIter ) {
105 
108  std::vector< TTStub< Ref_Phase2TrackerDigi_ > > tempOutput;
109 
110  for ( auto upperClusterIter = upperClusters.begin();
111  upperClusterIter != upperClusters.end();
112  ++upperClusterIter ) {
113 
115  TTStub< Ref_Phase2TrackerDigi_ > tempTTStub( stackDetid );
116  tempTTStub.addClusterRef( edmNew::makeRefTo( clusterHandle, lowerClusterIter ) );
117  tempTTStub.addClusterRef( edmNew::makeRefTo( clusterHandle, upperClusterIter ) );
118 
120  bool thisConfirmation = false;
121  int thisDisplacement = 999999;
122  int thisOffset = 0;
123  float thisROffset = 0;
124  float thisHardBend = 0;
125 
126  theStubFindingAlgoHandle->PatternHitCorrelation( thisConfirmation, thisDisplacement, thisOffset, thisROffset, thisHardBend, tempTTStub );
127 
129  if ( thisConfirmation )
130  {
131  tempTTStub.setTriggerDisplacement( thisDisplacement );
132  tempTTStub.setTriggerOffset( thisOffset );
133  tempTTStub.setRealTriggerOffset( thisROffset );
134  tempTTStub.setHardwareBend( thisHardBend );
135  tempOutput.push_back( tempTTStub );
136  }
137  }
138 
141  if ( ForbidMultipleStubs && tempOutput.size() > 1 )
142  {
144  std::sort( tempOutput.begin(), tempOutput.end(), TTStubBuilder< Ref_Phase2TrackerDigi_ >::SortStubsBend );
145 
147  typename std::vector< TTStub< Ref_Phase2TrackerDigi_ > >::iterator tempIter = tempOutput.begin();
148  ++tempIter;
149 
151 
153  tempOutput.erase( tempIter, tempOutput.end() );
154  }
155 
158 
160  for ( unsigned int iTempStub = 0; iTempStub < tempOutput.size(); ++iTempStub )
161  {
163  const TTStub< Ref_Phase2TrackerDigi_ >& tempTTStub = tempOutput[iTempStub];
164 
165  // A temporary stub, for FE problems
166  TTStub< Ref_Phase2TrackerDigi_ > tempTTStub2( tempTTStub.getDetId() );
167 
168  tempTTStub2.addClusterRef( (tempTTStub.getClusterRef(0)) );
169  tempTTStub2.addClusterRef( (tempTTStub.getClusterRef(1)) );
170  tempTTStub2.setTriggerDisplacement( 2.*tempTTStub.getTriggerDisplacement() );
171  tempTTStub2.setTriggerOffset( 2.*tempTTStub.getTriggerOffset() );
172  tempTTStub2.setRealTriggerOffset( 2.*tempTTStub.getRealTriggerOffset() );
173  tempTTStub2.setHardwareBend( tempTTStub.getHardwareBend() );
174 
175 
177  if ( !applyFE ) // No dynamic inefficiencies (DEFAULT)
178  {
180  tempInner.push_back( *(tempTTStub.getClusterRef(0)) );
181  tempOuter.push_back( *(tempTTStub.getClusterRef(1)) );
182  tempAccepted.push_back( tempTTStub );
183  }
184  else
185  {
186  bool FEreject = false;
189  MeasurementPoint mp0 = tempTTStub.getClusterRef(0)->findAverageLocalCoordinates();
190  int seg = static_cast<int>(mp0.y());
191  if (isPS) seg = seg/16;
192  int chip = 1000*nmod+10*int(tempTTStub.getTriggerPosition()/chipSize)+seg;
193  int CIC_chip = 10*nmod+seg;
194 
195  // First look is the stub is passing trough the very front end (CBC/MPA)
196  (isPS)
197  ? maxStubs = maxStubs_PS
198  : maxStubs = maxStubs_2S;
199 
200  if (isPS) // MPA
201  {
202  if ( moduleStubs_MPA.find( chip ) == moduleStubs_MPA.end() )
203  {
205  moduleStubs_MPA.emplace(chip,1);
206  }
207  else
208  {
209  if ( moduleStubs_MPA[chip] < int(maxStubs) )
210  {
211  ++moduleStubs_MPA[chip];
212  }
213  else
214  {
215  FEreject = true;
216  }
217  }
218  }
219  else // CBC
220  {
221  if ( moduleStubs_CBC.find( chip ) == moduleStubs_CBC.end() )
222  {
224  moduleStubs_CBC.emplace(chip,1);
225  }
226  else
227  {
228  if ( moduleStubs_CBC[chip] < int(maxStubs) )
229  {
230  ++moduleStubs_CBC[chip];
231  }
232  else
233  {
234  FEreject = true;
235  }
236  }
237  }
238 
239  // End of the MPA/CBC loop
240 
241  // If the stub has been already thrown out, there is no reason to include it into the CIC stream
242  // We keep is in the stub final container tough, but flagged as reject by FE
243 
244  if (FEreject)
245  {
246  tempTTStub2.setTriggerDisplacement( 500+2.*tempTTStub.getTriggerDisplacement() );
247  tempTTStub2.setTriggerOffset( 500+2.*tempTTStub.getTriggerOffset() );
248  tempTTStub2.setRealTriggerOffset( 500+2.*tempTTStub.getRealTriggerOffset() );
249 
250  tempInner.push_back( *(tempTTStub2.getClusterRef(0)) );
251  tempOuter.push_back( *(tempTTStub2.getClusterRef(1)) );
252  tempAccepted.push_back( tempTTStub2 );
253  continue;
254  }
255 
256  (isPS)
257  ? maxStubs = maxStubs_PS_CIC_5
258  : maxStubs = maxStubs_2S_CIC_5;
259 
260  if (is10G_PS) maxStubs = maxStubs_PS_CIC_10;
261 
262  if ( moduleStubs_CIC.find( CIC_chip ) == moduleStubs_CIC.end() )
263  {
265  std::vector< TTStub< Ref_Phase2TrackerDigi_ > > tempStubs(1,tempTTStub);
266  moduleStubs_CIC.emplace(CIC_chip,tempStubs);
267  tempInner.push_back( *(tempTTStub.getClusterRef(0)) );
268  tempOuter.push_back( *(tempTTStub.getClusterRef(1)) );
269  tempAccepted.push_back( tempTTStub ); // The stub is added
270  }
271  else
272  {
273  bool CIC_reject=true;
274 
275  if ( moduleStubs_CIC[CIC_chip].size() < maxStubs )
276  {
277  moduleStubs_CIC[CIC_chip].push_back( tempTTStub ); //We add the new stub
278  tempInner.push_back( *(tempTTStub.getClusterRef(0)) );
279  tempOuter.push_back( *(tempTTStub.getClusterRef(1)) );
280  tempAccepted.push_back( tempTTStub ); // The stub is added
281  }
282  else
283  {
284  moduleStubs_CIC[CIC_chip].push_back( tempTTStub ); //We add the new stub
285 
287  bendMap.clear();
288  bendMap.reserve(moduleStubs_CIC[CIC_chip].size());
289 
290  for ( unsigned int i = 0; i < moduleStubs_CIC[CIC_chip].size(); ++i )
291  {
292  bendMap.emplace_back(i,moduleStubs_CIC[CIC_chip].at(i).getTriggerBend());
293  }
294 
295  std::sort( bendMap.begin(), bendMap.end(), TTStubBuilder< Ref_Phase2TrackerDigi_ >::SortStubBendPairs );
296 
297  // bendMap contains link over all the stubs included in moduleStubs_CIC[CIC_chip]
298 
299  for ( unsigned int i = 0; i < maxStubs; ++i )
300  {
301  // The stub we have added is among the first ones, add it
302  if (bendMap[i].first==moduleStubs_CIC[CIC_chip].size()-1)
303  {
304  CIC_reject=false;
305  }
306  }
307 
308  if (CIC_reject) // The stub added does not pass the cut
309  {
310  tempTTStub2.setTriggerDisplacement( 1000+2.*tempTTStub.getTriggerDisplacement() );
311  tempTTStub2.setTriggerOffset( 1000+2.*tempTTStub.getTriggerOffset() );
312  tempTTStub2.setRealTriggerOffset( 1000+2.*tempTTStub.getRealTriggerOffset() );
313 
314  tempInner.push_back( *(tempTTStub2.getClusterRef(0)) );
315  tempOuter.push_back( *(tempTTStub2.getClusterRef(1)) );
316  tempAccepted.push_back( tempTTStub2 );
317  }
318  else
319  {
320  tempInner.push_back( *(tempTTStub.getClusterRef(0)) );
321  tempOuter.push_back( *(tempTTStub.getClusterRef(1)) );
322  tempAccepted.push_back( tempTTStub ); // The stub is added
323  }
324  }
325  }
326  }
327  }
328  }
329 
331  if ( !tempInner.empty() )
332  {
333  typename edmNew::DetSetVector< TTCluster< Ref_Phase2TrackerDigi_ > >::FastFiller lowerOutputFiller( *ttClusterDSVForOutput, lowerDetid );
334  for ( unsigned int m = 0; m < tempInner.size(); m++ )
335  {
336  lowerOutputFiller.push_back( tempInner.at(m) );
337  }
338  if ( lowerOutputFiller.empty() )
339  lowerOutputFiller.abort();
340  }
341 
342  if ( !tempOuter.empty() )
343  {
344  typename edmNew::DetSetVector< TTCluster< Ref_Phase2TrackerDigi_ > >::FastFiller upperOutputFiller( *ttClusterDSVForOutput, upperDetid );
345  for ( unsigned int m = 0; m < tempOuter.size(); m++ )
346  {
347  upperOutputFiller.push_back( tempOuter.at(m) );
348  }
349  if ( upperOutputFiller.empty() )
350  upperOutputFiller.abort();
351  }
352 
353  if ( !tempAccepted.empty() )
354  {
355  typename edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ > >::FastFiller tempAcceptedFiller( *ttStubDSVForOutputTemp, stackDetid);
356  for ( unsigned int m = 0; m < tempAccepted.size(); m++ )
357  {
358  tempAcceptedFiller.push_back( tempAccepted.at(m) );
359  }
360  if ( tempAcceptedFiller.empty() )
361  tempAcceptedFiller.abort();
362  }
363 
364  }
365 
368  edm::OrphanHandle< edmNew::DetSetVector< TTCluster< Ref_Phase2TrackerDigi_ > > > ttClusterAcceptedHandle = iEvent.put( std::move(ttClusterDSVForOutput), "ClusterAccepted" );
369 
371  typename edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ > >::const_iterator stubDetIter;
372 
373  for ( stubDetIter = ttStubDSVForOutputTemp->begin();
374  stubDetIter != ttStubDSVForOutputTemp->end();
375  ++stubDetIter ) {
377  DetId thisStackedDetId = stubDetIter->id();
378  typename edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ > >::FastFiller acceptedOutputFiller( *ttStubDSVForOutputAccepted, thisStackedDetId );
379 
382  DetId lowerDetid = thisStackedDetId+1;
383  DetId upperDetid = thisStackedDetId+2;
384 
386  edmNew::DetSet< TTCluster< Ref_Phase2TrackerDigi_ > > lowerClusters = (*ttClusterAcceptedHandle)[ lowerDetid ];
387  edmNew::DetSet< TTCluster< Ref_Phase2TrackerDigi_ > > upperClusters = (*ttClusterAcceptedHandle)[ upperDetid ];
388 
390  edmNew::DetSet< TTStub< Ref_Phase2TrackerDigi_ > > theseStubs = (*ttStubDSVForOutputTemp)[ thisStackedDetId ];
391 
394  typename edmNew::DetSet< TTCluster< Ref_Phase2TrackerDigi_ > >::iterator clusterIter;
395  typename edmNew::DetSet< TTStub< Ref_Phase2TrackerDigi_ > >::iterator stubIter;
396  for ( stubIter = theseStubs.begin();
397  stubIter != theseStubs.end();
398  ++stubIter ) {
400  TTStub< Ref_Phase2TrackerDigi_ > tempTTStub( stubIter->getDetId() );
401 
403  const edm::Ref< edmNew::DetSetVector< TTCluster< Ref_Phase2TrackerDigi_ > >, TTCluster< Ref_Phase2TrackerDigi_ > >& lowerClusterToBeReplaced = stubIter->getClusterRef(0);
404  const edm::Ref< edmNew::DetSetVector< TTCluster< Ref_Phase2TrackerDigi_ > >, TTCluster< Ref_Phase2TrackerDigi_ > >& upperClusterToBeReplaced = stubIter->getClusterRef(1);
405 
406  bool lowerOK = false;
407  bool upperOK = false;
408 
409  for ( clusterIter = lowerClusters.begin();
410  clusterIter != lowerClusters.end() && !lowerOK;
411  ++clusterIter ) {
412  if ( clusterIter->getHits() == lowerClusterToBeReplaced->getHits() ) {
413  tempTTStub.addClusterRef( edmNew::makeRefTo( ttClusterAcceptedHandle, clusterIter ) );
414  lowerOK = true;
415  }
416  }
417 
418  for ( clusterIter = upperClusters.begin();
419  clusterIter != upperClusters.end() && !upperOK;
420  ++clusterIter ) {
421  if ( clusterIter->getHits() == upperClusterToBeReplaced->getHits() ) {
422  tempTTStub.addClusterRef( edmNew::makeRefTo( ttClusterAcceptedHandle, clusterIter ) );
423  upperOK = true;
424  }
425  }
426 
428  if ( !lowerOK || !upperOK ) continue;
429 
430  tempTTStub.setTriggerDisplacement( 2.*stubIter->getTriggerDisplacement() );
431  tempTTStub.setTriggerOffset( 2.*stubIter->getTriggerOffset() );
432  tempTTStub.setRealTriggerOffset( 2.*stubIter->getRealTriggerOffset() );
433  tempTTStub.setHardwareBend( stubIter->getHardwareBend() );
434 
435  acceptedOutputFiller.push_back( tempTTStub );
436 
437  }
438 
439  if ( acceptedOutputFiller.empty() )
440  acceptedOutputFiller.abort();
441 
442  }
443 
445  iEvent.put( std::move(ttStubDSVForOutputAccepted), "StubAccepted" );
446  iEvent.put( std::move(ttStubDSVForOutputRejected), "StubRejected" );
447 
448  ++ievt;
449  if (ievt%8==0) moduleStubs_CIC.clear(); // Everything is cleared up after 8BX
450  if (ievt%2==0) moduleStubs_MPA.clear(); // Everything is cleared up after 2BX
451  moduleStubs_CBC.clear(); // Everything is cleared up after everyBX
452 
453 }
size
Write out results.
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
edm::EDGetTokenT< edmNew::DetSetVector< TTCluster< T > > > clustersToken
Definition: TTStubBuilder.h:55
const_iterator end(bool update=false) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
unsigned int maxStubs_PS_CIC_10
Definition: TTStubBuilder.h:77
T y() const
Definition: PV2DBase.h:46
unsigned int tidRing(const DetId &id) const
std::unordered_map< int, int > moduleStubs_MPA
Definition: TTStubBuilder.h:87
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
unsigned int high_rate_max_ring[5]
Definition: TTStubBuilder.h:96
unsigned int tidWheel(const DetId &id) const
DetId getDetId() const
Detector element.
Definition: TTStub.h:40
bool ForbidMultipleStubs
Definition: TTStubBuilder.h:56
id_type id(size_t cell) const
DetId partnerDetId(const DetId &id) const
double getHardwareBend() const
In FULL-STRIP units!
Definition: TTStub.h:168
bool isLower(const DetId &id) const
unsigned int maxStubs_2S_CIC_5
Definition: TTStubBuilder.h:75
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
std::unordered_map< int, int > moduleStubs_CBC
Definition: TTStubBuilder.h:88
void setHardwareBend(float aBend)
In FULL-STRIP units!
Definition: TTStub.h:148
void setTriggerDisplacement(int aDisplacement)
In FULL-STRIP units! (hence, not implemented herein)
Definition: TTStub.h:133
double getTriggerOffset() const
In HALF-STRIP units!
Definition: TTStub.h:136
bool empty() const
Definition: DetSetNew.h:90
std::unordered_map< int, std::vector< TTStub< Ref_Phase2TrackerDigi_ > > > moduleStubs_CIC
Temporary storage for stubs before max check.
Definition: TTStubBuilder.h:86
unsigned int maxStubs_2S
Definition: TTStubBuilder.h:73
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
ModuleType getDetectorType(DetId) const
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
unsigned int maxStubs_PS
Definition: TTStubBuilder.h:74
double getTriggerDisplacement() const
Trigger information.
Definition: TTStub.h:130
Definition: DetId.h:18
void setTriggerOffset(int anOffset)
In FULL-STRIP units! (hence, not implemented herein)
Definition: TTStub.h:139
NOTE: this is needed even if it seems not.
Definition: TTCluster.h:27
uint32_t stack(const DetId &id) const
void addClusterRef(edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aTTCluster)
Definition: TTStub.h:122
unsigned int layer(const DetId &id) const
unsigned int maxStubs_PS_CIC_5
Definition: TTStubBuilder.h:76
iterator end()
Definition: DetSetNew.h:70
void setRealTriggerOffset(float anOffset)
In FULL-STRIP units! (hence, not implemented herein)
Definition: TTStub.h:145
T get() const
Definition: EventSetup.h:63
double getRealTriggerOffset() const
In HALF-STRIP units!
Definition: TTStub.h:142
double getTriggerPosition() const
In HALF-STRIP units!
Definition: TTStub.h:153
const edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > & getClusterRef(unsigned int hitIdentifier) const
Clusters composing the Stub.
Definition: TTStub.h:116
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
const_iterator begin(bool update=false) const
Plugin to load the Stub finding algorithm and produce the collection of Stubs that goes in the event ...
Definition: TTStubBuilder.h:43
edm::ESHandle< TTStubAlgorithm< T > > theStubFindingAlgoHandle
Data members.
Definition: TTStubBuilder.h:54
iterator begin()
Definition: DetSetNew.h:67
template<typename T >
void TTStubBuilder< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate
template<>
void TTStubBuilder< Ref_Phase2TrackerDigi_ >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
private

Implement the producer.

template<typename T >
bool TTStubBuilder< T >::SortStubBendPairs ( const std::pair< unsigned int, double > &  left,
const std::pair< unsigned int, double > &  right 
)
staticprivate

Sort routine for stub ordering.

Sorting method for stubs NOTE: this must be static!

Definition at line 156 of file TTStubBuilder.h.

157 {
158  return fabs(left.second) < fabs(right.second);
159 }
template<typename T >
bool TTStubBuilder< T >::SortStubsBend ( const TTStub< T > &  left,
const TTStub< T > &  right 
)
staticprivate

Analogous sorting routine directly from stubs.

Definition at line 163 of file TTStubBuilder.h.

References TTStub< T >::getTriggerBend(), iEvent, and TTStubBuilder< T >::produce().

164 {
165  return fabs(left.getTriggerBend()) < fabs(right.getTriggerBend());
166 }
double getTriggerBend() const
In FULL-STRIP units!
Definition: TTStub.h:159

Member Data Documentation

template<typename T >
bool TTStubBuilder< T >::applyFE
private

Definition at line 70 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::TTStubBuilder().

template<typename T >
edm::EDGetTokenT< edmNew::DetSetVector< TTCluster< T > > > TTStubBuilder< T >::clustersToken
private

Definition at line 55 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::TTStubBuilder().

template<typename T >
bool TTStubBuilder< T >::ForbidMultipleStubs
private

Definition at line 56 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::TTStubBuilder().

template<typename T >
unsigned int TTStubBuilder< T >::high_rate_max_ring[5]
private

Definition at line 96 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::TTStubBuilder().

template<typename T >
int TTStubBuilder< T >::ievt
private

Definition at line 82 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::beginRun().

template<typename T >
unsigned int TTStubBuilder< T >::maxStubs_2S
private

Definition at line 73 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::TTStubBuilder().

template<typename T >
unsigned int TTStubBuilder< T >::maxStubs_2S_CIC_5
private

Definition at line 75 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::TTStubBuilder().

template<typename T >
unsigned int TTStubBuilder< T >::maxStubs_PS
private

Definition at line 74 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::TTStubBuilder().

template<typename T >
unsigned int TTStubBuilder< T >::maxStubs_PS_CIC_10
private

Definition at line 77 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::TTStubBuilder().

template<typename T >
unsigned int TTStubBuilder< T >::maxStubs_PS_CIC_5
private

Definition at line 76 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::TTStubBuilder().

template<typename T >
std::unordered_map< int, int > TTStubBuilder< T >::moduleStubs_CBC
private

Definition at line 88 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::beginRun().

template<typename T >
std::unordered_map< int, std::vector< TTStub< Ref_Phase2TrackerDigi_ > > > TTStubBuilder< T >::moduleStubs_CIC
private

Temporary storage for stubs before max check.

Definition at line 86 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::beginRun().

template<typename T >
std::unordered_map< int, int > TTStubBuilder< T >::moduleStubs_MPA
private

Definition at line 87 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::beginRun().

template<typename T >
unsigned int TTStubBuilder< T >::tedd1_maxring
private

Definition at line 79 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::TTStubBuilder().

template<typename T >
unsigned int TTStubBuilder< T >::tedd2_maxring
private

Definition at line 80 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::TTStubBuilder().

template<typename T >
edm::ESHandle< TTStubAlgorithm< T > > TTStubBuilder< T >::theStubFindingAlgoHandle
private

Data members.

Definition at line 54 of file TTStubBuilder.h.

Referenced by TTStubBuilder< T >::beginRun().