CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | 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::one::EDProducer< edm::one::WatchRuns > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

enum  FEreject { CBCFailOffset = 500, CICFailOffset = 1000 }
 
- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase 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
 

Public Member Functions

 TTStubBuilder (const edm::ParameterSet &iConfig)
 Constructor. More...
 
 ~TTStubBuilder () override
 Destructor;. More...
 
- Public Member Functions inherited from edm::one::EDProducer< edm::one::WatchRuns >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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<typename TT >
void fill (edmNew::DetSetVector< TT > &outputEP, const DetId &detId, const std::vector< TT > &inputVec) const
 Fill output cluster & stub collections. More...
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
template<>
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
template<>
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
template<>
void updateStubs (const edm::OrphanHandle< edmNew::DetSetVector< TTCluster< Ref_Phase2TrackerDigi_ >>> &clusterHandle, const edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ >> &inputEDstubs, edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ >> &outputEDstubs) const
 
void updateStubs (const edm::OrphanHandle< edmNew::DetSetVector< TTCluster< Ref_Phase2TrackerDigi_ >>> &clusterHandle, const edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ >> &inputEDstubs, edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ >> &outputEDstubs) const
 Update output stubs with Refs to cluster collection that is associated to stubs. 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
 FE truncation. More...
 
edm::EDGetTokenT
< edmNew::DetSetVector
< TTCluster< T > > > 
clustersToken
 
bool ForbidMultipleStubs
 
unsigned int high_rate_max_layer
 
unsigned int high_rate_max_ring [5]
 
int ievt
 Temporary storage for stubs over several events for truncation use. More...
 
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
 
std::unordered_map< int, int > moduleStubs_MPA
 
edm::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
tGeomToken
 
edm::ESHandle< TTStubAlgorithm
< T > > 
theStubFindingAlgoHandle
 Data members. More...
 
edm::ESGetToken
< TrackerTopology,
TrackerTopologyRcd
tTopoToken
 
edm::ESGetToken
< TTStubAlgorithm< T >
, TTStubAlgorithmRecord
ttStubToken
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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
Ian Tomalin
Date
2013 - 2020

Definition at line 45 of file TTStubBuilder.h.

Member Enumeration Documentation

template<typename T >
enum TTStubBuilder::FEreject
Enumerator
CBCFailOffset 
CICFailOffset 

Definition at line 54 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 125 of file TTStubBuilder.h.

References edm::BeginRun, and edm::ParameterSet::getParameter().

125  {
126  clustersToken = consumes<edmNew::DetSetVector<TTCluster<T>>>(iConfig.getParameter<edm::InputTag>("TTClusters"));
127  tTopoToken = esConsumes<TrackerTopology, TrackerTopologyRcd>();
128  tGeomToken = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>();
129  ttStubToken = esConsumes<TTStubAlgorithm<T>, TTStubAlgorithmRecord, edm::Transition::BeginRun>();
130  ForbidMultipleStubs = iConfig.getParameter<bool>("OnlyOnePerInputCluster");
131  applyFE = iConfig.getParameter<bool>("FEineffs");
132  maxStubs_2S = iConfig.getParameter<uint32_t>("CBClimit");
133  maxStubs_PS = iConfig.getParameter<uint32_t>("MPAlimit");
134  maxStubs_2S_CIC_5 = iConfig.getParameter<uint32_t>("SS5GCIClimit");
135  maxStubs_PS_CIC_5 = iConfig.getParameter<uint32_t>("PS5GCIClimit");
136  maxStubs_PS_CIC_10 = iConfig.getParameter<uint32_t>("PS10GCIClimit");
137  unsigned int tedd1_max10Gring = iConfig.getParameter<uint32_t>("TEDD1Max10GRing");
138  unsigned int tedd2_max10Gring = iConfig.getParameter<uint32_t>("TEDD2Max10GRing");
139  high_rate_max_layer = iConfig.getParameter<uint32_t>("BarrelMax10GLay");
140  // Stubs passing & failing FE chip cuts, plus associated clusters.
141  produces<edmNew::DetSetVector<TTCluster<T>>>("ClusterAccepted");
142  produces<edmNew::DetSetVector<TTCluster<T>>>("ClusterRejected");
143  produces<edmNew::DetSetVector<TTStub<T>>>("StubAccepted");
144  produces<edmNew::DetSetVector<TTStub<T>>>("StubRejected");
145 
146  high_rate_max_ring[0] = tedd1_max10Gring;
147  high_rate_max_ring[1] = tedd1_max10Gring;
148  high_rate_max_ring[2] = tedd2_max10Gring;
149  high_rate_max_ring[3] = tedd2_max10Gring;
150  high_rate_max_ring[4] = tedd2_max10Gring;
151 }
unsigned int maxStubs_PS_CIC_10
Definition: TTStubBuilder.h:99
unsigned int high_rate_max_layer
unsigned int high_rate_max_ring[5]
bool ForbidMultipleStubs
Definition: TTStubBuilder.h:63
unsigned int maxStubs_2S_CIC_5
Definition: TTStubBuilder.h:97
unsigned int maxStubs_2S
Definition: TTStubBuilder.h:95
edm::EDGetTokenT< edmNew::DetSetVector< TTCluster< T > > > clustersToken
Definition: TTStubBuilder.h:59
Class to store the TTStubAlgorithm used in TTStubBuilder.
unsigned int maxStubs_PS
Definition: TTStubBuilder.h:96
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
unsigned int maxStubs_PS_CIC_5
Definition: TTStubBuilder.h:98
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken
Definition: TTStubBuilder.h:60
bool applyFE
FE truncation.
Definition: TTStubBuilder.h:92
edm::ESGetToken< TTStubAlgorithm< T >, TTStubAlgorithmRecord > ttStubToken
Definition: TTStubBuilder.h:62
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tGeomToken
Definition: TTStubBuilder.h:61
template<typename T >
TTStubBuilder< T >::~TTStubBuilder ( )
override

Destructor;.

Destructor.

Definition at line 155 of file TTStubBuilder.h.

155 {}

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 159 of file TTStubBuilder.h.

References edm::EventSetup::getHandle().

159  {
162  ievt = 0;
163  moduleStubs_CIC.clear();
164  moduleStubs_MPA.clear();
165  moduleStubs_CBC.clear();
166 }
edm::ESHandle< TTStubAlgorithm< T > > theStubFindingAlgoHandle
Data members.
Definition: TTStubBuilder.h:58
int ievt
Temporary storage for stubs over several events for truncation use.
std::unordered_map< int, int > moduleStubs_MPA
std::unordered_map< int, int > moduleStubs_CBC
std::unordered_map< int, std::vector< TTStub< Ref_Phase2TrackerDigi_ > > > moduleStubs_CIC
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
edm::ESGetToken< TTStubAlgorithm< T >, TTStubAlgorithmRecord > ttStubToken
Definition: TTStubBuilder.h:62
template<typename T >
void TTStubBuilder< T >::endRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
overrideprivate

End run.

Definition at line 170 of file TTStubBuilder.h.

170 {}
template<typename T >
template<typename TT >
void TTStubBuilder< T >::fill ( edmNew::DetSetVector< TT > &  outputEP,
const DetId detId,
const std::vector< TT > &  inputVec 
) const
inlineprivate

Fill output cluster & stub collections.

Create the FastFiller

Definition at line 78 of file TTStubBuilder.h.

References edmNew::DetSetVector< T >::FastFiller::begin(), filterCSVwithJSON::copy, and edmNew::DetSetVector< T >::FastFiller::resize().

78  {
80  typename edmNew::DetSetVector<TT>::FastFiller outputFiller(outputEP, detId);
81  outputFiller.resize(inputVec.size());
82  std::copy(inputVec.begin(), inputVec.end(), outputFiller.begin());
83  }
template<typename T >
void TTStubBuilder< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual
template<>
void TTStubBuilder< Ref_Phase2TrackerDigi_ >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

– Prepare output TTClusters associated to TTStubs

TTStubs with Refs to clusters pointing to collection of clusters in entire tracker.

TTStubs with Refs to clusters pointing to collection of clusters associated to stubs.

Read the Clusters from the entire tracker.

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 FIX ME: Should take this from TrackerTopology, but it was buggy in 2017 (SV)

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 of cluster pair

If the Stub is above threshold

Stub accepted

End of loop over upper clusters

Here tempOutput stores all the stubs from this lower cluster Check if there is need to store only one or two (2S/PS modules cases) (if only one already, skip this step)

If so, sort the stubs by bend and keep only the first one (2S case) or the first pair (PS case) (smallest |bend|)

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

tempIter points now to the second or third element (2S/PS)

Delete all-but-the first one from tempOutput

Here, tempOutput is either of size 1 (if ForbidMultupleStubs = true), or of size N with all the valid combinations ...

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

Put in the output

This means that ALL stubs go into the output

This means that only some stubs go to the output

Find out which MPA/CBC ASIC

Find out which CIC ASIC

TO FIX: The maxStub stubs with lowest |bend| are retained. This algo considers all stubs since the last multiple of 8 events, (i.e. in 1-8 events), whereas true CIC chip considers all stubs in current block of 8 events (i.e. always in 8 events). So may be optimistic.

Sort stubs by |bend|.

End of check on max number of stubs per module

End of nested loop

End of loop over pairs of Clusters

Fill output collections

End of loop over detector elements

The TTStubs created above contain Refs to the ClusterInclusive collection (all clusters in Tracker). Replace them with new TTStubs with Refs to ClusterAccepted collection (only clusters in Stubs), so big ClusterInclusive collection can be dropped.

Put output in the event (2)

Implements edm::one::EDProducerBase.

Definition at line 90 of file TTStubBuilder.cc.

References TTStub< T >::addClusterRef(), edmNew::DetSet< T >::begin(), TrackerGeometry::dets(), edmNew::DetSet< T >::empty(), edmNew::DetSet< T >::end(), PVValHelper::fill(), first, edm::Event::getByToken(), TrackerGeometry::getDetectorType(), edm::EventSetup::getHandle(), mps_fire::i, TrackerTopology::isLower(), TrackerTopology::layer(), edmNew::makeRefTo(), eostools::move(), TrackerTopology::partnerDetId(), TrackerGeometry::Ph2PSP, edm::ESHandle< class >::product(), edm::Event::put(), TTStub< T >::setBendBE(), TTStub< T >::setBendOffset(), TTStub< T >::setModuleTypePS(), TTStub< T >::setRawBend(), findQualityFiles::size, TrackerTopology::stack(), DetId::subdetId(), StripSubdetector::TID, TrackerTopology::tidRing(), TrackerTopology::tidWheel(), StripSubdetector::TOB, and PV2DBase< T, PVType, FrameType >::y().

90  {
91  //Retrieve tracker topology from geometry
93  const TrackerTopology* const tTopo = tTopoHandle.product();
95  const TrackerGeometry* const theTrackerGeom = tGeomHandle.product();
96 
99  auto ttClusterDSVForOutputAcc = std::make_unique<edmNew::DetSetVector<TTCluster<Ref_Phase2TrackerDigi_>>>();
100  auto ttClusterDSVForOutputRej = std::make_unique<edmNew::DetSetVector<TTCluster<Ref_Phase2TrackerDigi_>>>();
102  auto ttStubDSVForOutputAccTemp = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
103  auto ttStubDSVForOutputRejTemp = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
105  auto ttStubDSVForOutputAcc = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
106  auto ttStubDSVForOutputRej = std::make_unique<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>();
107 
110  iEvent.getByToken(clustersToken, clusterHandle);
111 
112  int nmod = -1;
113 
114  // Loop over all the tracker elements
115 
116  for (const auto& gd : theTrackerGeom->dets()) {
117  DetId detid = (*gd).geographicalId();
118  if (detid.subdetId() != StripSubdetector::TOB && detid.subdetId() != StripSubdetector::TID)
119  continue; // only run on OT
120  if (!tTopo->isLower(detid))
121  continue; // loop on the stacks: choose the lower sensor
122  DetId lowerDetid = detid;
123  DetId upperDetid = tTopo->partnerDetId(detid);
124  DetId stackDetid = tTopo->stack(detid);
125  bool isPS = (theTrackerGeom->getDetectorType(stackDetid) == TrackerGeometry::ModuleType::Ph2PSP);
126 
127  bool is10G_PS = false;
128 
129  // Determine if this module is a 10G transmission scheme module
130  //
131  // TO FIX: take this info from Tracker -> DTC cabling map.
132 
133  if (detid.subdetId() == StripSubdetector::TOB) {
134  if (tTopo->layer(detid) <= high_rate_max_layer)
135  is10G_PS = true;
136  } else if (detid.subdetId() == StripSubdetector::TID) {
137  if (tTopo->tidRing(detid) <= high_rate_max_ring[tTopo->tidWheel(detid) - 1])
138  is10G_PS = true;
139  }
140 
141  ++nmod;
142 
143  unsigned int maxStubs;
144  std::vector<std::pair<unsigned int, double>> bendMap;
145 
147  if (clusterHandle->find(lowerDetid) == clusterHandle->end() ||
148  clusterHandle->find(upperDetid) == clusterHandle->end())
149  continue;
150 
152  edmNew::DetSet<TTCluster<Ref_Phase2TrackerDigi_>> lowerClusters = (*clusterHandle)[lowerDetid];
153  edmNew::DetSet<TTCluster<Ref_Phase2TrackerDigi_>> upperClusters = (*clusterHandle)[upperDetid];
154 
157  if (lowerClusters.empty() || upperClusters.empty())
158  continue;
159 
161  std::vector<TTCluster<Ref_Phase2TrackerDigi_>> tempClusLowerAcc;
162  std::vector<TTCluster<Ref_Phase2TrackerDigi_>> tempClusLowerRej;
163  std::vector<TTCluster<Ref_Phase2TrackerDigi_>> tempClusUpperAcc;
164  std::vector<TTCluster<Ref_Phase2TrackerDigi_>> tempClusUpperRej;
165  std::vector<TTStub<Ref_Phase2TrackerDigi_>> tempStubAcc;
166  std::vector<TTStub<Ref_Phase2TrackerDigi_>> tempStubRej;
167  tempClusLowerAcc.clear();
168  tempClusLowerRej.clear();
169  tempClusUpperAcc.clear();
170  tempClusUpperRej.clear();
171  tempStubAcc.clear();
172  tempStubRej.clear();
173 
176  const int chipSize = isPS ? 120 : 127;
177  // No. of macro pixels along local y in each half of 2S module.
178  constexpr int numMacroPixels = 16;
179 
181  for (auto lowerClusterIter = lowerClusters.begin(); lowerClusterIter != lowerClusters.end(); ++lowerClusterIter) {
183  std::vector<TTStub<Ref_Phase2TrackerDigi_>> tempOutput;
184 
185  for (auto upperClusterIter = upperClusters.begin(); upperClusterIter != upperClusters.end(); ++upperClusterIter) {
187  TTStub<Ref_Phase2TrackerDigi_> tempTTStub(stackDetid);
188  tempTTStub.addClusterRef(edmNew::makeRefTo(clusterHandle, lowerClusterIter));
189  tempTTStub.addClusterRef(edmNew::makeRefTo(clusterHandle, upperClusterIter));
190  tempTTStub.setModuleTypePS(isPS);
191 
193  bool thisConfirmation = false;
194  int thisDisplacement = 999999;
195  int thisOffset = 0;
196  float thisHardBend = 0;
197 
198  theStubFindingAlgoHandle->PatternHitCorrelation(
199  thisConfirmation, thisDisplacement, thisOffset, thisHardBend, tempTTStub);
200  // Removed real offset. Ivan Reid 10/2019
201 
203  if (thisConfirmation) {
204  tempTTStub.setRawBend(thisDisplacement);
205  tempTTStub.setBendOffset(thisOffset);
206  tempTTStub.setBendBE(thisHardBend);
207  tempOutput.push_back(tempTTStub);
208  }
209  }
210 
213  if (ForbidMultipleStubs && tempOutput.size() > 1 + static_cast<unsigned int>(isPS)) {
215  std::sort(tempOutput.begin(), tempOutput.end(), TTStubBuilder<Ref_Phase2TrackerDigi_>::SortStubsBend);
216 
218  typename std::vector<TTStub<Ref_Phase2TrackerDigi_>>::iterator tempIter = tempOutput.begin();
219  ++tempIter;
220  if (isPS)
221  ++tempIter; // PS module case
223 
225  tempOutput.erase(tempIter, tempOutput.end());
226  }
227 
230 
232 
233  for (auto& tempTTStub : tempOutput) {
235  if (not applyFE) // No dynamic inefficiencies
236  {
238  tempClusLowerAcc.push_back(*(tempTTStub.clusterRef(0)));
239  tempClusUpperAcc.push_back(*(tempTTStub.clusterRef(1)));
240  tempStubAcc.push_back(tempTTStub);
241  } else {
242  bool FEreject = false;
243 
245  MeasurementPoint mp0 = tempTTStub.clusterRef(0)->findAverageLocalCoordinates();
246  int seg = static_cast<int>(mp0.y()); // Identifies which half of module
247  if (isPS)
248  seg = seg / numMacroPixels;
250  int chip = 1000 * nmod + 10 * int(tempTTStub.innerClusterPosition() / chipSize) + seg;
252  int CIC_chip = 10 * nmod + seg;
253 
254  // First look is the stub is passing trough the very front end (CBC/MPA)
255  maxStubs = isPS ? maxStubs_PS : maxStubs_2S;
256 
257  if (isPS) // MPA
258  {
259  if (moduleStubs_MPA[chip] < int(maxStubs)) {
260  moduleStubs_MPA[chip]++;
261  } else {
262  FEreject = true;
263  }
264  } else // CBC
265  {
266  if (moduleStubs_CBC[chip] < int(maxStubs)) {
267  moduleStubs_CBC[chip]++;
268  } else {
269  FEreject = true;
270  }
271  }
272 
273  // End of the MPA/CBC loop
274 
275  // If the stub has been already thrown out, there is no reason to include it into the CIC stream
276  // We put it in the rejected container, flagged with offset to indicate reason.
277 
278  if (FEreject) {
279  tempTTStub.setRawBend(CBCFailOffset + 2. * tempTTStub.rawBend());
280  tempTTStub.setBendOffset(CBCFailOffset + 2. * tempTTStub.bendOffset());
281  tempClusLowerRej.push_back(*(tempTTStub.clusterRef(0)));
282  tempClusUpperRej.push_back(*(tempTTStub.clusterRef(1)));
283  tempStubRej.push_back(tempTTStub);
284  continue;
285  }
286 
287  maxStubs = isPS ? maxStubs_PS_CIC_5 : maxStubs_2S_CIC_5;
288 
289  if (is10G_PS)
290  maxStubs = maxStubs_PS_CIC_10;
291 
292  bool CIC_reject = true;
293 
294  moduleStubs_CIC[CIC_chip].push_back(tempTTStub); //We temporarily add the new stub
295 
296  if (moduleStubs_CIC[CIC_chip].size() <= maxStubs) {
297  tempClusLowerAcc.push_back(*(tempTTStub.clusterRef(0)));
298  tempClusUpperAcc.push_back(*(tempTTStub.clusterRef(1)));
299  tempStubAcc.push_back(tempTTStub); // The stub is kept
300 
301  } else {
305 
307  bendMap.clear();
308  bendMap.reserve(moduleStubs_CIC[CIC_chip].size());
309 
310  for (unsigned int i = 0; i < moduleStubs_CIC[CIC_chip].size(); ++i) {
311  bendMap.emplace_back(i, moduleStubs_CIC[CIC_chip].at(i).bendFE());
312  }
313 
314  std::sort(bendMap.begin(), bendMap.end(), TTStubBuilder<Ref_Phase2TrackerDigi_>::SortStubBendPairs);
315 
316  // bendMap contains link over all the stubs included in moduleStubs_CIC[CIC_chip]
317 
318  for (unsigned int i = 0; i < maxStubs; ++i) {
319  // The stub we have just added is amongst those with smallest |bend| so keep it.
320  if (bendMap[i].first == moduleStubs_CIC[CIC_chip].size() - 1) {
321  CIC_reject = false;
322  }
323  }
324 
325  if (CIC_reject) // The stub added does not pass the cut
326  {
327  tempTTStub.setRawBend(CICFailOffset + 2. * tempTTStub.rawBend());
328  tempTTStub.setBendOffset(CICFailOffset + 2. * tempTTStub.bendOffset());
329  tempClusLowerRej.push_back(*(tempTTStub.clusterRef(0)));
330  tempClusUpperRej.push_back(*(tempTTStub.clusterRef(1)));
331  tempStubRej.push_back(tempTTStub);
332  } else {
333  tempClusLowerAcc.push_back(*(tempTTStub.clusterRef(0)));
334  tempClusUpperAcc.push_back(*(tempTTStub.clusterRef(1)));
335  tempStubAcc.push_back(tempTTStub); // The stub is added
336  }
337  }
338  }
339  }
340  }
341 
343  if (not tempClusLowerAcc.empty())
344  this->fill(*ttClusterDSVForOutputAcc, lowerDetid, tempClusLowerAcc);
345  if (not tempClusLowerRej.empty())
346  this->fill(*ttClusterDSVForOutputRej, lowerDetid, tempClusLowerRej);
347  if (not tempClusUpperAcc.empty())
348  this->fill(*ttClusterDSVForOutputAcc, upperDetid, tempClusUpperAcc);
349  if (not tempClusUpperRej.empty())
350  this->fill(*ttClusterDSVForOutputRej, upperDetid, tempClusUpperRej);
351  if (not tempStubAcc.empty())
352  this->fill(*ttStubDSVForOutputAccTemp, stackDetid, tempStubAcc);
353  if (not tempStubRej.empty())
354  this->fill(*ttStubDSVForOutputRejTemp, stackDetid, tempStubRej);
355 
356  }
357 
358  // Store the subset of clusters associated to stubs.
359 
361  iEvent.put(std::move(ttClusterDSVForOutputAcc), "ClusterAccepted");
363  iEvent.put(std::move(ttClusterDSVForOutputRej), "ClusterRejected");
364 
368 
369  this->updateStubs(ttClusterAccHandle, *ttStubDSVForOutputAccTemp, *ttStubDSVForOutputAcc);
370  this->updateStubs(ttClusterRejHandle, *ttStubDSVForOutputRejTemp, *ttStubDSVForOutputRej);
371 
373  iEvent.put(std::move(ttStubDSVForOutputAcc), "StubAccepted");
374  iEvent.put(std::move(ttStubDSVForOutputRej), "StubRejected");
375 
376  ++ievt;
377  if (ievt % 8 == 0)
378  moduleStubs_CIC.clear(); // Everything is cleared up after 8BX
379  if (ievt % 2 == 0)
380  moduleStubs_MPA.clear(); // Everything is cleared up after 2BX
381  moduleStubs_CBC.clear(); // Everything is cleared up after everyBX
382 }
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)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
unsigned int maxStubs_PS_CIC_10
Definition: TTStubBuilder.h:99
T y() const
Definition: PV2DBase.h:44
unsigned int tidRing(const DetId &id) const
unsigned int high_rate_max_layer
edm::ESHandle< TTStubAlgorithm< T > > theStubFindingAlgoHandle
Data members.
Definition: TTStubBuilder.h:58
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void updateStubs(const edm::OrphanHandle< edmNew::DetSetVector< TTCluster< Ref_Phase2TrackerDigi_ >>> &clusterHandle, const edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ >> &inputEDstubs, edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ >> &outputEDstubs) const
Update output stubs with Refs to cluster collection that is associated to stubs.
unsigned int high_rate_max_ring[5]
unsigned int tidWheel(const DetId &id) const
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
bool ForbidMultipleStubs
Definition: TTStubBuilder.h:63
int ievt
Temporary storage for stubs over several events for truncation use.
DetId partnerDetId(const DetId &id) const
bool isLower(const DetId &id) const
unsigned int maxStubs_2S_CIC_5
Definition: TTStubBuilder.h:97
bool empty() const
Definition: DetSetNew.h:70
def move
Definition: eostools.py:511
unsigned int maxStubs_2S
Definition: TTStubBuilder.h:95
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
edm::EDGetTokenT< edmNew::DetSetVector< TTCluster< T > > > clustersToken
Definition: TTStubBuilder.h:59
static constexpr auto TOB
ModuleType getDetectorType(DetId) const
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
std::unordered_map< int, int > moduleStubs_MPA
unsigned int maxStubs_PS
Definition: TTStubBuilder.h:96
std::unordered_map< int, int > moduleStubs_CBC
Definition: DetId.h:17
void fill(edmNew::DetSetVector< TT > &outputEP, const DetId &detId, const std::vector< TT > &inputVec) const
Fill output cluster &amp; stub collections.
Definition: TTStubBuilder.h:78
uint32_t stack(const DetId &id) const
T const * product() const
Definition: ESHandle.h:86
unsigned int layer(const DetId &id) const
unsigned int maxStubs_PS_CIC_5
Definition: TTStubBuilder.h:98
iterator end()
Definition: DetSetNew.h:56
std::unordered_map< int, std::vector< TTStub< Ref_Phase2TrackerDigi_ > > > moduleStubs_CIC
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken
Definition: TTStubBuilder.h:60
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
bool applyFE
FE truncation.
Definition: TTStubBuilder.h:92
static constexpr auto TID
tuple size
Write out results.
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tGeomToken
Definition: TTStubBuilder.h:61
Plugin to load the Stub finding algorithm and produce the collection of Stubs that goes in the event ...
Definition: TTStubBuilder.h:45
iterator begin()
Definition: DetSetNew.h:54
template<>
void TTStubBuilder< Ref_Phase2TrackerDigi_ >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual
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 174 of file TTStubBuilder.h.

References funct::abs().

175  {
176  return std::abs(left.second) < std::abs(right.second);
177 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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 181 of file TTStubBuilder.h.

References funct::abs(), and TTStub< T >::bendFE().

181  {
182  return std::abs(left.bendFE()) < std::abs(right.bendFE());
183 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double bendFE() const
BendFE(): In FULL-STRIP units from FE! Rename of getTriggerBend()
Definition: TTStub.h:203
template<>
void TTStubBuilder< Ref_Phase2TrackerDigi_ >::updateStubs ( const edm::OrphanHandle< edmNew::DetSetVector< TTCluster< Ref_Phase2TrackerDigi_ >>> &  clusterHandle,
const edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ >> &  inputEDstubs,
edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ >> &  outputEDstubs 
) const
private

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
Ian Tomalin
Date
2013 - 2020Update output stubs with Refs to cluster collection that is associated to stubs.

Loop over tracker modules

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 in this module

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

getters for RawBend & BendOffset are in FULL-strip units, setters are in HALF-strip units

End of loop over stubs of this module

End of loop over stub DetSetVector

Definition at line 18 of file TTStubBuilder.cc.

References edmNew::DetSet< T >::begin(), edmNew::DetSet< T >::end(), edmNew::makeRefTo(), callgraph::module, and edmNew::DetSetVector< T >::push_back().

21  {
23  for (const auto& module : inputEDstubs) {
25  DetId thisStackedDetId = module.id();
26  typename edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>::FastFiller outputFiller(outputEDstubs,
27  thisStackedDetId);
28 
31  DetId lowerDetid = thisStackedDetId + 1;
32  DetId upperDetid = thisStackedDetId + 2;
33 
35  edmNew::DetSet<TTCluster<Ref_Phase2TrackerDigi_>> lowerClusters = (*clusterHandle)[lowerDetid];
36  edmNew::DetSet<TTCluster<Ref_Phase2TrackerDigi_>> upperClusters = (*clusterHandle)[upperDetid];
37 
39  edmNew::DetSet<TTStub<Ref_Phase2TrackerDigi_>> theseStubs = inputEDstubs[thisStackedDetId];
40 
43  typename edmNew::DetSet<TTCluster<Ref_Phase2TrackerDigi_>>::const_iterator clusterIter;
44  for (const auto& stub : theseStubs) {
46  TTStub<Ref_Phase2TrackerDigi_> tempTTStub(stub.getDetId());
47 
50  lowerClusterToBeReplaced = stub.clusterRef(0);
51  const edm::Ref<edmNew::DetSetVector<TTCluster<Ref_Phase2TrackerDigi_>>, TTCluster<Ref_Phase2TrackerDigi_>>&
52  upperClusterToBeReplaced = stub.clusterRef(1);
53 
54  bool lowerOK = false;
55  bool upperOK = false;
56 
57  for (clusterIter = lowerClusters.begin(); clusterIter != lowerClusters.end() && !lowerOK; ++clusterIter) {
58  if (clusterIter->getHits() == lowerClusterToBeReplaced->getHits()) {
59  tempTTStub.addClusterRef(edmNew::makeRefTo(clusterHandle, clusterIter));
60  lowerOK = true;
61  }
62  }
63 
64  for (clusterIter = upperClusters.begin(); clusterIter != upperClusters.end() && !upperOK; ++clusterIter) {
65  if (clusterIter->getHits() == upperClusterToBeReplaced->getHits()) {
66  tempTTStub.addClusterRef(edmNew::makeRefTo(clusterHandle, clusterIter));
67  upperOK = true;
68  }
69  }
70 
72  if (!lowerOK || !upperOK)
73  continue;
74 
76  tempTTStub.setRawBend(2. * stub.rawBend());
77  tempTTStub.setBendOffset(2. * stub.bendOffset());
78  tempTTStub.setBendBE(stub.bendBE());
79  tempTTStub.setModuleTypePS(stub.moduleTypePS());
80 
81  outputFiller.push_back(tempTTStub);
82 
83  }
84  }
85 }
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)
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
Definition: DetId.h:17
NOTE: this is needed even if it seems not.
Definition: TTCluster.h:27
iterator end()
Definition: DetSetNew.h:56
tuple module
Definition: callgraph.py:69
iterator begin()
Definition: DetSetNew.h:54
template<typename T >
void TTStubBuilder< T >::updateStubs ( const edm::OrphanHandle< edmNew::DetSetVector< TTCluster< Ref_Phase2TrackerDigi_ >>> &  clusterHandle,
const edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ >> &  inputEDstubs,
edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ >> &  outputEDstubs 
) const
private

Update output stubs with Refs to cluster collection that is associated to stubs.

Member Data Documentation

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

FE truncation.

Definition at line 92 of file TTStubBuilder.h.

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

Definition at line 59 of file TTStubBuilder.h.

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

Definition at line 63 of file TTStubBuilder.h.

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

Definition at line 106 of file TTStubBuilder.h.

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

Definition at line 105 of file TTStubBuilder.h.

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

Temporary storage for stubs over several events for truncation use.

Definition at line 109 of file TTStubBuilder.h.

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

Definition at line 95 of file TTStubBuilder.h.

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

Definition at line 97 of file TTStubBuilder.h.

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

Definition at line 96 of file TTStubBuilder.h.

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

Definition at line 99 of file TTStubBuilder.h.

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

Definition at line 98 of file TTStubBuilder.h.

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

Definition at line 112 of file TTStubBuilder.h.

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

Definition at line 110 of file TTStubBuilder.h.

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

Definition at line 111 of file TTStubBuilder.h.

template<typename T >
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> TTStubBuilder< T >::tGeomToken
private

Definition at line 61 of file TTStubBuilder.h.

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

Data members.

Definition at line 58 of file TTStubBuilder.h.

template<typename T >
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> TTStubBuilder< T >::tTopoToken
private

Definition at line 60 of file TTStubBuilder.h.

template<typename T >
edm::ESGetToken<TTStubAlgorithm<T>, TTStubAlgorithmRecord> TTStubBuilder< T >::ttStubToken
private

Definition at line 62 of file TTStubBuilder.h.