CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
StubKiller.cc
Go to the documentation of this file.
4 
5 using namespace std;
6 
7 namespace tmtt {
8 
9  StubKiller::StubKiller(StubKiller::KillOptions killScenario,
10  const TrackerTopology* trackerTopology,
11  const TrackerGeometry* trackerGeometry,
12  const edm::Event& event)
13  : killScenario_(killScenario),
14  trackerTopology_(trackerTopology),
15  trackerGeometry_(trackerGeometry),
16  minPhiToKill_(0),
17  maxPhiToKill_(0),
18  minZToKill_(0),
19  maxZToKill_(0),
20  minRToKill_(0),
21  maxRToKill_(0),
22  fractionOfStubsToKillInLayers_(0),
23  fractionOfStubsToKillEverywhere_(0),
24  fractionOfModulesToKillEverywhere_(0) {
25  if (rndmService_.isAvailable()) {
27  } else {
28  throw cms::Exception("BadConfig")
29  << "StubKiller: requires RandomNumberGeneratorService, not present in cfg file, namely:" << endl
30  << "process.RandomNumberGeneratorService=cms.Service('RandomNumberGeneratorService',TMTrackProducer=cms.PSet("
31  "initialSeed=cms.untracked.uint32(12345)))";
32  }
33 
34  // These scenarios correspond to slide 12 of https://indico.cern.ch/event/719985/contributions/2970687/attachments/1634587/2607365/StressTestTF-Acosta-Apr18.pdf
35  // Scenario 1
36 
37  // kill layer 5 in one quadrant +5 % random module loss to connect to what was done before
39  layersToKill_ = {5};
40  minPhiToKill_ = 0;
41  maxPhiToKill_ = 0.5 * M_PI;
42  minZToKill_ = -1000;
43  maxZToKill_ = 0;
44  minRToKill_ = 0;
45  maxRToKill_ = 1000;
49  }
50  // Scenario 2
51  // kill layer 1 in one quadrant +5 % random module loss
52  else if (killScenario_ == KillOptions::layer1) {
53  layersToKill_ = {1};
54  minPhiToKill_ = 0;
55  maxPhiToKill_ = 0.5 * M_PI;
56  minZToKill_ = -1000;
57  maxZToKill_ = 0;
58  minRToKill_ = 0;
59  maxRToKill_ = 1000;
63  }
64  // Scenario 3
65  // kill layer 1 + layer 2, both in same quadrant
67  layersToKill_ = {1, 2};
68  minPhiToKill_ = 0;
69  maxPhiToKill_ = 0.5 * M_PI;
70  minZToKill_ = -1000;
71  maxZToKill_ = 0;
72  minRToKill_ = 0;
73  maxRToKill_ = 1000;
77  }
78  // Scenario 4
79  // kill layer 1 and disk 1, both in same quadrant
81  layersToKill_ = {1, 11};
82  minPhiToKill_ = 0;
83  maxPhiToKill_ = 0.5 * M_PI;
84  minZToKill_ = -1000;
85  maxZToKill_ = 0;
86  minRToKill_ = 0;
87  maxRToKill_ = 66.5;
91  }
92  // An extra scenario not listed in the slides
93  // 5% random module loss throughout tracker
94  else if (killScenario_ == KillOptions::random) {
95  layersToKill_ = {};
99  }
100 
101  deadModules_.clear();
103  this->chooseModulesToKill();
104  }
106  }
107 
108  // Indicate if given stub was killed by dead tracker module, based on dead module scenario.
109 
112  return false;
113  else {
114  // Check if stub is in dead region specified by *ToKill_
115  // And randomly kill stubs throughout tracker (not just thos in specific regions/modules)
116  bool killStubRandomly = killStub(stub,
120  minZToKill_,
121  maxZToKill_,
122  minRToKill_,
123  maxRToKill_,
126  // Kill modules in specifid modules
127  // Random modules throughout the tracker, and those modules in specific regions (so may already have been killed by killStub above)
128  bool killStubInDeadModules = killStubInDeadModule(stub);
129  return killStubRandomly || killStubInDeadModules;
130  }
131  }
132 
133  // Indicate if given stub was killed by dead tracker module, based on specified dead regions
134  // rather than based on the dead module scenario.
135  // layersToKill - a vector stating the layers we are killing stubs in. Can be an empty vector.
136  // Barrel layers are encoded as 1-6. The endcap layers are encoded as 11-15 (-z) and 21-25 (+z)
137  // min/max Phi/Z/R - stubs within the region specified by these boundaries and layersToKill are flagged for killing
138  // fractionOfStubsToKillInLayers - The fraction of stubs to kill in the specified layers/region.
139  // fractionOfStubsToKillEverywhere - The fraction of stubs to kill throughout the tracker
140 
142  const vector<int>& layersToKill,
143  const double minPhiToKill,
144  const double maxPhiToKill,
145  const double minZToKill,
146  const double maxZToKill,
147  const double minRToKill,
148  const double maxRToKill,
149  const double fractionOfStubsToKillInLayers,
150  const double fractionOfStubsToKillEverywhere) const {
151  // Only kill stubs in specified layers
152  if (not layersToKill.empty()) {
153  // Get the layer the stub is in, and check if it's in the layer you want to kill
154  DetId stackDetid = stub->getDetId();
155  DetId geoDetId(stackDetid.rawId() + 1);
156 
157  // If this module is in the deadModule list, don't also try to kill the stub here
158  if (deadModules_.empty() || deadModules_.find(geoDetId) == deadModules_.end()) {
159  bool isInBarrel = geoDetId.subdetId() == StripSubdetector::TOB || geoDetId.subdetId() == StripSubdetector::TIB;
160 
161  int layerID = 0;
162  if (isInBarrel) {
163  layerID = trackerTopology_->layer(geoDetId);
164  } else {
165  layerID = 10 * trackerTopology_->side(geoDetId) + trackerTopology_->tidWheel(geoDetId);
166  }
167 
168  if (find(layersToKill.begin(), layersToKill.end(), layerID) != layersToKill.end()) {
169  // Get the phi and z of stub, and check if it's in the region you want to kill
170  const GeomDetUnit* det0 = trackerGeometry_->idToDetUnit(geoDetId);
171  const PixelGeomDetUnit* theGeomDet = dynamic_cast<const PixelGeomDetUnit*>(det0);
172  const PixelTopology* topol = dynamic_cast<const PixelTopology*>(&(theGeomDet->specificTopology()));
173  MeasurementPoint measurementPoint = stub->clusterRef(0)->findAverageLocalCoordinatesCentered();
174  LocalPoint clustlp = topol->localPosition(measurementPoint);
175  GlobalPoint pos = theGeomDet->surface().toGlobal(clustlp);
176 
177  double stubPhi = reco::deltaPhi(pos.phi(), 0.);
178 
179  if (stubPhi > minPhiToKill && stubPhi < maxPhiToKill && pos.z() > minZToKill && pos.z() < maxZToKill &&
180  pos.perp() > minRToKill && pos.perp() < maxRToKill) {
181  // Kill fraction of stubs
182  if (fractionOfStubsToKillInLayers == 1) {
183  return true;
184  } else {
185  if (rndmEngine_->flat() < fractionOfStubsToKillInLayers) {
186  return true;
187  }
188  }
189  }
190  }
191  }
192  }
193 
194  // Kill fraction of stubs throughout tracker
195  if (fractionOfStubsToKillEverywhere > 0) {
196  if (rndmEngine_->flat() < fractionOfStubsToKillEverywhere) {
197  return true;
198  }
199  }
200 
201  return false;
202  }
203 
204  // Indicate if given stub was in (partially) dead tracker module, based on dead module scenario.
205 
207  if (not deadModules_.empty()) {
208  DetId stackDetid = stub->getDetId();
209  DetId geoDetId(stackDetid.rawId() + 1);
210  auto deadModule = deadModules_.find(geoDetId);
211  if (deadModule != deadModules_.end()) {
212  if (deadModule->second == 1) {
213  return true;
214  } else {
215  if (rndmEngine_->flat() < deadModule->second) {
216  return true;
217  }
218  }
219  }
220  }
221 
222  return false;
223  }
224 
225  // Identify modules to be killed, chosen randomly from those in the whole tracker.
226 
228  for (const GeomDetUnit* gd : trackerGeometry_->detUnits()) {
229  if (!trackerTopology_->isLower(gd->geographicalId()))
230  continue;
232  deadModules_[gd->geographicalId()] = 1;
233  }
234  }
235  }
236 
237  // Identify modules to be killed, chosen based on location in tracker.
238 
240  for (const GeomDetUnit* gd : trackerGeometry_->detUnits()) {
241  float moduleR = gd->position().perp();
242  float moduleZ = gd->position().z();
243  float modulePhi = reco::deltaPhi(gd->position().phi(), 0.);
244  DetId geoDetId = gd->geographicalId();
245  bool isInBarrel = geoDetId.subdetId() == StripSubdetector::TOB || geoDetId.subdetId() == StripSubdetector::TIB;
246 
247  int layerID = 0;
248  if (isInBarrel) {
249  layerID = trackerTopology_->layer(geoDetId);
250  } else {
251  layerID = 10 * trackerTopology_->side(geoDetId) + trackerTopology_->tidWheel(geoDetId);
252  }
253  if (find(layersToKill_.begin(), layersToKill_.end(), layerID) != layersToKill_.end()) {
254  if (modulePhi > minPhiToKill_ && modulePhi < maxPhiToKill_ && moduleZ > minZToKill_ && moduleZ < maxZToKill_ &&
255  moduleR > minRToKill_ && moduleR < maxRToKill_) {
256  if (deadModules_.find(gd->geographicalId()) == deadModules_.end()) {
257  deadModules_[gd->geographicalId()] = fractionOfStubsToKillInLayers_;
258  }
259  }
260  }
261  }
262  }
263 }; // namespace tmtt
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
bool killStub(const TTStub< Ref_Phase2TrackerDigi_ > *stub) const
Definition: StubKiller.cc:110
double minPhiToKill_
Definition: StubKiller.h:62
const TrackerGeometry * trackerGeometry_
Definition: StubKiller.h:59
double fractionOfModulesToKillEverywhere_
Definition: StubKiller.h:70
T perp() const
Definition: PV3DBase.h:69
double maxPhiToKill_
Definition: StubKiller.h:63
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
KillOptions killScenario_
Definition: StubKiller.h:57
CLHEP::HepRandomEngine * rndmEngine_
Definition: StubKiller.h:75
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
bool killStubInDeadModule(const TTStub< Ref_Phase2TrackerDigi_ > *stub) const
Definition: StubKiller.cc:206
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
unsigned int side(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
DetId getDetId() const
Detector element.
Definition: TTStub.h:44
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
double fractionOfStubsToKillInLayers_
Definition: StubKiller.h:68
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
bool isLower(const DetId &id) const
std::map< DetId, float > deadModules_
Definition: StubKiller.h:72
void addDeadLayerModulesToDeadModuleList()
Definition: StubKiller.cc:239
T z() const
Definition: PV3DBase.h:61
std::vector< int > layersToKill_
Definition: StubKiller.h:61
bool isAvailable() const
Definition: Service.h:40
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
static constexpr auto TOB
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
double minRToKill_
Definition: StubKiller.h:66
#define M_PI
const edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > & clusterRef(unsigned int hitStackMember) const
Clusters composing the Stub – see https://twiki.cern.ch/twiki/bin/viewauth/CMS/SLHCTrackerTriggerSWTo...
Definition: TTStub.h:150
Definition: DetId.h:17
const TrackerTopology * trackerTopology_
Definition: StubKiller.h:58
static constexpr auto TIB
double fractionOfStubsToKillEverywhere_
Definition: StubKiller.h:69
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
void chooseModulesToKill()
Definition: StubKiller.cc:227
unsigned int layer(const DetId &id) const
StreamID streamID() const
Definition: Event.h:98
double minZToKill_
Definition: StubKiller.h:64
edm::Service< edm::RandomNumberGenerator > rndmService_
Definition: StubKiller.h:74
double maxZToKill_
Definition: StubKiller.h:65
double maxRToKill_
Definition: StubKiller.h:67