File indexing completed on 2023-10-25 09:56:37
0001 #include "L1Trigger/VertexFinder/interface/TP.h"
0002
0003 namespace l1tVertexFinder {
0004
0005 TP::TP()
0006 : settings_(nullptr),
0007 inTimeBx_(false),
0008 physicsCollision_(false),
0009 use_(false),
0010 useForEff_(false),
0011 useForAlgEff_(false),
0012 useForVertexReco_(false),
0013 nLayersWithStubs_(0) {}
0014
0015 TP::TP(const TrackingParticlePtr& tpPtr, const AnalysisSettings& settings)
0016 : trackingParticle_(tpPtr), settings_(&settings) {
0017 const std::vector<SimTrack>& vst = trackingParticle_->g4Tracks();
0018 EncodedEventId eid = vst.at(0).eventId();
0019 inTimeBx_ = (eid.bunchCrossing() == 0);
0020 physicsCollision_ = (eid.event() == 0);
0021
0022 this->fillUse();
0023 this->fillUseForEff();
0024 }
0025
0026
0027 void TP::setMatchingStubs(const std::vector<Stub>& vMatchingStubs) {
0028 assocStubs_ = vMatchingStubs;
0029
0030 this->fillUseForAlgEff();
0031 this->fillUseForVertexReco();
0032
0033 nLayersWithStubs_ = countLayers();
0034 }
0035
0036
0037
0038
0039 unsigned int TP::countLayers(bool onlyPS) {
0040
0041
0042
0043 bool useLayerID = settings_->useLayerID();
0044
0045 float layerIDfromRadiusBin = settings_->layerIDfromRadiusBin();
0046
0047 float trackerInnerRadius = settings_->trackerInnerRadius();
0048
0049 const int maxLayerID(30);
0050 std::vector<bool> foundLayers(maxLayerID, false);
0051
0052 if (useLayerID) {
0053
0054 for (const Stub& stub : assocStubs_) {
0055 if ((!onlyPS) || stub.psModule()) {
0056 int layerID = stub.layerId();
0057 if (layerID >= 0 && layerID < maxLayerID) {
0058 foundLayers[layerID] = true;
0059 } else {
0060 throw cms::Exception("Utility::invalid layer ID");
0061 }
0062 }
0063 }
0064 } else {
0065
0066 for (const Stub& stub : assocStubs_) {
0067 if ((!onlyPS) || stub.psModule()) {
0068 int layerID = (int)((stub.r() - trackerInnerRadius) / layerIDfromRadiusBin);
0069 if (layerID >= 0 && layerID < maxLayerID) {
0070 foundLayers[layerID] = true;
0071 } else {
0072 throw cms::Exception("Utility::invalid layer ID");
0073 }
0074 }
0075 }
0076 }
0077
0078 unsigned int ncount = 0;
0079 for (const bool& found : foundLayers) {
0080 if (found)
0081 ncount++;
0082 }
0083
0084 return ncount;
0085 }
0086
0087 void TP::fillUseForVertexReco() {
0088 useForVertexReco_ = false;
0089 if (use_) {
0090 useForVertexReco_ = settings_->tpsUseForVtxReco()(trackingParticle_.get());
0091 }
0092
0093 if (useForVertexReco_) {
0094 useForVertexReco_ = (countLayers() >= settings_->genMinStubLayers() and countLayers(true) >= 2);
0095 }
0096 }
0097
0098
0099 void TP::fillUse() {
0100
0101
0102 use_ = settings_->tpsUse()(trackingParticle_.get());
0103 }
0104
0105
0106 void TP::fillUseForEff() {
0107 useForEff_ = false;
0108 if (use_) {
0109 useForEff_ = settings_->tpsUseForEff()(trackingParticle_.get());
0110 }
0111 }
0112
0113
0114 void TP::fillUseForAlgEff() {
0115 useForAlgEff_ = false;
0116 if (useForEff_) {
0117 useForAlgEff_ = (countLayers() >= settings_->genMinStubLayers());
0118 }
0119 }
0120
0121 }