From 68827f3bea4b4c190930b7332d5bc2f0e13b83dd Mon Sep 17 00:00:00 2001 From: tschuh Date: Fri, 29 Oct 2021 22:59:39 +0100 Subject: [PATCH] code-format, llvm-ccdb and clang-tidy (#103) --- DataFormats/L1TrackTrigger/interface/TTBV.h | 8 +- .../L1TrackTrigger/interface/TTTypes.h | 16 +- .../interface/TrackBuilderChannel.h | 5 +- .../interface/TrackBuilderChannelRcd.h | 3 +- .../plugins/ProducerAS.cc | 6 +- .../plugins/ProducerKFin.cc | 14 +- .../plugins/ProducerKFout.cc | 233 +++---- .../plugins/ProducerTT.cc | 10 +- .../src/TrackBuilderChannel.cc | 11 +- .../TrackFindingTracklet/test/AnalyzerKFin.cc | 43 +- .../test/AnalyzerKFout.cc | 21 +- .../TrackFindingTracklet/test/AnalyzerTT.cc | 8 +- .../test/AnalyzerTracklet.cc | 30 +- L1Trigger/TrackTrigger/interface/Setup.h | 19 +- L1Trigger/TrackTrigger/interface/SetupRcd.h | 10 +- L1Trigger/TrackTrigger/src/Setup.cc | 9 +- .../TrackerDTC/interface/LayerEncoding.h | 5 +- .../TrackerDTC/interface/LayerEncodingRcd.h | 3 +- L1Trigger/TrackerDTC/plugins/ProducerED.cc | 3 +- L1Trigger/TrackerDTC/src/LayerEncoding.cc | 2 +- L1Trigger/TrackerDTC/src/Stub.cc | 19 +- L1Trigger/TrackerDTC/test/Analyzer.cc | 7 +- L1Trigger/TrackerDTC/test/AnalyzerDAQ.cc | 3 +- L1Trigger/TrackerTFP/interface/DataFormats.h | 594 +++++++++++++----- L1Trigger/TrackerTFP/interface/Demonstrator.h | 10 +- L1Trigger/TrackerTFP/interface/DistServer.h | 44 +- .../TrackerTFP/interface/GeometricProcessor.h | 11 +- .../TrackerTFP/interface/HoughTransform.h | 16 +- L1Trigger/TrackerTFP/interface/KalmanFilter.h | 22 +- .../interface/KalmanFilterFormats.h | 163 +++-- .../interface/KalmanFilterFormatsRcd.h | 3 +- .../TrackerTFP/interface/LayerEncoding.h | 13 +- .../TrackerTFP/interface/LayerEncodingRcd.h | 3 +- .../TrackerTFP/interface/MiniHoughTransform.h | 11 +- L1Trigger/TrackerTFP/interface/State.h | 5 +- .../TrackerTFP/interface/ZHoughTransform.h | 11 +- L1Trigger/TrackerTFP/plugins/ProducerGP.cc | 10 +- L1Trigger/TrackerTFP/plugins/ProducerHT.cc | 10 +- L1Trigger/TrackerTFP/plugins/ProducerKF.cc | 11 +- L1Trigger/TrackerTFP/plugins/ProducerKFin.cc | 19 +- L1Trigger/TrackerTFP/plugins/ProducerMHT.cc | 10 +- L1Trigger/TrackerTFP/plugins/ProducerTT.cc | 10 +- L1Trigger/TrackerTFP/plugins/ProducerZHT.cc | 10 +- .../TrackerTFP/plugins/ProducerZHTout.cc | 18 +- L1Trigger/TrackerTFP/src/DataFormats.cc | 473 +++++++------- L1Trigger/TrackerTFP/src/Demonstrator.cc | 25 +- L1Trigger/TrackerTFP/src/DistServer.cc | 89 ++- .../TrackerTFP/src/GeometricProcessor.cc | 41 +- L1Trigger/TrackerTFP/src/HoughTransform.cc | 62 +- L1Trigger/TrackerTFP/src/KalmanFilter.cc | 150 +++-- .../TrackerTFP/src/KalmanFilterFormats.cc | 234 ++++--- L1Trigger/TrackerTFP/src/LayerEncoding.cc | 45 +- .../TrackerTFP/src/MiniHoughTransform.cc | 100 +-- L1Trigger/TrackerTFP/src/State.cc | 94 ++- L1Trigger/TrackerTFP/src/ZHoughTransform.cc | 103 ++- .../TrackerTFP/test/AnalyzerDemonstrator.cc | 27 +- L1Trigger/TrackerTFP/test/AnalyzerGP.cc | 6 +- L1Trigger/TrackerTFP/test/AnalyzerHT.cc | 20 +- L1Trigger/TrackerTFP/test/AnalyzerKF.cc | 49 +- L1Trigger/TrackerTFP/test/AnalyzerKFin.cc | 43 +- L1Trigger/TrackerTFP/test/AnalyzerMHT.cc | 29 +- L1Trigger/TrackerTFP/test/AnalyzerTT.cc | 37 +- L1Trigger/TrackerTFP/test/AnalyzerZHT.cc | 30 +- L1Trigger/TrackerTFP/test/ProducerAS.cc | 6 +- .../interface/StubAssociation.h | 10 +- .../plugins/StubAssociator.cc | 14 +- .../src/StubAssociation.cc | 2 +- 67 files changed, 1959 insertions(+), 1222 deletions(-) diff --git a/DataFormats/L1TrackTrigger/interface/TTBV.h b/DataFormats/L1TrackTrigger/interface/TTBV.h index e92f198bad1d1..f18f96cacd900 100644 --- a/DataFormats/L1TrackTrigger/interface/TTBV.h +++ b/DataFormats/L1TrackTrigger/interface/TTBV.h @@ -268,7 +268,9 @@ class TTBV { double val(double base) const { return (this->val() + .5) * base; } // conversion: range based to double for given precision assuming biased (floor) representation, reinterpret sign - double val(double base, int start, int end = 0, bool twos = false) const { return (this->val(start, end, twos) + .5) * base; } + double val(double base, int start, int end = 0, bool twos = false) const { + return (this->val(start, end, twos) + .5) * base; + } // maniplulation and conversion: extracts range based to double reinterpret sign and removes these bits double extract(double base, int size, bool twos = false) { @@ -332,7 +334,7 @@ class TTBV { std::vector ids(bool b = true, bool singed = false) const { std::vector v; v.reserve(bs_.count()); - for(int i = 0; i < size_; i++) + for (int i = 0; i < size_; i++) if (bs_[i] == b) v.push_back(singed ? i + size_ / 2 : i); return v; @@ -356,6 +358,4 @@ class TTBV { } }; - - #endif diff --git a/DataFormats/L1TrackTrigger/interface/TTTypes.h b/DataFormats/L1TrackTrigger/interface/TTTypes.h index 76618292faf33..379cfed2375bc 100644 --- a/DataFormats/L1TrackTrigger/interface/TTTypes.h +++ b/DataFormats/L1TrackTrigger/interface/TTTypes.h @@ -24,17 +24,17 @@ /// Templated aliases template -using TTClusterDetSetVecT = edmNew::DetSetVector >; +using TTClusterDetSetVecT = edmNew::DetSetVector>; template -using TTStubDetSetVecT = edmNew::DetSetVector >; +using TTStubDetSetVecT = edmNew::DetSetVector>; template -using TTClusterRefT = edm::Ref, TTCluster >; +using TTClusterRefT = edm::Ref, TTCluster>; template -using TTStubRefT = edm::Ref, TTStub >; +using TTStubRefT = edm::Ref, TTStub>; template -using TTTrackPtrT = edm::Ptr >; +using TTTrackPtrT = edm::Ptr>; /// Specialized aliases typedef edm::Ref, Phase2TrackerDigi> Ref_Phase2TrackerDigi_; @@ -45,8 +45,8 @@ typedef TTStubDetSetVecT TTStubDetSetVec; typedef TTClusterRefT TTClusterRef; typedef TTStubRefT TTStubRef; -typedef edmNew::DetSet > TTStubDetSet; -typedef edmNew::DetSet > TTClusterDetSet; +typedef edmNew::DetSet> TTStubDetSet; +typedef edmNew::DetSet> TTClusterDetSet; typedef edm::Ref>, TTTrack> TTTrackRef; typedef TTTrackPtrT TTTrackPtr; @@ -66,6 +66,6 @@ namespace tt { typedef std::vector StreamsTrack; typedef std::map TTTrackRefMap; typedef std::vector> TTTracks; -} // namespace tt +} // namespace tt #endif diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackBuilderChannel.h b/L1Trigger/TrackFindingTracklet/interface/TrackBuilderChannel.h index 527cdc4c4996d..a207a556fa10e 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackBuilderChannel.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackBuilderChannel.h @@ -20,11 +20,12 @@ namespace trackFindingTracklet { public: TrackBuilderChannel() {} TrackBuilderChannel(const edm::ParameterSet& iConfig); - ~TrackBuilderChannel(){} + ~TrackBuilderChannel() {} // sets channelId of given TTTrack, return false if track outside pt range bool channelId(const TTTrack& ttTrack, int& channelId); // number of used channels int numChannels() const { return numChannels_; } + private: // use tracklet seed type as channel id if False, binned track pt used if True bool useDuplicateRemoval_; @@ -34,7 +35,7 @@ namespace trackFindingTracklet { int numChannels_; }; -} // namespace trackFindingTracklet +} // namespace trackFindingTracklet EVENTSETUP_DATA_DEFAULT_RECORD(trackFindingTracklet::TrackBuilderChannel, trackFindingTracklet::TrackBuilderChannelRcd); diff --git a/L1Trigger/TrackFindingTracklet/interface/TrackBuilderChannelRcd.h b/L1Trigger/TrackFindingTracklet/interface/TrackBuilderChannelRcd.h index 63e181b3120db..097b0ae5192c3 100644 --- a/L1Trigger/TrackFindingTracklet/interface/TrackBuilderChannelRcd.h +++ b/L1Trigger/TrackFindingTracklet/interface/TrackBuilderChannelRcd.h @@ -9,7 +9,8 @@ namespace trackFindingTracklet { typedef edm::mpl::Vector RcdsTrackBuilderChannel; - class TrackBuilderChannelRcd : public edm::eventsetup::DependentRecordImplementation {}; + class TrackBuilderChannelRcd + : public edm::eventsetup::DependentRecordImplementation {}; } // namespace trackFindingTracklet diff --git a/L1Trigger/TrackFindingTracklet/plugins/ProducerAS.cc b/L1Trigger/TrackFindingTracklet/plugins/ProducerAS.cc index ae3067a394e5d..a3f5296472aa1 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/ProducerAS.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/ProducerAS.cc @@ -50,9 +50,7 @@ namespace trackFindingTracklet { const Setup* setup_; }; - ProducerAS::ProducerAS(const ParameterSet& iConfig) : - iConfig_(iConfig) - { + ProducerAS::ProducerAS(const ParameterSet& iConfig) : iConfig_(iConfig) { const string& labelKF = iConfig.getParameter("LabelKF"); const string& labelTT = iConfig.getParameter("LabelTT"); const string& branch = iConfig.getParameter("BranchAcceptedTracks"); @@ -96,6 +94,6 @@ namespace trackFindingTracklet { iEvent.emplace(edPutToken_, move(ttTrackMap)); } -} // namespace trackFindingTracklet +} // namespace trackFindingTracklet DEFINE_FWK_MODULE(trackFindingTracklet::ProducerAS); \ No newline at end of file diff --git a/L1Trigger/TrackFindingTracklet/plugins/ProducerKFin.cc b/L1Trigger/TrackFindingTracklet/plugins/ProducerKFin.cc index 10e4e6e462786..a83a57659b60d 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/ProducerKFin.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/ProducerKFin.cc @@ -74,9 +74,7 @@ namespace trackFindingTracklet { bool enableTruncation_; }; - ProducerKFin::ProducerKFin(const ParameterSet& iConfig) : - iConfig_(iConfig) - { + ProducerKFin::ProducerKFin(const ParameterSet& iConfig) : iConfig_(iConfig) { const InputTag& inputTag = iConfig.getParameter("InputTag"); const string& branchAcceptedStubs = iConfig.getParameter("BranchAcceptedStubs"); const string& branchAcceptedTracks = iConfig.getParameter("BranchAcceptedTracks"); @@ -180,13 +178,15 @@ namespace trackFindingTracklet { // get rphi parameter double inv2R = dfinv2R.digi(-ttTrackRef->rInv() / 2.); // calculcate track phi at radius hybridChosenRofPhi with respect to phi sector centre - double phiT = dfphiT.digi(deltaPhi(ttTrackRef->phi() + dataFormats_->chosenRofPhi() * inv2R - ttTrackRef->phiSector() * setup_->baseRegion())); - const int sectorPhi = phiT < 0. ? 0 : 1; // dirty hack + double phiT = dfphiT.digi(deltaPhi(ttTrackRef->phi() + dataFormats_->chosenRofPhi() * inv2R - + ttTrackRef->phiSector() * setup_->baseRegion())); + const int sectorPhi = phiT < 0. ? 0 : 1; // dirty hack phiT -= (sectorPhi - .5) * setup_->baseSector(); // cut on nonant size and pt if (!dfphiT.inRange(phiT) || !dfinv2R.inRange(inv2R)) continue; - const double offsetPhi = (ttTrackRef->phiSector() * setup_->numSectorsPhi() + sectorPhi - .5) * setup_->baseSector(); + const double offsetPhi = + (ttTrackRef->phiSector() * setup_->numSectorsPhi() + sectorPhi - .5) * setup_->baseSector(); // check hitPattern TTBV hitPattern(0, setup_->numLayers()); static constexpr double scalePhi = 4.0; @@ -279,6 +279,6 @@ namespace trackFindingTracklet { iEvent.emplace(edPutTokenLostTracks_, move(streamLostTracks)); } -} // namespace trackFindingTracklet +} // namespace trackFindingTracklet DEFINE_FWK_MODULE(trackFindingTracklet::ProducerKFin); \ No newline at end of file diff --git a/L1Trigger/TrackFindingTracklet/plugins/ProducerKFout.cc b/L1Trigger/TrackFindingTracklet/plugins/ProducerKFout.cc index d3aa2545f4930..3891bd672fb86 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/ProducerKFout.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/ProducerKFout.cc @@ -33,8 +33,8 @@ namespace trackFindingTracklet { public: explicit ProducerKFout(const ParameterSet&); ~ProducerKFout() override {} - template - int digitise(const vector Bins, T Value, T factor = 1 ); + template + int digitise(const vector Bins, T Value, T factor = 1); private: void beginRun(const Run&, const EventSetup&) override; @@ -61,20 +61,18 @@ namespace trackFindingTracklet { const Setup* setup_; // helper class to extract structured data from TTDTC::Frames const DataFormats* dataFormats_; - // Bins for dPhi/dZ use to create weight LUT + // Bins for dPhi/dZ use to create weight LUT vector dPhiBins_; vector dZBins_; - + // Constant used throughout for partial ttrack words int partialTrackWordBits_; - // For convenience and keeping readable code, accessed many times + // For convenience and keeping readable code, accessed many times int numWorkers_; }; - ProducerKFout::ProducerKFout(const ParameterSet& iConfig) : - iConfig_(iConfig) - { + ProducerKFout::ProducerKFout(const ParameterSet& iConfig) : iConfig_(iConfig) { const string& labelKF = iConfig.getParameter("LabelKF"); const string& labelAS = iConfig.getParameter("LabelAS"); const string& branchStubs = iConfig.getParameter("BranchAcceptedStubs"); @@ -106,21 +104,28 @@ namespace trackFindingTracklet { dataFormats_ = &iSetup.getData(esGetTokenDataFormats_); // Calculate 1/dz**2 and 1/dphi**2 bins for v0 and v1 weightings - for (int i = 0; i < pow(2,dataFormats_->width(Variable::dPhi, Process::kfin)) / pow(2, setup_->weightBinFraction()); i++) - dPhiBins_.push_back( pow(dataFormats_->base(Variable::dPhi, Process::kfin) * ( i + 1) * pow(2, setup_->weightBinFraction()),-2)); - - for (int i = 0; i < pow(2,dataFormats_->width(Variable::dZ, Process::kfin)) / pow(2, setup_->weightBinFraction()); i++) - dZBins_.push_back( pow(dataFormats_->base(Variable::dZ, Process::kfin) * ( i + 1) * pow(2, setup_->weightBinFraction()),-2)); - - partialTrackWordBits_ = TTBV::S_/2; + for (int i = 0; + i < pow(2, dataFormats_->width(Variable::dPhi, Process::kfin)) / pow(2, setup_->weightBinFraction()); + i++) + dPhiBins_.push_back( + pow(dataFormats_->base(Variable::dPhi, Process::kfin) * (i + 1) * pow(2, setup_->weightBinFraction()), -2)); + + for (int i = 0; i < pow(2, dataFormats_->width(Variable::dZ, Process::kfin)) / pow(2, setup_->weightBinFraction()); + i++) + dZBins_.push_back( + pow(dataFormats_->base(Variable::dZ, Process::kfin) * (i + 1) * pow(2, setup_->weightBinFraction()), -2)); + + partialTrackWordBits_ = TTBV::S_ / 2; numWorkers_ = setup_->kfNumWorker(); } // Helper function to convert floating chi2 to chi2 bin - template - int ProducerKFout::digitise(const vector Bins, T Value, T factor ) { - for (int i = 0; i < (int)Bins.size(); i++){ - if (Value*factor > Bins[i] && Value*factor <= Bins[i+1]) {return i;} + template + int ProducerKFout::digitise(const vector Bins, T Value, T factor) { + for (int i = 0; i < (int)Bins.size(); i++) { + if (Value * factor > Bins[i] && Value * factor <= Bins[i + 1]) { + return i; + } } return -1; } @@ -140,18 +145,18 @@ namespace trackFindingTracklet { Handle handleTTTrackRefMap; iEvent.getByToken(edGetTokenTTTrackRefMap_, handleTTTrackRefMap); const TTTrackRefMap& ttTrackRefMap = *handleTTTrackRefMap.product(); - // 18 Output Links (First Vector) each has a vector of tracks per event (second vector) each track is 3 32 bit TTBV partial tracks - vector> SortedPartialTracks(setup_->numRegions() * setup_->tfpNumChannel(),vector(0)); + // 18 Output Links (First Vector) each has a vector of tracks per event (second vector) each track is 3 32 bit TTBV partial tracks + vector> SortedPartialTracks(setup_->numRegions() * setup_->tfpNumChannel(), vector(0)); - TrackKFOutSAPtrCollectionss InTrackStreams; + TrackKFOutSAPtrCollectionss InTrackStreams; TrackKFOutSAPtrCollectionss OutTrackStreams; // Setup empty collections for input tracks to distribution server - for (int iRegion = 0; iRegion < setup_->numRegions(); iRegion++){ + for (int iRegion = 0; iRegion < setup_->numRegions(); iRegion++) { TrackKFOutSAPtrCollections temp_collection; - for (int iLink=0; iLink < setup_->tfpNumChannel(); iLink++){ + for (int iLink = 0; iLink < setup_->tfpNumChannel(); iLink++) { TrackKFOutSAPtrCollection temp; - for (int iTrack = 0; iTrack < setup_->numFramesIO()* ((double)TTBV::S_/setup_->tttrackBits()); iTrack++) + for (int iTrack = 0; iTrack < setup_->numFramesIO() * ((double)TTBV::S_ / setup_->tttrackBits()); iTrack++) temp.emplace_back(std::make_shared()); temp_collection.push_back(temp); } @@ -159,11 +164,11 @@ namespace trackFindingTracklet { } // Setup empty collections for oiutpu tracks from distribution server - for (int iRegion = 0; iRegion < setup_->numRegions(); iRegion++){ + for (int iRegion = 0; iRegion < setup_->numRegions(); iRegion++) { TrackKFOutSAPtrCollections temp_collection; - for (int iLink=0; iLink < numWorkers_; iLink++){ + for (int iLink = 0; iLink < numWorkers_; iLink++) { TrackKFOutSAPtrCollection temp; - for (int iTrack = 0; iTrack < setup_->numFramesIO()* ((double)TTBV::S_/setup_->tttrackBits()); iTrack++) + for (int iTrack = 0; iTrack < setup_->numFramesIO() * ((double)TTBV::S_ / setup_->tttrackBits()); iTrack++) temp.emplace_back(std::make_shared()); temp_collection.push_back(temp); } @@ -172,140 +177,158 @@ namespace trackFindingTracklet { StreamsTrack OutputStreamsTracks(setup_->numRegions() * setup_->tfpNumChannel()); - for (int iLink = 0; iLink < (int)streamsTracks.size(); iLink++ ){ - - for (int iTrack = 0; iTrack < (int)streamsTracks[iLink].size(); iTrack++ ){ + for (int iLink = 0; iLink < (int)streamsTracks.size(); iLink++) { + for (int iTrack = 0; iTrack < (int)streamsTracks[iLink].size(); iTrack++) { const auto& track = streamsTracks[iLink].at(iTrack); - TrackKF InTrack(track,dataFormats_); - + TrackKF InTrack(track, dataFormats_); + double temp_z0 = InTrack.zT() - ((InTrack.cot() * setup_->chosenRofZ())); // Correction to Phi calcuation depending if +ve/-ve phi sector - const double baseSectorCorr = InTrack.sectorPhi() ? -setup_->baseSector(): setup_->baseSector(); + const double baseSectorCorr = InTrack.sectorPhi() ? -setup_->baseSector() : setup_->baseSector(); double temp_phi0 = InTrack.phiT() - ((InTrack.inv2R()) * setup_->hybridChosenRofPhi()) + baseSectorCorr; - + double temp_tanL = InTrack.cotGlobal(); - - TTBV HitPattern(0,setup_->numLayers()); + + TTBV HitPattern(0, setup_->numLayers()); double tempchi2rphi = 0; - double tempchi2rz = 0; + double tempchi2rz = 0; - for (int iStub = 0; iStub < setup_->numLayers() - 1; iStub++ ){ - const auto& stub = streamsStubs[setup_->numLayers()*iLink+iStub].at(iTrack); - StubKF InStub(stub,dataFormats_,iStub); + for (int iStub = 0; iStub < setup_->numLayers() - 1; iStub++) { + const auto& stub = streamsStubs[setup_->numLayers() * iLink + iStub].at(iTrack); + StubKF InStub(stub, dataFormats_, iStub); if (!stub.first.isNonnull()) continue; HitPattern.set(iStub); - double phiSquared = pow(InStub.phi(),2); - double zSquared = pow(InStub.z(),2); + double phiSquared = pow(InStub.phi(), 2); + double zSquared = pow(InStub.z(), 2); - double tempv0 = dPhiBins_[(InStub.dPhi()/(dataFormats_->base(Variable::dPhi, Process::kfin)*pow(2,setup_->weightBinFraction())))]; - double tempv1 = dZBins_[(InStub.dZ()/(dataFormats_->base(Variable::dZ, Process::kfin)*pow(2,setup_->weightBinFraction())))]; + double tempv0 = dPhiBins_[(InStub.dPhi() / (dataFormats_->base(Variable::dPhi, Process::kfin) * + pow(2, setup_->weightBinFraction())))]; + double tempv1 = dZBins_[( + InStub.dZ() / (dataFormats_->base(Variable::dZ, Process::kfin) * pow(2, setup_->weightBinFraction())))]; double tempRphi = phiSquared * tempv0; - double tempRz = zSquared * tempv1; + double tempRz = zSquared * tempv1; tempchi2rphi += tempRphi; - tempchi2rz += tempRz; - } // Iterate over track stubs + tempchi2rz += tempRz; + } // Iterate over track stubs // TODO extract TTTrack bit widths from TTTrack word pending update to the TTTrack_word class - TTBV TrackValid(1,1,false); - TTBV extraMVA(0,6,false); - TTBV TQMVA(0,3,false); - TTBV BendChi2(0,3,false); - TTBV Chi2rphi(digitise(setup_->kfoutchi2rphiBins(),tempchi2rphi,(double)setup_->kfoutchi2rphiConv()),4,false); - TTBV Chi2rz(digitise(setup_->kfoutchi2rzBins(),tempchi2rz,(double)setup_->kfoutchi2rzConv()),4,false); - TTBV D0(0,13,false); - TTBV z0(temp_z0 ,dataFormats_->base(Variable::zT,Process::kf) ,12,true); - TTBV TanL(temp_tanL,dataFormats_->base(Variable::cot,Process::kf),16,true); - TTBV phi0(temp_phi0,dataFormats_->base(Variable::phiT,Process::kf),12,true); - TTBV InvR(-InTrack.inv2R(),dataFormats_->base(Variable::inv2R,Process::kf) ,16,true ); + TTBV TrackValid(1, 1, false); + TTBV extraMVA(0, 6, false); + TTBV TQMVA(0, 3, false); + TTBV BendChi2(0, 3, false); + TTBV Chi2rphi( + digitise(setup_->kfoutchi2rphiBins(), tempchi2rphi, (double)setup_->kfoutchi2rphiConv()), 4, false); + TTBV Chi2rz(digitise(setup_->kfoutchi2rzBins(), tempchi2rz, (double)setup_->kfoutchi2rzConv()), 4, false); + TTBV D0(0, 13, false); + TTBV z0(temp_z0, dataFormats_->base(Variable::zT, Process::kf), 12, true); + TTBV TanL(temp_tanL, dataFormats_->base(Variable::cot, Process::kf), 16, true); + TTBV phi0(temp_phi0, dataFormats_->base(Variable::phiT, Process::kf), 12, true); + TTBV InvR(-InTrack.inv2R(), dataFormats_->base(Variable::inv2R, Process::kf), 16, true); InvR.resize(15); - // 13 + 3 + 7 + 3 + 3 - TTBV PartialTrack3((D0 + BendChi2 + HitPattern + TQMVA + extraMVA),partialTrackWordBits_,false); - // 16 + 12 + 4 - TTBV PartialTrack2((TanL + z0 + Chi2rz),partialTrackWordBits_,false); - // 1 + 15 + 12 + 4 - TTBV PartialTrack1(( TrackValid + InvR + phi0 + Chi2rphi ),partialTrackWordBits_,false); - - int sortKey = (InTrack.sectorEta() < (int)(setup_->numSectorsEta()/2)) ? 0 : 1; + // 13 + 3 + 7 + 3 + 3 + TTBV PartialTrack3((D0 + BendChi2 + HitPattern + TQMVA + extraMVA), partialTrackWordBits_, false); + // 16 + 12 + 4 + TTBV PartialTrack2((TanL + z0 + Chi2rz), partialTrackWordBits_, false); + // 1 + 15 + 12 + 4 + TTBV PartialTrack1((TrackValid + InvR + phi0 + Chi2rphi), partialTrackWordBits_, false); + + int sortKey = (InTrack.sectorEta() < (int)(setup_->numSectorsEta() / 2)) ? 0 : 1; // Set correct bit to valid for track valid - TrackKFOut Temp_track(PartialTrack1.set(31),PartialTrack2,PartialTrack3,sortKey,track,iTrack,iLink,true); + TrackKFOut Temp_track( + PartialTrack1.set(31), PartialTrack2, PartialTrack3, sortKey, track, iTrack, iLink, true); - InTrackStreams[iLink/numWorkers_][iLink%numWorkers_][iTrack] = (std::make_shared(Temp_track)); + InTrackStreams[iLink / numWorkers_][iLink % numWorkers_][iTrack] = (std::make_shared(Temp_track)); - } // Iterate over Tracks + } // Iterate over Tracks //Pad out input streams to Dist server with extra null track if odd number of tracks on a stream int iFinTrack = (int)streamsTracks[iLink].size(); if (iFinTrack % numWorkers_ != 0) { - TrackKFOut null_track(0,0,0,iLink%numWorkers_,tt::FrameTrack(),iFinTrack+1,iLink,true); - InTrackStreams[iLink/numWorkers_][iLink%numWorkers_][iFinTrack] = (std::make_shared(null_track)); + TrackKFOut null_track(0, 0, 0, iLink % numWorkers_, tt::FrameTrack(), iFinTrack + 1, iLink, true); + InTrackStreams[iLink / numWorkers_][iLink % numWorkers_][iFinTrack] = + (std::make_shared(null_track)); } - } // Iterate over Links + } // Iterate over Links // Fill products and match up tracks // One distribution server for every region, num inputs = num KF workers, num outputs = num output links - vector< DistServer > distServers(setup_->numRegions(), DistServer(numWorkers_, setup_->tfpNumChannel(),2)); //Magic number for interleaving in dist server + vector distServers( + setup_->numRegions(), + DistServer(numWorkers_, setup_->tfpNumChannel(), 2)); //Magic number for interleaving in dist server - for (int iRegion = 0; iRegionnumRegions(); iRegion++){ - for (int iTrack=0; iTracknumFramesIO()* ((double)TTBV::S_/setup_->tttrackBits()); iTrack++){ + for (int iRegion = 0; iRegion < setup_->numRegions(); iRegion++) { + for (int iTrack = 0; iTrack < setup_->numFramesIO() * ((double)TTBV::S_ / setup_->tttrackBits()); iTrack++) { TrackKFOutSAPtrCollection DistIn; - for (int iWorker=0; iWorkertfpNumChannel(); iLink++) - OutTrackStreams[iRegion][iLink][iTrack] = DistOut[iLink]; // Reorganise output of distribution server in output streams - } + for (int iWorker = 0; iWorker < numWorkers_; iWorker++) + DistIn.push_back(InTrackStreams[iRegion][iWorker][iTrack]); // Reorganise input to distribution server + TrackKFOutSAPtrCollection DistOut = distServers[iRegion].clock(DistIn); // Run dist server + for (int iLink = 0; iLink < setup_->tfpNumChannel(); iLink++) + OutTrackStreams[iRegion][iLink][iTrack] = + DistOut[iLink]; // Reorganise output of distribution server in output streams + } } // Pack output of distribution server onto each link, with correct partial tracks in correct places - for (int iRegion = 0; iRegion < setup_->numRegions(); iRegion++ ){ - for (int iLink = 0; iLink < setup_->tfpNumChannel(); iLink++ ){ - for (int iTrack = 0; iTrack < (int)OutTrackStreams[iRegion][iLink].size(); iTrack++ ){ - SortedPartialTracks[2*iRegion+iLink].push_back(OutTrackStreams[iRegion][iLink][iTrack]->PartialTrack1()); - SortedPartialTracks[2*iRegion+iLink].push_back(OutTrackStreams[iRegion][iLink][iTrack]->PartialTrack2()); - SortedPartialTracks[2*iRegion+iLink].push_back(OutTrackStreams[iRegion][iLink][iTrack]->PartialTrack3()); - OutputStreamsTracks[2*iRegion+iLink].emplace_back(OutTrackStreams[iRegion][iLink][iTrack]->track()); + for (int iRegion = 0; iRegion < setup_->numRegions(); iRegion++) { + for (int iLink = 0; iLink < setup_->tfpNumChannel(); iLink++) { + for (int iTrack = 0; iTrack < (int)OutTrackStreams[iRegion][iLink].size(); iTrack++) { + SortedPartialTracks[2 * iRegion + iLink].push_back( + OutTrackStreams[iRegion][iLink][iTrack]->PartialTrack1()); + SortedPartialTracks[2 * iRegion + iLink].push_back( + OutTrackStreams[iRegion][iLink][iTrack]->PartialTrack2()); + SortedPartialTracks[2 * iRegion + iLink].push_back( + OutTrackStreams[iRegion][iLink][iTrack]->PartialTrack3()); + OutputStreamsTracks[2 * iRegion + iLink].emplace_back(OutTrackStreams[iRegion][iLink][iTrack]->track()); } } } - const TTBV NullBitTrack(0,partialTrackWordBits_,false); - for (int iLink = 0; iLink < (int)OutputStreamsTracks.size(); iLink++ ){ + const TTBV NullBitTrack(0, partialTrackWordBits_, false); + for (int iLink = 0; iLink < (int)OutputStreamsTracks.size(); iLink++) { // Iterate through partial tracks int numLinkTracks = (int)OutputStreamsTracks[iLink].size(); if (numLinkTracks == 0) continue; // Don't fill links if no tracks if ((numLinkTracks % 2 != 0)) { SortedPartialTracks[iLink].push_back(NullBitTrack); //Pad out final set of bits - OutputStreamsTracks[iLink].emplace_back(OutputStreamsTracks[iLink][numLinkTracks++]); //Pad out with final repeated track - } //If there is an odd number of tracks - for (int iTrack = 0; iTrack < (int)(SortedPartialTracks[iLink].size()); iTrack++ ){ - if (iTrack % 2 != 1) // Write to links every other partial track, 3 partial tracks per full TTTrack + OutputStreamsTracks[iLink].emplace_back( + OutputStreamsTracks[iLink][numLinkTracks++]); //Pad out with final repeated track + } //If there is an odd number of tracks + for (int iTrack = 0; iTrack < (int)(SortedPartialTracks[iLink].size()); iTrack++) { + if (iTrack % 2 != 1) // Write to links every other partial track, 3 partial tracks per full TTTrack continue; TTTrackRef TrackRef; - for (auto &it : ttTrackRefMap) { //Iterate through ttTrackRefMap to find TTTrackRef Key by a TTTrack Value - if(it.second == OutputStreamsTracks[iLink][(int)(iTrack-1)/3].first) + for (auto& it : ttTrackRefMap) { //Iterate through ttTrackRefMap to find TTTrackRef Key by a TTTrack Value + if (it.second == OutputStreamsTracks[iLink][(int)(iTrack - 1) / 3].first) TrackRef = it.first; } - if ((int)iTrack/3 <= setup_->numFramesIO()* ((double)TTBV::S_/setup_->tttrackBits())) - accepted[iLink].emplace_back(std::make_pair(TrackRef,(SortedPartialTracks[iLink][iTrack-1].slice(partialTrackWordBits_) + SortedPartialTracks[iLink][iTrack].slice(partialTrackWordBits_)).bs())); + if ((int)iTrack / 3 <= setup_->numFramesIO() * ((double)TTBV::S_ / setup_->tttrackBits())) + accepted[iLink].emplace_back( + std::make_pair(TrackRef, + (SortedPartialTracks[iLink][iTrack - 1].slice(partialTrackWordBits_) + + SortedPartialTracks[iLink][iTrack].slice(partialTrackWordBits_)) + .bs())); else - lost[iLink].emplace_back(std::make_pair(TrackRef,(SortedPartialTracks[iLink][iTrack-1].slice(partialTrackWordBits_) + SortedPartialTracks[iLink][iTrack].slice(partialTrackWordBits_)).bs())); - } //Iterate through sorted partial tracks - } // Iterate through links - } // Config Supported + lost[iLink].emplace_back( + std::make_pair(TrackRef, + (SortedPartialTracks[iLink][iTrack - 1].slice(partialTrackWordBits_) + + SortedPartialTracks[iLink][iTrack].slice(partialTrackWordBits_)) + .bs())); + } //Iterate through sorted partial tracks + } // Iterate through links + } // Config Supported // store products iEvent.emplace(edPutTokenAccepted_, move(accepted)); iEvent.emplace(edPutTokenLost_, move(lost)); } -} // namespace trackFindingTracklet +} // namespace trackFindingTracklet DEFINE_FWK_MODULE(trackFindingTracklet::ProducerKFout); - diff --git a/L1Trigger/TrackFindingTracklet/plugins/ProducerTT.cc b/L1Trigger/TrackFindingTracklet/plugins/ProducerTT.cc index 9651ded3267f0..eba1cf2902748 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/ProducerTT.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/ProducerTT.cc @@ -56,9 +56,7 @@ namespace trackFindingTracklet { const DataFormats* dataFormats_; }; - ProducerTT::ProducerTT(const ParameterSet& iConfig) : - iConfig_(iConfig) - { + ProducerTT::ProducerTT(const ParameterSet& iConfig) : iConfig_(iConfig) { const string& label = iConfig.getParameter("LabelKF"); const string& branchStubs = iConfig.getParameter("BranchAcceptedStubs"); const string& branchTracks = iConfig.getParameter("BranchAcceptedTracks"); @@ -100,7 +98,9 @@ namespace trackFindingTracklet { // count number of kf tracks int nTracks(0); for (const StreamTrack& stream : streamsTracks) - nTracks += accumulate(stream.begin(), stream.end(), 0, [](int& sum, const FrameTrack& frame){ return sum += frame.first.isNonnull() ? 1 : 0; }); + nTracks += accumulate(stream.begin(), stream.end(), 0, [](int& sum, const FrameTrack& frame) { + return sum += frame.first.isNonnull() ? 1 : 0; + }); ttTracks.reserve(nTracks); // convert kf track frames per channel and stub frames per channel and layer to TTTracks for (int channel = 0; channel < (int)streamsTracks.size(); channel++) { @@ -129,6 +129,6 @@ namespace trackFindingTracklet { iEvent.emplace(edPutToken_, move(ttTracks)); } -} // namespace trackFindingTracklet +} // namespace trackFindingTracklet DEFINE_FWK_MODULE(trackFindingTracklet::ProducerTT); \ No newline at end of file diff --git a/L1Trigger/TrackFindingTracklet/src/TrackBuilderChannel.cc b/L1Trigger/TrackFindingTracklet/src/TrackBuilderChannel.cc index 607f559dae984..091eba2451b58 100644 --- a/L1Trigger/TrackFindingTracklet/src/TrackBuilderChannel.cc +++ b/L1Trigger/TrackFindingTracklet/src/TrackBuilderChannel.cc @@ -7,11 +7,10 @@ using namespace edm; namespace trackFindingTracklet { - TrackBuilderChannel::TrackBuilderChannel(const edm::ParameterSet& iConfig) : - useDuplicateRemoval_(iConfig.getParameter("UseDuplicateRemoval")), - boundaries_(iConfig.getParameter>("PtBoundaries")), - numChannels_(useDuplicateRemoval_ ? 2 * boundaries_.size() : iConfig.getParameter("NumSeedTypes")) - {} + TrackBuilderChannel::TrackBuilderChannel(const edm::ParameterSet& iConfig) + : useDuplicateRemoval_(iConfig.getParameter("UseDuplicateRemoval")), + boundaries_(iConfig.getParameter>("PtBoundaries")), + numChannels_(useDuplicateRemoval_ ? 2 * boundaries_.size() : iConfig.getParameter("NumSeedTypes")) {} // sets channelId of given TTTrack, return false if track outside pt range bool TrackBuilderChannel::channelId(const TTTrack& ttTrack, int& channelId) { @@ -32,4 +31,4 @@ namespace trackFindingTracklet { return true; } -} // namespace trackFindingTracklet \ No newline at end of file +} // namespace trackFindingTracklet \ No newline at end of file diff --git a/L1Trigger/TrackFindingTracklet/test/AnalyzerKFin.cc b/L1Trigger/TrackFindingTracklet/test/AnalyzerKFin.cc index 7e3b1c7a594ba..fb393037ea805 100644 --- a/L1Trigger/TrackFindingTracklet/test/AnalyzerKFin.cc +++ b/L1Trigger/TrackFindingTracklet/test/AnalyzerKFin.cc @@ -50,7 +50,10 @@ namespace trackFindingTracklet { private: // - void formTracks(const StreamsTrack& streamsTrack, const StreamsStub& streamsStubs, vector>& tracks, int channel) const; + void formTracks(const StreamsTrack& streamsTrack, + const StreamsStub& streamsStubs, + vector>& tracks, + int channel) const; // void associate(const vector>& tracks, const StubAssociation* ass, set& tps, int& sum) const; @@ -93,7 +96,8 @@ namespace trackFindingTracklet { stringstream log_; }; - AnalyzerKFin::AnalyzerKFin(const ParameterSet& iConfig) : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { + AnalyzerKFin::AnalyzerKFin(const ParameterSet& iConfig) + : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { usesResource("TFileService"); // book in- and output ED products const string& label = iConfig.getParameter("LabelKFin"); @@ -195,7 +199,9 @@ namespace trackFindingTracklet { vector> lost; formTracks(lostTracks, lostStubs, lost, offset + channel); nTracks += tracks.size(); - nStubs += accumulate(tracks.begin(), tracks.end(), 0, [](int& sum, const vector& track){ return sum += (int)track.size(); }); + nStubs += accumulate(tracks.begin(), tracks.end(), 0, [](int& sum, const vector& track) { + return sum += (int)track.size(); + }); nLost += lost.size(); allTracks += tracks.size(); if (!useMCTruth_) @@ -212,7 +218,7 @@ namespace trackFindingTracklet { vector recovered; recovered.reserve(tpPtrsLost.size()); set_intersection(tpPtrsLost.begin(), tpPtrsLost.end(), tpPtrs.begin(), tpPtrs.end(), back_inserter(recovered)); - for(const TPPtr& tpPtr : recovered) + for (const TPPtr& tpPtr : recovered) tpPtrsLost.erase(tpPtr); prof_->Fill(4, allMatched); prof_->Fill(5, allTracks); @@ -250,8 +256,10 @@ namespace trackFindingTracklet { const int wErrs = ceil(log10(*max_element(errs.begin(), errs.end()))) + 5; log_ << " KFin SUMMARY " << endl; log_ << "number of stubs per TFP = " << setw(wNums) << numStubs << " +- " << setw(wErrs) << errStubs << endl; - log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks << endl; - log_ << "number of lost tracks per TFP = " << setw(wNums) << numTracksLost << " +- " << setw(wErrs) << errTracksLost << endl; + log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks + << endl; + log_ << "number of lost tracks per TFP = " << setw(wNums) << numTracksLost << " +- " << setw(wErrs) << errTracksLost + << endl; log_ << " max tracking efficiency = " << setw(wNums) << eff << " +- " << setw(wErrs) << errEff << endl; log_ << " lost tracking efficiency = " << setw(wNums) << effLoss << " +- " << setw(wErrs) << errEffLoss << endl; log_ << " fake rate = " << setw(wNums) << fracFake << endl; @@ -261,21 +269,31 @@ namespace trackFindingTracklet { } // - void AnalyzerKFin::formTracks(const StreamsTrack& streamsTrack, const StreamsStub& streamsStubs, vector>& tracks, int channel) const { + void AnalyzerKFin::formTracks(const StreamsTrack& streamsTrack, + const StreamsStub& streamsStubs, + vector>& tracks, + int channel) const { const int offset = channel * setup_->numLayers(); const StreamTrack& streamTrack = streamsTrack[channel]; - const int numTracks = accumulate(streamTrack.begin(), streamTrack.end(), 0, [](int& sum, const FrameTrack& frame){ return sum += (frame.first.isNonnull() ? 1 : 0); }); + const int numTracks = accumulate(streamTrack.begin(), streamTrack.end(), 0, [](int& sum, const FrameTrack& frame) { + return sum += (frame.first.isNonnull() ? 1 : 0); + }); tracks.reserve(numTracks); for (int frame = 0; frame < (int)streamTrack.size(); frame++) { const FrameTrack& frameTrack = streamTrack[frame]; if (frameTrack.first.isNull()) continue; - const auto end = find_if(next(streamTrack.begin(), frame + 1), streamTrack.end(), [](const FrameTrack& frame){ return frame.first.isNonnull(); }); + const auto end = find_if(next(streamTrack.begin(), frame + 1), streamTrack.end(), [](const FrameTrack& frame) { + return frame.first.isNonnull(); + }); const int size = distance(next(streamTrack.begin(), frame), end); int numStubs(0); for (int layer = 0; layer < setup_->numLayers(); layer++) { const StreamStub& stream = streamsStubs[offset + layer]; - numStubs += accumulate(stream.begin() + frame, stream.begin() + frame + size, 0, [](int& sum, const FrameStub& frame){ return sum += (frame.first.isNonnull() ? 1 : 0); }); + numStubs += + accumulate(stream.begin() + frame, stream.begin() + frame + size, 0, [](int& sum, const FrameStub& frame) { + return sum += (frame.first.isNonnull() ? 1 : 0); + }); } vector stubs; stubs.reserve(numStubs); @@ -291,7 +309,10 @@ namespace trackFindingTracklet { } // - void AnalyzerKFin::associate(const vector>& tracks, const StubAssociation* ass, set& tps, int& sum) const { + void AnalyzerKFin::associate(const vector>& tracks, + const StubAssociation* ass, + set& tps, + int& sum) const { for (const vector& ttStubRefs : tracks) { const vector& tpPtrs = ass->associate(ttStubRefs); if (tpPtrs.empty()) diff --git a/L1Trigger/TrackFindingTracklet/test/AnalyzerKFout.cc b/L1Trigger/TrackFindingTracklet/test/AnalyzerKFout.cc index d0ec65401b52d..766e2d8811a86 100644 --- a/L1Trigger/TrackFindingTracklet/test/AnalyzerKFout.cc +++ b/L1Trigger/TrackFindingTracklet/test/AnalyzerKFout.cc @@ -82,10 +82,8 @@ namespace trackFindingTracklet { stringstream log_; }; - AnalyzerKFout::AnalyzerKFout(const ParameterSet& iConfig) : - useMCTruth_(iConfig.getParameter("UseMCTruth")), - nEvents_(0) - { + AnalyzerKFout::AnalyzerKFout(const ParameterSet& iConfig) + : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { usesResource("TFileService"); // book in- and output ED products const string& label = iConfig.getParameter("LabelKFout"); @@ -171,7 +169,9 @@ namespace trackFindingTracklet { if (frame.first.isNonnull()) tracks.insert(frame.first); nTracksRegion += tracks.size(); - nStubsRegion += accumulate(tracks.begin(), tracks.end(), 0, [](int& sum, const TTTrackRef& ttTrackRef){ return sum += (int)ttTrackRef->getStubRefs().size(); }); + nStubsRegion += accumulate(tracks.begin(), tracks.end(), 0, [](int& sum, const TTTrackRef& ttTrackRef) { + return sum += (int)ttTrackRef->getStubRefs().size(); + }); set tracksLost; for (const FrameTrack& frame : lost) if (frame.first.isNonnull()) @@ -225,8 +225,10 @@ namespace trackFindingTracklet { const int wErrs = ceil(log10(*max_element(errs.begin(), errs.end()))) + 5; log_ << " KFout SUMMARY " << endl; //log_ << "number of stubs per TFP = " << setw(wNums) << numStubs << " +- " << setw(wErrs) << errStubs << endl; - log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks << endl; - log_ << "number of lost tracks per TFP = " << setw(wNums) << numTracksLost << " +- " << setw(wErrs) << errTracksLost << endl; + log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks + << endl; + log_ << "number of lost tracks per TFP = " << setw(wNums) << numTracksLost << " +- " << setw(wErrs) << errTracksLost + << endl; log_ << " tracking efficiency = " << setw(wNums) << eff << " +- " << setw(wErrs) << errEff << endl; log_ << " lost tracking efficiency = " << setw(wNums) << effLoss << " +- " << setw(wErrs) << errEffLoss << endl; log_ << " fake rate = " << setw(wNums) << fracFake << endl; @@ -236,7 +238,10 @@ namespace trackFindingTracklet { } // - void AnalyzerKFout::associate(const set& ttTracks, const StubAssociation* ass, set& tps, int& sum) const { + void AnalyzerKFout::associate(const set& ttTracks, + const StubAssociation* ass, + set& tps, + int& sum) const { for (const TTTrackRef& ttTrack : ttTracks) { const vector& ttStubRefs = ttTrack->getStubRefs(); const vector& tpPtrs = ass->associate(ttStubRefs); diff --git a/L1Trigger/TrackFindingTracklet/test/AnalyzerTT.cc b/L1Trigger/TrackFindingTracklet/test/AnalyzerTT.cc index 27f34346fab66..0bce4194f7451 100644 --- a/L1Trigger/TrackFindingTracklet/test/AnalyzerTT.cc +++ b/L1Trigger/TrackFindingTracklet/test/AnalyzerTT.cc @@ -38,7 +38,6 @@ namespace trackFindingTracklet { void endJob() override {} private: - // ED input token of TTTrackRefMap EDGetTokenT edGetTokenTTTrackMap_; // ED input token of TTStubRef to TPPtr association for tracking efficiency @@ -47,9 +46,9 @@ namespace trackFindingTracklet { ESGetToken esGetTokenSetup_; // stores, calculates and provides run-time constants const Setup* setup_; - + // histos - + TH1F* hisQoverPt_; TH1F* hisPhi0_; TH1F* hisEta_; @@ -58,7 +57,6 @@ namespace trackFindingTracklet { TProfile* profResPhi0OverEta_; TProfile* profResEtaOverEta_; TProfile* profResZ0OverEta_; - }; AnalyzerTT::AnalyzerTT(const ParameterSet& iConfig) { @@ -106,7 +104,7 @@ namespace trackFindingTracklet { continue; const TPPtr& tpPtr = tpPtrs.front(); const math::XYZPointD& v = tpPtr->vertex(); - const double qOverPtTT = ttTrackRef->rInv() / setup_->invPtToDphi() / 2.0; + const double qOverPtTT = ttTrackRef->rInv() / setup_->invPtToDphi() / 2.0; const double qOverPtTP = tpPtr->charge() / tpPtr->pt(); const double qOverPtDiff = qOverPtTP - qOverPtTT; const double phi0TT = deltaPhi(ttTrackRef->phi() + ttTrackRef->phiSector() * setup_->baseRegion()); diff --git a/L1Trigger/TrackFindingTracklet/test/AnalyzerTracklet.cc b/L1Trigger/TrackFindingTracklet/test/AnalyzerTracklet.cc index 82d2c24b3f626..b7a7ef2ade4c0 100644 --- a/L1Trigger/TrackFindingTracklet/test/AnalyzerTracklet.cc +++ b/L1Trigger/TrackFindingTracklet/test/AnalyzerTracklet.cc @@ -50,7 +50,11 @@ namespace trackFindingTracklet { private: // gets all TPs associated too any of the tracks & number of tracks matching at least one TP - void associate(const vector>& tracks, const StubAssociation* ass, set& tps, int& nMatchTrk, bool perfect = false) const; + void associate(const vector>& tracks, + const StubAssociation* ass, + set& tps, + int& nMatchTrk, + bool perfect = false) const; // ED input token of tracks EDGetTokenT edGetToken_; @@ -86,7 +90,8 @@ namespace trackFindingTracklet { stringstream log_; }; - AnalyzerTracklet::AnalyzerTracklet(const ParameterSet& iConfig) : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { + AnalyzerTracklet::AnalyzerTracklet(const ParameterSet& iConfig) + : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { usesResource("TFileService"); // book in- and output ED products const InputTag& inputTag = iConfig.getParameter("InputTag"); @@ -171,7 +176,10 @@ namespace trackFindingTracklet { ttTrackRefsRegions[ttTrack.phiSector()].emplace_back(TTTrackRef(handle, i++)); for (int region = 0; region < setup_->numRegions(); region++) { const vector& ttTrackRefs = ttTrackRefsRegions[region]; - const int nStubs = accumulate(ttTrackRefs.begin(), ttTrackRefs.end(), 0, [](int& sum, const TTTrackRef& ttTrackRef){ return sum += ttTrackRef->getStubRefs().size(); }); + const int nStubs = + accumulate(ttTrackRefs.begin(), ttTrackRefs.end(), 0, [](int& sum, const TTTrackRef& ttTrackRef) { + return sum += ttTrackRef->getStubRefs().size(); + }); const int nTracks = ttTrackRefs.size(); hisChannel_->Fill(nTracks); profChannel_->Fill(region, nTracks); @@ -188,7 +196,10 @@ namespace trackFindingTracklet { // convert vector of tracks to vector of vector of associated stubs vector> tracks; tracks.reserve(ttTracks.size()); - transform(ttTracks.begin(), ttTracks.end(), back_inserter(tracks), [](const TTTrack& ttTrack){ return ttTrack.getStubRefs(); }); + transform( + ttTracks.begin(), ttTracks.end(), back_inserter(tracks), [](const TTTrack& ttTrack) { + return ttTrack.getStubRefs(); + }); if (useMCTruth_) { int tmp(0); associate(tracks, selection, tpPtrsSelection, tmp); @@ -212,7 +223,7 @@ namespace trackFindingTracklet { return; // effi eff_->SetPassedHistogram(*hisEff_, "f"); - eff_->SetTotalHistogram (*hisEffTotal_, "f"); + eff_->SetTotalHistogram(*hisEffTotal_, "f"); // printout SF summary const double totalTPs = prof_->GetBinContent(9); const double numStubs = prof_->GetBinContent(1); @@ -237,7 +248,8 @@ namespace trackFindingTracklet { log_ << " Tracklet SUMMARY " << endl; log_ << "number of stubs per TFP = " << setw(wNums) << numStubs << " +- " << setw(wErrs) << errStubs << endl; log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks << endl; - log_ << "current tracking efficiency = " << setw(wNums) << effPerfect << " +- " << setw(wErrs) << errEffPerfect << endl; + log_ << "current tracking efficiency = " << setw(wNums) << effPerfect << " +- " << setw(wErrs) << errEffPerfect + << endl; log_ << "max tracking efficiency = " << setw(wNums) << eff << " +- " << setw(wErrs) << errEff << endl; log_ << " fake rate = " << setw(wNums) << fracFake << endl; log_ << " duplicate rate = " << setw(wNums) << fracDup << endl; @@ -246,7 +258,11 @@ namespace trackFindingTracklet { } // gets all TPs associated too any of the tracks & number of tracks matching at least one TP - void AnalyzerTracklet::associate(const vector>& tracks, const StubAssociation* ass, set& tps, int& nMatchTrk, bool perfect) const { + void AnalyzerTracklet::associate(const vector>& tracks, + const StubAssociation* ass, + set& tps, + int& nMatchTrk, + bool perfect) const { for (const vector& ttStubRefs : tracks) { const vector& tpPtrs = perfect ? ass->associateFinal(ttStubRefs) : ass->associate(ttStubRefs); if (tpPtrs.empty()) diff --git a/L1Trigger/TrackTrigger/interface/Setup.h b/L1Trigger/TrackTrigger/interface/Setup.h index 756fd4e4926bf..3c7502f342744 100644 --- a/L1Trigger/TrackTrigger/interface/Setup.h +++ b/L1Trigger/TrackTrigger/interface/Setup.h @@ -86,7 +86,7 @@ namespace tt { GlobalPoint stubPos(const TTStubRef& ttStubRef) const; // empty trackerDTC EDProduct TTDTC ttDTC() const { return TTDTC(numRegions_, numOverlappingRegions_, numDTCsPerRegion_); } - // checks if stub collection is considered forming a reconstructable track + // checks if stub collection is considered forming a reconstructable track bool reconstructable(const std::vector& ttStubRefs) const; // checks if tracking particle is selected for efficiency measurements bool useForAlgEff(const TrackingParticle& tp) const; @@ -453,12 +453,12 @@ namespace tt { double kfRangeFactor() const { return kfRangeFactor_; } // Parameter specifying KalmanFilter Output Formatter - - // Final Chi2rphi digitization TODO extract from TTTrack Word + + // Final Chi2rphi digitization TODO extract from TTTrack Word std::vector kfoutchi2rphiBins() const { return kfoutchi2rphiBins_; } - // Final Chi2rz digitization TODO extract from TTTrack Word + // Final Chi2rz digitization TODO extract from TTTrack Word std::vector kfoutchi2rzBins() const { return kfoutchi2rzBins_; } - // Conversion factor between dphi^2/weight and chi2rphi + // Conversion factor between dphi^2/weight and chi2rphi int kfoutchi2rphiConv() const { return kfoutchi2rphiConv_; } // Conversion factor between dz^2/weight and chi2rz int kfoutchi2rzConv() const { return kfoutchi2rzConv_; } @@ -833,18 +833,18 @@ namespace tt { // Parameter specifying KalmanFilter Output Formatter edm::ParameterSet pSetKFOut_; // Bins used to digitize dPhi for chi2 calculation - std::vector kfoutdPhiBins_; + std::vector kfoutdPhiBins_; // Bins used to digitize dZ for chi2 calculation std::vector kfoutdZBins_; // v0 weight Bins corresponding to dPhi Bins for chi2 calculation std::vector kfoutv0Bins_; // v1 weight Bins corresponding to dZ Bins for chi2 calculation std::vector kfoutv1Bins_; - // Final Chi2rphi digitization TODO extract from TTTrack Word + // Final Chi2rphi digitization TODO extract from TTTrack Word std::vector kfoutchi2rphiBins_; - // Final Chi2rz digitization TODO extract from TTTrack Word + // Final Chi2rz digitization TODO extract from TTTrack Word std::vector kfoutchi2rzBins_; - // Conversion factor between dphi^2/weight and chi2rphi + // Conversion factor between dphi^2/weight and chi2rphi int kfoutchi2rphiConv_; // Conversion factor between dz^2/weight and chi2rz int kfoutchi2rzConv_; @@ -1002,7 +1002,6 @@ namespace tt { // KF int kfWidthLayerCount_; - }; } // namespace tt diff --git a/L1Trigger/TrackTrigger/interface/SetupRcd.h b/L1Trigger/TrackTrigger/interface/SetupRcd.h index 007beaf2e27f5..2a4b324436e3c 100644 --- a/L1Trigger/TrackTrigger/interface/SetupRcd.h +++ b/L1Trigger/TrackTrigger/interface/SetupRcd.h @@ -15,11 +15,11 @@ namespace tt { typedef edm::mpl::Vector + TrackerTopologyRcd, + IdealMagneticFieldRecord, + IdealGeometryRecord, + TrackerDetToDTCELinkCablingMapRcd, + TTStubAlgorithmRecord> Rcds; // record of tt::Setup diff --git a/L1Trigger/TrackTrigger/src/Setup.cc b/L1Trigger/TrackTrigger/src/Setup.cc index 1de2724f4e4ed..6ad3bf49dff05 100644 --- a/L1Trigger/TrackTrigger/src/Setup.cc +++ b/L1Trigger/TrackTrigger/src/Setup.cc @@ -472,7 +472,8 @@ namespace tt { constexpr bool stableOnly = false; tpSelector_ = TrackingParticleSelector( ptMin, ptMax, -etaMax, etaMax, tip, lip, minHit, signalOnly, intimeOnly, chargedOnly, stableOnly); - tpSelectorLoose_ = TrackingParticleSelector(ptMin, ptMax, -etaMax, etaMax, tip, lip, minHit, false, false, false, stableOnly); + tpSelectorLoose_ = + TrackingParticleSelector(ptMin, ptMax, -etaMax, etaMax, tip, lip, minHit, false, false, false, stableOnly); } // stub layer id (barrel: 1 - 6, endcap: 11 - 15) @@ -581,7 +582,6 @@ namespace tt { const double extra = sm->barrel() ? 0. : pow(sm->pitchCol() * inv2R, 2); const double digi = pow(tmttBasePhi_ / 12., 2); return sigma + scat + extra + digi; - } // stub projected chi2z wheight @@ -593,7 +593,7 @@ namespace tt { return sigma + digi; } - // checks if stub collection is considered forming a reconstructable track + // checks if stub collection is considered forming a reconstructable track bool Setup::reconstructable(const vector& ttStubRefs) const { set hitPattern; for (const TTStubRef& ttStubRef : ttStubRefs) @@ -656,7 +656,8 @@ namespace tt { tmttWidthLayer_ = ceil(log2(numLayers_)); tmttWidthSectorEta_ = ceil(log2(numSectorsEta_)); tmttWidthInv2R_ = ceil(log2(htNumBinsInv2R_)); - tmttNumUnusedBits_ = TTBV::S_ - tmttWidthLayer_ - 2 * tmttWidthSectorEta_ - tmttWidthR_ - tmttWidthPhi_ - tmttWidthZ_ - 2 *tmttWidthInv2R_ - numSectorsPhi_ - 1; + tmttNumUnusedBits_ = TTBV::S_ - tmttWidthLayer_ - 2 * tmttWidthSectorEta_ - tmttWidthR_ - tmttWidthPhi_ - + tmttWidthZ_ - 2 * tmttWidthInv2R_ - numSectorsPhi_ - 1; // hybrid const double hybridRangeInv2R = 2. * invPtToDphi_ / hybridMinPtStub_; const double hybridRangeR = diff --git a/L1Trigger/TrackerDTC/interface/LayerEncoding.h b/L1Trigger/TrackerDTC/interface/LayerEncoding.h index ba8ba1c4a5fed..f5cd9d195c070 100644 --- a/L1Trigger/TrackerDTC/interface/LayerEncoding.h +++ b/L1Trigger/TrackerDTC/interface/LayerEncoding.h @@ -20,9 +20,10 @@ namespace trackerDTC { public: LayerEncoding() {} LayerEncoding(const edm::ParameterSet& iConfig, const tt::Setup* setup); - ~LayerEncoding(){} + ~LayerEncoding() {} // decode layer id for given sensor module int decode(tt::SensorModule* sm) const; + private: // helper class to store configurations const tt::Setup* setup_; @@ -30,7 +31,7 @@ namespace trackerDTC { std::vector> encodingsLayerId_; }; -} // namespace trackerDTC +} // namespace trackerDTC EVENTSETUP_DATA_DEFAULT_RECORD(trackerDTC::LayerEncoding, trackerDTC::LayerEncodingRcd); diff --git a/L1Trigger/TrackerDTC/interface/LayerEncodingRcd.h b/L1Trigger/TrackerDTC/interface/LayerEncodingRcd.h index 135227b749979..39d023eddaa0f 100644 --- a/L1Trigger/TrackerDTC/interface/LayerEncodingRcd.h +++ b/L1Trigger/TrackerDTC/interface/LayerEncodingRcd.h @@ -10,7 +10,8 @@ namespace trackerDTC { typedef edm::mpl::Vector RcdsLayerEncoding; // record of trackerDTC::LayerEncoding - class LayerEncodingRcd : public edm::eventsetup::DependentRecordImplementation {}; + class LayerEncodingRcd : public edm::eventsetup::DependentRecordImplementation { + }; } // namespace trackerDTC diff --git a/L1Trigger/TrackerDTC/plugins/ProducerED.cc b/L1Trigger/TrackerDTC/plugins/ProducerED.cc index a675048285635..46ad569e81355 100644 --- a/L1Trigger/TrackerDTC/plugins/ProducerED.cc +++ b/L1Trigger/TrackerDTC/plugins/ProducerED.cc @@ -61,8 +61,7 @@ namespace trackerDTC { ParameterSet iConfig_; }; - ProducerED::ProducerED(const ParameterSet& iConfig) - : iConfig_(iConfig) { + ProducerED::ProducerED(const ParameterSet& iConfig) : iConfig_(iConfig) { // book in- and output ED products const auto& inputTag = iConfig.getParameter("InputTag"); const auto& branchAccepted = iConfig.getParameter("BranchAccepted"); diff --git a/L1Trigger/TrackerDTC/src/LayerEncoding.cc b/L1Trigger/TrackerDTC/src/LayerEncoding.cc index 511cbe0c3ede4..718732ce48e1b 100644 --- a/L1Trigger/TrackerDTC/src/LayerEncoding.cc +++ b/L1Trigger/TrackerDTC/src/LayerEncoding.cc @@ -41,4 +41,4 @@ namespace trackerDTC { return distance(encoding.begin(), pos); } -} // namespace trackerDTC \ No newline at end of file +} // namespace trackerDTC \ No newline at end of file diff --git a/L1Trigger/TrackerDTC/src/Stub.cc b/L1Trigger/TrackerDTC/src/Stub.cc index f30ca39ce0b41..b10f4a1c56f87 100644 --- a/L1Trigger/TrackerDTC/src/Stub.cc +++ b/L1Trigger/TrackerDTC/src/Stub.cc @@ -11,8 +11,17 @@ using namespace tt; namespace trackerDTC { - Stub::Stub(const ParameterSet& iConfig, const Setup* setup, const LayerEncoding* layerEncoding, SensorModule* sm, const TTStubRef& ttStubRef) - : setup_(setup), layerEncoding_(layerEncoding), sm_(sm), ttStubRef_(ttStubRef), hybrid_(iConfig.getParameter("UseHybrid")), valid_(true) { + Stub::Stub(const ParameterSet& iConfig, + const Setup* setup, + const LayerEncoding* layerEncoding, + SensorModule* sm, + const TTStubRef& ttStubRef) + : setup_(setup), + layerEncoding_(layerEncoding), + sm_(sm), + ttStubRef_(ttStubRef), + hybrid_(iConfig.getParameter("UseHybrid")), + valid_(true) { regions_.reserve(setup->numOverlappingRegions()); // get stub local coordinates const MeasurementPoint& mp = ttStubRef->clusterRef(0)->findAverageLocalCoordinatesCentered(); @@ -166,7 +175,7 @@ namespace trackerDTC { const TTBV hwValid(1, 1); // assemble final bitset return Frame(hwGap.str() + hwR.str() + hwZ.str() + hwPhi.str() + hwAlpha.str() + hwBend.str() + hwLayer.str() + - hwValid.str()); + hwValid.str()); } Frame Stub::formatTMTT(int region) const { @@ -235,7 +244,9 @@ namespace trackerDTC { for (int sectorPhi = 0; sectorPhi < setup_->numSectorsPhi(); sectorPhi++) hwSectorPhis[sectorPhi] = sectorsPhi[region * setup_->numSectorsPhi() + sectorPhi]; // assemble final bitset - return Frame(hwGap.str() + hwValid.str() + hwR.str() + hwPhi.str() + hwZ.str() + hwLayer.str() + hwSectorPhis.str() + hwSectorEtaMin.str() + hwSectorEtaMax.str() + hwInv2RMin.str() + hwInv2RMax.str()); + return Frame(hwGap.str() + hwValid.str() + hwR.str() + hwPhi.str() + hwZ.str() + hwLayer.str() + + hwSectorPhis.str() + hwSectorEtaMin.str() + hwSectorEtaMax.str() + hwInv2RMin.str() + + hwInv2RMax.str()); } } // namespace trackerDTC \ No newline at end of file diff --git a/L1Trigger/TrackerDTC/test/Analyzer.cc b/L1Trigger/TrackerDTC/test/Analyzer.cc index ea4b7228c6346..7c0f5a38b5f67 100644 --- a/L1Trigger/TrackerDTC/test/Analyzer.cc +++ b/L1Trigger/TrackerDTC/test/Analyzer.cc @@ -147,7 +147,9 @@ namespace trackerDTC { }; Analyzer::Analyzer(const ParameterSet& iConfig) - : useMCTruth_(iConfig.getParameter("UseMCTruth")), hybrid_(iConfig.getParameter("UseHybrid")), nEvents_(0) { + : useMCTruth_(iConfig.getParameter("UseMCTruth")), + hybrid_(iConfig.getParameter("UseHybrid")), + nEvents_(0) { usesResource("TFileService"); // book in- and output ED products const auto& inputTagAccepted = iConfig.getParameter("InputTagAccepted"); @@ -453,7 +455,8 @@ namespace trackerDTC { constexpr bool stableOnly = false; tpSelector_ = TrackingParticleSelector( ptMin, ptMax, -etaMax, etaMax, tip, lip, minHit, signalOnly, intimeOnly, chargedOnly, stableOnly); - tpSelectorLoose_ = TrackingParticleSelector(ptMin, ptMax, -etaMax, etaMax, tip, lip, minHit, false, false, false, stableOnly); + tpSelectorLoose_ = + TrackingParticleSelector(ptMin, ptMax, -etaMax, etaMax, tip, lip, minHit, false, false, false, stableOnly); } // book histograms diff --git a/L1Trigger/TrackerDTC/test/AnalyzerDAQ.cc b/L1Trigger/TrackerDTC/test/AnalyzerDAQ.cc index d52c40f32a313..ebfa0708ccb62 100644 --- a/L1Trigger/TrackerDTC/test/AnalyzerDAQ.cc +++ b/L1Trigger/TrackerDTC/test/AnalyzerDAQ.cc @@ -41,7 +41,6 @@ namespace trackerDTC { void endJob() override {} private: - // ED input token of accepted TTClusters EDGetTokenT edGetToken_; // Setup token @@ -96,7 +95,7 @@ namespace trackerDTC { iEvent.getByToken(edGetToken_, handle); // apply cabling map, reorganise cluster collections vector>> dtcs(setup_->numDTCs(), - vector>(setup_->numModulesPerDTC())); + vector>(setup_->numModulesPerDTC())); for (auto itModule = handle->begin(); itModule != handle->end(); itModule++) { // DetSetVec->detId - 1 or + 0 = tk layout det id depending from which of both sensor planes the cluster has been constructed const DetId& detIdModule = itModule->detId(); diff --git a/L1Trigger/TrackerTFP/interface/DataFormats.h b/L1Trigger/TrackerTFP/interface/DataFormats.h index c7c51f2ebfc3f..379e37bdc961b 100644 --- a/L1Trigger/TrackerTFP/interface/DataFormats.h +++ b/L1Trigger/TrackerTFP/interface/DataFormats.h @@ -27,9 +27,39 @@ namespace trackerTFP { // track trigger processes enum class Process { begin, fe = begin, dtc, pp, gp, ht, mht, zht, kfin, kf, dr, end, x }; // track trigger variables - enum class Variable { begin, r = begin, phi, z, layer, sectorsPhi, sectorEta, sectorPhi, phiT, inv2R, zT, cot, dPhi, dZ, match, hitPattern, phi0, z0, end, x }; + enum class Variable { + begin, + r = begin, + phi, + z, + layer, + sectorsPhi, + sectorEta, + sectorPhi, + phiT, + inv2R, + zT, + cot, + dPhi, + dZ, + match, + hitPattern, + phi0, + z0, + end, + x + }; // track trigger process order - constexpr std::initializer_list Processes = {Process::fe, Process::dtc, Process::pp, Process::gp, Process::ht, Process::mht, Process::zht, Process::kfin, Process::kf, Process::dr}; + constexpr std::initializer_list Processes = {Process::fe, + Process::dtc, + Process::pp, + Process::gp, + Process::ht, + Process::mht, + Process::zht, + Process::kfin, + Process::kf, + Process::dr}; // conversion: Process to int inline constexpr int operator+(Process p) { return static_cast(p); } // conversion: Variable to int @@ -82,6 +112,7 @@ namespace trackerTFP { double base() const { return base_; } // covered range double range() const { return range_; } + protected: // true if twos'complement or false if binary representation is chosen bool twos_; @@ -94,46 +125,79 @@ namespace trackerTFP { }; // class representing format of a specific variable - template + template class Format : public DataFormat { public: Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); ~Format() {} }; - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); - template<> Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); + template <> + Format::Format(const edm::ParameterSet& iConfig, const tt::Setup* setup); /*! \class trackerTFP::DataFormats * \brief Class to calculate and provide dataformats used by Track Trigger emulator @@ -144,68 +208,272 @@ namespace trackerTFP { private: // variable flavour mapping, Each row below declares which processing steps use the variable named in the comment at the end of the row static constexpr std::array, +Variable::end> config_ = {{ - // Process::fe Process::dtc Process::pp Process::gp Process::ht Process::mht Process::zht Process::kfin Process::kf Process::dr - {{Process::x, Process::ht, Process::ht, Process::ht, Process::ht, Process::ht, Process::ht, Process::ht, Process::ht, Process::x }}, // Variable::r - {{Process::x, Process::dtc, Process::dtc, Process::gp, Process::ht, Process::mht, Process::zht, Process::zht, Process::kf, Process::x }}, // Variable::phi - {{Process::x, Process::dtc, Process::dtc, Process::gp, Process::gp, Process::gp, Process::zht, Process::zht, Process::kf, Process::x }}, // Variable::z - {{Process::x, Process::ht, Process::ht, Process::ht, Process::ht, Process::ht, Process::ht, Process::x, Process::x, Process::x }}, // Variable::layer - {{Process::x, Process::dtc, Process::dtc, Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::x }}, // Variable::sectorsPhi - {{Process::x, Process::gp, Process::gp, Process::gp, Process::gp, Process::gp, Process::gp, Process::gp, Process::gp, Process::x }}, // Variable::sectorEta - {{Process::x, Process::x, Process::x, Process::gp, Process::gp, Process::gp, Process::gp, Process::gp, Process::gp, Process::x }}, // Variable::sectorPhi - {{Process::x, Process::ht, Process::ht, Process::ht, Process::ht, Process::mht, Process::mht, Process::mht, Process::kf, Process::x }}, // Variable::phiT - {{Process::x, Process::ht, Process::ht, Process::ht, Process::ht, Process::mht, Process::mht, Process::mht, Process::kf, Process::dr}}, // Variable::inv2R - {{Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::zht, Process::zht, Process::kf, Process::x }}, // Variable::zT - {{Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::zht, Process::zht, Process::kf, Process::dr}}, // Variable::cot - {{Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::kfin, Process::kfin, Process::x }}, // Variable::dPhi - {{Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::kfin, Process::kfin, Process::x }}, // Variable::dZ - {{Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::kf, Process::x }}, // Variable::match - {{Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::kfin, Process::x, Process::x }}, // Variable::hitPattern - {{Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::dr}}, // Variable::phi0 - {{Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::x, Process::dr}} // Variable::z0 + // Process::fe Process::dtc Process::pp Process::gp Process::ht Process::mht Process::zht Process::kfin Process::kf Process::dr + {{Process::x, + Process::ht, + Process::ht, + Process::ht, + Process::ht, + Process::ht, + Process::ht, + Process::ht, + Process::ht, + Process::x}}, // Variable::r + {{Process::x, + Process::dtc, + Process::dtc, + Process::gp, + Process::ht, + Process::mht, + Process::zht, + Process::zht, + Process::kf, + Process::x}}, // Variable::phi + {{Process::x, + Process::dtc, + Process::dtc, + Process::gp, + Process::gp, + Process::gp, + Process::zht, + Process::zht, + Process::kf, + Process::x}}, // Variable::z + {{Process::x, + Process::ht, + Process::ht, + Process::ht, + Process::ht, + Process::ht, + Process::ht, + Process::x, + Process::x, + Process::x}}, // Variable::layer + {{Process::x, + Process::dtc, + Process::dtc, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x}}, // Variable::sectorsPhi + {{Process::x, + Process::gp, + Process::gp, + Process::gp, + Process::gp, + Process::gp, + Process::gp, + Process::gp, + Process::gp, + Process::x}}, // Variable::sectorEta + {{Process::x, + Process::x, + Process::x, + Process::gp, + Process::gp, + Process::gp, + Process::gp, + Process::gp, + Process::gp, + Process::x}}, // Variable::sectorPhi + {{Process::x, + Process::ht, + Process::ht, + Process::ht, + Process::ht, + Process::mht, + Process::mht, + Process::mht, + Process::kf, + Process::x}}, // Variable::phiT + {{Process::x, + Process::ht, + Process::ht, + Process::ht, + Process::ht, + Process::mht, + Process::mht, + Process::mht, + Process::kf, + Process::dr}}, // Variable::inv2R + {{Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::zht, + Process::zht, + Process::kf, + Process::x}}, // Variable::zT + {{Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::zht, + Process::zht, + Process::kf, + Process::dr}}, // Variable::cot + {{Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::kfin, + Process::kfin, + Process::x}}, // Variable::dPhi + {{Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::kfin, + Process::kfin, + Process::x}}, // Variable::dZ + {{Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::kf, + Process::x}}, // Variable::match + {{Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::kfin, + Process::x, + Process::x}}, // Variable::hitPattern + {{Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::dr}}, // Variable::phi0 + {{Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::x, + Process::dr}} // Variable::z0 }}; // stub word assembly, shows which stub variables are used by each process static constexpr std::array, +Process::end> stubs_ = {{ - {}, // Process::fe - {Variable::r, Variable::phi, Variable::z, Variable::layer, Variable::sectorsPhi, Variable::sectorEta, Variable::sectorEta, Variable::inv2R, Variable::inv2R}, // Process::dtc - {Variable::r, Variable::phi, Variable::z, Variable::layer, Variable::sectorsPhi, Variable::sectorEta, Variable::sectorEta, Variable::inv2R, Variable::inv2R}, // Process::pp - {Variable::r, Variable::phi, Variable::z, Variable::layer, Variable::inv2R, Variable::inv2R}, // Process::gp - {Variable::r, Variable::phi, Variable::z, Variable::layer, Variable::sectorPhi, Variable::sectorEta, Variable::phiT}, // Process::ht - {Variable::r, Variable::phi, Variable::z, Variable::layer, Variable::sectorPhi, Variable::sectorEta, Variable::phiT, Variable::inv2R}, // Process::mht - {Variable::r, Variable::phi, Variable::z, Variable::layer, Variable::sectorPhi, Variable::sectorEta, Variable::phiT, Variable::inv2R, Variable::zT, Variable::cot}, // Process::zht - {Variable::r, Variable::phi, Variable::z, Variable::dPhi, Variable::dZ}, // Process::kfin - {Variable::r, Variable::phi, Variable::z, Variable::dPhi, Variable::dZ}, // Process::kf - {} // Process::dr + {}, // Process::fe + {Variable::r, + Variable::phi, + Variable::z, + Variable::layer, + Variable::sectorsPhi, + Variable::sectorEta, + Variable::sectorEta, + Variable::inv2R, + Variable::inv2R}, // Process::dtc + {Variable::r, + Variable::phi, + Variable::z, + Variable::layer, + Variable::sectorsPhi, + Variable::sectorEta, + Variable::sectorEta, + Variable::inv2R, + Variable::inv2R}, // Process::pp + {Variable::r, Variable::phi, Variable::z, Variable::layer, Variable::inv2R, Variable::inv2R}, // Process::gp + {Variable::r, + Variable::phi, + Variable::z, + Variable::layer, + Variable::sectorPhi, + Variable::sectorEta, + Variable::phiT}, // Process::ht + {Variable::r, + Variable::phi, + Variable::z, + Variable::layer, + Variable::sectorPhi, + Variable::sectorEta, + Variable::phiT, + Variable::inv2R}, // Process::mht + {Variable::r, + Variable::phi, + Variable::z, + Variable::layer, + Variable::sectorPhi, + Variable::sectorEta, + Variable::phiT, + Variable::inv2R, + Variable::zT, + Variable::cot}, // Process::zht + {Variable::r, Variable::phi, Variable::z, Variable::dPhi, Variable::dZ}, // Process::kfin + {Variable::r, Variable::phi, Variable::z, Variable::dPhi, Variable::dZ}, // Process::kf + {} // Process::dr }}; // track word assembly, shows which track variables are used by each process static constexpr std::array, +Process::end> tracks_ = {{ - {}, // Process::fe - {}, // Process::dtc - {}, // Process::pp - {}, // Process::gp - {}, // Process::ht - {}, // Process::mht - {}, // Process::zht - {Variable::hitPattern, Variable::sectorPhi, Variable::sectorEta, Variable::phiT, Variable::inv2R, Variable::zT, Variable::cot}, // Process::kfin - {Variable::match, Variable::sectorPhi, Variable::sectorEta, Variable::phiT, Variable::inv2R, Variable::cot, Variable::zT}, // Process::kf - {Variable::phi0, Variable::inv2R, Variable::z0, Variable::cot} // Process::dr + {}, // Process::fe + {}, // Process::dtc + {}, // Process::pp + {}, // Process::gp + {}, // Process::ht + {}, // Process::mht + {}, // Process::zht + {Variable::hitPattern, + Variable::sectorPhi, + Variable::sectorEta, + Variable::phiT, + Variable::inv2R, + Variable::zT, + Variable::cot}, // Process::kfin + {Variable::match, + Variable::sectorPhi, + Variable::sectorEta, + Variable::phiT, + Variable::inv2R, + Variable::cot, + Variable::zT}, // Process::kf + {Variable::phi0, Variable::inv2R, Variable::z0, Variable::cot} // Process::dr }}; + public: DataFormats(); DataFormats(const edm::ParameterSet& iConfig, const tt::Setup* setup); - ~DataFormats(){} + ~DataFormats() {} // bool indicating if hybrid or tmtt being used bool hybrid() const { return iConfig_.getParameter("UseHybrid"); } // converts bits to ntuple of variables - template + template void convertStub(Process p, const tt::Frame& bv, std::tuple& data) const; // converts ntuple of variables to bits - template + template void convertStub(Process p, const std::tuple& data, tt::Frame& bv) const; // converts bits to ntuple of variables - template + template void convertTrack(Process p, const tt::Frame& bv, std::tuple& data) const; // converts ntuple of variables to bits - template + template void convertTrack(Process p, const std::tuple& data, tt::Frame& bv) const; // access to run-time constants const tt::Setup* setup() const { return setup_; } @@ -221,37 +489,38 @@ namespace trackerTFP { int numChannel(Process p) const { return numChannel_[+p]; } // number of channels of a given process for whole system int numStreams(Process p) const { return numStreams_[+p]; } - // + // int numStreamsStubs(Process p) const { return numStreamsStubs_[+p]; } - // + // int numStreamsTracks(Process p) const { return numStreamsTracks_[+p]; } // access to spedific format const DataFormat& format(Variable v, Process p) const { return *formats_[+v][+p]; } // critical radius defining region overlap shape in cm double chosenRofPhi() const { return hybrid() ? setup_->hybridChosenRofPhi() : setup_->chosenRofPhi(); } + private: // number of unique data formats int numDataFormats_; // method to count number of unique data formats - template + template void countFormats(); // constructs data formats of all unique used variables and flavours - template + template void fillDataFormats(); // helper (loop) data formats of all unique used variables and flavours - template + template void fillFormats(); // helper (loop) to convert bits to ntuple of variables - template + template void extractStub(Process p, TTBV& ttBV, std::tuple& data) const; // helper (loop) to convert bits to ntuple of variables - template + template void extractTrack(Process p, TTBV& ttBV, std::tuple& data) const; // helper (loop) to convert ntuple of variables to bits - template + template void attachStub(Process p, const std::tuple& data, TTBV& ttBV) const; // helper (loop) to convert ntuple of variables to bits - template + template void attachTrack(Process p, const std::tuple& data, TTBV& ttBV) const; // configuration during construction edm::ParameterSet iConfig_; @@ -276,12 +545,12 @@ namespace trackerTFP { }; // base class to represent stubs - template + template class Stub { public: // construct Stub from Frame Stub(const tt::FrameStub& frame, const DataFormats* dataFormats, Process p); - template + template // construct Stub from other Stub Stub(const Stub& stub, Ts... data); // construct Stub from TTStubRef @@ -302,6 +571,7 @@ namespace trackerTFP { const tt::Frame& bv() const { return frame_.second; } // id of collection this stub belongs to int trackId() const { return trackId_; } + protected: // number of used bits for given variable int width(Variable v) const { return dataFormats_->width(v, p_); } @@ -326,7 +596,7 @@ namespace trackerTFP { public: // construct StubPP from Frame StubPP(const tt::FrameStub& frame, const DataFormats* dataFormats); - ~StubPP(){} + ~StubPP() {} // true if stub belongs to given sector bool inSector(int sector) const { return sectors_[sector]; } // sectors this stub belongs to @@ -349,6 +619,7 @@ namespace trackerTFP { int inv2RMin() const { return std::get<7>(data_); } // last inv2R bin this stub belongs to int inv2RMax() const { return std::get<8>(data_); } + private: // sectors this stub belongs to TTBV sectors_; @@ -361,7 +632,7 @@ namespace trackerTFP { StubGP(const tt::FrameStub& frame, const DataFormats* dataFormats, int sectorPhi, int sectorEta); // construct StubGO from StubPP StubGP(const StubPP& stub, int sectorPhi, int sectorEta); - ~StubGP(){} + ~StubGP() {} // true if stub belongs to given inv2R bin bool inInv2RBin(int inv2RBin) const { return inv2RBins_[inv2RBin]; } // inv2R bins this stub belongs to @@ -382,6 +653,7 @@ namespace trackerTFP { int inv2RMin() const { return std::get<4>(data_); } // last inv2R bin this stub belongs to int inv2RMax() const { return std::get<5>(data_); } + private: // inv2R bins this stub belongs to TTBV inv2RBins_; @@ -398,7 +670,7 @@ namespace trackerTFP { StubHT(const tt::FrameStub& frame, const DataFormats* dataFormats, int inv2R); // construct StubHT from StubGP and HT cell assignment StubHT(const StubGP& stub, int phiT, int inv2R); - ~StubHT(){} + ~StubHT() {} // stub qOver pt int inv2R() const { return inv2R_; } // stub radius wrt chosenRofPhi @@ -415,6 +687,7 @@ namespace trackerTFP { int sectorEta() const { return std::get<5>(data_); }; // stub phi at radius chosenRofPhi wrt phi sector centre int phiT() const { return std::get<6>(data_); }; + private: // fills track id void fillTrackId(); @@ -429,7 +702,7 @@ namespace trackerTFP { StubMHT(const tt::FrameStub& frame, const DataFormats* dataFormats); // construct StubMHT from StubHT and MHT cell assignment StubMHT(const StubHT& stub, int phiT, int inv2R); - ~StubMHT(){} + ~StubMHT() {} // stub radius wrt choenRofPhi double r() const { return std::get<0>(data_); } // stub phi residual wrt finer track parameter @@ -446,6 +719,7 @@ namespace trackerTFP { int phiT() const { return std::get<6>(data_); } // stub inv2R int inv2R() const { return std::get<7>(data_); } + private: // fills track id void fillTrackId(); @@ -462,7 +736,7 @@ namespace trackerTFP { StubZHT(const StubZHT& stub, double zT, double cot, int id); // StubZHT(const StubZHT& stub, int cot, int zT); - ~StubZHT(){} + ~StubZHT() {} // stub radius wrt chonseRofPhi double r() const { return std::get<0>(data_); } // stub phiresiudal wrt finer track parameter @@ -486,6 +760,7 @@ namespace trackerTFP { double cotf() const { return cot_; } double ztf() const { return zT_; } double chi() const { return chi_; } + private: // fills track id void fillTrackId(); @@ -503,8 +778,15 @@ namespace trackerTFP { // construct StubKFin from StubZHT StubKFin(const StubZHT& stub, double dPhi, double dZ, int layer); // construct StubKFin from TTStubRef - StubKFin(const TTStubRef& ttStubRef, const DataFormats* dataFormats, double r, double phi, double z, double dPhi, double dZ, int layer); - ~StubKFin(){} + StubKFin(const TTStubRef& ttStubRef, + const DataFormats* dataFormats, + double r, + double phi, + double z, + double dPhi, + double dZ, + int layer); + ~StubKFin() {} // kf layer id int layer() const { return layer_; } // stub radius wrt chosenRofPhi @@ -517,6 +799,7 @@ namespace trackerTFP { double dPhi() const { return std::get<3>(data_); } // stub z uncertainty double dZ() const { return std::get<4>(data_); } + private: // kf layer id int layer_; @@ -529,7 +812,7 @@ namespace trackerTFP { StubKF(const tt::FrameStub& frame, const DataFormats* dataFormats, int layer); // construct StubKF from StubKFin StubKF(const StubKFin& stub, double inv2R, double phiT, double cot, double zT); - ~StubKF(){} + ~StubKF() {} // kf layer id int layer() const { return layer_; } // stub radius wrt choenRofPhi @@ -542,22 +825,23 @@ namespace trackerTFP { double dPhi() const { return std::get<3>(data_); } // stub z uncertainty double dZ() const { return std::get<4>(data_); } + private: // kf layer id int layer_; }; // base class to represent tracks - template + template class Track { public: // construct Track from Frame Track(const tt::FrameTrack& frame, const DataFormats* dataFormats, Process p); // construct Track from other Track - template + template Track(const Track& track, Ts... data); // construct Track from Stub - template + template Track(const Stub& stub, const TTTrackRef& ttTrackRef, Ts... data); // construct Track from TTTrackRef Track(const TTTrackRef& ttTrackRef, const DataFormats* dataFormats, Process p, Ts... data); @@ -576,6 +860,7 @@ namespace trackerTFP { const tt::Frame& bv() const { return frame_.second; } // access to ntuple of variables this track is assemled of const std::tuple& data() const { return data_; } + protected: //number of bits uesd of given variable int width(Variable v) const { return dataFormats_->width(v, p_); } @@ -604,8 +889,16 @@ namespace trackerTFP { // construct TrackKFin from StubKFin TrackKFin(const StubZHT& stub, const TTTrackRef& ttTrackRef, const TTBV& maybePattern); // construct TrackKFin from TTTrackRef - TrackKFin(const TTTrackRef& ttTrackRef, const DataFormats* dataFormats, const TTBV& maybePattern, double phiT, double qOverPt, double zT, double cot, int sectorPhi, int sectorEta); - ~TrackKFin(){} + TrackKFin(const TTTrackRef& ttTrackRef, + const DataFormats* dataFormats, + const TTBV& maybePattern, + double phiT, + double qOverPt, + double zT, + double cot, + int sectorPhi, + int sectorEta); + ~TrackKFin() {} // pattern of layers which are only maybe crossed by found candidate const TTBV& maybePattern() const { return std::get<0>(data_); } // phi sector @@ -636,6 +929,7 @@ namespace trackerTFP { const std::vector>& stubs() const { return stubs_; } // global cotTheta double cotGlobal() const { return cot() + setup()->sectorCot(sectorEta()); } + private: // stubs organized in layer std::vector> stubs_; @@ -650,7 +944,7 @@ namespace trackerTFP { TrackKF(const tt::FrameTrack& frame, const DataFormats* dataFormats); // construct TrackKF from TrackKFKFin TrackKF(const TrackKFin& track, double phiT, double inv2R, double zT, double cot); - ~TrackKF(){} + ~TrackKF() {} // true if kf prameter consistent with mht parameter bool match() const { return std::get<0>(data_); } // phi sector @@ -669,56 +963,63 @@ namespace trackerTFP { double cotGlobal() const { return cot() + setup()->sectorCot(sectorEta()); } // conversion to TTTrack with given stubs TTTrack ttTrack(const std::vector& stubs) const; + private: }; //Class to represent KFout 96-bit track for use in distribution server class TrackKFOut { - public: - TrackKFOut() : TrackKFOut(0,0,0,0,tt::FrameTrack(), 0, 0, false) {} - // construct TrackKF from Partial Tracks - TrackKFOut(TTBV PartialTrack1, TTBV PartialTrack2, TTBV PartialTrack3, int sortKey,const tt::FrameTrack& track,int trackID, int linkID, bool valid) - : PartialTrack1_(PartialTrack1), - PartialTrack2_(PartialTrack2), - PartialTrack3_(PartialTrack3), - sortKey_(sortKey), - track_(track), - trackID_(trackID), - linkID_(linkID), - valid_(valid) { - }; - - ~TrackKFOut(){} - - int sortKey() const { return sortKey_; } - - bool dataValid() const { return valid_; } - - int trackID() const { return trackID_; } - int linkID() const { return linkID_; } - - TTBV PartialTrack1() const { return PartialTrack1_; } - TTBV PartialTrack2() const { return PartialTrack2_; } - TTBV PartialTrack3() const { return PartialTrack3_; } - - tt::FrameTrack track() const { return track_; } - - private: - TTBV PartialTrack1_ ; - TTBV PartialTrack2_; - TTBV PartialTrack3_; - int sortKey_; - tt::FrameTrack track_; - int trackID_; - int linkID_; - bool valid_; + public: + TrackKFOut() : TrackKFOut(0, 0, 0, 0, tt::FrameTrack(), 0, 0, false) {} + // construct TrackKF from Partial Tracks + TrackKFOut(TTBV PartialTrack1, + TTBV PartialTrack2, + TTBV PartialTrack3, + int sortKey, + const tt::FrameTrack& track, + int trackID, + int linkID, + bool valid) + : PartialTrack1_(PartialTrack1), + PartialTrack2_(PartialTrack2), + PartialTrack3_(PartialTrack3), + sortKey_(sortKey), + track_(track), + trackID_(trackID), + linkID_(linkID), + valid_(valid){}; + + ~TrackKFOut() {} + + int sortKey() const { return sortKey_; } + + bool dataValid() const { return valid_; } + + int trackID() const { return trackID_; } + int linkID() const { return linkID_; } + + TTBV PartialTrack1() const { return PartialTrack1_; } + TTBV PartialTrack2() const { return PartialTrack2_; } + TTBV PartialTrack3() const { return PartialTrack3_; } + + tt::FrameTrack track() const { return track_; } + + private: + TTBV PartialTrack1_; + TTBV PartialTrack2_; + TTBV PartialTrack3_; + int sortKey_; + tt::FrameTrack track_; + int trackID_; + int linkID_; + bool valid_; }; typedef std::vector TrackKFOutSACollection; typedef std::shared_ptr TrackKFOutSAPtr; typedef std::vector TrackKFOutSAPtrCollection; - typedef std::vector< std::vector > > TrackKFOutSAPtrCollections; - typedef std::vector< std::vector< std::vector > > > TrackKFOutSAPtrCollectionss; + typedef std::vector>> TrackKFOutSAPtrCollections; + typedef std::vector>>> TrackKFOutSAPtrCollectionss; // class to represent tracks generated by process duplicate removal class TrackDR : public Track { public: @@ -726,7 +1027,7 @@ namespace trackerTFP { TrackDR(const tt::FrameTrack& frame, const DataFormats* dataFormats); // construct TrackDR from TrackKF TrackDR(const TrackKF& track); - ~TrackDR(){} + ~TrackDR() {} // track phi at radius 0 wrt processing nonant centre double phi0() const { return std::get<0>(data_); } // track inv2R @@ -737,10 +1038,11 @@ namespace trackerTFP { double cot() const { return std::get<3>(data_); } // conversion to TTTrack TTTrack ttTrack() const; + private: }; -} // namespace trackerTFP +} // namespace trackerTFP EVENTSETUP_DATA_DEFAULT_RECORD(trackerTFP::DataFormats, trackerTFP::DataFormatsRcd); diff --git a/L1Trigger/TrackerTFP/interface/Demonstrator.h b/L1Trigger/TrackerTFP/interface/Demonstrator.h index e457e88cddb9a..b57bca6e3ca25 100644 --- a/L1Trigger/TrackerTFP/interface/Demonstrator.h +++ b/L1Trigger/TrackerTFP/interface/Demonstrator.h @@ -18,11 +18,13 @@ namespace trackerTFP { */ class Demonstrator { public: - Demonstrator(){} + Demonstrator() {} Demonstrator(const edm::ParameterSet& iConfig, const tt::Setup* setup); - ~Demonstrator(){} + ~Demonstrator() {} // plays input through modelsim and compares result with output - void analyze(const std::vector>& input, const std::vector>& output) const; + void analyze(const std::vector>& input, + const std::vector>& output) const; + private: // converts streams of bv into stringstream void convert(const std::vector>& bits, std::stringstream& ss) const; @@ -59,7 +61,7 @@ namespace trackerTFP { int numRegions_; }; -} // namespace trackerTFP +} // namespace trackerTFP EVENTSETUP_DATA_DEFAULT_RECORD(trackerTFP::Demonstrator, trackerTFP::DemonstratorRcd); diff --git a/L1Trigger/TrackerTFP/interface/DistServer.h b/L1Trigger/TrackerTFP/interface/DistServer.h index c80707231a090..5c093ab796b06 100644 --- a/L1Trigger/TrackerTFP/interface/DistServer.h +++ b/L1Trigger/TrackerTFP/interface/DistServer.h @@ -7,27 +7,27 @@ namespace trackerTFP { - class DistServer { - public: - DistServer( unsigned int nInputs, unsigned int nOutputs, unsigned int nInterleaving ); - ~DistServer() {} - - TrackKFOutSAPtrCollection clock(TrackKFOutSAPtrCollection& inputs); - - unsigned int nInputs() const { return nInputs_; } - unsigned int nOutputs() const { return nOutputs_; } - unsigned int nInterleaving() const { return nInterleaving_; } - std::vector< std::vector< unsigned int> >& addr() { return addr_; } - TrackKFOutSAPtrCollections& inputs() { return inputs_; } - - private: - unsigned int nInputs_; - unsigned int nOutputs_; - unsigned int nInterleaving_; - - TrackKFOutSAPtrCollections inputs_; - std::vector< std::vector< unsigned int> > addr_; - }; -} + class DistServer { + public: + DistServer(unsigned int nInputs, unsigned int nOutputs, unsigned int nInterleaving); + ~DistServer() {} + + TrackKFOutSAPtrCollection clock(TrackKFOutSAPtrCollection& inputs); + + unsigned int nInputs() const { return nInputs_; } + unsigned int nOutputs() const { return nOutputs_; } + unsigned int nInterleaving() const { return nInterleaving_; } + std::vector >& addr() { return addr_; } + TrackKFOutSAPtrCollections& inputs() { return inputs_; } + + private: + unsigned int nInputs_; + unsigned int nOutputs_; + unsigned int nInterleaving_; + + TrackKFOutSAPtrCollections inputs_; + std::vector > addr_; + }; +} // namespace trackerTFP #endif \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/interface/GeometricProcessor.h b/L1Trigger/TrackerTFP/interface/GeometricProcessor.h index 9bcaffaccae51..0cf1279c64bea 100644 --- a/L1Trigger/TrackerTFP/interface/GeometricProcessor.h +++ b/L1Trigger/TrackerTFP/interface/GeometricProcessor.h @@ -13,8 +13,11 @@ namespace trackerTFP { // Class to route Stubs of one region to one stream per sector class GeometricProcessor { public: - GeometricProcessor(const edm::ParameterSet& iConfig, const tt::Setup* setup_, const DataFormats* dataFormats, int region); - ~GeometricProcessor(){} + GeometricProcessor(const edm::ParameterSet& iConfig, + const tt::Setup* setup_, + const DataFormats* dataFormats, + int region); + ~GeometricProcessor() {} // read in and organize input product (fill vector input_) void consume(const TTDTC& ttDTC); @@ -23,7 +26,7 @@ namespace trackerTFP { private: // remove and return first element of deque, returns nullptr if empty - template + template T* pop_front(std::deque& ts) const; // true if truncation is enbaled @@ -42,6 +45,6 @@ namespace trackerTFP { std::vector>> input_; }; -} +} // namespace trackerTFP #endif \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/interface/HoughTransform.h b/L1Trigger/TrackerTFP/interface/HoughTransform.h index f0dea1d2cf04d..50ab325782f3d 100644 --- a/L1Trigger/TrackerTFP/interface/HoughTransform.h +++ b/L1Trigger/TrackerTFP/interface/HoughTransform.h @@ -15,7 +15,7 @@ namespace trackerTFP { class HoughTransform { public: HoughTransform(const edm::ParameterSet& iConfig, const tt::Setup* setup, const DataFormats* dataFormats, int region); - ~HoughTransform(){} + ~HoughTransform() {} // read in and organize input product void consume(const tt::StreamsStub& streams); @@ -24,12 +24,18 @@ namespace trackerTFP { private: // remove and return first element of deque, returns nullptr if empty - template + template T* pop_front(std::deque& ts) const; // associate stubs with phiT bins in this inv2R column - void fillIn(int inv2R, std::deque& inputSector, std::vector& acceptedSector, std::vector& lostSector); + void fillIn(int inv2R, + std::deque& inputSector, + std::vector& acceptedSector, + std::vector& lostSector); // identify tracks - void readOut(const std::vector& acceptedSector, const std::vector& lostSector, std::deque& acceptedAll, std::deque& lostAll) const; + void readOut(const std::vector& acceptedSector, + const std::vector& lostSector, + std::deque& acceptedAll, + std::deque& lostAll) const; // identify lost tracks void analyze(); // store tracks @@ -55,6 +61,6 @@ namespace trackerTFP { std::vector>> input_; }; -} +} // namespace trackerTFP #endif \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/interface/KalmanFilter.h b/L1Trigger/TrackerTFP/interface/KalmanFilter.h index d4d84b4c04392..535677b01e535 100644 --- a/L1Trigger/TrackerTFP/interface/KalmanFilter.h +++ b/L1Trigger/TrackerTFP/interface/KalmanFilter.h @@ -14,20 +14,29 @@ namespace trackerTFP { // Class to do helix fit to all tracks in a region. class KalmanFilter { public: - KalmanFilter(const edm::ParameterSet& iConfig, const tt::Setup* setup, const DataFormats* dataFormats, KalmanFilterFormats* kalmanFilterFormats, int region); - ~KalmanFilter(){} + KalmanFilter(const edm::ParameterSet& iConfig, + const tt::Setup* setup, + const DataFormats* dataFormats, + KalmanFilterFormats* kalmanFilterFormats, + int region); + ~KalmanFilter() {} // read in and organize input tracks and stubs void consume(const tt::StreamsTrack& streamsTrack, const tt::StreamsStub& streamsStub); // fill output products - void produce(tt::StreamsStub& accpetedStubs, tt::StreamsTrack& acceptedTracks, tt::StreamsStub& lostStubs, tt::StreamsTrack& lostTracks, int& numAcceptedStates, int& numLostStates); + void produce(tt::StreamsStub& accpetedStubs, + tt::StreamsTrack& acceptedTracks, + tt::StreamsStub& lostStubs, + tt::StreamsTrack& lostTracks, + int& numAcceptedStates, + int& numLostStates); private: // remove and return first element of deque, returns nullptr if empty - template + template T* pop_front(std::deque& ts) const; // remove and return first element of vector, returns nullptr if empty - template + template T* pop_front(std::vector& ts) const; // adds a layer to states @@ -98,9 +107,8 @@ namespace trackerTFP { DataFormatKF* C22_; DataFormatKF* C23_; DataFormatKF* C33_; - }; -} +} // namespace trackerTFP #endif \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/interface/KalmanFilterFormats.h b/L1Trigger/TrackerTFP/interface/KalmanFilterFormats.h index 46d2b8d254fe6..d95de14292e4b 100644 --- a/L1Trigger/TrackerTFP/interface/KalmanFilterFormats.h +++ b/L1Trigger/TrackerTFP/interface/KalmanFilterFormats.h @@ -21,7 +21,47 @@ enabling tuning of bit widths namespace trackerTFP { - enum class VariableKF { begin, x0 = begin, x1, x2, x3, H00, H12, m0, m1, v0, v1, r0, r1, S00, S01, S12, S13, K00, K10, K21, K31, R00, R11, R00Rough, R11Rough, invR00Approx, invR11Approx, invR00Cor, invR11Cor, invR00, invR11, C00, C01, C11, C22, C23, C33, end, x }; + enum class VariableKF { + begin, + x0 = begin, + x1, + x2, + x3, + H00, + H12, + m0, + m1, + v0, + v1, + r0, + r1, + S00, + S01, + S12, + S13, + K00, + K10, + K21, + K31, + R00, + R11, + R00Rough, + R11Rough, + invR00Approx, + invR11Approx, + invR00Cor, + invR11Cor, + invR00, + invR11, + C00, + C01, + C11, + C22, + C23, + C33, + end, + x + }; inline constexpr int operator+(VariableKF v) { return static_cast(v); } inline constexpr VariableKF operator++(VariableKF v) { return VariableKF(+v + 1); } @@ -40,6 +80,7 @@ namespace trackerTFP { bool inRange(double d) const; void updateRangeActual(double d); int integer(double d) const { return floor(d / base_); } + protected: VariableKF v_; bool twos_; @@ -49,65 +90,103 @@ namespace trackerTFP { std::pair rangeActual_; }; - template + template class FormatKF : public DataFormatKF { public: FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); ~FormatKF() {} + private: - void calcRange() { range_ = base_ * pow( 2, width_ ); } + void calcRange() { range_ = base_ * pow(2, width_); } }; - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); - template<> FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig); class KalmanFilterFormats { public: KalmanFilterFormats(); KalmanFilterFormats(const edm::ParameterSet& iConfig, const DataFormats* dataFormats); - ~KalmanFilterFormats(){} + ~KalmanFilterFormats() {} const tt::Setup* setup() const { return setup_; } const DataFormats* dataFormats() const { return dataFormats_; } int width(VariableKF v) const { return formats_[+v].width(); } double base(VariableKF v) const { return formats_[+v].base(); } DataFormatKF& format(VariableKF v) { return formats_[+v]; } void endJob(); + private: - template + template void fillFormats(); const edm::ParameterSet iConfig_; const DataFormats* dataFormats_; @@ -115,7 +194,7 @@ namespace trackerTFP { std::vector formats_; }; -} // namespace trackerTFP +} // namespace trackerTFP EVENTSETUP_DATA_DEFAULT_RECORD(trackerTFP::KalmanFilterFormats, trackerTFP::KalmanFilterFormatsRcd); diff --git a/L1Trigger/TrackerTFP/interface/KalmanFilterFormatsRcd.h b/L1Trigger/TrackerTFP/interface/KalmanFilterFormatsRcd.h index 91f4fa58b97d7..c1c2a3298b97b 100644 --- a/L1Trigger/TrackerTFP/interface/KalmanFilterFormatsRcd.h +++ b/L1Trigger/TrackerTFP/interface/KalmanFilterFormatsRcd.h @@ -9,7 +9,8 @@ namespace trackerTFP { typedef edm::mpl::Vector RcdsKalmanFilterFormats; - class KalmanFilterFormatsRcd : public edm::eventsetup::DependentRecordImplementation {}; + class KalmanFilterFormatsRcd + : public edm::eventsetup::DependentRecordImplementation {}; } // namespace trackerTFP diff --git a/L1Trigger/TrackerTFP/interface/LayerEncoding.h b/L1Trigger/TrackerTFP/interface/LayerEncoding.h index 7fb9ea7bf6024..8466521a51c14 100644 --- a/L1Trigger/TrackerTFP/interface/LayerEncoding.h +++ b/L1Trigger/TrackerTFP/interface/LayerEncoding.h @@ -19,15 +19,20 @@ namespace trackerTFP { public: LayerEncoding() {} LayerEncoding(const DataFormats* dataFormats); - ~LayerEncoding(){} + ~LayerEncoding() {} // Set of layers in each (zT,tanL) digi Bin of each eta sector numbered 0->N - const std::vector& layerEncoding(int binEta, int binZT, int binCot) const { return layerEncoding_.at(binEta).at(binZT).at(binCot); } + const std::vector& layerEncoding(int binEta, int binZT, int binCot) const { + return layerEncoding_.at(binEta).at(binZT).at(binCot); + } // maybe layers for given ets sector, bin in zT and bin in cotThea - const std::vector& maybeLayer(int binEta, int binZT, int binCot) const { return maybeLayer_.at(binEta).at(binZT).at(binCot); } + const std::vector& maybeLayer(int binEta, int binZT, int binCot) const { + return maybeLayer_.at(binEta).at(binZT).at(binCot); + } // encoded layer id for given eta sector, bin in zT, bin in cotThea and decoed layer id const int layerIdKF(int binEta, int binZT, int binCot, int layerId) const; // pattern of maybe layers for given eta sector, bin in zT and bin in cotThea TTBV maybePattern(int binEta, int binZT, int binCot) const; + private: // helper class providing run-time constants const tt::Setup* setup_; @@ -43,7 +48,7 @@ namespace trackerTFP { std::vector>>> maybeLayer_; }; -} // namespace trackerTFP +} // namespace trackerTFP EVENTSETUP_DATA_DEFAULT_RECORD(trackerTFP::LayerEncoding, trackerTFP::LayerEncodingRcd); diff --git a/L1Trigger/TrackerTFP/interface/LayerEncodingRcd.h b/L1Trigger/TrackerTFP/interface/LayerEncodingRcd.h index 9d72602fb5954..3ac343084f6d5 100644 --- a/L1Trigger/TrackerTFP/interface/LayerEncodingRcd.h +++ b/L1Trigger/TrackerTFP/interface/LayerEncodingRcd.h @@ -10,7 +10,8 @@ namespace trackerTFP { typedef edm::mpl::Vector RcdsLayerEncoding; // record of trackerTFP::LayerEncoding - class LayerEncodingRcd : public edm::eventsetup::DependentRecordImplementation {}; + class LayerEncodingRcd : public edm::eventsetup::DependentRecordImplementation { + }; } // namespace trackerTFP diff --git a/L1Trigger/TrackerTFP/interface/MiniHoughTransform.h b/L1Trigger/TrackerTFP/interface/MiniHoughTransform.h index 2dc35ed92cdd4..8cdaa35d922f2 100644 --- a/L1Trigger/TrackerTFP/interface/MiniHoughTransform.h +++ b/L1Trigger/TrackerTFP/interface/MiniHoughTransform.h @@ -14,8 +14,11 @@ namespace trackerTFP { // Class to refine HT track candidates in r-phi, by subdividing each HT cell into a finer granularity array class MiniHoughTransform { public: - MiniHoughTransform(const edm::ParameterSet& iConfig, const tt::Setup* setup, const DataFormats* dataFormats, int region); - ~MiniHoughTransform(){} + MiniHoughTransform(const edm::ParameterSet& iConfig, + const tt::Setup* setup, + const DataFormats* dataFormats, + int region); + ~MiniHoughTransform() {} // read in and organize input product (fill vector input_) void consume(const tt::StreamsStub& streams); @@ -24,7 +27,7 @@ namespace trackerTFP { private: // remove and return first element of deque, returns nullptr if empty - template + template T* pop_front(std::deque& ts) const; // perform finer pattern recognition per track void fill(int channel, const std::vector& input, std::vector>& output); @@ -61,6 +64,6 @@ namespace trackerTFP { std::vector> input_; }; -} +} // namespace trackerTFP #endif \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/interface/State.h b/L1Trigger/TrackerTFP/interface/State.h index c2e3d46a005a4..91804aa4648e8 100644 --- a/L1Trigger/TrackerTFP/interface/State.h +++ b/L1Trigger/TrackerTFP/interface/State.h @@ -7,7 +7,6 @@ #include #include - namespace trackerTFP { // Class to represent a Kalman Filter State @@ -21,7 +20,7 @@ namespace trackerTFP { State(State* state, StubKFin* stub); // updated state constructor State(State* state, const std::vector& doubles); - ~State(){} + ~State() {} // Determine quality of completed state void finish(); @@ -127,6 +126,6 @@ namespace trackerTFP { int numConsistentLayers_; }; -} +} // namespace trackerTFP #endif \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/interface/ZHoughTransform.h b/L1Trigger/TrackerTFP/interface/ZHoughTransform.h index 63cab73c502e5..1fbb2c622c7b3 100644 --- a/L1Trigger/TrackerTFP/interface/ZHoughTransform.h +++ b/L1Trigger/TrackerTFP/interface/ZHoughTransform.h @@ -13,8 +13,11 @@ namespace trackerTFP { // Class to refine MHT track candidates in r-z class ZHoughTransform { public: - ZHoughTransform(const edm::ParameterSet& iConfig, const tt::Setup* setup, const DataFormats* dataFormats, int region); - ~ZHoughTransform(){} + ZHoughTransform(const edm::ParameterSet& iConfig, + const tt::Setup* setup, + const DataFormats* dataFormats, + int region); + ~ZHoughTransform() {} // read in and organize input product (fill vector input_) void consume(const tt::StreamsStub& streams); @@ -23,7 +26,7 @@ namespace trackerTFP { private: // remove and return first element of deque, returns nullptr if empty - template + template T* pop_front(std::deque& ts) const; // perform finer pattern recognition per track void fill(int channel, const std::deque& input, std::vector>& output); @@ -48,6 +51,6 @@ namespace trackerTFP { int stage_; }; -} +} // namespace trackerTFP #endif \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/plugins/ProducerGP.cc b/L1Trigger/TrackerTFP/plugins/ProducerGP.cc index 73f654ff41190..3dedce5c702fc 100644 --- a/L1Trigger/TrackerTFP/plugins/ProducerGP.cc +++ b/L1Trigger/TrackerTFP/plugins/ProducerGP.cc @@ -36,8 +36,8 @@ namespace trackerTFP { ~ProducerGP() override {} private: - virtual void beginRun(const Run&, const EventSetup&) override; - virtual void produce(Event&, const EventSetup&) override; + void beginRun(const Run&, const EventSetup&) override; + void produce(Event&, const EventSetup&) override; virtual void endJob() {} // ED input token of DTC stubs @@ -58,9 +58,7 @@ namespace trackerTFP { const DataFormats* dataFormats_; }; - ProducerGP::ProducerGP(const ParameterSet& iConfig) : - iConfig_(iConfig) - { + ProducerGP::ProducerGP(const ParameterSet& iConfig) : iConfig_(iConfig) { const string& label = iConfig.getParameter("LabelDTC"); const string& branchAccepted = iConfig.getParameter("BranchAcceptedStubs"); const string& branchLost = iConfig.getParameter("BranchLostStubs"); @@ -109,6 +107,6 @@ namespace trackerTFP { iEvent.emplace(edPutTokenLost_, move(lost)); } -} // namespace trackerTFP +} // namespace trackerTFP DEFINE_FWK_MODULE(trackerTFP::ProducerGP); \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/plugins/ProducerHT.cc b/L1Trigger/TrackerTFP/plugins/ProducerHT.cc index 132bb4a256bd7..0262859657afa 100644 --- a/L1Trigger/TrackerTFP/plugins/ProducerHT.cc +++ b/L1Trigger/TrackerTFP/plugins/ProducerHT.cc @@ -35,8 +35,8 @@ namespace trackerTFP { ~ProducerHT() override {} private: - virtual void beginRun(const Run&, const EventSetup&) override; - virtual void produce(Event&, const EventSetup&) override; + void beginRun(const Run&, const EventSetup&) override; + void produce(Event&, const EventSetup&) override; virtual void endJob() {} // ED input token of gp stubs @@ -57,9 +57,7 @@ namespace trackerTFP { const DataFormats* dataFormats_; }; - ProducerHT::ProducerHT(const ParameterSet& iConfig) : - iConfig_(iConfig) - { + ProducerHT::ProducerHT(const ParameterSet& iConfig) : iConfig_(iConfig) { const string& label = iConfig.getParameter("LabelGP"); const string& branchAccepted = iConfig.getParameter("BranchAcceptedStubs"); const string& branchLost = iConfig.getParameter("BranchLostStubs"); @@ -110,6 +108,6 @@ namespace trackerTFP { iEvent.emplace(edPutTokenLost_, move(lost)); } -} // namespace trackerTFP +} // namespace trackerTFP DEFINE_FWK_MODULE(trackerTFP::ProducerHT); \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/plugins/ProducerKF.cc b/L1Trigger/TrackerTFP/plugins/ProducerKF.cc index 5d117ed49eb64..1aca41b22cc48 100644 --- a/L1Trigger/TrackerTFP/plugins/ProducerKF.cc +++ b/L1Trigger/TrackerTFP/plugins/ProducerKF.cc @@ -39,7 +39,7 @@ namespace trackerTFP { void beginRun(const Run&, const EventSetup&) override; void produce(Event&, const EventSetup&) override; //void endStream() { kalmanFilterFormats_->endJob(); } - void endStream() {} + void endStream() override {} // ED input token of sf stubs and tracks EDGetTokenT edGetTokenStubs_; @@ -69,8 +69,7 @@ namespace trackerTFP { KalmanFilterFormats* kalmanFilterFormats_; }; - ProducerKF::ProducerKF(const ParameterSet& iConfig) : iConfig_(iConfig) - { + ProducerKF::ProducerKF(const ParameterSet& iConfig) : iConfig_(iConfig) { const string& label = iConfig.getParameter("LabelKFin"); const string& branchAcceptedStubs = iConfig.getParameter("BranchAcceptedStubs"); const string& branchAcceptedTracks = iConfig.getParameter("BranchAcceptedTracks"); @@ -139,10 +138,10 @@ namespace trackerTFP { iEvent.emplace(edPutTokenAcceptedTracks_, move(acceptedTracks)); iEvent.emplace(edPutTokenLostStubs_, move(lostStubs)); iEvent.emplace(edPutTokenLostTracks_, move(lostTracks)); - iEvent.emplace(edPutTokenNumAcceptedStates_, move(numAcceptedStates)); - iEvent.emplace(edPutTokenNumLostStates_, move(numLostStates)); + iEvent.emplace(edPutTokenNumAcceptedStates_, numAcceptedStates); + iEvent.emplace(edPutTokenNumLostStates_, numLostStates); } -} // namespace trackerTFP +} // namespace trackerTFP DEFINE_FWK_MODULE(trackerTFP::ProducerKF); \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/plugins/ProducerKFin.cc b/L1Trigger/TrackerTFP/plugins/ProducerKFin.cc index c98524a6675cf..e1dd4c892d81d 100644 --- a/L1Trigger/TrackerTFP/plugins/ProducerKFin.cc +++ b/L1Trigger/TrackerTFP/plugins/ProducerKFin.cc @@ -40,8 +40,8 @@ namespace trackerTFP { ~ProducerKFin() override {} private: - virtual void beginRun(const Run&, const EventSetup&) override; - virtual void produce(Event&, const EventSetup&) override; + void beginRun(const Run&, const EventSetup&) override; + void produce(Event&, const EventSetup&) override; virtual void endJob() {} // ED input token of TTTracks @@ -72,9 +72,7 @@ namespace trackerTFP { bool enableTruncation_; }; - ProducerKFin::ProducerKFin(const ParameterSet& iConfig) : - iConfig_(iConfig) - { + ProducerKFin::ProducerKFin(const ParameterSet& iConfig) : iConfig_(iConfig) { const string& labelTTTracks = iConfig.getParameter("LabelZHTout"); const string& labelStubs = iConfig.getParameter("LabelZHT"); const string& branchAcceptedStubs = iConfig.getParameter("BranchAcceptedStubs"); @@ -82,7 +80,8 @@ namespace trackerTFP { const string& branchLostStubs = iConfig.getParameter("BranchLostStubs"); const string& branchLostTracks = iConfig.getParameter("BranchLostTracks"); // book in- and output ED products - edGetTokenTTTracks_ = consumes>>(InputTag(labelTTTracks, branchAcceptedTracks)); + edGetTokenTTTracks_ = + consumes>>(InputTag(labelTTTracks, branchAcceptedTracks)); edGetTokenStubs_ = consumes(InputTag(labelStubs, branchAcceptedStubs)); edPutTokenAcceptedStubs_ = produces(branchAcceptedStubs); edPutTokenAcceptedTracks_ = produces(branchAcceptedTracks); @@ -139,7 +138,9 @@ namespace trackerTFP { for (int channel = 0; channel < dataFormats_->numChannel(Process::zht); channel++) { const int index = region * dataFormats_->numChannel(Process::zht) + channel; const StreamStub& stream = streams[index]; - nStubsZHR += accumulate(stream.begin(), stream.end(), 0, [](int& sum, const FrameStub& frame){ return sum += frame.first.isNonnull() ? 1 : 0; }); + nStubsZHR += accumulate(stream.begin(), stream.end(), 0, [](int& sum, const FrameStub& frame) { + return sum += frame.first.isNonnull() ? 1 : 0; + }); } vector stubsZHT; stubsZHT.reserve(nStubsZHR); @@ -171,7 +172,7 @@ namespace trackerTFP { continue; layerCounts[layerIdKF]++; deque& stubs = dequesStubs[sectorPhi * setup_->numLayers() + layerIdKF]; - auto identical = [ttStubRef, ttTrack](const StubZHT& stub){ + auto identical = [ttStubRef, ttTrack](const StubZHT& stub) { return (int)ttTrack.trackSeedType() == stub.trackId() && ttStubRef == stub.ttStubRef(); }; stubZHT = &*find_if(stubsZHT.begin(), stubsZHT.end(), identical); @@ -222,6 +223,6 @@ namespace trackerTFP { iEvent.emplace(edPutTokenLostTracks_, move(streamLostTracks)); } -} // namespace trackerTFP +} // namespace trackerTFP DEFINE_FWK_MODULE(trackerTFP::ProducerKFin); \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/plugins/ProducerMHT.cc b/L1Trigger/TrackerTFP/plugins/ProducerMHT.cc index 30f2af865476e..96ff7aa29620c 100644 --- a/L1Trigger/TrackerTFP/plugins/ProducerMHT.cc +++ b/L1Trigger/TrackerTFP/plugins/ProducerMHT.cc @@ -35,8 +35,8 @@ namespace trackerTFP { ~ProducerMHT() override {} private: - virtual void beginRun(const Run&, const EventSetup&) override; - virtual void produce(Event&, const EventSetup&) override; + void beginRun(const Run&, const EventSetup&) override; + void produce(Event&, const EventSetup&) override; virtual void endJob() {} // ED input token of gp stubs @@ -57,9 +57,7 @@ namespace trackerTFP { const DataFormats* dataFormats_; }; - ProducerMHT::ProducerMHT(const ParameterSet& iConfig) : - iConfig_(iConfig) - { + ProducerMHT::ProducerMHT(const ParameterSet& iConfig) : iConfig_(iConfig) { const string& label = iConfig.getParameter("LabelHT"); const string& branchAccepted = iConfig.getParameter("BranchAcceptedStubs"); const string& branchLost = iConfig.getParameter("BranchLostStubs"); @@ -110,6 +108,6 @@ namespace trackerTFP { iEvent.emplace(edPutTokenLost_, move(lost)); } -} // namespace trackerTFP +} // namespace trackerTFP DEFINE_FWK_MODULE(trackerTFP::ProducerMHT); \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/plugins/ProducerTT.cc b/L1Trigger/TrackerTFP/plugins/ProducerTT.cc index 6413af9eac538..0294a79df1cd6 100644 --- a/L1Trigger/TrackerTFP/plugins/ProducerTT.cc +++ b/L1Trigger/TrackerTFP/plugins/ProducerTT.cc @@ -56,9 +56,7 @@ namespace trackerTFP { const DataFormats* dataFormats_; }; - ProducerTT::ProducerTT(const ParameterSet& iConfig) : - iConfig_(iConfig) - { + ProducerTT::ProducerTT(const ParameterSet& iConfig) : iConfig_(iConfig) { const string& label = iConfig.getParameter("LabelKF"); const string& branchStubs = iConfig.getParameter("BranchAcceptedStubs"); const string& branchTracks = iConfig.getParameter("BranchAcceptedTracks"); @@ -99,7 +97,9 @@ namespace trackerTFP { const StreamsStub& streamsStubs = *handleStubs.product(); int nTracks(0); for (const StreamTrack& stream : streamsTracks) - nTracks += accumulate(stream.begin(), stream.end(), 0, [](int& sum, const FrameTrack& frame){ return sum += frame.first.isNonnull() ? 1 : 0; }); + nTracks += accumulate(stream.begin(), stream.end(), 0, [](int& sum, const FrameTrack& frame) { + return sum += frame.first.isNonnull() ? 1 : 0; + }); ttTracks.reserve(nTracks); for (int channel = 0; channel < dataFormats_->numStreamsTracks(Process::kf); channel++) { int iTrk(0); @@ -122,6 +122,6 @@ namespace trackerTFP { iEvent.emplace(edPutToken_, move(ttTracks)); } -} // namespace trackerTFP +} // namespace trackerTFP DEFINE_FWK_MODULE(trackerTFP::ProducerTT); \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/plugins/ProducerZHT.cc b/L1Trigger/TrackerTFP/plugins/ProducerZHT.cc index d9f1b19f480b4..38943b1372087 100644 --- a/L1Trigger/TrackerTFP/plugins/ProducerZHT.cc +++ b/L1Trigger/TrackerTFP/plugins/ProducerZHT.cc @@ -35,8 +35,8 @@ namespace trackerTFP { ~ProducerZHT() override {} private: - virtual void beginRun(const Run&, const EventSetup&) override; - virtual void produce(Event&, const EventSetup&) override; + void beginRun(const Run&, const EventSetup&) override; + void produce(Event&, const EventSetup&) override; virtual void endJob() {} // ED input token of gp stubs @@ -57,9 +57,7 @@ namespace trackerTFP { const DataFormats* dataFormats_; }; - ProducerZHT::ProducerZHT(const ParameterSet& iConfig) : - iConfig_(iConfig) - { + ProducerZHT::ProducerZHT(const ParameterSet& iConfig) : iConfig_(iConfig) { const string& label = iConfig.getParameter("LabelMHT"); const string& branchAccepted = iConfig.getParameter("BranchAcceptedStubs"); const string& branchLost = iConfig.getParameter("BranchLostStubs"); @@ -110,6 +108,6 @@ namespace trackerTFP { iEvent.emplace(edPutTokenLost_, move(lost)); } -} // namespace trackerTFP +} // namespace trackerTFP DEFINE_FWK_MODULE(trackerTFP::ProducerZHT); \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/plugins/ProducerZHTout.cc b/L1Trigger/TrackerTFP/plugins/ProducerZHTout.cc index 43b7fcd5c2f64..774fe46024a4d 100644 --- a/L1Trigger/TrackerTFP/plugins/ProducerZHTout.cc +++ b/L1Trigger/TrackerTFP/plugins/ProducerZHTout.cc @@ -35,8 +35,8 @@ namespace trackerTFP { ~ProducerZHTout() override {} private: - virtual void beginRun(const Run&, const EventSetup&) override; - virtual void produce(Event&, const EventSetup&) override; + void beginRun(const Run&, const EventSetup&) override; + void produce(Event&, const EventSetup&) override; virtual void endJob() {} // ED input token of sf stubs @@ -55,9 +55,7 @@ namespace trackerTFP { const DataFormats* dataFormats_; }; - ProducerZHTout::ProducerZHTout(const ParameterSet& iConfig) : - iConfig_(iConfig) - { + ProducerZHTout::ProducerZHTout(const ParameterSet& iConfig) : iConfig_(iConfig) { const string& label = iConfig.getParameter("LabelZHT"); const string& branchAcceptedStubs = iConfig.getParameter("BranchAcceptedStubs"); const string& branchAcceptedTracks = iConfig.getParameter("BranchAcceptedTracks"); @@ -96,7 +94,7 @@ namespace trackerTFP { Handle handle; iEvent.getByToken(edGetToken_, handle); const StreamsStub& streams = *handle.product(); - for (int region = 0; region < setup_->numRegions(); region++ ) { + for (int region = 0; region < setup_->numRegions(); region++) { for (int channel = 0; channel < dataFormats_->numChannel(Process::zht); channel++) { const int index = region * dataFormats_->numChannel(Process::zht) + channel; // convert stream to stubs @@ -104,18 +102,18 @@ namespace trackerTFP { vector stubs; stubs.reserve(stream.size()); for (const FrameStub& frame : stream) - if(frame.first.isNonnull()) + if (frame.first.isNonnull()) stubs.emplace_back(frame, dataFormats_); // form tracks int i(0); for (auto it = stubs.begin(); it != stubs.end();) { const auto start = it; const int id = it->trackId(); - auto different = [id](const StubZHT& stub){ return id != stub.trackId(); }; + auto different = [id](const StubZHT& stub) { return id != stub.trackId(); }; it = find_if(it, stubs.end(), different); vector ttStubRefs; ttStubRefs.reserve(distance(start, it)); - transform(start, it, back_inserter(ttStubRefs), [](const StubZHT& stub){ return stub.ttStubRef(); }); + transform(start, it, back_inserter(ttStubRefs), [](const StubZHT& stub) { return stub.ttStubRef(); }); const double zT = dfZT.floating(start->zT()); const double cot = dfCot.floating(start->cot()); const double phiT = dfPhiT.floating(start->phiT()); @@ -135,6 +133,6 @@ namespace trackerTFP { iEvent.emplace(edPutToken_, ttTracks.begin(), ttTracks.end()); } -} // namespace trackerTFP +} // namespace trackerTFP DEFINE_FWK_MODULE(trackerTFP::ProducerZHTout); \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/src/DataFormats.cc b/L1Trigger/TrackerTFP/src/DataFormats.cc index 14b74458c6226..79ca9d6fbeb72 100644 --- a/L1Trigger/TrackerTFP/src/DataFormats.cc +++ b/L1Trigger/TrackerTFP/src/DataFormats.cc @@ -17,13 +17,12 @@ using namespace tt; namespace trackerTFP { // default constructor, trying to needs space as proper constructed object - DataFormats::DataFormats() : - numDataFormats_(0), - formats_(+Variable::end, std::vector(+Process::end, nullptr)), - numUnusedBitsStubs_(+Process::end, TTBV::S_), - numUnusedBitsTracks_(+Process::end, TTBV::S_), - numChannel_(+Process::end, 0) - { + DataFormats::DataFormats() + : numDataFormats_(0), + formats_(+Variable::end, std::vector(+Process::end, nullptr)), + numUnusedBitsStubs_(+Process::end, TTBV::S_), + numUnusedBitsTracks_(+Process::end, TTBV::S_), + numChannel_(+Process::end, 0) { setup_ = nullptr; countFormats(); dataFormats_.reserve(numDataFormats_); @@ -33,13 +32,13 @@ namespace trackerTFP { } // method to count number of unique data formats - template + template void DataFormats::countFormats() { - if constexpr(config_[+v][+p] == p) + if constexpr (config_[+v][+p] == p) numDataFormats_++; - if constexpr(++p != Process::end) + if constexpr (++p != Process::end) countFormats(); - else if constexpr(++v != Variable::end) + else if constexpr (++v != Variable::end) countFormats<++v>(); } @@ -62,7 +61,9 @@ namespace trackerTFP { numChannel_[+Process::zht] = setup_->htNumBinsInv2R(); numChannel_[+Process::kfin] = setup_->kfNumWorker() * setup_->numLayers(); numChannel_[+Process::kf] = setup_->kfNumWorker(); - transform(numChannel_.begin(), numChannel_.end(), back_inserter(numStreams_), [this](int channel){ return channel * setup_->numRegions(); }); + transform(numChannel_.begin(), numChannel_.end(), back_inserter(numStreams_), [this](int channel) { + return channel * setup_->numRegions(); + }); numStreamsStubs_ = numStreams_; numStreamsStubs_[+Process::kf] = numStreams_[+Process::kfin]; numStreamsTracks_ = vector(+Process::end, 0); @@ -71,46 +72,46 @@ namespace trackerTFP { } // constructs data formats of all unique used variables and flavours - template + template void DataFormats::fillDataFormats() { - if constexpr(config_[+v][+p] == p) { + if constexpr (config_[+v][+p] == p) { dataFormats_.emplace_back(Format(iConfig_, setup_)); fillFormats(); } - if constexpr(++p != Process::end) + if constexpr (++p != Process::end) fillDataFormats(); - else if constexpr(++v != Variable::end) + else if constexpr (++v != Variable::end) fillDataFormats<++v>(); } // helper (loop) data formats of all unique used variables and flavours - template + template void DataFormats::fillFormats() { if (config_[+v][+it] == p) { formats_[+v][+it] = &dataFormats_.back(); } - if constexpr(++it != Process::end) + if constexpr (++it != Process::end) fillFormats(); } // converts bits to ntuple of variables - template + template void DataFormats::convertStub(Process p, const Frame& bv, tuple& data) const { TTBV ttBV(bv); extractStub(p, ttBV, data); } // helper (loop) to convert bits to ntuple of variables - template + template void DataFormats::extractStub(Process p, TTBV& ttBV, std::tuple& data) const { Variable v = *next(stubs_[+p].begin(), sizeof...(Ts) - 1 - it); formats_[+v][+p]->extract(ttBV, get(data)); - if constexpr(it + 1 != sizeof...(Ts)) + if constexpr (it + 1 != sizeof...(Ts)) extractStub(p, ttBV, data); } // converts ntuple of variables to bits - template + template void DataFormats::convertStub(Process p, const std::tuple& data, Frame& bv) const { TTBV ttBV(1, numUnusedBitsStubs_[+p]); attachStub(p, data, ttBV); @@ -118,32 +119,32 @@ namespace trackerTFP { } // helper (loop) to convert ntuple of variables to bits - template + template void DataFormats::attachStub(Process p, const tuple& data, TTBV& ttBV) const { Variable v = *next(stubs_[+p].begin(), it); formats_[+v][+p]->attach(get(data), ttBV); - if constexpr(it + 1 != sizeof...(Ts)) + if constexpr (it + 1 != sizeof...(Ts)) attachStub(p, data, ttBV); } // converts bits to ntuple of variables - template + template void DataFormats::convertTrack(Process p, const Frame& bv, tuple& data) const { TTBV ttBV(bv); extractTrack(p, ttBV, data); } // helper (loop) to convert bits to ntuple of variables - template + template void DataFormats::extractTrack(Process p, TTBV& ttBV, std::tuple& data) const { Variable v = *next(tracks_[+p].begin(), sizeof...(Ts) - 1 - it); formats_[+v][+p]->extract(ttBV, get(data)); - if constexpr(it + 1 != sizeof...(Ts)) + if constexpr (it + 1 != sizeof...(Ts)) extractTrack(p, ttBV, data); } // converts ntuple of variables to bits - template + template void DataFormats::convertTrack(Process p, const std::tuple& data, Frame& bv) const { TTBV ttBV(1, numUnusedBitsTracks_[+p]); attachTrack(p, data, ttBV); @@ -151,61 +152,46 @@ namespace trackerTFP { } // helper (loop) to convert ntuple of variables to bits - template + template void DataFormats::attachTrack(Process p, const tuple& data, TTBV& ttBV) const { Variable v = *next(tracks_[+p].begin(), it); formats_[+v][+p]->attach(get(data), ttBV); - if constexpr(it + 1 != sizeof...(Ts)) + if constexpr (it + 1 != sizeof...(Ts)) attachTrack(p, data, ttBV); } // construct Stub from Frame - template - Stub::Stub(const FrameStub& frame, const DataFormats* dataFormats, Process p) : - dataFormats_(dataFormats), - p_(p), - frame_(frame), - trackId_(0) - { + template + Stub::Stub(const FrameStub& frame, const DataFormats* dataFormats, Process p) + : dataFormats_(dataFormats), p_(p), frame_(frame), trackId_(0) { dataFormats_->convertStub(p, frame.second, data_); } // construct Stub from other Stub - template - template - Stub::Stub(const Stub& stub, Ts... data) : - dataFormats_(stub.dataFormats()), - p_(++stub.p()), - frame_(stub.frame().first, Frame()), - data_(data...), - trackId_(0) - { - } + template + template + Stub::Stub(const Stub& stub, Ts... data) + : dataFormats_(stub.dataFormats()), + p_(++stub.p()), + frame_(stub.frame().first, Frame()), + data_(data...), + trackId_(0) {} // construct Stub from TTStubRef - template - Stub::Stub(const TTStubRef& ttStubRef, const DataFormats* dataFormats, Process p, Ts... data) : - dataFormats_(dataFormats), - p_(p), - frame_(ttStubRef, Frame()), - data_(data...), - trackId_(0) - { - } + template + Stub::Stub(const TTStubRef& ttStubRef, const DataFormats* dataFormats, Process p, Ts... data) + : dataFormats_(dataFormats), p_(p), frame_(ttStubRef, Frame()), data_(data...), trackId_(0) {} // construct StubPP from Frame - StubPP::StubPP(const FrameStub& frame, const DataFormats* formats) : - Stub(frame, formats, Process::pp) - { - for(int sectorEta = sectorEtaMin(); sectorEta <= sectorEtaMax(); sectorEta++) - for(int sectorPhi = 0; sectorPhi < width(Variable::sectorsPhi); sectorPhi++) + StubPP::StubPP(const FrameStub& frame, const DataFormats* formats) : Stub(frame, formats, Process::pp) { + for (int sectorEta = sectorEtaMin(); sectorEta <= sectorEtaMax(); sectorEta++) + for (int sectorPhi = 0; sectorPhi < width(Variable::sectorsPhi); sectorPhi++) sectors_[sectorEta * width(Variable::sectorsPhi) + sectorPhi] = sectorsPhi()[sectorPhi]; } // construct StubGP from Frame - StubGP::StubGP(const FrameStub& frame, const DataFormats* formats, int sectorPhi, int sectorEta) : - Stub(frame, formats, Process::gp), sectorPhi_(sectorPhi), sectorEta_(sectorEta) - { + StubGP::StubGP(const FrameStub& frame, const DataFormats* formats, int sectorPhi, int sectorEta) + : Stub(frame, formats, Process::gp), sectorPhi_(sectorPhi), sectorEta_(sectorEta) { const Setup* setup = dataFormats_->setup(); inv2RBins_ = TTBV(0, setup->htNumBinsInv2R()); for (int inv2R = inv2RMin(); inv2R <= inv2RMax(); inv2R++) @@ -213,11 +199,10 @@ namespace trackerTFP { } // construct StubGP from StubPP - StubGP::StubGP(const StubPP& stub, int sectorPhi, int sectorEta) : - Stub(stub, stub.r(), stub.phi(), stub.z(), stub.layer(), stub.inv2RMin(), stub.inv2RMax()), - sectorPhi_(sectorPhi), - sectorEta_(sectorEta) - { + StubGP::StubGP(const StubPP& stub, int sectorPhi, int sectorEta) + : Stub(stub, stub.r(), stub.phi(), stub.z(), stub.layer(), stub.inv2RMin(), stub.inv2RMax()), + sectorPhi_(sectorPhi), + sectorEta_(sectorEta) { const Setup* setup = dataFormats_->setup(); get<1>(data_) -= (sectorPhi_ - .5) * setup->baseSector(); get<2>(data_) -= (r() + dataFormats_->chosenRofPhi()) * setup->sectorCot(sectorEta_); @@ -225,18 +210,17 @@ namespace trackerTFP { } // construct StubHT from Frame - StubHT::StubHT(const FrameStub& frame, const DataFormats* formats, int inv2R) : - Stub(frame, formats, Process::ht), inv2R_(inv2R) - { + StubHT::StubHT(const FrameStub& frame, const DataFormats* formats, int inv2R) + : Stub(frame, formats, Process::ht), inv2R_(inv2R) { fillTrackId(); } // construct StubHT from StubGP and HT cell assignment - StubHT::StubHT(const StubGP& stub, int phiT, int inv2R) : - Stub(stub, stub.r(), stub.phi(), stub.z(), stub.layer(), stub.sectorPhi(), stub.sectorEta(), phiT), - inv2R_(inv2R) - { - get<1>(data_) -= format(Variable::inv2R).floating(this->inv2R()) * r() + format(Variable::phiT).floating(this->phiT()); + StubHT::StubHT(const StubGP& stub, int phiT, int inv2R) + : Stub(stub, stub.r(), stub.phi(), stub.z(), stub.layer(), stub.sectorPhi(), stub.sectorEta(), phiT), + inv2R_(inv2R) { + get<1>(data_) -= + format(Variable::inv2R).floating(this->inv2R()) * r() + format(Variable::phiT).floating(this->phiT()); fillTrackId(); dataFormats_->convertStub(p_, data_, frame_.second); } @@ -247,16 +231,21 @@ namespace trackerTFP { } // construct StubMHT from Frame - StubMHT::StubMHT(const FrameStub& frame, const DataFormats* formats) : - Stub(frame, formats, Process::mht) - { + StubMHT::StubMHT(const FrameStub& frame, const DataFormats* formats) : Stub(frame, formats, Process::mht) { fillTrackId(); } // construct StubMHT from StubHT and MHT cell assignment - StubMHT::StubMHT(const StubHT& stub, int phiT, int inv2R) : - Stub(stub, stub.r(), stub.phi(), stub.z(), stub.layer(), stub.sectorPhi(), stub.sectorEta(), stub.phiT(), stub.inv2R()) - { + StubMHT::StubMHT(const StubHT& stub, int phiT, int inv2R) + : Stub(stub, + stub.r(), + stub.phi(), + stub.z(), + stub.layer(), + stub.sectorPhi(), + stub.sectorEta(), + stub.phiT(), + stub.inv2R()) { const Setup* setup = dataFormats_->setup(); // update track (phIT, inv2R), and phi residuals w.r.t. track, to reflect MHT cell assignment. get<6>(data_) = this->phiT() * setup->mhtNumBinsPhiT() + phiT; @@ -269,22 +258,30 @@ namespace trackerTFP { // fills track id void StubMHT::fillTrackId() { TTBV ttBV(bv()); - trackId_ = ttBV.extract(width(Variable::sectorPhi) + width(Variable::sectorEta) + width(Variable::phiT) + width(Variable::inv2R)); + trackId_ = ttBV.extract(width(Variable::sectorPhi) + width(Variable::sectorEta) + width(Variable::phiT) + + width(Variable::inv2R)); } // construct StubZHT from Frame - StubZHT::StubZHT(const FrameStub& frame, const DataFormats* formats) : - Stub(frame, formats, Process::zht) - { + StubZHT::StubZHT(const FrameStub& frame, const DataFormats* formats) : Stub(frame, formats, Process::zht) { cot_ = 0.; zT_ = 0.; fillTrackId(); } // construct StubZHT from StubMHT - StubZHT::StubZHT(const StubMHT& stub) : - Stub(stub, stub.r(), stub.phi(), stub.z(), stub.layer(), stub.sectorPhi(), stub.sectorEta(), stub.phiT(), stub.inv2R(), 0, 0) - { + StubZHT::StubZHT(const StubMHT& stub) + : Stub(stub, + stub.r(), + stub.phi(), + stub.z(), + stub.layer(), + stub.sectorPhi(), + stub.sectorEta(), + stub.phiT(), + stub.inv2R(), + 0, + 0) { cot_ = 0.; zT_ = 0.; r_ = format(Variable::r).digi(this->r() + dataFormats_->chosenRofPhi() - dataFormats_->setup()->chosenRofZ()); @@ -292,10 +289,21 @@ namespace trackerTFP { trackId_ = stub.trackId(); } - // - StubZHT::StubZHT(const StubZHT& stub, double zT, double cot, int id) : - Stub(stub.frame().first, stub.dataFormats(), Process::zht, stub.r(), stub.phi(), stub.z(), stub.layer(), stub.sectorPhi(), stub.sectorEta(), stub.phiT(), stub.inv2R(), stub.zT(), stub.cot()) - { + // + StubZHT::StubZHT(const StubZHT& stub, double zT, double cot, int id) + : Stub(stub.frame().first, + stub.dataFormats(), + Process::zht, + stub.r(), + stub.phi(), + stub.z(), + stub.layer(), + stub.sectorPhi(), + stub.sectorEta(), + stub.phiT(), + stub.inv2R(), + stub.zT(), + stub.cot()) { // update track (zT, cot), and phi residuals w.r.t. track, to reflect ZHT cell assignment. r_ = stub.r_; cot_ = stub.cotf() + cot; @@ -308,10 +316,23 @@ namespace trackerTFP { } // - StubZHT::StubZHT(const StubZHT& stub, int cot, int zT) : - Stub(stub.frame().first, stub.dataFormats(), Process::zht, stub.r(), stub.phi(), 0., stub.layer(), stub.sectorPhi(), stub.sectorEta(), stub.phiT(), stub.inv2R(), zT, cot) - { - get<2>(data_) = format(Variable::z).digi(stub.z() - (format(Variable::zT).floating(zT) - stub.r_ * format(Variable::cot).floating(cot))); + StubZHT::StubZHT(const StubZHT& stub, int cot, int zT) + : Stub(stub.frame().first, + stub.dataFormats(), + Process::zht, + stub.r(), + stub.phi(), + 0., + stub.layer(), + stub.sectorPhi(), + stub.sectorEta(), + stub.phiT(), + stub.inv2R(), + zT, + cot) { + get<2>(data_) = + format(Variable::z) + .digi(stub.z() - (format(Variable::zT).floating(zT) - stub.r_ * format(Variable::cot).floating(cot))); dataFormats_->convertStub(p_, data_, frame_.second); fillTrackId(); } @@ -319,89 +340,76 @@ namespace trackerTFP { // fills track id void StubZHT::fillTrackId() { TTBV ttBV(bv()); - trackId_ = ttBV.extract(width(Variable::sectorPhi) + width(Variable::sectorEta) + width(Variable::phiT) + width(Variable::inv2R) + width(Variable::zT) + width(Variable::cot)); + trackId_ = ttBV.extract(width(Variable::sectorPhi) + width(Variable::sectorEta) + width(Variable::phiT) + + width(Variable::inv2R) + width(Variable::zT) + width(Variable::cot)); } // construct StubKFin from Frame - StubKFin::StubKFin(const FrameStub& frame, const DataFormats* formats, int layer) : - Stub(frame, formats, Process::kfin), - layer_(layer) {} + StubKFin::StubKFin(const FrameStub& frame, const DataFormats* formats, int layer) + : Stub(frame, formats, Process::kfin), layer_(layer) {} // construct StubKFin from StubZHT - StubKFin::StubKFin(const StubZHT& stub, double dPhi, double dZ, int layer) : - Stub(stub, stub.r(), stub.phi(), stub.z(), dPhi, dZ), - layer_(layer) - { + StubKFin::StubKFin(const StubZHT& stub, double dPhi, double dZ, int layer) + : Stub(stub, stub.r(), stub.phi(), stub.z(), dPhi, dZ), layer_(layer) { dataFormats_->convertStub(p_, data_, frame_.second); } // construct StubKFin from TTStubRef - StubKFin::StubKFin(const TTStubRef& ttStubRef, const DataFormats* dataFormats, double r, double phi, double z, double dPhi, double dZ, int layer) : - Stub(ttStubRef, dataFormats, Process::kfin, r, phi, z, dPhi, dZ), - layer_(layer) - { + StubKFin::StubKFin(const TTStubRef& ttStubRef, + const DataFormats* dataFormats, + double r, + double phi, + double z, + double dPhi, + double dZ, + int layer) + : Stub(ttStubRef, dataFormats, Process::kfin, r, phi, z, dPhi, dZ), layer_(layer) { dataFormats_->convertStub(p_, data_, frame_.second); } // construct StubKF from Frame - StubKF::StubKF(const FrameStub& frame, const DataFormats* formats, int layer) : - Stub(frame, formats, Process::kf), layer_(layer) {} + StubKF::StubKF(const FrameStub& frame, const DataFormats* formats, int layer) + : Stub(frame, formats, Process::kf), layer_(layer) {} // construct StubKF from StubKFin - StubKF::StubKF(const StubKFin& stub, double inv2R, double phiT, double cot, double zT) : - Stub(stub, stub.r(), 0., 0., stub.dPhi(), stub.dZ()), - layer_(stub.layer()) - { + StubKF::StubKF(const StubKFin& stub, double inv2R, double phiT, double cot, double zT) + : Stub(stub, stub.r(), 0., 0., stub.dPhi(), stub.dZ()), layer_(stub.layer()) { const Setup* setup = dataFormats_->setup(); get<1>(data_) = format(Variable::phi).digi(stub.phi() - (phiT + this->r() * inv2R)); - const double d = (dataFormats_->hybrid() ? setup->hybridChosenRofPhi() : setup->chosenRofPhi()) - setup->chosenRofZ(); + const double d = + (dataFormats_->hybrid() ? setup->hybridChosenRofPhi() : setup->chosenRofPhi()) - setup->chosenRofZ(); const double rz = format(Variable::r).digi(this->r() + d); get<2>(data_) = format(Variable::z).digi(stub.z() - (zT + rz * cot)); dataFormats_->convertStub(p_, data_, frame_.second); } // construct Track from Frame - template - Track::Track(const FrameTrack& frame, const DataFormats* dataFormats, Process p) : - dataFormats_(dataFormats), - p_(p), - frame_(frame) - { + template + Track::Track(const FrameTrack& frame, const DataFormats* dataFormats, Process p) + : dataFormats_(dataFormats), p_(p), frame_(frame) { dataFormats_->convertTrack(p_, frame.second, data_); } // construct Track from other Track - template - template - Track::Track(const Track& track, Ts... data) : - dataFormats_(track.dataFormats()), - p_(++track.p()), - frame_(track.frame().first, Frame()), - data_(data...) {} + template + template + Track::Track(const Track& track, Ts... data) + : dataFormats_(track.dataFormats()), p_(++track.p()), frame_(track.frame().first, Frame()), data_(data...) {} // construct Track from Stub - template - template - Track::Track(const Stub& stub, const TTTrackRef& ttTrackRef, Ts... data) : - dataFormats_(stub.dataFormats()), - p_(++stub.p()), - frame_(ttTrackRef, Frame()), - data_(data...) {} + template + template + Track::Track(const Stub& stub, const TTTrackRef& ttTrackRef, Ts... data) + : dataFormats_(stub.dataFormats()), p_(++stub.p()), frame_(ttTrackRef, Frame()), data_(data...) {} // construct Track from TTTrackRef - template - Track::Track(const TTTrackRef& ttTrackRef, const DataFormats* dataFormats, Process p, Ts... data) : - dataFormats_(dataFormats), - p_(p), - frame_(ttTrackRef, Frame()), - data_(data...) {} + template + Track::Track(const TTTrackRef& ttTrackRef, const DataFormats* dataFormats, Process p, Ts... data) + : dataFormats_(dataFormats), p_(p), frame_(ttTrackRef, Frame()), data_(data...) {} // construct TrackKFin from Frame - TrackKFin::TrackKFin(const FrameTrack& frame, const DataFormats* dataFormats, const vector& stubs) : - Track(frame, dataFormats, Process::kfin), - stubs_(setup()->numLayers()), - hitPattern_(0, setup()->numLayers()) - { + TrackKFin::TrackKFin(const FrameTrack& frame, const DataFormats* dataFormats, const vector& stubs) + : Track(frame, dataFormats, Process::kfin), stubs_(setup()->numLayers()), hitPattern_(0, setup()->numLayers()) { vector nStubs(stubs_.size(), 0); for (StubKFin* stub : stubs) nStubs[stub->layer()]++; @@ -415,11 +423,10 @@ namespace trackerTFP { } // construct TrackKFin from StubZHT - TrackKFin::TrackKFin(const StubZHT& stub, const TTTrackRef& ttTrackRef, const TTBV& maybePattern) : - Track(stub, ttTrackRef, maybePattern, stub.sectorPhi(), stub.sectorEta(), 0., 0., 0., 0.), - stubs_(setup()->numLayers()), - hitPattern_(0, setup()->numLayers()) - { + TrackKFin::TrackKFin(const StubZHT& stub, const TTTrackRef& ttTrackRef, const TTBV& maybePattern) + : Track(stub, ttTrackRef, maybePattern, stub.sectorPhi(), stub.sectorEta(), 0., 0., 0., 0.), + stubs_(setup()->numLayers()), + hitPattern_(0, setup()->numLayers()) { get<3>(data_) = format(Variable::phiT, Process::mht).floating(stub.phiT()); get<4>(data_) = format(Variable::inv2R, Process::mht).floating(stub.inv2R()); get<5>(data_) = format(Variable::zT, Process::zht).floating(stub.zT()); @@ -428,11 +435,18 @@ namespace trackerTFP { } // construct TrackKFin from TTTrackRef - TrackKFin::TrackKFin(const TTTrackRef& ttTrackRef, const DataFormats* dataFormats, const TTBV& maybePattern, double phiT, double inv2R, double zT, double cot, int sectorPhi, int sectorEta) : - Track(ttTrackRef, dataFormats, Process::kfin, maybePattern, sectorPhi, sectorEta, phiT, inv2R, zT, cot), - stubs_(setup()->numLayers()), - hitPattern_(0, setup()->numLayers()) - { + TrackKFin::TrackKFin(const TTTrackRef& ttTrackRef, + const DataFormats* dataFormats, + const TTBV& maybePattern, + double phiT, + double inv2R, + double zT, + double cot, + int sectorPhi, + int sectorEta) + : Track(ttTrackRef, dataFormats, Process::kfin, maybePattern, sectorPhi, sectorEta, phiT, inv2R, zT, cot), + stubs_(setup()->numLayers()), + hitPattern_(0, setup()->numLayers()) { dataFormats_->convertTrack(p_, data_, frame_.second); } @@ -446,14 +460,14 @@ namespace trackerTFP { } // construct TrackKF from Frame - TrackKF::TrackKF(const FrameTrack& frame, const DataFormats* dataFormats) : - Track(frame, dataFormats, Process::kf) {} + TrackKF::TrackKF(const FrameTrack& frame, const DataFormats* dataFormats) : Track(frame, dataFormats, Process::kf) {} // construct TrackKF from TrackKfin - TrackKF::TrackKF(const TrackKFin& track, double phiT, double inv2R, double zT, double cot) : - Track(track, false, track.sectorPhi(), track.sectorEta(), track.phiT(), track.inv2R(), track.cot(), track.zT()) - { - get<0>(data_) = abs(inv2R) < dataFormats_->format(Variable::inv2R, Process::zht).base() / 2. && abs(phiT) < dataFormats_->format(Variable::phiT, Process::zht).base() / 2.; + TrackKF::TrackKF(const TrackKFin& track, double phiT, double inv2R, double zT, double cot) + : Track( + track, false, track.sectorPhi(), track.sectorEta(), track.phiT(), track.inv2R(), track.cot(), track.zT()) { + get<0>(data_) = abs(inv2R) < dataFormats_->format(Variable::inv2R, Process::zht).base() / 2. && + abs(phiT) < dataFormats_->format(Variable::phiT, Process::zht).base() / 2.; get<3>(data_) += phiT; get<4>(data_) += inv2R; get<5>(data_) += cot; @@ -464,7 +478,9 @@ namespace trackerTFP { // conversion to TTTrack with given stubs TTTrack TrackKF::ttTrack(const vector& stubs) const { const double invR = -this->inv2R() * 2.; - const double phi0 = deltaPhi(this->phiT() - this->inv2R() * dataFormats_->chosenRofPhi() + setup()->baseSector() * (this->sectorPhi() - .5) + setup()->baseRegion() * frame_.first->phiSector()); + const double phi0 = + deltaPhi(this->phiT() - this->inv2R() * dataFormats_->chosenRofPhi() + + setup()->baseSector() * (this->sectorPhi() - .5) + setup()->baseRegion() * frame_.first->phiSector()); const double cot = this->cot() + setup()->sectorCot(this->sectorEta()); const double z0 = this->zT() - this->cot() * setup()->chosenRofZ(); TTBV hitVector(0, setup()->numLayers()); @@ -487,25 +503,24 @@ namespace trackerTFP { static constexpr double trkMVA3 = 0.; const int hitPattern = hitVector.val(); const double bField = setup()->bField(); - TTTrack ttTrack(invR, phi0, cot, z0, d0, chi2phi, chi2z, trkMVA1, trkMVA2, trkMVA3, hitPattern, nPar, bField); + TTTrack ttTrack( + invR, phi0, cot, z0, d0, chi2phi, chi2z, trkMVA1, trkMVA2, trkMVA3, hitPattern, nPar, bField); ttTrack.setStubRefs(ttStubRefs); ttTrack.setPhiSector(frame_.first->phiSector()); ttTrack.setEtaSector(this->sectorEta()); ttTrack.setTrackSeedType(frame_.first->trackSeedType()); - ttTrack.setStubPtConsistency( - StubPtConsistency::getConsistency(ttTrack, setup()->trackerGeometry(), setup()->trackerTopology(), bField, nPar)); + ttTrack.setStubPtConsistency(StubPtConsistency::getConsistency( + ttTrack, setup()->trackerGeometry(), setup()->trackerTopology(), bField, nPar)); return ttTrack; } // construct TrackDR from Frame - TrackDR::TrackDR(const FrameTrack& frame, const DataFormats* dataFormats) : - Track(frame, dataFormats, Process::dr) {} + TrackDR::TrackDR(const FrameTrack& frame, const DataFormats* dataFormats) : Track(frame, dataFormats, Process::dr) {} // construct TrackDR from TrackKF - TrackDR::TrackDR(const TrackKF& track) : - Track(track, 0., 0., 0., 0.) - { - get<0>(data_) = track.phiT() + track.inv2R() * dataFormats_->chosenRofPhi() + dataFormats_->format(Variable::phi, Process::gp).range() * (track.sectorPhi() - .5); + TrackDR::TrackDR(const TrackKF& track) : Track(track, 0., 0., 0., 0.) { + get<0>(data_) = track.phiT() + track.inv2R() * dataFormats_->chosenRofPhi() + + dataFormats_->format(Variable::phi, Process::gp).range() * (track.sectorPhi() - .5); get<1>(data_) = track.inv2R(); get<2>(data_) = track.zT() - track.cot() * setup()->chosenRofZ(); get<3>(data_) = track.cot() + setup()->sectorCot(track.sectorEta()); @@ -529,20 +544,21 @@ namespace trackerTFP { static constexpr double bField = 0.; const int sectorPhi = frame_.first->phiSector(); const int sectorEta = frame_.first->etaSector(); - TTTrack ttTrack(inv2R, phi0, cot, z0, d0, chi2phi, chi2z, trkMVA1, trkMVA2, trkMVA3, hitPattern, nPar, bField); + TTTrack ttTrack( + inv2R, phi0, cot, z0, d0, chi2phi, chi2z, trkMVA1, trkMVA2, trkMVA3, hitPattern, nPar, bField); ttTrack.setPhiSector(sectorPhi); ttTrack.setEtaSector(sectorEta); return ttTrack; } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { range_ = 2. * M_PI / (double)(setup->numRegions() * setup->numSectorsPhi()); base_ = range_ / (double)setup->htNumBinsPhiT(); width_ = ceil(log2(setup->htNumBinsPhiT())); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const Format ht(iConfig, setup); range_ = ht.range(); @@ -550,7 +566,7 @@ namespace trackerTFP { width_ = ceil(log2(setup->htNumBinsPhiT() * setup->mhtNumBinsPhiT())); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const double mintPt = iConfig.getParameter("UseHybrid") ? setup->hybridMinPtCand() : setup->minPt(); range_ = 2. * setup->invPtToDphi() / mintPt; @@ -558,7 +574,7 @@ namespace trackerTFP { width_ = ceil(log2(setup->htNumBinsInv2R())); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const Format ht(iConfig, setup); range_ = ht.range(); @@ -566,9 +582,10 @@ namespace trackerTFP { width_ = ceil(log2(setup->htNumBinsInv2R() * setup->mhtNumBinsInv2R())); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { - const double chosenRofPhi = iConfig.getParameter("UseHybrid") ? setup->hybridChosenRofPhi() : setup->chosenRofPhi(); + const double chosenRofPhi = + iConfig.getParameter("UseHybrid") ? setup->hybridChosenRofPhi() : setup->chosenRofPhi(); width_ = setup->tmttWidthR(); range_ = 2. * max(abs(setup->outerRadius() - chosenRofPhi), abs(setup->innerRadius() - chosenRofPhi)); const Format phiT(iConfig, setup); @@ -578,7 +595,7 @@ namespace trackerTFP { base_ *= pow(2., shift); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const Format phiT(iConfig, setup); const Format inv2R(iConfig, setup); @@ -589,7 +606,7 @@ namespace trackerTFP { width_ = ceil(log2(range_ / base_)); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { width_ = setup->tmttWidthPhi(); const Format phiT(iConfig, setup); @@ -600,7 +617,7 @@ namespace trackerTFP { base_ = phiT.base() * pow(2., shift); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const Format phiT(iConfig, setup); range_ = 2. * phiT.base(); @@ -609,7 +626,7 @@ namespace trackerTFP { width_ = ceil(log2(range_ / base_)); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const Format phiT(iConfig, setup); range_ = 2. * phiT.base(); @@ -618,7 +635,7 @@ namespace trackerTFP { width_ = ceil(log2(range_ / base_)); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const Format phi(iConfig, setup); const double rangeFactor = iConfig.getParameter("KalmanFilter").getParameter("RangeFactor"); @@ -627,7 +644,7 @@ namespace trackerTFP { width_ = ceil(log2(range_ / base_)); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { width_ = setup->tmttWidthZ(); range_ = 2. * setup->halfLength(); @@ -636,7 +653,7 @@ namespace trackerTFP { base_ = r.base() * pow(2., shift); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { range_ = setup->neededRangeChiZ(); const Format dtc(iConfig, setup); @@ -644,7 +661,7 @@ namespace trackerTFP { width_ = ceil(log2(range_ / base_)); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const int numBinsZT = iConfig.getParameter("ZHoughTransform").getParameter("NumBinsZT"); const int numStages = iConfig.getParameter("ZHoughTransform").getParameter("NumStages"); @@ -658,7 +675,7 @@ namespace trackerTFP { base_ = z.base() * pow(2., shift); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const int numBinsCot = iConfig.getParameter("ZHoughTransform").getParameter("NumBinsCot"); const int numStages = iConfig.getParameter("ZHoughTransform").getParameter("NumStages"); @@ -669,7 +686,7 @@ namespace trackerTFP { base_ = pow(2., shift); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { /*const Format zT(iConfig, setup); const Format cot(iConfig, setup); @@ -686,11 +703,12 @@ namespace trackerTFP { base_ = z.base(); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const Format phiT(iConfig, setup); const Format inv2R(iConfig, setup); - const double chosenRofPhi = iConfig.getParameter("UseHybrid") ? setup->hybridChosenRofPhi() : setup->chosenRofPhi(); + const double chosenRofPhi = + iConfig.getParameter("UseHybrid") ? setup->hybridChosenRofPhi() : setup->chosenRofPhi(); const double rangeR = 2. * max(abs(setup->outerRadius() - chosenRofPhi), abs(setup->innerRadius() - chosenRofPhi)); range_ = phiT.base() + inv2R.base() * rangeR + setup->maxdPhi(); const Format dtc(iConfig, setup); @@ -698,7 +716,7 @@ namespace trackerTFP { width_ = ceil(log2(range_ / base_)); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { /*const Format z(iConfig, setup); const double rangeFactor = iConfig.getParameter("KalmanFilter").getParameter("RangeFactor"); @@ -707,7 +725,8 @@ namespace trackerTFP { width_ = ceil(log2(range_ / base_));*/ const Format zT(iConfig, setup); const Format cot(iConfig, setup); - const double rangeR = 2. * max(abs(setup->outerRadius() - setup->chosenRofZ()), abs(setup->innerRadius() - setup->chosenRofZ())); + const double rangeR = + 2. * max(abs(setup->outerRadius() - setup->chosenRofZ()), abs(setup->innerRadius() - setup->chosenRofZ())); range_ = zT.base() + cot.base() * rangeR + setup->maxdZ(); const Format dtc(iConfig, setup); base_ = dtc.base(); @@ -716,46 +735,52 @@ namespace trackerTFP { width_ = ceil(log2(range_ / base_)); } - template<> + template <> Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(false) { range_ = setup->numLayers(); width_ = ceil(log2(range_)); } - template<> - Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(false) { + template <> + Format::Format(const ParameterSet& iConfig, const Setup* setup) + : DataFormat(false) { range_ = setup->numSectorsEta(); width_ = ceil(log2(range_)); } - template<> - Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(false) { + template <> + Format::Format(const ParameterSet& iConfig, const Setup* setup) + : DataFormat(false) { range_ = setup->numSectorsPhi(); width_ = ceil(log2(range_)); } - template<> - Format::Format(const ParameterSet& iConfig, const Setup* setup) : DataFormat(false) { + template <> + Format::Format(const ParameterSet& iConfig, const Setup* setup) + : DataFormat(false) { range_ = setup->numSectorsPhi(); width_ = setup->numSectorsPhi(); } - template<> - Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) : DataFormat(false) { + template <> + Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) + : DataFormat(false) { width_ = 1; range_ = 1.; } - template<> - Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) : DataFormat(false) { + template <> + Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) + : DataFormat(false) { width_ = setup->numLayers(); } - template<> + template <> Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const Format inv2R(iConfig, setup); const Format phiT(iConfig, setup); - const double chosenRofPhi = iConfig.getParameter("UseHybrid") ? setup->hybridChosenRofPhi() : setup->chosenRofPhi(); + const double chosenRofPhi = + iConfig.getParameter("UseHybrid") ? setup->hybridChosenRofPhi() : setup->chosenRofPhi(); width_ = setup->tfpWidthPhi0(); range_ = 2. * M_PI / (double)setup->numRegions() + inv2R.range() * chosenRofPhi; base_ = phiT.base(); @@ -763,8 +788,9 @@ namespace trackerTFP { base_ *= pow(2., shift); } - template<> - Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { + template <> + Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) + : DataFormat(true) { const Format inv2R(iConfig, setup); width_ = setup->tfpWidthInv2R(); range_ = inv2R.range(); @@ -773,7 +799,7 @@ namespace trackerTFP { base_ *= pow(2., shift); } - template<> + template <> Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const Format zT(iConfig, setup); width_ = setup->tfpWidthZ0(); @@ -783,7 +809,7 @@ namespace trackerTFP { base_ *= pow(2., shift); } - template<> + template <> Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const Format cot(iConfig, setup); width_ = setup->tfpWidthCot(); @@ -793,7 +819,7 @@ namespace trackerTFP { base_ *= pow(2., shift); } - template<> + template <> Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const Format phi0(iConfig, setup); const Format phiT(iConfig, setup); @@ -803,8 +829,9 @@ namespace trackerTFP { width_ = ceil(log2(range_ / base_)); } - template<> - Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { + template <> + Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) + : DataFormat(true) { const Format dr(iConfig, setup); const Format mht(iConfig, setup); const double rangeFactor = iConfig.getParameter("KalmanFilter").getParameter("RangeFactor"); @@ -813,7 +840,7 @@ namespace trackerTFP { width_ = ceil(log2(range_ / base_)); } - template<> + template <> Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const Format z0(iConfig, setup); const Format zT(iConfig, setup); @@ -823,7 +850,7 @@ namespace trackerTFP { width_ = ceil(log2(range_ / base_)); } - template<> + template <> Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) : DataFormat(true) { const Format dr(iConfig, setup); const Format zht(iConfig, setup); @@ -833,20 +860,22 @@ namespace trackerTFP { width_ = ceil(log2(range_ / base_)); } - template<> - Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) : DataFormat(false) { + template <> + Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) + : DataFormat(false) { const Format phi(iConfig, setup); range_ = setup->maxdPhi(); base_ = phi.base(); width_ = ceil(log2(range_ / base_)); } - template<> - Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) : DataFormat(false) { + template <> + Format::Format(const edm::ParameterSet& iConfig, const Setup* setup) + : DataFormat(false) { const Format z(iConfig, setup); range_ = setup->maxdZ(); base_ = z.base(); width_ = ceil(log2(range_ / base_)); } -} // namespace trackerTFP \ No newline at end of file +} // namespace trackerTFP \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/src/Demonstrator.cc b/L1Trigger/TrackerTFP/src/Demonstrator.cc index 1deb94e85696d..8ebbe1c2c93f4 100644 --- a/L1Trigger/TrackerTFP/src/Demonstrator.cc +++ b/L1Trigger/TrackerTFP/src/Demonstrator.cc @@ -11,16 +11,16 @@ using namespace tt; namespace trackerTFP { - Demonstrator::Demonstrator(const ParameterSet& iConfig, const Setup* setup) : - dirIPBB_(iConfig.getParameter("DirIPBB")), - runTime_(iConfig.getParameter("RunTime")), - dirIn_(dirIPBB_ + "in.txt"), - dirOut_(dirIPBB_ + "out.txt"), - dirPre_(dirIPBB_ + "pre.txt"), - dirDiff_(dirIPBB_ + "diff.txt"), - numFrames_(setup->numFramesIO()), - numFramesInfra_(setup->numFramesInfra()), - numRegions_(setup->numRegions()) {} + Demonstrator::Demonstrator(const ParameterSet& iConfig, const Setup* setup) + : dirIPBB_(iConfig.getParameter("DirIPBB")), + runTime_(iConfig.getParameter("RunTime")), + dirIn_(dirIPBB_ + "in.txt"), + dirOut_(dirIPBB_ + "out.txt"), + dirPre_(dirIPBB_ + "pre.txt"), + dirDiff_(dirIPBB_ + "diff.txt"), + numFrames_(setup->numFramesIO()), + numFramesInfra_(setup->numFramesInfra()), + numRegions_(setup->numRegions()) {} // plays input through modelsim and compares result with output void Demonstrator::analyze(const vector>& input, const vector>& output) const { @@ -101,7 +101,6 @@ namespace trackerTFP { exception << "Bit error detected."; throw exception; } - } // creates emp file header @@ -127,7 +126,7 @@ namespace trackerTFP { for (int gap = 0; gap < numFramesInfra_; gap++) { ss << frame(nFrame); for (int link = 0; link < numLinks; link++) - ss << " 0v" << string(TTBV::S_ / 4, '0' ); + ss << " 0v" << string(TTBV::S_ / 4, '0'); ss << endl; } return ss.str(); @@ -147,4 +146,4 @@ namespace trackerTFP { return ss.str(); } -} // namespace trackerTFP \ No newline at end of file +} // namespace trackerTFP \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/src/DistServer.cc b/L1Trigger/TrackerTFP/src/DistServer.cc index a1387ffee23a3..9bb81d337e278 100644 --- a/L1Trigger/TrackerTFP/src/DistServer.cc +++ b/L1Trigger/TrackerTFP/src/DistServer.cc @@ -1,66 +1,61 @@ #include "L1Trigger/TrackerTFP/interface/DistServer.h" #include "L1Trigger/TrackerTFP/interface/DataFormats.h" - #include -#include +#include using namespace std; using namespace trackerTFP; -DistServer::DistServer( unsigned int nInputs, unsigned int nOutputs, unsigned int nInterleaving ) : - nInputs_(nInputs), - nOutputs_(nOutputs), - nInterleaving_(nInterleaving), - inputs_(nInputs_) { - for ( unsigned int iInput=0; iInputnInputs(); ++iInput ) { - addr_.emplace_back(this->nInterleaving(),0); - for ( unsigned int iInterleave=0; iInterleavenInterleaving(); ++iInterleave ) { - addr_[iInput][iInterleave] = iInterleave; - } - } +DistServer::DistServer(unsigned int nInputs, unsigned int nOutputs, unsigned int nInterleaving) + : nInputs_(nInputs), nOutputs_(nOutputs), nInterleaving_(nInterleaving), inputs_(nInputs_) { + for (unsigned int iInput = 0; iInput < this->nInputs(); ++iInput) { + addr_.emplace_back(this->nInterleaving(), 0); + for (unsigned int iInterleave = 0; iInterleave < this->nInterleaving(); ++iInterleave) { + addr_[iInput][iInterleave] = iInterleave; } + } +} TrackKFOutSAPtrCollection DistServer::clock(TrackKFOutSAPtrCollection& data) { - for ( unsigned int iInput=0; iInputdataValid() ) { - inputs()[iInput].push_back( data[iInput] ); - } + for (unsigned int iInput = 0; iInput < nInputs(); ++iInput) { + if (data[iInput]->dataValid()) { + inputs()[iInput].push_back(data[iInput]); } - - vector< vector< bool > > lMap(nInputs(), vector(nOutputs()) ); - - TrackKFOutSAPtrCollection lInputs(nInputs(),std::make_shared()); + } - std::vector< std::vector< unsigned int> >& addr = this->addr(); + vector > lMap(nInputs(), vector(nOutputs())); - for ( unsigned int iInput = 0; iInputsortKey() ] = true; - } - } - - for ( unsigned int iInput = 0; iInput& toRotate = addr[iInput]; - rotate(toRotate.begin(), toRotate.begin()+1, toRotate.end() ); - } + TrackKFOutSAPtrCollection lInputs(nInputs(), std::make_shared()); - TrackKFOutSAPtrCollection lOutputs(nOutputs(),std::make_shared()); + std::vector >& addr = this->addr(); - unsigned int nOutputs = 0; - for ( unsigned int iOutput = 0; iOutputnInterleaving(); - nOutputs++; - break; - } - } + for (unsigned int iInput = 0; iInput < nInputs(); ++iInput) { + unsigned int lAddr = addr[iInput][0]; + if (lAddr < inputs()[iInput].size()) { + lInputs[iInput] = inputs()[iInput][lAddr]; + lMap[iInput][lInputs[iInput]->sortKey()] = true; } + } + + for (unsigned int iInput = 0; iInput < nInputs(); ++iInput) { + vector& toRotate = addr[iInput]; + rotate(toRotate.begin(), toRotate.begin() + 1, toRotate.end()); + } + + TrackKFOutSAPtrCollection lOutputs(nOutputs(), std::make_shared()); + + unsigned int nOutputs = 0; + for (unsigned int iOutput = 0; iOutput < lOutputs.size(); ++iOutput) { + for (unsigned int iInput = 0; iInput < nInputs(); ++iInput) { + if (lMap[iInput][iOutput]) { + lOutputs[iOutput] = lInputs[iInput]; + addr[iInput].back() += this->nInterleaving(); + nOutputs++; + break; + } + } + } - - return lOutputs; + return lOutputs; } \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/src/GeometricProcessor.cc b/L1Trigger/TrackerTFP/src/GeometricProcessor.cc index 9f066b51205c0..f745ac9d3fa0e 100644 --- a/L1Trigger/TrackerTFP/src/GeometricProcessor.cc +++ b/L1Trigger/TrackerTFP/src/GeometricProcessor.cc @@ -12,16 +12,19 @@ using namespace tt; namespace trackerTFP { - GeometricProcessor::GeometricProcessor(const ParameterSet& iConfig, const Setup* setup, const DataFormats* dataFormats, int region) : - enableTruncation_(iConfig.getParameter("EnableTruncation")), - setup_(setup), - dataFormats_(dataFormats), - region_(region), - input_(dataFormats_->numChannel(Process::gp), vector>(dataFormats_->numChannel(Process::pp))) {} + GeometricProcessor::GeometricProcessor(const ParameterSet& iConfig, + const Setup* setup, + const DataFormats* dataFormats, + int region) + : enableTruncation_(iConfig.getParameter("EnableTruncation")), + setup_(setup), + dataFormats_(dataFormats), + region_(region), + input_(dataFormats_->numChannel(Process::gp), vector>(dataFormats_->numChannel(Process::pp))) {} // read in and organize input product (fill vector input_) void GeometricProcessor::consume(const TTDTC& ttDTC) { - auto validFrame = [](int& sum, const FrameStub& frame){ return sum += frame.first.isNonnull() ? 1 : 0; }; + auto validFrame = [](int& sum, const FrameStub& frame) { return sum += frame.first.isNonnull() ? 1 : 0; }; int nStubsPP(0); for (int channel = 0; channel < dataFormats_->numChannel(Process::pp); channel++) { const StreamStub& stream = ttDTC.stream(region_, channel); @@ -41,11 +44,11 @@ namespace trackerTFP { } } // remove all gaps between end and last stub - for(vector>& input : input_) - for(deque& stubs : input) - for(auto it = stubs.end(); it != stubs.begin();) + for (vector>& input : input_) + for (deque& stubs : input) + for (auto it = stubs.end(); it != stubs.begin();) it = (*--it) ? stubs.begin() : stubs.erase(it); - auto validStub = [](int& sum, StubPP* stub){ return sum += stub ? 1 : 0; }; + auto validStub = [](int& sum, StubPP* stub) { return sum += stub ? 1 : 0; }; int nStubsGP(0); for (const vector>& sector : input_) for (const deque& channel : sector) @@ -60,15 +63,15 @@ namespace trackerTFP { vector> stacks(dataFormats_->numChannel(Process::pp)); const int sectorPhi = sector % setup_->numSectorsPhi(); const int sectorEta = sector / setup_->numSectorsPhi(); - auto size = [](int& sum, const deque& stubs){ return sum += stubs.size(); }; + auto size = [](int& sum, const deque& stubs) { return sum += stubs.size(); }; const int nStubs = accumulate(inputs.begin(), inputs.end(), 0, size); vector acceptedSector; vector lostSector; acceptedSector.reserve(nStubs); lostSector.reserve(nStubs); // clock accurate firmware emulation, each while trip describes one clock tick, one stub in and one stub out per tick - while(!all_of(inputs.begin(), inputs.end(), [](const deque& stubs){ return stubs.empty(); }) or - !all_of(stacks.begin(), stacks.end(), [](const deque& stubs){ return stubs.empty(); })) { + while (!all_of(inputs.begin(), inputs.end(), [](const deque& stubs) { return stubs.empty(); }) or + !all_of(stacks.begin(), stacks.end(), [](const deque& stubs) { return stubs.empty(); })) { // fill input fifos for (int channel = 0; channel < dataFormats_->numChannel(Process::pp); channel++) { deque& stack = stacks[channel]; @@ -96,15 +99,15 @@ namespace trackerTFP { // truncate if desired if (enableTruncation_ && (int)acceptedSector.size() > setup_->numFrames()) { const auto limit = next(acceptedSector.begin(), setup_->numFrames()); - copy_if(limit, acceptedSector.end(), back_inserter(lostSector), [](const StubGP* stub){ return stub; }); + copy_if(limit, acceptedSector.end(), back_inserter(lostSector), [](const StubGP* stub) { return stub; }); acceptedSector.erase(limit, acceptedSector.end()); } // remove all gaps between end and last stub - for(auto it = acceptedSector.end(); it != acceptedSector.begin();) + for (auto it = acceptedSector.end(); it != acceptedSector.begin();) it = (*--it) ? acceptedSector.begin() : acceptedSector.erase(it); // fill products auto put = [](const vector& stubs, StreamStub& stream) { - auto toFrame = [](StubGP* stub){ return stub ? stub->frame() : FrameStub(); }; + auto toFrame = [](StubGP* stub) { return stub ? stub->frame() : FrameStub(); }; stream.reserve(stubs.size()); transform(stubs.begin(), stubs.end(), back_inserter(stream), toFrame); }; @@ -115,7 +118,7 @@ namespace trackerTFP { } // remove and return first element of deque, returns nullptr if empty - template + template T* GeometricProcessor::pop_front(deque& ts) const { T* t = nullptr; if (!ts.empty()) { @@ -125,4 +128,4 @@ namespace trackerTFP { return t; } -} \ No newline at end of file +} // namespace trackerTFP \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/src/HoughTransform.cc b/L1Trigger/TrackerTFP/src/HoughTransform.cc index 6dba096a54593..dfaecf8ff7c65 100644 --- a/L1Trigger/TrackerTFP/src/HoughTransform.cc +++ b/L1Trigger/TrackerTFP/src/HoughTransform.cc @@ -15,20 +15,22 @@ using namespace tt; namespace trackerTFP { - HoughTransform::HoughTransform(const ParameterSet& iConfig, const Setup* setup, const DataFormats* dataFormats, int region) : - enableTruncation_(iConfig.getParameter("EnableTruncation")), - setup_(setup), - dataFormats_(dataFormats), - inv2R_(dataFormats_->format(Variable::inv2R, Process::ht)), - phiT_(dataFormats_->format(Variable::phiT, Process::ht)), - region_(region), - input_(dataFormats_->numChannel(Process::ht), vector>(dataFormats_->numChannel(Process::gp))) - {} + HoughTransform::HoughTransform(const ParameterSet& iConfig, + const Setup* setup, + const DataFormats* dataFormats, + int region) + : enableTruncation_(iConfig.getParameter("EnableTruncation")), + setup_(setup), + dataFormats_(dataFormats), + inv2R_(dataFormats_->format(Variable::inv2R, Process::ht)), + phiT_(dataFormats_->format(Variable::phiT, Process::ht)), + region_(region), + input_(dataFormats_->numChannel(Process::ht), vector>(dataFormats_->numChannel(Process::gp))) {} // read in and organize input product (fill vector input_) void HoughTransform::consume(const StreamsStub& streams) { const int offset = region_ * dataFormats_->numChannel(Process::gp); - auto validFrame = [](int& sum, const FrameStub& frame){ return sum += frame.first.isNonnull() ? 1 : 0; }; + auto validFrame = [](int& sum, const FrameStub& frame) { return sum += frame.first.isNonnull() ? 1 : 0; }; int nStubsGP(0); for (int sector = 0; sector < dataFormats_->numChannel(Process::gp); sector++) { const StreamStub& stream = streams[offset + sector]; @@ -50,11 +52,11 @@ namespace trackerTFP { } } // remove all gaps between end and last stub - for(vector>& input : input_) - for(deque& stubs : input) - for(auto it = stubs.end(); it != stubs.begin();) + for (vector>& input : input_) + for (deque& stubs : input) + for (auto it = stubs.end(); it != stubs.begin();) it = (*--it) ? stubs.begin() : stubs.erase(it); - auto validStub = [](int& sum, StubGP* stub){ return sum += stub ? 1 : 0; }; + auto validStub = [](int& sum, StubGP* stub) { return sum += stub ? 1 : 0; }; int nStubsHT(0); for (const vector>& binInv2R : input_) for (const deque& sector : binInv2R) @@ -82,11 +84,13 @@ namespace trackerTFP { readOut(acceptedSector, lostSector, acceptedAll, lostAll); } // truncate accepted stream - const auto limit = enableTruncation_ ? next(acceptedAll.begin(), min(setup_->numFrames(), (int)acceptedAll.size())) : acceptedAll.end(); - copy_if(limit, acceptedAll.end(), back_inserter(lostAll), [](StubHT* stub){ return stub; }); + const auto limit = enableTruncation_ + ? next(acceptedAll.begin(), min(setup_->numFrames(), (int)acceptedAll.size())) + : acceptedAll.end(); + copy_if(limit, acceptedAll.end(), back_inserter(lostAll), [](StubHT* stub) { return stub; }); acceptedAll.erase(limit, acceptedAll.end()); // store found tracks - auto put = [](const deque& stubs, StreamStub& stream){ + auto put = [](const deque& stubs, StreamStub& stream) { stream.reserve(stubs.size()); for (StubHT* stub : stubs) stream.emplace_back(stub ? stub->frame() : FrameStub()); @@ -99,7 +103,10 @@ namespace trackerTFP { } // associate stubs with phiT bins in this inv2R column - void HoughTransform::fillIn(int inv2R, deque& inputSector, vector& acceptedSector, vector& lostSector) { + void HoughTransform::fillIn(int inv2R, + deque& inputSector, + vector& acceptedSector, + vector& lostSector) { // fifo, used to store stubs which belongs to a second possible track deque stack; // clock accurate firmware emulation, each while trip describes one clock tick, one stub in and one stub out per tick @@ -134,13 +141,18 @@ namespace trackerTFP { acceptedSector.push_back(stubHT ? stubHT : pop_front(stack)); } // truncate to many input stubs - const auto limit = enableTruncation_ ? next(acceptedSector.begin(), min(setup_->numFrames(), (int)acceptedSector.size())) : acceptedSector.end(); - copy_if(limit, acceptedSector.end(), back_inserter(lostSector), [](StubHT* stub){ return stub; }); + const auto limit = enableTruncation_ + ? next(acceptedSector.begin(), min(setup_->numFrames(), (int)acceptedSector.size())) + : acceptedSector.end(); + copy_if(limit, acceptedSector.end(), back_inserter(lostSector), [](StubHT* stub) { return stub; }); acceptedSector.erase(limit, acceptedSector.end()); } // identify tracks - void HoughTransform::readOut(const vector& acceptedSector, const vector& lostSector, deque& acceptedAll, deque& lostAll) const { + void HoughTransform::readOut(const vector& acceptedSector, + const vector& lostSector, + deque& acceptedAll, + deque& lostAll) const { // used to recognise in which order tracks are found TTBV trkFoundPhiTs(0, setup_->htNumBinsPhiT()); // hitPattern for all possible tracks, used to find tracks @@ -151,7 +163,7 @@ namespace trackerTFP { vector> tracks(setup_->htNumBinsPhiT()); for (int binPhiT = 0; binPhiT < setup_->htNumBinsPhiT(); binPhiT++) { const int phiT = phiT_.toSigned(binPhiT); - auto samePhiT = [phiT](int& sum, StubHT* stub){ return sum += stub->phiT() == phiT; }; + auto samePhiT = [phiT](int& sum, StubHT* stub) { return sum += stub->phiT() == phiT; }; const int numAccepted = accumulate(acceptedSector.begin(), acceptedSector.end(), 0, samePhiT); const int numLost = accumulate(lostSector.begin(), lostSector.end(), 0, samePhiT); tracks[binPhiT].reserve(numAccepted + numLost); @@ -181,7 +193,7 @@ namespace trackerTFP { for (int binPhiT : trkFoundPhiTs.ids(false)) { const vector& track = tracks[binPhiT]; set layers; - auto toLayer = [](StubHT* stub){ return stub->layer(); }; + auto toLayer = [](StubHT* stub) { return stub->layer(); }; transform(track.begin(), track.end(), inserter(layers, layers.begin()), toLayer); if ((int)layers.size() >= setup_->htMinLayers()) lostAll.insert(lostAll.end(), track.begin(), track.end()); @@ -189,7 +201,7 @@ namespace trackerTFP { } // remove and return first element of deque, returns nullptr if empty - template + template T* HoughTransform::pop_front(deque& ts) const { T* t = nullptr; if (!ts.empty()) { @@ -199,4 +211,4 @@ namespace trackerTFP { return t; } -} // namespace trackerTFP \ No newline at end of file +} // namespace trackerTFP \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/src/KalmanFilter.cc b/L1Trigger/TrackerTFP/src/KalmanFilter.cc index e02291fb1feda..bc162d338c5ba 100644 --- a/L1Trigger/TrackerTFP/src/KalmanFilter.cc +++ b/L1Trigger/TrackerTFP/src/KalmanFilter.cc @@ -15,55 +15,59 @@ using namespace tt; namespace trackerTFP { - KalmanFilter::KalmanFilter(const ParameterSet& iConfig, const Setup* setup, const DataFormats* dataFormats, KalmanFilterFormats* kalmanFilterFormats, int region) : - enableTruncation_(iConfig.getParameter("EnableTruncation")), - setup_(setup), - dataFormats_(dataFormats), - kalmanFilterFormats_(kalmanFilterFormats), - region_(region), - input_(dataFormats_->numChannel(Process::kf)), - layer_(0), - x0_(&kalmanFilterFormats_->format(VariableKF::x0)), - x1_(&kalmanFilterFormats_->format(VariableKF::x1)), - x2_(&kalmanFilterFormats_->format(VariableKF::x2)), - x3_(&kalmanFilterFormats_->format(VariableKF::x3)), - H00_(&kalmanFilterFormats_->format(VariableKF::H00)), - H12_(&kalmanFilterFormats_->format(VariableKF::H12)), - m0_(&kalmanFilterFormats_->format(VariableKF::m0)), - m1_(&kalmanFilterFormats_->format(VariableKF::m1)), - v0_(&kalmanFilterFormats_->format(VariableKF::v0)), - v1_(&kalmanFilterFormats_->format(VariableKF::v1)), - r0_(&kalmanFilterFormats_->format(VariableKF::r0)), - r1_(&kalmanFilterFormats_->format(VariableKF::r1)), - S00_(&kalmanFilterFormats_->format(VariableKF::S00)), - S01_(&kalmanFilterFormats_->format(VariableKF::S01)), - S12_(&kalmanFilterFormats_->format(VariableKF::S12)), - S13_(&kalmanFilterFormats_->format(VariableKF::S13)), - K00_(&kalmanFilterFormats_->format(VariableKF::K00)), - K10_(&kalmanFilterFormats_->format(VariableKF::K10)), - K21_(&kalmanFilterFormats_->format(VariableKF::K21)), - K31_(&kalmanFilterFormats_->format(VariableKF::K31)), - R00_(&kalmanFilterFormats_->format(VariableKF::R00)), - R11_(&kalmanFilterFormats_->format(VariableKF::R11)), - R00Rough_(&kalmanFilterFormats_->format(VariableKF::R00Rough)), - R11Rough_(&kalmanFilterFormats_->format(VariableKF::R11Rough)), - invR00Approx_(&kalmanFilterFormats_->format(VariableKF::invR00Approx)), - invR11Approx_(&kalmanFilterFormats_->format(VariableKF::invR11Approx)), - invR00Cor_(&kalmanFilterFormats_->format(VariableKF::invR00Cor)), - invR11Cor_(&kalmanFilterFormats_->format(VariableKF::invR11Cor)), - invR00_(&kalmanFilterFormats_->format(VariableKF::invR00)), - invR11_(&kalmanFilterFormats_->format(VariableKF::invR11)), - C00_(&kalmanFilterFormats_->format(VariableKF::C00)), - C01_(&kalmanFilterFormats_->format(VariableKF::C01)), - C11_(&kalmanFilterFormats_->format(VariableKF::C11)), - C22_(&kalmanFilterFormats_->format(VariableKF::C22)), - C23_(&kalmanFilterFormats_->format(VariableKF::C23)), - C33_(&kalmanFilterFormats_->format(VariableKF::C33)) {} + KalmanFilter::KalmanFilter(const ParameterSet& iConfig, + const Setup* setup, + const DataFormats* dataFormats, + KalmanFilterFormats* kalmanFilterFormats, + int region) + : enableTruncation_(iConfig.getParameter("EnableTruncation")), + setup_(setup), + dataFormats_(dataFormats), + kalmanFilterFormats_(kalmanFilterFormats), + region_(region), + input_(dataFormats_->numChannel(Process::kf)), + layer_(0), + x0_(&kalmanFilterFormats_->format(VariableKF::x0)), + x1_(&kalmanFilterFormats_->format(VariableKF::x1)), + x2_(&kalmanFilterFormats_->format(VariableKF::x2)), + x3_(&kalmanFilterFormats_->format(VariableKF::x3)), + H00_(&kalmanFilterFormats_->format(VariableKF::H00)), + H12_(&kalmanFilterFormats_->format(VariableKF::H12)), + m0_(&kalmanFilterFormats_->format(VariableKF::m0)), + m1_(&kalmanFilterFormats_->format(VariableKF::m1)), + v0_(&kalmanFilterFormats_->format(VariableKF::v0)), + v1_(&kalmanFilterFormats_->format(VariableKF::v1)), + r0_(&kalmanFilterFormats_->format(VariableKF::r0)), + r1_(&kalmanFilterFormats_->format(VariableKF::r1)), + S00_(&kalmanFilterFormats_->format(VariableKF::S00)), + S01_(&kalmanFilterFormats_->format(VariableKF::S01)), + S12_(&kalmanFilterFormats_->format(VariableKF::S12)), + S13_(&kalmanFilterFormats_->format(VariableKF::S13)), + K00_(&kalmanFilterFormats_->format(VariableKF::K00)), + K10_(&kalmanFilterFormats_->format(VariableKF::K10)), + K21_(&kalmanFilterFormats_->format(VariableKF::K21)), + K31_(&kalmanFilterFormats_->format(VariableKF::K31)), + R00_(&kalmanFilterFormats_->format(VariableKF::R00)), + R11_(&kalmanFilterFormats_->format(VariableKF::R11)), + R00Rough_(&kalmanFilterFormats_->format(VariableKF::R00Rough)), + R11Rough_(&kalmanFilterFormats_->format(VariableKF::R11Rough)), + invR00Approx_(&kalmanFilterFormats_->format(VariableKF::invR00Approx)), + invR11Approx_(&kalmanFilterFormats_->format(VariableKF::invR11Approx)), + invR00Cor_(&kalmanFilterFormats_->format(VariableKF::invR00Cor)), + invR11Cor_(&kalmanFilterFormats_->format(VariableKF::invR11Cor)), + invR00_(&kalmanFilterFormats_->format(VariableKF::invR00)), + invR11_(&kalmanFilterFormats_->format(VariableKF::invR11)), + C00_(&kalmanFilterFormats_->format(VariableKF::C00)), + C01_(&kalmanFilterFormats_->format(VariableKF::C01)), + C11_(&kalmanFilterFormats_->format(VariableKF::C11)), + C22_(&kalmanFilterFormats_->format(VariableKF::C22)), + C23_(&kalmanFilterFormats_->format(VariableKF::C23)), + C33_(&kalmanFilterFormats_->format(VariableKF::C33)) {} // read in and organize input product (fill vector input_) void KalmanFilter::consume(const StreamsTrack& streamsTrack, const StreamsStub& streamsStub) { - auto valid = [](const auto& frame){ return frame.first.isNonnull(); }; - auto acc = [](int& sum, const auto& frame){ return sum += (frame.first.isNonnull() ? 1 : 0); }; + auto valid = [](const auto& frame) { return frame.first.isNonnull(); }; + auto acc = [](int& sum, const auto& frame) { return sum += (frame.first.isNonnull() ? 1 : 0); }; int nTracks(0); int nStubs(0); const int offset = region_ * dataFormats_->numChannel(Process::kf); @@ -116,8 +120,14 @@ namespace trackerTFP { } // fill output products - void KalmanFilter::produce(StreamsStub& acceptedStubs, StreamsTrack& acceptedTracks, StreamsStub& lostStubs, StreamsTrack& lostTracks, int& numAcceptedStates, int& numLostStates) { - auto put = [this](const deque& states, StreamsStub& streamsStubs, StreamsTrack& streamsTracks, int channel) { + void KalmanFilter::produce(StreamsStub& acceptedStubs, + StreamsTrack& acceptedTracks, + StreamsStub& lostStubs, + StreamsTrack& lostTracks, + int& numAcceptedStates, + int& numLostStates) { + auto put = [this]( + const deque& states, StreamsStub& streamsStubs, StreamsTrack& streamsTracks, int channel) { const int streamId = region_ * dataFormats_->numChannel(Process::kf) + channel; const int offset = streamId * setup_->numLayers(); StreamTrack& tracks = streamsTracks[streamId]; @@ -169,7 +179,11 @@ namespace trackerTFP { // storing of best states missed due to truncation sort(untruncatedStream.begin(), untruncatedStream.end()); sort(truncatedStream.begin(), truncatedStream.end()); - set_difference(untruncatedStream.begin(), untruncatedStream.end(), truncatedStream.begin(), truncatedStream.end(), back_inserter(lost)); + set_difference(untruncatedStream.begin(), + untruncatedStream.end(), + truncatedStream.begin(), + truncatedStream.end(), + back_inserter(lost)); // store found tracks put(stream, acceptedStubs, acceptedTracks, channel); // store lost tracks @@ -193,7 +207,8 @@ namespace trackerTFP { vector delay(latency, nullptr); // each trip corresponds to a f/w clock tick // done if no states to process left, taking as much time as needed - while (!stream.empty() || !stack.empty() || !all_of(delay.begin(), delay.end(), [](const State* state){ return state == nullptr; })) { + while (!stream.empty() || !stack.empty() || + !all_of(delay.begin(), delay.end(), [](const State* state) { return state == nullptr; })) { State* state = pop_front(stream); // Process a combinatoric state if no (non-combinatoric?) state available if (!state) @@ -201,7 +216,7 @@ namespace trackerTFP { streamOutput.push_back(state); // The remainder of the code in this loop deals with combinatoric states. //if (!state || !state->stub() || state->layer() != layer_) - //state = nullptr; + //state = nullptr; if (state != nullptr) // Assign next combinatoric stub to state comb(state); @@ -212,7 +227,7 @@ namespace trackerTFP { } stream = streamOutput; for (State*& state : stream) { - if (!state || !state->stub() || state->layer() != layer_ ) + if (!state || !state->stub() || state->layer() != layer_) continue; // Update state with next stub using KF maths update(state); @@ -242,7 +257,8 @@ namespace trackerTFP { if (hitPattern.count() == setup_->kfMaxLayers()) valid = false; // Impossible for this state to ever get enough layers to form valid track - if (hitPattern.count() + track->hitPattern().count(stub->layer() + 1, setup_->numLayers()) < setup_->kfMinLayers()) + if (hitPattern.count() + track->hitPattern().count(stub->layer() + 1, setup_->numLayers()) < + setup_->kfMinLayers()) valid = false; if (layer_ == setup_->numLayers() - 1) valid = false; @@ -269,7 +285,11 @@ namespace trackerTFP { void KalmanFilter::accumulator(deque& stream) { // accumulator delivers contigious stream of best state per track // remove gaps and not final states - stream.erase(remove_if(stream.begin(), stream.end(), [this](State* state){ return !state || state->hitPattern().count() < setup_->kfMinLayers(); }), stream.end()); + stream.erase( + remove_if(stream.begin(), + stream.end(), + [this](State* state) { return !state || state->hitPattern().count() < setup_->kfMinLayers(); }), + stream.end()); // Determine quality of completed state for (State* state : stream) state->finish(); @@ -277,12 +297,16 @@ namespace trackerTFP { auto lessSkippedLayers = [](State* lhs, State* rhs) { return lhs->numSkippedLayers() < rhs->numSkippedLayers(); }; stable_sort(stream.begin(), stream.end(), lessSkippedLayers); // sort in number of consistent stubs - auto moreConsistentLayers = [](State* lhs, State* rhs) { return lhs->numConsistentLayers() > rhs->numConsistentLayers(); }; + auto moreConsistentLayers = [](State* lhs, State* rhs) { + return lhs->numConsistentLayers() > rhs->numConsistentLayers(); + }; stable_sort(stream.begin(), stream.end(), moreConsistentLayers); // sort in track id - stable_sort(stream.begin(), stream.end(), [](State* lhs, State* rhs){ return lhs->trackId() < rhs->trackId(); }); + stable_sort(stream.begin(), stream.end(), [](State* lhs, State* rhs) { return lhs->trackId() < rhs->trackId(); }); // keep first state (best due to previous sorts) per track id - stream.erase(unique(stream.begin(), stream.end(), [](State* lhs, State* rhs){ return lhs->track() == rhs->track(); }), stream.end()); + stream.erase( + unique(stream.begin(), stream.end(), [](State* lhs, State* rhs) { return lhs->track() == rhs->track(); }), + stream.end()); } // updates state @@ -319,11 +343,11 @@ namespace trackerTFP { const double r0C = x1_->digi(m0 - x1); const double r0 = r0_->digi(r0C - x0 * H00); // stub z residual wrt current state - const double r1C = x3_->digi(m1 - x3); + const double r1C = x3_->digi(m1 - x3); const double r1 = r1_->digi(r1C - x2 * H12); // matrix S = H*C - const double S00 = S00_->digi(C01 + H00 * C00); - const double S01 = S01_->digi(C11 + H00 * C01); + const double S00 = S00_->digi(C01 + H00 * C00); + const double S01 = S01_->digi(C11 + H00 * C01); const double S12 = S12_->digi(C23 + H12 * C22); const double S13 = S13_->digi(C33 + H12 * C23); // Cov. matrix of predicted residuals R = V+HCHt = C+H*St @@ -401,7 +425,7 @@ namespace trackerTFP { } // remove and return first element of deque, returns nullptr if empty - template + template T* KalmanFilter::pop_front(deque& ts) const { T* t = nullptr; if (!ts.empty()) { @@ -412,7 +436,7 @@ namespace trackerTFP { } // remove and return first element of vector, returns nullptr if empty - template + template T* KalmanFilter::pop_front(vector& ts) const { T* t = nullptr; if (!ts.empty()) { @@ -422,4 +446,4 @@ namespace trackerTFP { return t; } -} // namespace trackerTFP \ No newline at end of file +} // namespace trackerTFP \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/src/KalmanFilterFormats.cc b/L1Trigger/TrackerTFP/src/KalmanFilterFormats.cc index b12e43b88a726..a2be1e49fe209 100644 --- a/L1Trigger/TrackerTFP/src/KalmanFilterFormats.cc +++ b/L1Trigger/TrackerTFP/src/KalmanFilterFormats.cc @@ -15,51 +15,55 @@ using namespace tt; namespace trackerTFP { - constexpr auto variableKFstrs_ = {"x0", "x1", "x2", "x3", "H00", "H12", "m0", "m1", "v0", "v1", "r0", "r1", "S00", "S01", "S12", "S13", "K00", "K10", "K21", "K31", "R00", "R11", "R00Rough", "R11Rough", "invR00Approx", "invR11Approx", "invR00Cor", "invR11Cor", "invR00", "invR11", "C00", "C01", "C11", "C22", "C23", "C33"}; + constexpr auto variableKFstrs_ = { + "x0", "x1", "x2", "x3", "H00", "H12", "m0", "m1", "v0", + "v1", "r0", "r1", "S00", "S01", "S12", "S13", "K00", "K10", + "K21", "K31", "R00", "R11", "R00Rough", "R11Rough", "invR00Approx", "invR11Approx", "invR00Cor", + "invR11Cor", "invR00", "invR11", "C00", "C01", "C11", "C22", "C23", "C33"}; void KalmanFilterFormats::endJob() { - const int wName = strlen(*max_element(variableKFstrs_.begin(), variableKFstrs_.end(), [this](const auto& a, const auto& b){return strlen(a) < strlen(b); })); + const int wName = + strlen(*max_element(variableKFstrs_.begin(), variableKFstrs_.end(), [this](const auto& a, const auto& b) { + return strlen(a) < strlen(b); + })); static constexpr int wWidth = 3; for (VariableKF v = VariableKF::begin; v != VariableKF::end; v = VariableKF(+v + 1)) { const pair& range = format(v).rangeActual(); const double r = format(v).twos() ? max(abs(range.first), abs(range.second)) * 2. : range.second; const int width = ceil(log2(r / format(v).base())); - cout << setw(wName) << *next(variableKFstrs_.begin(), +v) << ": " << setw(wWidth) << width << " " << setw(wWidth) << format(v).width() << " | " << setw(wWidth) << format(v).width() - width << endl; + cout << setw(wName) << *next(variableKFstrs_.begin(), +v) << ": " << setw(wWidth) << width << " " << setw(wWidth) + << format(v).width() << " | " << setw(wWidth) << format(v).width() - width << endl; //cout << " " << range.first << " " << range.second << " " << format(v).base() << endl; } } - KalmanFilterFormats::KalmanFilterFormats() : - iConfig_(), - dataFormats_(nullptr), - setup_(nullptr) - { + KalmanFilterFormats::KalmanFilterFormats() : iConfig_(), dataFormats_(nullptr), setup_(nullptr) { formats_.reserve(+VariableKF::end); } - KalmanFilterFormats::KalmanFilterFormats(const ParameterSet& iConfig, const DataFormats* dataFormats) : - iConfig_(dataFormats->hybrid() ? iConfig.getParameter("hybrid") : iConfig.getParameter("tmtt")), - dataFormats_(dataFormats), - setup_(dataFormats_->setup()) - { + KalmanFilterFormats::KalmanFilterFormats(const ParameterSet& iConfig, const DataFormats* dataFormats) + : iConfig_(dataFormats->hybrid() ? iConfig.getParameter("hybrid") + : iConfig.getParameter("tmtt")), + dataFormats_(dataFormats), + setup_(dataFormats_->setup()) { formats_.reserve(+VariableKF::end); fillFormats(); } - template + template void KalmanFilterFormats::fillFormats() { formats_.emplace_back(FormatKF(dataFormats_, iConfig_)); - if constexpr(++it != VariableKF::end) + if constexpr (++it != VariableKF::end) fillFormats<++it>(); } - DataFormatKF::DataFormatKF(const VariableKF& v, bool twos) : - v_(v), - twos_(twos), - width_(0), - base_(1.), - range_(0.), - rangeActual_(numeric_limits::max(), numeric_limits::lowest()) {} + DataFormatKF::DataFormatKF(const VariableKF& v, bool twos) + : v_(v), + twos_(twos), + width_(0), + base_(1.), + range_(0.), + rangeActual_(numeric_limits::max(), numeric_limits::lowest()) {} // returns false if data format would oferflow for this double value bool DataFormatKF::inRange(double d) const { @@ -74,16 +78,17 @@ namespace trackerTFP { string v = *next(variableKFstrs_.begin(), +v_); cms::Exception exception("out_of_range"); exception.addContext("trackerTFP:DataFormatKF::updateRangeActual"); - exception << "Variable " << v << " = " << d << " is out of range " - << (twos_ ? -range_ / 2. : 0) << " to " << (twos_ ? range_ / 2. : range_) << "." << endl; + exception << "Variable " << v << " = " << d << " is out of range " << (twos_ ? -range_ / 2. : 0) << " to " + << (twos_ ? range_ / 2. : range_) << "." << endl; if (twos_ || d >= 0.) exception.addAdditionalInfo("Consider raising BaseShift" + v + " in KalmnaFilterFormats_cfi.py."); //throw exception; } } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::x0, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::x0, true) { const DataFormat& input = dataFormats->format(Variable::inv2R, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftx0"); base_ = pow(2, baseShift) * input.base(); @@ -91,8 +96,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::x1, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::x1, true) { const DataFormat& input = dataFormats->format(Variable::phiT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftx1"); base_ = pow(2, baseShift) * input.base(); @@ -100,8 +106,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::x2, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::x2, true) { const DataFormat& input = dataFormats->format(Variable::cot, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftx2"); base_ = pow(2, baseShift) * input.base(); @@ -109,8 +116,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::x3, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::x3, true) { const DataFormat& input = dataFormats->format(Variable::zT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftx3"); base_ = pow(2, baseShift) * input.base(); @@ -118,16 +126,18 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::H00, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::H00, true) { const DataFormat& kfin = dataFormats->format(Variable::r, Process::kfin); base_ = kfin.base(); width_ = kfin.width(); range_ = kfin.range(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::H12, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::H12, true) { const Setup* setup = dataFormats->setup(); const DataFormat& kfin = dataFormats->format(Variable::r, Process::kfin); base_ = kfin.base(); @@ -135,24 +145,27 @@ namespace trackerTFP { width_ = ceil(log2(range_ / base_)); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::m0, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::m0, true) { const DataFormat& kfin = dataFormats->format(Variable::phi, Process::kfin); base_ = kfin.base(); width_ = kfin.width(); range_ = kfin.range(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::m1, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::m1, true) { const DataFormat& kfin = dataFormats->format(Variable::z, Process::kfin); base_ = kfin.base(); width_ = kfin.width(); range_ = kfin.range(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::v0, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::v0, false) { const DataFormat& x1 = dataFormats->format(Variable::phiT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftv0"); base_ = pow(2., baseShift) * x1.base() * x1.base(); @@ -160,8 +173,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::v1, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::v1, true) { const DataFormat& x3 = dataFormats->format(Variable::zT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftv1"); base_ = pow(2., baseShift) * x3.base() * x3.base(); @@ -169,8 +183,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::r0, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::r0, true) { const DataFormat& x1 = dataFormats->format(Variable::phiT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftr0"); base_ = pow(2., baseShift) * x1.base(); @@ -178,8 +193,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::r1, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::r1, true) { const DataFormat& x3 = dataFormats->format(Variable::zT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftr1"); base_ = pow(2., baseShift) * x3.base(); @@ -187,8 +203,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::S00, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::S00, true) { const DataFormat& x0 = dataFormats->format(Variable::inv2R, Process::kf); const DataFormat& x1 = dataFormats->format(Variable::phiT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftS00"); @@ -197,8 +214,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::S01, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::S01, true) { const DataFormat& x1 = dataFormats->format(Variable::phiT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftS01"); base_ = pow(2., baseShift) * x1.base() * x1.base(); @@ -206,8 +224,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::S12, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::S12, true) { const DataFormat& x2 = dataFormats->format(Variable::cot, Process::kf); const DataFormat& x3 = dataFormats->format(Variable::zT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftS12"); @@ -216,8 +235,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::S13, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::S13, true) { const DataFormat& x3 = dataFormats->format(Variable::zT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftS13"); base_ = pow(2., baseShift) * x3.base() * x3.base(); @@ -225,8 +245,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::K00, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::K00, true) { const DataFormat& x0 = dataFormats->format(Variable::inv2R, Process::kf); const DataFormat& x1 = dataFormats->format(Variable::phiT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftK00"); @@ -235,16 +256,18 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::K10, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::K10, true) { const int baseShift = iConfig.getParameter("BaseShiftK10"); base_ = pow(2., baseShift); width_ = dataFormats->setup()->widthDSPab(); calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::K21, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::K21, true) { const DataFormat& x2 = dataFormats->format(Variable::cot, Process::kf); const DataFormat& x3 = dataFormats->format(Variable::zT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftK21"); @@ -253,16 +276,18 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::K31, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::K31, true) { const int baseShift = iConfig.getParameter("BaseShiftK31"); base_ = pow(2., baseShift); width_ = dataFormats->setup()->widthDSPab(); calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::R00, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::R00, false) { const DataFormat& x1 = dataFormats->format(Variable::phiT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftR00"); base_ = pow(2., baseShift) * x1.base() * x1.base(); @@ -270,8 +295,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::R11, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::R11, false) { const DataFormat& x3 = dataFormats->format(Variable::zT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftR11"); base_ = pow(2., baseShift) * x3.base() * x3.base(); @@ -279,8 +305,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::R00Rough, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::R00Rough, false) { const FormatKF R00(dataFormats, iConfig); width_ = dataFormats->setup()->widthAddrBRAM18(); range_ = R00.range(); @@ -288,8 +315,9 @@ namespace trackerTFP { base_ = pow(2., baseShift) * R00.base(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::R11Rough, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::R11Rough, false) { const FormatKF R11(dataFormats, iConfig); width_ = dataFormats->setup()->widthAddrBRAM18(); range_ = R11.range(); @@ -297,8 +325,9 @@ namespace trackerTFP { base_ = pow(2., baseShift) * R11.base(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::invR00Approx, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::invR00Approx, false) { const DataFormat& x1 = dataFormats->format(Variable::phiT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftInvR00Approx"); base_ = pow(2., baseShift) / x1.base() / x1.base(); @@ -306,8 +335,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::invR11Approx, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::invR11Approx, false) { const DataFormat& x3 = dataFormats->format(Variable::zT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftInvR11Approx"); base_ = pow(2., baseShift) / x3.base() / x3.base(); @@ -315,24 +345,27 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::invR00Cor, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::invR00Cor, false) { const int baseShift = iConfig.getParameter("BaseShiftInvR00Cor"); base_ = pow(2., baseShift); width_ = dataFormats->setup()->widthDSPbu(); calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::invR11Cor, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::invR11Cor, false) { const int baseShift = iConfig.getParameter("BaseShiftInvR11Cor"); base_ = pow(2., baseShift); width_ = dataFormats->setup()->widthDSPbu(); calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::invR00, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::invR00, false) { const DataFormat& x1 = dataFormats->format(Variable::phiT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftInvR00"); base_ = pow(2., baseShift) / x1.base() / x1.base(); @@ -340,8 +373,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::invR11, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::invR11, false) { const DataFormat& x3 = dataFormats->format(Variable::zT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftInvR11"); base_ = pow(2., baseShift) / x3.base() / x3.base(); @@ -349,8 +383,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::C00, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::C00, false) { const DataFormat& x0 = dataFormats->format(Variable::inv2R, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftC00"); base_ = pow(2., baseShift) * x0.base() * x0.base(); @@ -358,8 +393,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::C01, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::C01, true) { const DataFormat& x0 = dataFormats->format(Variable::inv2R, Process::kf); const DataFormat& x1 = dataFormats->format(Variable::phiT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftC01"); @@ -368,8 +404,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::C11, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::C11, false) { const DataFormat& x1 = dataFormats->format(Variable::phiT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftC11"); base_ = pow(2., baseShift) * x1.base() * x1.base(); @@ -377,8 +414,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::C22, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::C22, false) { const DataFormat& x2 = dataFormats->format(Variable::cot, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftC22"); base_ = pow(2., baseShift) * x2.base() * x2.base(); @@ -386,8 +424,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::C23, true) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::C23, true) { const DataFormat& x2 = dataFormats->format(Variable::cot, Process::kf); const DataFormat& x3 = dataFormats->format(Variable::zT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftC23"); @@ -396,8 +435,9 @@ namespace trackerTFP { calcRange(); } - template<> - FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) : DataFormatKF(VariableKF::C33, false) { + template <> + FormatKF::FormatKF(const DataFormats* dataFormats, const edm::ParameterSet& iConfig) + : DataFormatKF(VariableKF::C33, false) { const DataFormat& x3 = dataFormats->format(Variable::zT, Process::kf); const int baseShift = iConfig.getParameter("BaseShiftC33"); base_ = pow(2., baseShift) * x3.base() * x3.base(); @@ -405,4 +445,4 @@ namespace trackerTFP { calcRange(); } -} // namespace trackerTFP \ No newline at end of file +} // namespace trackerTFP \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/src/LayerEncoding.cc b/L1Trigger/TrackerTFP/src/LayerEncoding.cc index 41f698b8c86cf..cfe13f2c377e7 100644 --- a/L1Trigger/TrackerTFP/src/LayerEncoding.cc +++ b/L1Trigger/TrackerTFP/src/LayerEncoding.cc @@ -11,14 +11,15 @@ using namespace tt; namespace trackerTFP { - LayerEncoding::LayerEncoding(const DataFormats* dataFormats) : - setup_(dataFormats->setup()), - dataFormats_(dataFormats), - zT_(&dataFormats->format(Variable::zT, Process::zht)), - cot_(&dataFormats->format(Variable::cot, Process::zht)), - layerEncoding_(setup_->numSectorsEta(), vector>>(pow(2, zT_->width()), vector>(pow(2, cot_->width())))), - maybeLayer_(setup_->numSectorsEta(), vector>>(pow(2, zT_->width()), vector>(pow(2, cot_->width())))) - { + LayerEncoding::LayerEncoding(const DataFormats* dataFormats) + : setup_(dataFormats->setup()), + dataFormats_(dataFormats), + zT_(&dataFormats->format(Variable::zT, Process::zht)), + cot_(&dataFormats->format(Variable::cot, Process::zht)), + layerEncoding_(setup_->numSectorsEta(), + vector>>(pow(2, zT_->width()), vector>(pow(2, cot_->width())))), + maybeLayer_(setup_->numSectorsEta(), + vector>>(pow(2, zT_->width()), vector>(pow(2, cot_->width())))) { // number of boundaries of fiducial area in r-z plane for a given set of rough r-z track parameter static constexpr int boundaries = 2; // find unique sensor mouldes in r-z @@ -28,9 +29,11 @@ namespace trackerTFP { sensorModules.reserve(setup_->sensorModules().size()); for (const SensorModule& sm : setup_->sensorModules()) sensorModules.push_back(&sm); - auto smallerR = [](const SensorModule* lhs, const SensorModule* rhs){ return lhs->r() < rhs->r(); }; - auto smallerZ = [](const SensorModule* lhs, const SensorModule* rhs){ return lhs->z() < rhs->z(); }; - auto equalRZ = [](const SensorModule* lhs, const SensorModule* rhs){ return abs(lhs->r() - rhs->r()) < delta && abs(lhs->z() - rhs->z()) < delta; }; + auto smallerR = [](const SensorModule* lhs, const SensorModule* rhs) { return lhs->r() < rhs->r(); }; + auto smallerZ = [](const SensorModule* lhs, const SensorModule* rhs) { return lhs->z() < rhs->z(); }; + auto equalRZ = [](const SensorModule* lhs, const SensorModule* rhs) { + return abs(lhs->r() - rhs->r()) < delta && abs(lhs->z() - rhs->z()) < delta; + }; stable_sort(sensorModules.begin(), sensorModules.end(), smallerR); stable_sort(sensorModules.begin(), sensorModules.end(), smallerZ); sensorModules.erase(unique(sensorModules.begin(), sensorModules.end(), equalRZ), sensorModules.end()); @@ -42,7 +45,8 @@ namespace trackerTFP { // z at radius choenRofZ of eta sector centre const double sectorZT = setup_->chosenRofZ() * sectorCot; // range of z at radius chosenRofZ this eta sector covers - const double rangeZT = setup_->chosenRofZ() * (sinh(setup_->boundarieEta(binEta + 1)) - sinh(setup_->boundarieEta(binEta))) / 2.; + const double rangeZT = + setup_->chosenRofZ() * (sinh(setup_->boundarieEta(binEta + 1)) - sinh(setup_->boundarieEta(binEta))) / 2.; // loop over bins in zT for (int binZT = 0; binZT < pow(2, zT_->width()); binZT++) { // z at radius chosenRofZ wrt zT of sectorZT of this bin centre @@ -73,7 +77,8 @@ namespace trackerTFP { const double zTi = zTs[sm->r() > setup_->chosenRofZ() ? i : j]; const double coti = cots[sm->r() > setup_->chosenRofZ() ? j : i]; // distance between module and boundary in moudle tilt angle direction - const double d = (zTi - sm->z() + (sm->r() - setup_->chosenRofZ()) * coti) / (sm->cosTilt() - sm->sinTilt() * coti); + const double d = + (zTi - sm->z() + (sm->r() - setup_->chosenRofZ()) * coti) / (sm->cosTilt() - sm->sinTilt() * coti); // compare distance with module size and add module layer id to layers if module is crossed if (abs(d) < sm->numColumns() * sm->pitchCol() / 2.) layers[i].insert(sm->layerId()); @@ -81,10 +86,18 @@ namespace trackerTFP { } // mayber layers are given by layer ids crossed by only one booundary set maybeLayer; - set_symmetric_difference(layers[0].begin(), layers[0].end(), layers[1].begin(), layers[1].end(), inserter(maybeLayer, maybeLayer.end())); + set_symmetric_difference(layers[0].begin(), + layers[0].end(), + layers[1].begin(), + layers[1].end(), + inserter(maybeLayer, maybeLayer.end())); // layerEncoding is given by sorted layer ids crossed by any booundary set layerEncoding; - set_union(layers[0].begin(), layers[0].end(), layers[1].begin(), layers[1].end(), inserter(layerEncoding, layerEncoding.end())); + set_union(layers[0].begin(), + layers[0].end(), + layers[1].begin(), + layers[1].end(), + inserter(layerEncoding, layerEncoding.end())); vector& le = layerEncoding_[binEta][binZT][binCot]; le = vector(layerEncoding.begin(), layerEncoding.end()); vector& ml = maybeLayer_[binEta][binZT][binCot]; @@ -114,4 +127,4 @@ namespace trackerTFP { return TTBV(0, setup_->numLayers()).set(maybeLayer(binEta, binZT, binCot)); } -} // namespace trackerTFP \ No newline at end of file +} // namespace trackerTFP \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/src/MiniHoughTransform.cc b/L1Trigger/TrackerTFP/src/MiniHoughTransform.cc index 0e363d6c257cb..1091739d471b0 100644 --- a/L1Trigger/TrackerTFP/src/MiniHoughTransform.cc +++ b/L1Trigger/TrackerTFP/src/MiniHoughTransform.cc @@ -15,22 +15,25 @@ using namespace tt; namespace trackerTFP { - MiniHoughTransform::MiniHoughTransform(const ParameterSet& iConfig, const Setup* setup, const DataFormats* dataFormats, int region) : - enableTruncation_(iConfig.getParameter("EnableTruncation")), - setup_(setup), - dataFormats_(dataFormats), - inv2R_(dataFormats_->format(Variable::inv2R, Process::ht)), - phiT_(dataFormats_->format(Variable::phiT, Process::ht)), - region_(region), - numBinsInv2R_(setup_->htNumBinsInv2R()), - numCells_(setup_->mhtNumCells()), - numNodes_(setup_->mhtNumDLBNodes()), - numChannel_(setup_->mhtNumDLBChannel()), - input_(numBinsInv2R_) {} + MiniHoughTransform::MiniHoughTransform(const ParameterSet& iConfig, + const Setup* setup, + const DataFormats* dataFormats, + int region) + : enableTruncation_(iConfig.getParameter("EnableTruncation")), + setup_(setup), + dataFormats_(dataFormats), + inv2R_(dataFormats_->format(Variable::inv2R, Process::ht)), + phiT_(dataFormats_->format(Variable::phiT, Process::ht)), + region_(region), + numBinsInv2R_(setup_->htNumBinsInv2R()), + numCells_(setup_->mhtNumCells()), + numNodes_(setup_->mhtNumDLBNodes()), + numChannel_(setup_->mhtNumDLBChannel()), + input_(numBinsInv2R_) {} // read in and organize input product (fill vector input_) void MiniHoughTransform::consume(const StreamsStub& streams) { - auto valid = [](int& sum, const FrameStub& frame){ return sum += (frame.first.isNonnull() ? 1 : 0); }; + auto valid = [](int& sum, const FrameStub& frame) { return sum += (frame.first.isNonnull() ? 1 : 0); }; int nStubsHT(0); for (int binInv2R = 0; binInv2R < numBinsInv2R_; binInv2R++) { const StreamStub& stream = streams[region_ * numBinsInv2R_ + binInv2R]; @@ -107,8 +110,8 @@ namespace trackerTFP { if (stubs.empty()) return; int id; - auto differentHT = [&id](StubHT* stub){ return id != stub->trackId(); }; - auto differentMHT = [&id](StubMHT* stub){ return !stub || id != stub->trackId(); }; + auto differentHT = [&id](StubHT* stub) { return id != stub->trackId(); }; + auto differentMHT = [&id](StubMHT* stub) { return !stub || id != stub->trackId(); }; for (auto it = stubs.begin(); it != stubs.end();) { const auto start = it; id = (*it)->trackId(); @@ -129,10 +132,34 @@ namespace trackerTFP { const bool compA = 2. * abs(chi) < phiT_.base(); const bool compB = 2. * abs(chi) < abs(r * inv2R_.base()); const bool compAB = compA && compB; - if (chi >= 0. && r >= 0.) { cells.push_back(3); if (compA) cells.push_back(1); if(compAB) cells.push_back(2); } - if (chi >= 0. && r < 0.) { cells.push_back(1); if (compA) cells.push_back(3); if(compAB) cells.push_back(0); } - if (chi < 0. && r >= 0.) { cells.push_back(0); if (compA) cells.push_back(2); if(compAB) cells.push_back(1); } - if (chi < 0. && r < 0.) { cells.push_back(2); if (compA) cells.push_back(0); if(compAB) cells.push_back(3); } + if (chi >= 0. && r >= 0.) { + cells.push_back(3); + if (compA) + cells.push_back(1); + if (compAB) + cells.push_back(2); + } + if (chi >= 0. && r < 0.) { + cells.push_back(1); + if (compA) + cells.push_back(3); + if (compAB) + cells.push_back(0); + } + if (chi < 0. && r >= 0.) { + cells.push_back(0); + if (compA) + cells.push_back(2); + if (compAB) + cells.push_back(1); + } + if (chi < 0. && r < 0.) { + cells.push_back(2); + if (compA) + cells.push_back(0); + if (compAB) + cells.push_back(3); + } // organise stubs in finer track candidates for (int cell : cells) { const int inv2R = cell / setup_->mhtNumBinsPhiT(); @@ -146,7 +173,7 @@ namespace trackerTFP { deque& stream = streams[channel * numCells_ + sel]; vector& mhtCell = mhtCells[sel]; set layers; - auto toLayer = [](StubMHT* stub){ return stub->layer(); }; + auto toLayer = [](StubMHT* stub) { return stub->layer(); }; transform(mhtCell.begin(), mhtCell.end(), inserter(layers, layers.begin()), toLayer); if ((int)layers.size() < setup_->mhtMinLayers()) mhtCell.clear(); @@ -158,7 +185,7 @@ namespace trackerTFP { for (int sel = 0; sel < numCells_; sel++) { deque& stream = streams[channel * numCells_ + sel]; // remove all gaps between end and last stub - for(auto it = stream.end(); it != stream.begin();) + for (auto it = stream.end(); it != stream.begin();) it = (*--it) ? stream.begin() : stream.erase(it); // read out fine track cannot start before rough track has read in completely, add gaps to take this into account int pos(0); @@ -175,8 +202,7 @@ namespace trackerTFP { const int diff = pos - d; it = stream.insert(it, diff, nullptr); it = next(it, diff); - } - else + } else it = stream.erase(remove(next(stream.begin(), pos), it, nullptr), it); it = next(it, s); } @@ -188,9 +214,9 @@ namespace trackerTFP { // Static load balancing of inputs: mux 4 streams to 1 stream void MiniHoughTransform::slb(vector>& inputs, vector& accepted, StreamStub& lost) const { - if (all_of(inputs.begin(), inputs.end(), [](const deque& stubs){ return stubs.empty(); })) + if (all_of(inputs.begin(), inputs.end(), [](const deque& stubs) { return stubs.empty(); })) return; - auto size = [](int& sum, const deque& stubs){ return sum += stubs.size(); }; + auto size = [](int& sum, const deque& stubs) { return sum += stubs.size(); }; const int nFrames = accumulate(inputs.begin(), inputs.end(), 0, size); accepted.reserve(nFrames); // input fifos @@ -199,10 +225,10 @@ namespace trackerTFP { TTBV empty(-1, numCells_, true); TTBV enable(0, numCells_); // clock accurate firmware emulation, each while trip describes one clock tick, one stub in and one stub out per tick - while(!all_of(inputs.begin(), inputs.end(), [](const deque& d){ return d.empty(); }) or - !all_of(stacks.begin(), stacks.end(), [](const deque& d){ return d.empty(); })) { + while (!all_of(inputs.begin(), inputs.end(), [](const deque& d) { return d.empty(); }) or + !all_of(stacks.begin(), stacks.end(), [](const deque& d) { return d.empty(); })) { // store stub in fifo - for(int channel = 0; channel < numCells_; channel++){ + for (int channel = 0; channel < numCells_; channel++) { StubMHT* stub = pop_front(inputs[channel]); if (stub) stacks[channel].push_back(stub); @@ -225,12 +251,11 @@ namespace trackerTFP { else // gap if no fifo has been chosen accepted.push_back(nullptr); - } // perform truncation if desired if (enableTruncation_ && (int)accepted.size() > setup_->numFrames()) { const auto limit = next(accepted.begin(), setup_->numFrames()); - auto valid = [](int& sum, StubMHT* stub){ return sum += stub ? 1 : 0; }; + auto valid = [](int& sum, StubMHT* stub) { return sum += stub ? 1 : 0; }; const int nLost = accumulate(limit, accepted.end(), 0, valid); lost.reserve(nLost); for (auto it = limit; it != accepted.end(); it++) @@ -239,15 +264,15 @@ namespace trackerTFP { accepted.erase(limit, accepted.end()); } // cosmetics -- remove gaps at the end of stream - for(auto it = accepted.end(); it != accepted.begin();) + for (auto it = accepted.end(); it != accepted.begin();) it = (*--it) == nullptr ? accepted.erase(it) : accepted.begin(); } // Dynamic load balancing of inputs: swapping parts of streams to balance the amount of tracks per stream void MiniHoughTransform::dlb(vector>& streams) const { - if (all_of(streams.begin(), streams.end(), [](const vector& stubs){ return stubs.empty(); })) + if (all_of(streams.begin(), streams.end(), [](const vector& stubs) { return stubs.empty(); })) return; - auto maxSize = [](int& size, const vector& stream){ return size = max(size, (int)stream.size()); }; + auto maxSize = [](int& size, const vector& stream) { return size = max(size, (int)stream.size()); }; const int nMax = accumulate(streams.begin(), streams.end(), 0, maxSize); for (vector& stream : streams) stream.resize(nMax, nullptr); @@ -261,7 +286,8 @@ namespace trackerTFP { newTrks.set(k); for (int k = 0; k < numChannel_; k++) if (newTrks[k]) - if ((swapping && loads[numChannel_ - k - 1] > loads[k]) || (!swapping && loads[k] > loads[numChannel_ - k - 1])) + if ((swapping && loads[numChannel_ - k - 1] > loads[k]) || + (!swapping && loads[k] > loads[numChannel_ - k - 1])) swapping = !swapping; for (int k = 0; k < numChannel_; k++) { if (streams[k][i]) @@ -273,12 +299,12 @@ namespace trackerTFP { } // remove all gaps between end and last stub for (vector& stream : streams) - for(auto it = stream.end(); it != stream.begin();) + for (auto it = stream.end(); it != stream.begin();) it = (*--it) ? stream.begin() : stream.erase(it); } // remove and return first element of deque, returns nullptr if empty - template + template T* MiniHoughTransform::pop_front(deque& ts) const { T* t = nullptr; if (!ts.empty()) { @@ -288,4 +314,4 @@ namespace trackerTFP { return t; } -} // namespace trackerTFP \ No newline at end of file +} // namespace trackerTFP \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/src/State.cc b/L1Trigger/TrackerTFP/src/State.cc index ddca52ba7f06a..adc3236cecc5b 100644 --- a/L1Trigger/TrackerTFP/src/State.cc +++ b/L1Trigger/TrackerTFP/src/State.cc @@ -6,68 +6,64 @@ using namespace tt; namespace trackerTFP { // default constructor - State::State(State* state) : - dataFormats_(state->dataFormats_), - setup_(state->setup_), - track_(state->track_), - trackId_(state->trackId_), - parent_(state->parent_), - stub_(state->stub_), - layerMap_(state->layerMap_), - hitPattern_(state->hitPattern_), - x0_(state->x0_), - x1_(state->x1_), - x2_(state->x2_), - x3_(state->x3_), - C00_(state->C00_), - C01_(state->C01_), - C11_(state->C11_), - C22_(state->C22_), - C23_(state->C23_), - C33_(state->C33_), - numSkippedLayers_(state->numSkippedLayers_), - numConsistentLayers_(state->numConsistentLayers_) - {} + State::State(State* state) + : dataFormats_(state->dataFormats_), + setup_(state->setup_), + track_(state->track_), + trackId_(state->trackId_), + parent_(state->parent_), + stub_(state->stub_), + layerMap_(state->layerMap_), + hitPattern_(state->hitPattern_), + x0_(state->x0_), + x1_(state->x1_), + x2_(state->x2_), + x3_(state->x3_), + C00_(state->C00_), + C01_(state->C01_), + C11_(state->C11_), + C22_(state->C22_), + C23_(state->C23_), + C33_(state->C33_), + numSkippedLayers_(state->numSkippedLayers_), + numConsistentLayers_(state->numConsistentLayers_) {} // proto state constructor - State::State(const DataFormats* dataFormats, TrackKFin* track, int trackId) : - dataFormats_(dataFormats), - setup_(dataFormats->setup()), - track_(track), - trackId_(trackId), - parent_(nullptr), - stub_(nullptr), - layerMap_(setup_->numLayers()), - hitPattern_(0, setup_->numLayers()), - numSkippedLayers_(0), - numConsistentLayers_(0) - { + State::State(const DataFormats* dataFormats, TrackKFin* track, int trackId) + : dataFormats_(dataFormats), + setup_(dataFormats->setup()), + track_(track), + trackId_(trackId), + parent_(nullptr), + stub_(nullptr), + layerMap_(setup_->numLayers()), + hitPattern_(0, setup_->numLayers()), + numSkippedLayers_(0), + numConsistentLayers_(0) { // initial track parameter residuals w.r.t. found track x0_ = 0.; x1_ = 0.; x2_ = 0.; x3_ = 0.; // initial uncertainties - C00_ = pow(dataFormats_->base(Variable::inv2R, Process::zht), 2); - C11_ = pow(dataFormats_->base(Variable::phiT, Process::zht), 2); - C22_ = pow(dataFormats_->base(Variable::cot, Process::zht), 2); - C33_ = pow(dataFormats_->base(Variable::zT, Process::zht), 2); - C01_ = 0.; - C23_ = 0.; + C00_ = pow(dataFormats_->base(Variable::inv2R, Process::zht), 2); + C11_ = pow(dataFormats_->base(Variable::phiT, Process::zht), 2); + C22_ = pow(dataFormats_->base(Variable::cot, Process::zht), 2); + C33_ = pow(dataFormats_->base(Variable::zT, Process::zht), 2); + C01_ = 0.; + C23_ = 0.; // first stub from first layer on input track with stubs stub_ = track->layerStub(track->hitPattern().plEncode()); } // combinatoric state constructor - State::State(State* state, StubKFin* stub) : State(state) - { + State::State(State* state, StubKFin* stub) : State(state) { parent_ = state->parent(); stub_ = stub; } // updated state constructor - State::State(State* state, const std::vector& doubles) : State(state) - { + State::State(State* state, const std::vector& doubles) : State(state) { parent_ = state; // updated track parameter and uncertainties x0_ = doubles[0]; @@ -113,10 +109,12 @@ namespace trackerTFP { void State::finish() { const vector stubs = this->stubs(); auto consistent = [this](int& sum, const StubKF& stub) { - auto inConsistentRange = [](float v, float r, float d){ return abs(v) <= (r + d) / 2.; }; + auto inConsistentRange = [](float v, float r, float d) { return abs(v) <= (r + d) / 2.; }; // Check stub consistent with helix, allowing for stub & digi uncertainty - const bool inRange0 = inConsistentRange(stub.phi(), stub.dPhi(), dataFormats_->format(Variable::dPhi, Process::kf).base()); - const bool inRange1 = inConsistentRange(stub.z(), stub.dZ(), dataFormats_->format(Variable::dZ, Process::kf).base()); + const bool inRange0 = + inConsistentRange(stub.phi(), stub.dPhi(), dataFormats_->format(Variable::dPhi, Process::kf).base()); + const bool inRange1 = + inConsistentRange(stub.z(), stub.dZ(), dataFormats_->format(Variable::dZ, Process::kf).base()); return sum += (inRange0 && inRange1 ? 1 : 0); }; numConsistentLayers_ = accumulate(stubs.begin(), stubs.end(), 0, consistent); @@ -126,4 +124,4 @@ namespace trackerTFP { numSkippedLayers_ = pattern.count(0, hitPattern_.pmEncode(), false); } -} // namespace trackerTFP \ No newline at end of file +} // namespace trackerTFP \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/src/ZHoughTransform.cc b/L1Trigger/TrackerTFP/src/ZHoughTransform.cc index b9b50085df86e..3b694013fc542 100644 --- a/L1Trigger/TrackerTFP/src/ZHoughTransform.cc +++ b/L1Trigger/TrackerTFP/src/ZHoughTransform.cc @@ -15,17 +15,20 @@ using namespace tt; namespace trackerTFP { - ZHoughTransform::ZHoughTransform(const ParameterSet& iConfig, const Setup* setup, const DataFormats* dataFormats, int region) : - enableTruncation_(iConfig.getParameter("EnableTruncation")), - setup_(setup), - dataFormats_(dataFormats), - region_(region), - input_(dataFormats->numChannel(Process::mht)), - stage_(0) {} + ZHoughTransform::ZHoughTransform(const ParameterSet& iConfig, + const Setup* setup, + const DataFormats* dataFormats, + int region) + : enableTruncation_(iConfig.getParameter("EnableTruncation")), + setup_(setup), + dataFormats_(dataFormats), + region_(region), + input_(dataFormats->numChannel(Process::mht)), + stage_(0) {} // read in and organize input product (fill vector input_) void ZHoughTransform::consume(const StreamsStub& streams) { - auto valid = [](int& sum, const FrameStub& frame){ return sum += (frame.first.isNonnull() ? 1 : 0); }; + auto valid = [](int& sum, const FrameStub& frame) { return sum += (frame.first.isNonnull() ? 1 : 0); }; const int offset = region_ * dataFormats_->numChannel(Process::mht); int nStubsMHT(0); for (int channel = 0; channel < dataFormats_->numChannel(Process::mht); channel++) { @@ -82,13 +85,15 @@ namespace trackerTFP { void ZHoughTransform::fill(int channel, const deque& stubs, vector>& streams) { if (stubs.empty()) return; - const double baseZT = dataFormats_->format(Variable::zT, Process::zht).base() * pow(2, setup_->zhtNumStages() - stage_); - const double baseCot = dataFormats_->format(Variable::cot, Process::zht).base() * pow(2, setup_->zhtNumStages() - stage_); + const double baseZT = + dataFormats_->format(Variable::zT, Process::zht).base() * pow(2, setup_->zhtNumStages() - stage_); + const double baseCot = + dataFormats_->format(Variable::cot, Process::zht).base() * pow(2, setup_->zhtNumStages() - stage_); int id; - auto different = [&id](StubZHT* stub){ return !stub || id != stub->trackId(); }; + auto different = [&id](StubZHT* stub) { return !stub || id != stub->trackId(); }; for (auto it = stubs.begin(); it != stubs.end();) { if (!*it) { - const auto begin = find_if(it, stubs.end(), [](StubZHT* stub){ return stub; }); + const auto begin = find_if(it, stubs.end(), [](StubZHT* stub) { return stub; }); const int nGaps = distance(it, begin); for (deque& stream : streams) stream.insert(stream.end(), nGaps, nullptr); @@ -116,10 +121,42 @@ namespace trackerTFP { const bool compA = 2. * abs(chi) < baseZT + dChi; const bool compB = 2. * abs(chi) < abs(r) * baseCot + dChi; const bool compC = 2. * abs(chi) < dChi; - if (chi >= 0. && r >= 0.) { cells.push_back(1); if (compA) cells.push_back(3); if(compB) cells.push_back(0); if(compC) cells.push_back(2); } - if (chi >= 0. && r < 0.) { cells.push_back(3); if (compA) cells.push_back(1); if(compB) cells.push_back(2); if(compC) cells.push_back(0); } - if (chi < 0. && r >= 0.) { cells.push_back(2); if (compA) cells.push_back(0); if(compB) cells.push_back(3); if(compC) cells.push_back(1); } - if (chi < 0. && r < 0.) { cells.push_back(0); if (compA) cells.push_back(2); if(compB) cells.push_back(1); if(compC) cells.push_back(3); } + if (chi >= 0. && r >= 0.) { + cells.push_back(1); + if (compA) + cells.push_back(3); + if (compB) + cells.push_back(0); + if (compC) + cells.push_back(2); + } + if (chi >= 0. && r < 0.) { + cells.push_back(3); + if (compA) + cells.push_back(1); + if (compB) + cells.push_back(2); + if (compC) + cells.push_back(0); + } + if (chi < 0. && r >= 0.) { + cells.push_back(2); + if (compA) + cells.push_back(0); + if (compB) + cells.push_back(3); + if (compC) + cells.push_back(1); + } + if (chi < 0. && r < 0.) { + cells.push_back(0); + if (compA) + cells.push_back(2); + if (compB) + cells.push_back(1); + if (compC) + cells.push_back(3); + } for (int cell : cells) { const double cot = (cell / setup_->zhtNumBinsZT() - .5) * baseCot / 2.; const double zT = (cell % setup_->zhtNumBinsZT() - .5) * baseZT / 2.; @@ -132,7 +169,7 @@ namespace trackerTFP { deque& stream = streams[channel * setup_->zhtNumCells() + sel]; vector& mhtCell = mhtCells[sel]; set layers; - auto toLayer = [](StubZHT* stub){ return stub->layer(); }; + auto toLayer = [](StubZHT* stub) { return stub->layer(); }; transform(mhtCell.begin(), mhtCell.end(), inserter(layers, layers.begin()), toLayer); if ((int)layers.size() < setup_->mhtMinLayers()) mhtCell.clear(); @@ -144,7 +181,7 @@ namespace trackerTFP { for (int sel = 0; sel < setup_->zhtNumCells(); sel++) { deque& stream = streams[channel * setup_->zhtNumCells() + sel]; // remove all gaps between end and last stub - for(auto it = stream.end(); it != stream.begin();) + for (auto it = stream.end(); it != stream.begin();) it = (*--it) ? stream.begin() : stream.erase(it); // read out fine track cannot start before rough track has read in completely, add gaps to take this into account int pos(0); @@ -161,8 +198,7 @@ namespace trackerTFP { const int diff = pos - d; it = stream.insert(it, diff, nullptr); it = next(it, diff); - } - else + } else it = stream.erase(remove(next(stream.begin(), pos), it, nullptr), it); it = next(it, s); } @@ -175,7 +211,7 @@ namespace trackerTFP { // Static load balancing of inputs: mux 4 streams to 1 stream void ZHoughTransform::slb(vector>& inputs, deque& accepted, StreamStub& lost) const { accepted.clear(); - if (all_of(inputs.begin(), inputs.end(), [](const deque& stubs){ return stubs.empty(); })) + if (all_of(inputs.begin(), inputs.end(), [](const deque& stubs) { return stubs.empty(); })) return; // input fifos vector> stacks(setup_->zhtNumCells()); @@ -183,10 +219,10 @@ namespace trackerTFP { TTBV empty(-1, setup_->zhtNumCells(), true); TTBV enable(0, setup_->zhtNumCells()); // clock accurate firmware emulation, each while trip describes one clock tick, one stub in and one stub out per tick - while(!all_of(inputs.begin(), inputs.end(), [](const deque& d){ return d.empty(); }) or - !all_of(stacks.begin(), stacks.end(), [](const deque& d){ return d.empty(); })) { + while (!all_of(inputs.begin(), inputs.end(), [](const deque& d) { return d.empty(); }) or + !all_of(stacks.begin(), stacks.end(), [](const deque& d) { return d.empty(); })) { // store stub in fifo - for(int channel = 0; channel < setup_->zhtNumCells(); channel++){ + for (int channel = 0; channel < setup_->zhtNumCells(); channel++) { StubZHT* stub = pop_front(inputs[channel]); if (stub) stacks[channel].push_back(stub); @@ -209,12 +245,11 @@ namespace trackerTFP { else // gap if no fifo has been chosen accepted.push_back(nullptr); - } // perform truncation if desired if (enableTruncation_ && (int)accepted.size() > setup_->numFrames()) { const auto limit = next(accepted.begin(), setup_->numFrames()); - auto valid = [](int& sum, StubZHT* stub){ return sum += stub ? 1 : 0; }; + auto valid = [](int& sum, StubZHT* stub) { return sum += stub ? 1 : 0; }; const int nLost = accumulate(limit, accepted.end(), 0, valid); lost.reserve(nLost); for (auto it = limit; it != accepted.end(); it++) @@ -223,7 +258,7 @@ namespace trackerTFP { accepted.erase(limit, accepted.end()); } // cosmetics -- remove gaps at the end of stream - for(auto it = accepted.end(); it != accepted.begin();) + for (auto it = accepted.end(); it != accepted.begin();) it = (*--it) == nullptr ? accepted.erase(it) : accepted.begin(); } @@ -253,16 +288,20 @@ namespace trackerTFP { const int zT = (cotp.first + cotp.second) / 2; const int pos = distance(candidates.begin(), m); deque& track = tracks[pos]; - auto different = [id](const StubZHT* stub){ return id != stub->trackId(); }; + auto different = [id](const StubZHT* stub) { return id != stub->trackId(); }; it = find_if(it, stubs.end(), different); for (auto s = start; s != it; s++) { - if (find_if(track.begin(), track.end(), [s](const FrameStub& stub){ return (*s)->ttStubRef() == stub.first; }) != track.end()) + if (find_if(track.begin(), track.end(), [s](const FrameStub& stub) { + return (*s)->ttStubRef() == stub.first; + }) != track.end()) continue; const StubZHT stub(**s, cot, zT); track.push_back(stub.frame()); } } - const int size = accumulate(tracks.begin(), tracks.end(), 0, [](int& sum, const deque& stubs){ return sum += (int)stubs.size(); }); + const int size = accumulate(tracks.begin(), tracks.end(), 0, [](int& sum, const deque& stubs) { + return sum += (int)stubs.size(); + }); stream.reserve(size); for (deque& track : tracks) for (const FrameStub& stub : track) @@ -270,7 +309,7 @@ namespace trackerTFP { } // remove and return first element of deque, returns nullptr if empty - template + template T* ZHoughTransform::pop_front(deque& ts) const { T* t = nullptr; if (!ts.empty()) { @@ -280,4 +319,4 @@ namespace trackerTFP { return t; } -} // namespace trackerTFP \ No newline at end of file +} // namespace trackerTFP \ No newline at end of file diff --git a/L1Trigger/TrackerTFP/test/AnalyzerDemonstrator.cc b/L1Trigger/TrackerTFP/test/AnalyzerDemonstrator.cc index 388cb64831b0b..13fb5b440130f 100644 --- a/L1Trigger/TrackerTFP/test/AnalyzerDemonstrator.cc +++ b/L1Trigger/TrackerTFP/test/AnalyzerDemonstrator.cc @@ -36,9 +36,12 @@ namespace trackerTFP { private: // - void convert(const Event& iEvent, const EDGetTokenT& tokenTracks, const EDGetTokenT& tokenStubs, vector>& bits) const; + void convert(const Event& iEvent, + const EDGetTokenT& tokenTracks, + const EDGetTokenT& tokenStubs, + vector>& bits) const; // - template + template void convert(const T& collection, vector>& bits) const; // ED input token of Tracks EDGetTokenT edGetTokenStubsIn_; @@ -66,9 +69,11 @@ namespace trackerTFP { edGetTokenStubsIn_ = consumes(InputTag(labelIn, branchStubs)); if (labelOut != "TrackFindingTrackletProducerKFout") edGetTokenStubsOut_ = consumes(InputTag(labelOut, branchStubs)); - if (labelIn == "TrackerTFPProducerKFin" || labelIn == "TrackerTFPProducerKF" || labelIn == "TrackFindingTrackletProducerKFin" || labelIn == "TrackFindingTrackletProducerKF") + if (labelIn == "TrackerTFPProducerKFin" || labelIn == "TrackerTFPProducerKF" || + labelIn == "TrackFindingTrackletProducerKFin" || labelIn == "TrackFindingTrackletProducerKF") edGetTokenTracksIn_ = consumes(InputTag(labelIn, branchTracks)); - if (labelOut == "TrackerTFPProducerKF" || labelOut == "TrackerTFPProducerDR" || labelOut == "TrackFindingTrackletProducerKF" || labelOut == "TrackFindingTrackletProducerKFout") + if (labelOut == "TrackerTFPProducerKF" || labelOut == "TrackerTFPProducerDR" || + labelOut == "TrackFindingTrackletProducerKF" || labelOut == "TrackFindingTrackletProducerKFout") edGetTokenTracksOut_ = consumes(InputTag(labelOut, branchTracks)); // book ES products esGetTokenSetup_ = esConsumes(); @@ -94,13 +99,16 @@ namespace trackerTFP { } // - void AnalyzerDemonstrator::convert(const Event& iEvent, const EDGetTokenT& tokenTracks, const EDGetTokenT& tokenStubs, vector>& bits) const { + void AnalyzerDemonstrator::convert(const Event& iEvent, + const EDGetTokenT& tokenTracks, + const EDGetTokenT& tokenStubs, + vector>& bits) const { const bool tracks = !tokenTracks.isUninitialized(); const bool stubs = !tokenStubs.isUninitialized(); Handle handleStubs; Handle handleTracks; int numChannelStubs(0); - if (stubs){ + if (stubs) { iEvent.getByToken(tokenStubs, handleStubs); numChannelStubs = handleStubs->size(); } @@ -118,7 +126,7 @@ namespace trackerTFP { const int offsetStubs = (region * numChannelTracks + channelTracks) * numChannelStubs; if (tracks) convert(handleTracks->at(offsetTracks + channelTracks), bits); - if (stubs){ + if (stubs) { for (int channelStubs = 0; channelStubs < numChannelStubs; channelStubs++) convert(handleStubs->at(offsetStubs + channelStubs), bits); } @@ -126,14 +134,13 @@ namespace trackerTFP { } } - // - template + template void AnalyzerDemonstrator::convert(const T& collection, vector>& bits) const { bits.emplace_back(); vector& bvs = bits.back(); bvs.reserve(collection.size()); - transform(collection.begin(), collection.end(), back_inserter(bvs), [](const auto& frame){ return frame.second; }); + transform(collection.begin(), collection.end(), back_inserter(bvs), [](const auto& frame) { return frame.second; }); } } // namespace trackerTFP diff --git a/L1Trigger/TrackerTFP/test/AnalyzerGP.cc b/L1Trigger/TrackerTFP/test/AnalyzerGP.cc index 9e33752db8f14..422b729696efb 100644 --- a/L1Trigger/TrackerTFP/test/AnalyzerGP.cc +++ b/L1Trigger/TrackerTFP/test/AnalyzerGP.cc @@ -69,7 +69,8 @@ namespace trackerTFP { stringstream log_; }; - AnalyzerGP::AnalyzerGP(const ParameterSet& iConfig) : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { + AnalyzerGP::AnalyzerGP(const ParameterSet& iConfig) + : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { usesResource("TFileService"); // book in- and output ED products const string& label = iConfig.getParameter("LabelGP"); @@ -179,7 +180,8 @@ namespace trackerTFP { const int wErrs = ceil(log10(*max_element(errs.begin(), errs.end()))) + 5; log_ << " GP SUMMARY " << endl; log_ << "number of stubs per TFP = " << setw(wNums) << numStubs << " +- " << setw(wErrs) << errStubs << endl; - log_ << "number of lost stubs per TFP = " << setw(wNums) << numStubsLost << " +- " << setw(wErrs) << errStubsLost << endl; + log_ << "number of lost stubs per TFP = " << setw(wNums) << numStubsLost << " +- " << setw(wErrs) << errStubsLost + << endl; log_ << " max tracking efficiency = " << setw(wNums) << eff << " +- " << setw(wErrs) << errEff << endl; log_ << "============================================================="; LogPrint("L1Trigger/TrackerTFP") << log_.str(); diff --git a/L1Trigger/TrackerTFP/test/AnalyzerHT.cc b/L1Trigger/TrackerTFP/test/AnalyzerHT.cc index d39c0c9dec646..86318e5100347 100644 --- a/L1Trigger/TrackerTFP/test/AnalyzerHT.cc +++ b/L1Trigger/TrackerTFP/test/AnalyzerHT.cc @@ -83,7 +83,8 @@ namespace trackerTFP { stringstream log_; }; - AnalyzerHT::AnalyzerHT(const ParameterSet& iConfig) : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { + AnalyzerHT::AnalyzerHT(const ParameterSet& iConfig) + : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { usesResource("TFileService"); // book in- and output ED products const string& label = iConfig.getParameter("LabelHT"); @@ -190,7 +191,7 @@ namespace trackerTFP { vector recovered; recovered.reserve(tpPtrsLost.size()); set_intersection(tpPtrsLost.begin(), tpPtrsLost.end(), tpPtrs.begin(), tpPtrs.end(), back_inserter(recovered)); - for(const TPPtr& tpPtr : recovered) + for (const TPPtr& tpPtr : recovered) tpPtrsLost.erase(tpPtr); prof_->Fill(4, allMatched); prof_->Fill(5, allTracks); @@ -228,8 +229,10 @@ namespace trackerTFP { const int wErrs = ceil(log10(*max_element(errs.begin(), errs.end()))) + 5; log_ << " HT SUMMARY " << endl; log_ << "number of stubs per TFP = " << setw(wNums) << numStubs << " +- " << setw(wErrs) << errStubs << endl; - log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks << endl; - log_ << "number of lost tracks per TFP = " << setw(wNums) << numTracksLost << " +- " << setw(wErrs) << errTracksLost << endl; + log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks + << endl; + log_ << "number of lost tracks per TFP = " << setw(wNums) << numTracksLost << " +- " << setw(wErrs) << errTracksLost + << endl; log_ << " max tracking efficiency = " << setw(wNums) << eff << " +- " << setw(wErrs) << errEff << endl; log_ << " lost tracking efficiency = " << setw(wNums) << effLoss << " +- " << setw(wErrs) << errEffLoss << endl; log_ << " fake rate = " << setw(wNums) << fracFake << endl; @@ -247,17 +250,20 @@ namespace trackerTFP { for (auto it = stubs.begin(); it != stubs.end();) { const auto start = it; const int id = it->trackId(); - auto different = [id](const StubHT& stub){ return id != stub.trackId(); }; + auto different = [id](const StubHT& stub) { return id != stub.trackId(); }; it = find_if(it, stubs.end(), different); vector ttStubRefs; ttStubRefs.reserve(distance(start, it)); - transform(start, it, back_inserter(ttStubRefs), [](const StubHT& stub){ return stub.ttStubRef(); }); + transform(start, it, back_inserter(ttStubRefs), [](const StubHT& stub) { return stub.ttStubRef(); }); tracks.push_back(ttStubRefs); } } // - void AnalyzerHT::associate(const vector>& tracks, const StubAssociation* ass, set& tps, int& sum) const { + void AnalyzerHT::associate(const vector>& tracks, + const StubAssociation* ass, + set& tps, + int& sum) const { for (const vector& ttStubRefs : tracks) { const vector& tpPtrs = ass->associate(ttStubRefs); if (tpPtrs.empty()) diff --git a/L1Trigger/TrackerTFP/test/AnalyzerKF.cc b/L1Trigger/TrackerTFP/test/AnalyzerKF.cc index 5b970208a8bdb..c49458177f6a9 100644 --- a/L1Trigger/TrackerTFP/test/AnalyzerKF.cc +++ b/L1Trigger/TrackerTFP/test/AnalyzerKF.cc @@ -51,7 +51,12 @@ namespace trackerTFP { private: // - void associate(const TTTracks& ttTracks, const StubAssociation* ass, set& tps, int& sum, const vector& his, TProfile* prof) const; + void associate(const TTTracks& ttTracks, + const StubAssociation* ass, + set& tps, + int& sum, + const vector& his, + TProfile* prof) const; // ED input token of accepted Tracks EDGetTokenT edGetTokenAcceptedStubs_; @@ -106,11 +111,8 @@ namespace trackerTFP { stringstream log_; }; - AnalyzerKF::AnalyzerKF(const ParameterSet& iConfig) : - useMCTruth_(iConfig.getParameter("UseMCTruth")), - nEvents_(0), - hisRes_(4) - { + AnalyzerKF::AnalyzerKF(const ParameterSet& iConfig) + : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0), hisRes_(4) { usesResource("TFileService"); // book in- and output ED products const string& label = iConfig.getParameter("LabelKF"); @@ -122,8 +124,10 @@ namespace trackerTFP { edGetTokenAcceptedTracks_ = consumes(InputTag(label, branchAcceptedTracks)); edGetTokenLostStubs_ = consumes(InputTag(label, branchLostStubs)); edGetTokenLostTracks_ = consumes(InputTag(label, branchLostTracks)); - edGetTokenNumAcceptedStates_ = consumes(InputTag(label, branchAcceptedTracks));; - edGetTokenNumLostStates_ = consumes(InputTag(label, branchLostTracks));; + edGetTokenNumAcceptedStates_ = consumes(InputTag(label, branchAcceptedTracks)); + ; + edGetTokenNumLostStates_ = consumes(InputTag(label, branchLostTracks)); + ; if (useMCTruth_) { const auto& inputTagSelecttion = iConfig.getParameter("InputTagSelection"); const auto& inputTagReconstructable = iConfig.getParameter("InputTagReconstructable"); @@ -258,15 +262,21 @@ namespace trackerTFP { hisChannel_->Fill(accepted.size()); profChannel_->Fill(channel, accepted.size()); TTTracks tracks; - const int nTracks = accumulate(accepted.begin(), accepted.end(), 0, [](int& sum, const FrameTrack& frame){ return sum += frame.first.isNonnull() ? 1 : 0; }); + const int nTracks = accumulate(accepted.begin(), accepted.end(), 0, [](int& sum, const FrameTrack& frame) { + return sum += frame.first.isNonnull() ? 1 : 0; + }); nTracksRegion += nTracks; tracks.reserve(nTracks); consume(accepted, acceptedStubs, index, tracks); for (const TTTrack& ttTrack : tracks) hisPhi_->Fill(ttTrack.momentum().phi()); - nStubsRegion += accumulate(tracks.begin(), tracks.end(), 0, [](int& sum, const auto& ttTrack){ return sum += (int)ttTrack.getStubRefs().size(); }); + nStubsRegion += accumulate(tracks.begin(), tracks.end(), 0, [](int& sum, const auto& ttTrack) { + return sum += (int)ttTrack.getStubRefs().size(); + }); TTTracks tracksLost; - const int nLost = accumulate(lost.begin(), lost.end(), 0, [](int& sum, const FrameTrack& frame){ return sum += frame.first.isNonnull() ? 1 : 0; }); + const int nLost = accumulate(lost.begin(), lost.end(), 0, [](int& sum, const FrameTrack& frame) { + return sum += frame.first.isNonnull() ? 1 : 0; + }); nLostRegion += nLost; tracksLost.reserve(nLost); consume(lost, lostStubs, index, tracksLost); @@ -301,9 +311,9 @@ namespace trackerTFP { return; // effi effEta_->SetPassedHistogram(*hisEffEta_, "f"); - effEta_->SetTotalHistogram (*hisEffEtaTotal_, "f"); + effEta_->SetTotalHistogram(*hisEffEtaTotal_, "f"); effInv2R_->SetPassedHistogram(*hisEffInv2R_, "f"); - effInv2R_->SetTotalHistogram (*hisEffInv2RTotal_, "f"); + effInv2R_->SetTotalHistogram(*hisEffInv2RTotal_, "f"); // printout SF summary const double totalTPs = prof_->GetBinContent(9); const double numStubs = prof_->GetBinContent(1); @@ -332,8 +342,10 @@ namespace trackerTFP { const int wErrs = ceil(log10(*max_element(errs.begin(), errs.end()))) + 5; log_ << " KF SUMMARY " << endl; log_ << "number of stubs per TFP = " << setw(wNums) << numStubs << " +- " << setw(wErrs) << errStubs << endl; - log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks << endl; - log_ << "number of lost tracks per TFP = " << setw(wNums) << numTracksLost << " +- " << setw(wErrs) << errTracksLost << endl; + log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks + << endl; + log_ << "number of lost tracks per TFP = " << setw(wNums) << numTracksLost << " +- " << setw(wErrs) << errTracksLost + << endl; log_ << " tracking efficiency = " << setw(wNums) << eff << " +- " << setw(wErrs) << errEff << endl; log_ << " lost tracking efficiency = " << setw(wNums) << effLoss << " +- " << setw(wErrs) << errEffLoss << endl; log_ << " fake rate = " << setw(wNums) << fracFake << endl; @@ -344,7 +356,12 @@ namespace trackerTFP { } // - void AnalyzerKF::associate(const TTTracks& ttTracks, const StubAssociation* ass, set& tps, int& sum, const vector& his, TProfile* prof) const { + void AnalyzerKF::associate(const TTTracks& ttTracks, + const StubAssociation* ass, + set& tps, + int& sum, + const vector& his, + TProfile* prof) const { for (const TTTrack& ttTrack : ttTracks) { const vector& ttStubRefs = ttTrack.getStubRefs(); const vector& tpPtrs = ass->associateFinal(ttStubRefs); diff --git a/L1Trigger/TrackerTFP/test/AnalyzerKFin.cc b/L1Trigger/TrackerTFP/test/AnalyzerKFin.cc index a73349fd5892f..158a188180adb 100644 --- a/L1Trigger/TrackerTFP/test/AnalyzerKFin.cc +++ b/L1Trigger/TrackerTFP/test/AnalyzerKFin.cc @@ -49,7 +49,10 @@ namespace trackerTFP { private: // - void formTracks(const StreamsTrack& streamsTrack, const StreamsStub& streamsStubs, vector>& tracks, int channel) const; + void formTracks(const StreamsTrack& streamsTrack, + const StreamsStub& streamsStubs, + vector>& tracks, + int channel) const; // void associate(const vector>& tracks, const StubAssociation* ass, set& tps, int& sum) const; @@ -88,7 +91,8 @@ namespace trackerTFP { stringstream log_; }; - AnalyzerKFin::AnalyzerKFin(const ParameterSet& iConfig) : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { + AnalyzerKFin::AnalyzerKFin(const ParameterSet& iConfig) + : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { usesResource("TFileService"); // book in- and output ED products const string& label = iConfig.getParameter("LabelKFin"); @@ -186,7 +190,9 @@ namespace trackerTFP { vector> lost; formTracks(lostTracks, lostStubs, lost, offset + channel); nTracks += tracks.size(); - nStubs += accumulate(tracks.begin(), tracks.end(), 0, [](int& sum, const vector& track){ return sum += (int)track.size(); }); + nStubs += accumulate(tracks.begin(), tracks.end(), 0, [](int& sum, const vector& track) { + return sum += (int)track.size(); + }); nLost += lost.size(); allTracks += tracks.size(); if (!useMCTruth_) @@ -203,7 +209,7 @@ namespace trackerTFP { vector recovered; recovered.reserve(tpPtrsLost.size()); set_intersection(tpPtrsLost.begin(), tpPtrsLost.end(), tpPtrs.begin(), tpPtrs.end(), back_inserter(recovered)); - for(const TPPtr& tpPtr : recovered) + for (const TPPtr& tpPtr : recovered) tpPtrsLost.erase(tpPtr); prof_->Fill(4, allMatched); prof_->Fill(5, allTracks); @@ -241,8 +247,10 @@ namespace trackerTFP { const int wErrs = ceil(log10(*max_element(errs.begin(), errs.end()))) + 5; log_ << " KFin SUMMARY " << endl; log_ << "number of stubs per TFP = " << setw(wNums) << numStubs << " +- " << setw(wErrs) << errStubs << endl; - log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks << endl; - log_ << "number of lost tracks per TFP = " << setw(wNums) << numTracksLost << " +- " << setw(wErrs) << errTracksLost << endl; + log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks + << endl; + log_ << "number of lost tracks per TFP = " << setw(wNums) << numTracksLost << " +- " << setw(wErrs) << errTracksLost + << endl; log_ << " max tracking efficiency = " << setw(wNums) << eff << " +- " << setw(wErrs) << errEff << endl; log_ << " lost tracking efficiency = " << setw(wNums) << effLoss << " +- " << setw(wErrs) << errEffLoss << endl; log_ << " fake rate = " << setw(wNums) << fracFake << endl; @@ -252,21 +260,31 @@ namespace trackerTFP { } // - void AnalyzerKFin::formTracks(const StreamsTrack& streamsTrack, const StreamsStub& streamsStubs, vector>& tracks, int channel) const { + void AnalyzerKFin::formTracks(const StreamsTrack& streamsTrack, + const StreamsStub& streamsStubs, + vector>& tracks, + int channel) const { const int offset = channel * setup_->numLayers(); const StreamTrack& streamTrack = streamsTrack[channel]; - const int numTracks = accumulate(streamTrack.begin(), streamTrack.end(), 0, [](int& sum, const FrameTrack& frame){ return sum += (frame.first.isNonnull() ? 1 : 0); }); + const int numTracks = accumulate(streamTrack.begin(), streamTrack.end(), 0, [](int& sum, const FrameTrack& frame) { + return sum += (frame.first.isNonnull() ? 1 : 0); + }); tracks.reserve(numTracks); for (int frame = 0; frame < (int)streamTrack.size(); frame++) { const FrameTrack& frameTrack = streamTrack[frame]; if (frameTrack.first.isNull()) continue; - const auto end = find_if(next(streamTrack.begin(), frame + 1), streamTrack.end(), [](const FrameTrack& frame){ return frame.first.isNonnull(); }); + const auto end = find_if(next(streamTrack.begin(), frame + 1), streamTrack.end(), [](const FrameTrack& frame) { + return frame.first.isNonnull(); + }); const int size = distance(next(streamTrack.begin(), frame), end); int numStubs(0); for (int layer = 0; layer < setup_->numLayers(); layer++) { const StreamStub& stream = streamsStubs[offset + layer]; - numStubs += accumulate(stream.begin() + frame, stream.begin() + frame + size, 0, [](int& sum, const FrameStub& frame){ return sum += (frame.first.isNonnull() ? 1 : 0); }); + numStubs += + accumulate(stream.begin() + frame, stream.begin() + frame + size, 0, [](int& sum, const FrameStub& frame) { + return sum += (frame.first.isNonnull() ? 1 : 0); + }); } vector stubs; stubs.reserve(numStubs); @@ -282,7 +300,10 @@ namespace trackerTFP { } // - void AnalyzerKFin::associate(const vector>& tracks, const StubAssociation* ass, set& tps, int& sum) const { + void AnalyzerKFin::associate(const vector>& tracks, + const StubAssociation* ass, + set& tps, + int& sum) const { for (const vector& ttStubRefs : tracks) { const vector& tpPtrs = ass->associate(ttStubRefs); if (tpPtrs.empty()) diff --git a/L1Trigger/TrackerTFP/test/AnalyzerMHT.cc b/L1Trigger/TrackerTFP/test/AnalyzerMHT.cc index 58723e11f7436..71701913da761 100644 --- a/L1Trigger/TrackerTFP/test/AnalyzerMHT.cc +++ b/L1Trigger/TrackerTFP/test/AnalyzerMHT.cc @@ -53,7 +53,6 @@ namespace trackerTFP { // void associate(const vector>& tracks, const StubAssociation* ass, set& tps, int& sum) const; - // ED input token of stubs EDGetTokenT edGetTokenAccepted_; // ED input token of lost stubs @@ -88,7 +87,8 @@ namespace trackerTFP { stringstream log_; }; - AnalyzerMHT::AnalyzerMHT(const ParameterSet& iConfig) : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { + AnalyzerMHT::AnalyzerMHT(const ParameterSet& iConfig) + : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { usesResource("TFileService"); // book in- and output ED products const string& label = iConfig.getParameter("LabelMHT"); @@ -179,7 +179,9 @@ namespace trackerTFP { const StreamStub& accepted = handleAccepted->at(index); hisChannel_->Fill(accepted.size()); profChannel_->Fill(channel, accepted.size()); - nStubs += accumulate(accepted.begin(), accepted.end(), 0, [](int& sum, const FrameStub& frame){ return sum += frame.first.isNonnull() ? 1 : 0; }); + nStubs += accumulate(accepted.begin(), accepted.end(), 0, [](int& sum, const FrameStub& frame) { + return sum += frame.first.isNonnull() ? 1 : 0; + }); vector> tracks; vector> lost; formTracks(accepted, tracks); @@ -203,7 +205,7 @@ namespace trackerTFP { vector recovered; recovered.reserve(tpPtrsLost.size()); set_intersection(tpPtrsLost.begin(), tpPtrsLost.end(), tpPtrs.begin(), tpPtrs.end(), back_inserter(recovered)); - for(const TPPtr& tpPtr : recovered) + for (const TPPtr& tpPtr : recovered) tpPtrsLost.erase(tpPtr); prof_->Fill(4, allMatched); prof_->Fill(5, allTracks); @@ -218,7 +220,7 @@ namespace trackerTFP { return; // effi eff_->SetPassedHistogram(*hisEff_, "f"); - eff_->SetTotalHistogram (*hisEffTotal_, "f"); + eff_->SetTotalHistogram(*hisEffTotal_, "f"); // printout MHT summary const double totalTPs = prof_->GetBinContent(9); const double numStubs = prof_->GetBinContent(1); @@ -244,8 +246,10 @@ namespace trackerTFP { const int wErrs = ceil(log10(*max_element(errs.begin(), errs.end()))) + 5; log_ << " MHT SUMMARY " << endl; log_ << "number of stubs per TFP = " << setw(wNums) << numStubs << " +- " << setw(wErrs) << errStubs << endl; - log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks << endl; - log_ << "number of lost tracks per TFP = " << setw(wNums) << numTracksLost << " +- " << setw(wErrs) << errTracksLost << endl; + log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks + << endl; + log_ << "number of lost tracks per TFP = " << setw(wNums) << numTracksLost << " +- " << setw(wErrs) << errTracksLost + << endl; log_ << " max tracking efficiency = " << setw(wNums) << eff << " +- " << setw(wErrs) << errEff << endl; log_ << " lost tracking efficiency = " << setw(wNums) << effLoss << " +- " << setw(wErrs) << errEffLoss << endl; log_ << " fake rate = " << setw(wNums) << fracFake << endl; @@ -259,22 +263,25 @@ namespace trackerTFP { vector stubs; stubs.reserve(stream.size()); for (const FrameStub& frame : stream) - if(frame.first.isNonnull()) + if (frame.first.isNonnull()) stubs.emplace_back(frame, dataFormats_); for (auto it = stubs.begin(); it != stubs.end();) { const auto start = it; const int id = it->trackId(); - auto different = [id](const StubMHT& stub){ return id != stub.trackId(); }; + auto different = [id](const StubMHT& stub) { return id != stub.trackId(); }; it = find_if(it, stubs.end(), different); vector ttStubRefs; ttStubRefs.reserve(distance(start, it)); - transform(start, it, back_inserter(ttStubRefs), [](const StubMHT& stub){ return stub.ttStubRef(); }); + transform(start, it, back_inserter(ttStubRefs), [](const StubMHT& stub) { return stub.ttStubRef(); }); tracks.push_back(ttStubRefs); } } // - void AnalyzerMHT::associate(const vector>& tracks, const StubAssociation* ass, set& tps, int& sum) const { + void AnalyzerMHT::associate(const vector>& tracks, + const StubAssociation* ass, + set& tps, + int& sum) const { for (const vector& ttStubRefs : tracks) { const vector& tpPtrs = ass->associate(ttStubRefs); if (tpPtrs.empty()) diff --git a/L1Trigger/TrackerTFP/test/AnalyzerTT.cc b/L1Trigger/TrackerTFP/test/AnalyzerTT.cc index f954816ec3d69..07c2558d2587d 100644 --- a/L1Trigger/TrackerTFP/test/AnalyzerTT.cc +++ b/L1Trigger/TrackerTFP/test/AnalyzerTT.cc @@ -33,7 +33,6 @@ namespace trackerTFP { void endJob() override {} private: - // ED input token of tt::TTTrackRefMap EDGetTokenT edGetTokenTTTrackMap_; // ED input token of TTStubRef to TPPtr association for tracking efficiency @@ -100,19 +99,31 @@ namespace trackerTFP { cout << gp.perp() << " " << gp.phi() << " " << gp.z() << " " << setup_->layerId(ttStubRef) << endl; } cout << found->hitPattern() << " " << found->trackSeedType() << endl; - cout << "m0SF = " << " " << -found->rInv() << endl; - cout << "c0SF = " << " " << deltaPhi(found->phi() + found->rInv() * setup_->chosenRofPhi() + off) << endl; - cout << "m1SF = " << " " << found->tanL() + setup_->sectorCot(found->etaSector()) << endl; - cout << "c1SF = " << " " << found->z0() - found->tanL() * setup_->chosenRofZ() << endl; - cout << "m0KF = " << " " << -fitted->rInv() * setup_->invPtToDphi() << endl; - cout << "c0KF = " << " " << fitted->phi() << endl; - cout << "m1KF = " << " " << fitted->tanL() << endl; - cout << "c1KF = " << " " << fitted->z0() << endl; - cout << "m0TP = " << " " << -tpPtr->charge() / tpPtr->pt() * setup_->invPtToDphi() << endl; - cout << "c0TP = " << " " << tpPtr->phi() << endl; - cout << "m1TP = " << " " << sinh(tpPtr->eta()) << endl; + cout << "m0SF = " + << " " << -found->rInv() << endl; + cout << "c0SF = " + << " " << deltaPhi(found->phi() + found->rInv() * setup_->chosenRofPhi() + off) << endl; + cout << "m1SF = " + << " " << found->tanL() + setup_->sectorCot(found->etaSector()) << endl; + cout << "c1SF = " + << " " << found->z0() - found->tanL() * setup_->chosenRofZ() << endl; + cout << "m0KF = " + << " " << -fitted->rInv() * setup_->invPtToDphi() << endl; + cout << "c0KF = " + << " " << fitted->phi() << endl; + cout << "m1KF = " + << " " << fitted->tanL() << endl; + cout << "c1KF = " + << " " << fitted->z0() << endl; + cout << "m0TP = " + << " " << -tpPtr->charge() / tpPtr->pt() * setup_->invPtToDphi() << endl; + cout << "c0TP = " + << " " << tpPtr->phi() << endl; + cout << "m1TP = " + << " " << sinh(tpPtr->eta()) << endl; const math::XYZPointD& v = tpPtr->vertex(); - cout << "c1TP = " << " " << v.z() - sinh(tpPtr->eta()) * (v.x() * cos(tpPtr->phi()) + v.y() * sin(tpPtr->phi())) << endl; + cout << "c1TP = " + << " " << v.z() - sinh(tpPtr->eta()) * (v.x() * cos(tpPtr->phi()) + v.y() * sin(tpPtr->phi())) << endl; throw cms::Exception("..."); } } diff --git a/L1Trigger/TrackerTFP/test/AnalyzerZHT.cc b/L1Trigger/TrackerTFP/test/AnalyzerZHT.cc index 318c09e08f51a..6dc0c00cb308d 100644 --- a/L1Trigger/TrackerTFP/test/AnalyzerZHT.cc +++ b/L1Trigger/TrackerTFP/test/AnalyzerZHT.cc @@ -87,7 +87,8 @@ namespace trackerTFP { stringstream log_; }; - AnalyzerZHT::AnalyzerZHT(const ParameterSet& iConfig) : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { + AnalyzerZHT::AnalyzerZHT(const ParameterSet& iConfig) + : useMCTruth_(iConfig.getParameter("UseMCTruth")), nEvents_(0) { usesResource("TFileService"); // book in- and output ED products const string& label = iConfig.getParameter("LabelZHT"); @@ -178,7 +179,9 @@ namespace trackerTFP { const StreamStub& accepted = handleAccepted->at(index); hisChannel_->Fill(accepted.size()); profChannel_->Fill(channel, accepted.size()); - nStubs += accumulate(accepted.begin(), accepted.end(), 0, [](int& sum, const FrameStub& frame){ return sum += frame.first.isNonnull() ? 1 : 0; }); + nStubs += accumulate(accepted.begin(), accepted.end(), 0, [](int& sum, const FrameStub& frame) { + return sum += frame.first.isNonnull() ? 1 : 0; + }); vector> tracks; vector> lost; formTracks(accepted, tracks); @@ -202,7 +205,7 @@ namespace trackerTFP { vector recovered; recovered.reserve(tpPtrsLost.size()); set_intersection(tpPtrsLost.begin(), tpPtrsLost.end(), tpPtrs.begin(), tpPtrs.end(), back_inserter(recovered)); - for(const TPPtr& tpPtr : recovered) + for (const TPPtr& tpPtr : recovered) tpPtrsLost.erase(tpPtr); prof_->Fill(4, allMatched); prof_->Fill(5, allTracks); @@ -211,7 +214,7 @@ namespace trackerTFP { prof_->Fill(8, tpPtrsLost.size()); nEvents_++; //if ((int)tpPtrsSelection.size() != selection->numTPs()) - //throw cms::Exception("..."); + //throw cms::Exception("..."); } void AnalyzerZHT::endJob() { @@ -219,7 +222,7 @@ namespace trackerTFP { return; // effi eff_->SetPassedHistogram(*hisEff_, "f"); - eff_->SetTotalHistogram (*hisEffTotal_, "f"); + eff_->SetTotalHistogram(*hisEffTotal_, "f"); // printout SF summary const double totalTPs = prof_->GetBinContent(9); const double numStubs = prof_->GetBinContent(1); @@ -245,8 +248,10 @@ namespace trackerTFP { const int wErrs = ceil(log10(*max_element(errs.begin(), errs.end()))) + 5; log_ << " ZHT SUMMARY " << endl; log_ << "number of stubs per TFP = " << setw(wNums) << numStubs << " +- " << setw(wErrs) << errStubs << endl; - log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks << endl; - log_ << "number of lost tracks per TFP = " << setw(wNums) << numTracksLost << " +- " << setw(wErrs) << errTracksLost << endl; + log_ << "number of tracks per TFP = " << setw(wNums) << numTracks << " +- " << setw(wErrs) << errTracks + << endl; + log_ << "number of lost tracks per TFP = " << setw(wNums) << numTracksLost << " +- " << setw(wErrs) << errTracksLost + << endl; log_ << " max tracking efficiency = " << setw(wNums) << eff << " +- " << setw(wErrs) << errEff << endl; log_ << " lost tracking efficiency = " << setw(wNums) << effLoss << " +- " << setw(wErrs) << errEffLoss << endl; log_ << " fake rate = " << setw(wNums) << fracFake << endl; @@ -260,22 +265,25 @@ namespace trackerTFP { vector stubs; stubs.reserve(stream.size()); for (const FrameStub& frame : stream) - if(frame.first.isNonnull()) + if (frame.first.isNonnull()) stubs.emplace_back(frame, dataFormats_); for (auto it = stubs.begin(); it != stubs.end();) { const auto start = it; const int id = it->trackId(); - auto different = [id](const StubZHT& stub){ return id != stub.trackId(); }; + auto different = [id](const StubZHT& stub) { return id != stub.trackId(); }; it = find_if(it, stubs.end(), different); vector ttStubRefs; ttStubRefs.reserve(distance(start, it)); - transform(start, it, back_inserter(ttStubRefs), [](const StubZHT& stub){ return stub.ttStubRef(); }); + transform(start, it, back_inserter(ttStubRefs), [](const StubZHT& stub) { return stub.ttStubRef(); }); tracks.push_back(ttStubRefs); } } // - void AnalyzerZHT::associate(const vector>& tracks, const StubAssociation* ass, set& tps, int& sum) const { + void AnalyzerZHT::associate(const vector>& tracks, + const StubAssociation* ass, + set& tps, + int& sum) const { for (const vector& ttStubRefs : tracks) { const vector& tpPtrs = ass->associate(ttStubRefs); if (tpPtrs.empty()) diff --git a/L1Trigger/TrackerTFP/test/ProducerAS.cc b/L1Trigger/TrackerTFP/test/ProducerAS.cc index 00467e075d335..b5f8040b47994 100644 --- a/L1Trigger/TrackerTFP/test/ProducerAS.cc +++ b/L1Trigger/TrackerTFP/test/ProducerAS.cc @@ -50,9 +50,7 @@ namespace trackerTFP { const Setup* setup_; }; - ProducerAS::ProducerAS(const ParameterSet& iConfig) : - iConfig_(iConfig) - { + ProducerAS::ProducerAS(const ParameterSet& iConfig) : iConfig_(iConfig) { const string& labelKF = iConfig.getParameter("LabelKF"); const string& labelTT = iConfig.getParameter("LabelTT"); const string& branch = iConfig.getParameter("BranchAcceptedTracks"); @@ -96,6 +94,6 @@ namespace trackerTFP { iEvent.emplace(edPutToken_, move(ttTrackMap)); } -} // namespace trackerTFP +} // namespace trackerTFP DEFINE_FWK_MODULE(trackerTFP::ProducerAS); \ No newline at end of file diff --git a/SimTracker/TrackTriggerAssociation/interface/StubAssociation.h b/SimTracker/TrackTriggerAssociation/interface/StubAssociation.h index 10cc218139282..faa2725dda2e5 100644 --- a/SimTracker/TrackTriggerAssociation/interface/StubAssociation.h +++ b/SimTracker/TrackTriggerAssociation/interface/StubAssociation.h @@ -25,9 +25,13 @@ namespace tt { // insert a TPPtr and its associated collection of TTstubRefs into the underlayering maps void insert(const TPPtr& tpPtr, const std::vector& ttSTubRefs); // returns map containing TTStubRef and their associated collection of TPPtrs - const std::map>& getTTStubToTrackingParticlesMap() const { return mapTTStubRefsTPPtrs_; } + const std::map>& getTTStubToTrackingParticlesMap() const { + return mapTTStubRefsTPPtrs_; + } // returns map containing TPPtr and their associated collection of TTStubRefs - const std::map>& getTrackingParticleToTTStubsMap() const { return mapTPPtrsTTStubRefs_; } + const std::map>& getTrackingParticleToTTStubsMap() const { + return mapTPPtrsTTStubRefs_; + } // returns collection of TPPtrs associated to given TTstubRef const std::vector& findTrackingParticlePtrs(const TTStubRef& ttStubRef) const; // returns collection of TTStubRefs associated to given TPPtr @@ -54,6 +58,6 @@ namespace tt { const std::vector emptyTTStubRefs_; }; -} // namespace tt +} // namespace tt #endif \ No newline at end of file diff --git a/SimTracker/TrackTriggerAssociation/plugins/StubAssociator.cc b/SimTracker/TrackTriggerAssociation/plugins/StubAssociator.cc index 5ead178f06aa2..8646c335f6fbd 100644 --- a/SimTracker/TrackTriggerAssociation/plugins/StubAssociator.cc +++ b/SimTracker/TrackTriggerAssociation/plugins/StubAssociator.cc @@ -59,8 +59,7 @@ namespace tt { ESGetToken esGetTokenSetup_; }; - StubAssociator::StubAssociator(const ParameterSet& iConfig) - { + StubAssociator::StubAssociator(const ParameterSet& iConfig) { // book in- and output ed products getTokenTTStubDetSetVec_ = consumes(iConfig.getParameter("InputTagTTStubDetSetVec")); getTokenTTClusterAssMap_ = consumes(iConfig.getParameter("InputTagTTClusterAssMap")); @@ -82,15 +81,16 @@ namespace tt { Handle handleTTStubAssMap; iEvent.getByToken(getTokenTTClusterAssMap_, handleTTClusterAssMap); map> mapTPPtrsTTStubRefs; - auto isNonnull = [](const TPPtr& tpPtr){ return tpPtr.isNonnull(); }; + auto isNonnull = [](const TPPtr& tpPtr) { return tpPtr.isNonnull(); }; for (TTStubDetSetVec::const_iterator ttModule = handleTTStubDetSetVec->begin(); - ttModule != handleTTStubDetSetVec->end(); - ttModule++) { + ttModule != handleTTStubDetSetVec->end(); + ttModule++) { for (TTStubDetSet::const_iterator ttStub = ttModule->begin(); ttStub != ttModule->end(); ttStub++) { const TTStubRef ttStubRef = makeRefTo(handleTTStubDetSetVec, ttStub); set tpPtrs; for (unsigned int iClus = 0; iClus < 2; iClus++) { - const vector& assocPtrs = handleTTClusterAssMap->findTrackingParticlePtrs(ttStubRef->clusterRef(iClus)); + const vector& assocPtrs = + handleTTClusterAssMap->findTrackingParticlePtrs(ttStubRef->clusterRef(iClus)); copy_if(assocPtrs.begin(), assocPtrs.end(), inserter(tpPtrs, tpPtrs.begin()), isNonnull); } for (const TPPtr& tpPtr : tpPtrs) @@ -111,6 +111,6 @@ namespace tt { iEvent.emplace(putTokenSelection_, move(selection)); } -} // namespace tt +} // namespace tt DEFINE_FWK_MODULE(tt::StubAssociator); \ No newline at end of file diff --git a/SimTracker/TrackTriggerAssociation/src/StubAssociation.cc b/SimTracker/TrackTriggerAssociation/src/StubAssociation.cc index 775c566791289..9a873d054c7b8 100644 --- a/SimTracker/TrackTriggerAssociation/src/StubAssociation.cc +++ b/SimTracker/TrackTriggerAssociation/src/StubAssociation.cc @@ -76,4 +76,4 @@ namespace tt { return tpPtrs; } -} // namespace tt \ No newline at end of file +} // namespace tt \ No newline at end of file