CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
IsoDepositVetoFactory.cc
Go to the documentation of this file.
2 
5 #include <regex>
6 
7 // ---------- FIRST DEFINE NEW VETOS ------------
8 namespace reco {
9  namespace isodeposit {
10 
11  class SwitchingEcalVeto : public AbsVeto {
12  public:
13  // creates SwitchingEcalVeto from another AbsVeto (which becomes owned by this veto)
15  bool veto(double eta, double phi, float value) const override {
16  return (fabs(eta) < 1.479) == (barrel_) ? veto_->veto(eta, phi, value) : false;
17  }
18  void centerOn(double eta, double phi) override { veto_->centerOn(eta, phi); }
19 
20  private:
21  std::unique_ptr<AbsVeto> veto_;
22  bool barrel_;
23  };
24 
25  class NumCrystalVeto : public AbsVeto {
26  public:
27  NumCrystalVeto(Direction dir, double iR) : vetoDir_(dir), iR_(iR) {}
28  bool veto(double eta, double phi, float value) const override {
29  if (fabs(vetoDir_.eta()) < 1.479) {
30  return (vetoDir_.deltaR(Direction(eta, phi)) < 0.0174 * iR_);
31  } else {
32  return (vetoDir_.deltaR(Direction(eta, phi)) < 0.00864 * fabs(sinh(eta)) * iR_);
33  }
34  }
35  void centerOn(double eta, double phi) override { vetoDir_ = Direction(eta, phi); }
36 
37  private:
39  float iR_;
40  };
41 
42  class NumCrystalEtaPhiVeto : public AbsVeto {
43  public:
44  NumCrystalEtaPhiVeto(const math::XYZVectorD &dir, double iEta, double iPhi)
45  : vetoDir_(dir.eta(), dir.phi()), iEta_(iEta), iPhi_(iPhi) {}
46  NumCrystalEtaPhiVeto(Direction dir, double iEta, double iPhi)
47  : vetoDir_(dir.eta(), dir.phi()), iEta_(iEta), iPhi_(iPhi) {}
48  bool veto(double eta, double phi, float value) const override {
49  double dPhi = phi - vetoDir_.phi();
50  double dEta = eta - vetoDir_.eta();
51  while (dPhi < -M_PI)
52  dPhi += 2 * M_PI;
53  while (dPhi >= M_PI)
54  dPhi -= 2 * M_PI;
55  if (fabs(vetoDir_.eta()) < 1.479) {
56  return ((fabs(dEta) < 0.0174 * iEta_) && (fabs(dPhi) < 0.0174 * iPhi_));
57  } else {
58  return ((fabs(dEta) < 0.00864 * fabs(sinh(eta)) * iEta_) && (fabs(dPhi) < 0.00864 * fabs(sinh(eta)) * iPhi_));
59  }
60  }
61  void centerOn(double eta, double phi) override { vetoDir_ = Direction(eta, phi); }
62 
63  private:
65  double iEta_, iPhi_;
66  };
67 
68  } // namespace isodeposit
69 } // namespace reco
70 
71 // ---------- THEN THE ACTUAL FACTORY CODE ------------
74  std::unique_ptr<reco::isodeposit::AbsVeto> ret(make(string, evdep, iC));
75  if (evdep != nullptr) {
76  throw cms::Exception("Configuration") << "The resulting AbsVeto depends on the edm::Event.\n"
77  << "Please use the two-arguments IsoDepositVetoFactory::make.\n";
78  }
79  return ret.release();
80 }
81 
85  using namespace reco::isodeposit;
86  static const std::regex ecalSwitch("^Ecal(Barrel|Endcaps):(.*)"), threshold("Threshold\\((\\d+\\.\\d+)\\)"),
87  thresholdtransverse("ThresholdFromTransverse\\((\\d+\\.\\d+)\\)"),
88  absthreshold("AbsThreshold\\((\\d+\\.\\d+)\\)"),
89  absthresholdtransverse("AbsThresholdFromTransverse\\((\\d+\\.\\d+)\\)"), cone("ConeVeto\\((\\d+\\.\\d+)\\)"),
90  angleCone("AngleCone\\((\\d+\\.\\d+)\\)"), angleVeto("AngleVeto\\((\\d+\\.\\d+)\\)"),
91  rectangularEtaPhiVeto(
92  "RectangularEtaPhiVeto\\(([+-]?\\d+\\.\\d+),([+-]?\\d+\\.\\d+),([+-]?\\d+\\.\\d+),([+-]?\\d+\\.\\d+)\\)"),
93  numCrystal("NumCrystalVeto\\((\\d+\\.\\d+)\\)"),
94  numCrystalEtaPhi("NumCrystalEtaPhiVeto\\((\\d+\\.\\d+),(\\d+\\.\\d+)\\)"),
95  otherCandidatesDR("OtherCandidatesByDR\\((\\w+:?\\w*:?\\w*),\\s*(\\d+\\.?|\\d*\\.\\d*)\\)"),
96  otherJetConstituentsDR(
97  "OtherJetConstituentsDeltaRVeto\\((\\w+:?\\w*:?\\w*),\\s*(\\d+\\.?|\\d*\\.\\d*),\\s*(\\w+:?\\w*:?\\w*),\\s*("
98  "\\d+\\.?|\\d*\\.\\d*)\\)"),
99  otherCand("^(.*?):(.*)"), number("^(\\d+\\.?|\\d*\\.\\d*)$");
100  std::cmatch match;
101 
102  evdep = nullptr; // by default it does not depend on this
103  if (regex_match(string, match, ecalSwitch)) {
104  return new SwitchingEcalVeto(make(match[2].first, iC), (match[1] == "Barrel"));
105  } else if (regex_match(string, match, threshold)) {
106  return new ThresholdVeto(atof(match[1].first));
107  } else if (regex_match(string, match, thresholdtransverse)) {
108  return new ThresholdVetoFromTransverse(atof(((std::string)match[1]).c_str()));
109  } else if (regex_match(string, match, absthreshold)) {
110  return new AbsThresholdVeto(atof(match[1].first));
111  } else if (regex_match(string, match, absthresholdtransverse)) {
112  return new AbsThresholdVetoFromTransverse(atof(((std::string)match[1]).c_str()));
113  } else if (regex_match(string, match, cone)) {
114  return new ConeVeto(Direction(), atof(match[1].first));
115  } else if (regex_match(string, match, number)) {
116  return new ConeVeto(Direction(), atof(match[1].first));
117  } else if (regex_match(string, match, angleCone)) {
118  return new AngleCone(Direction(), atof(match[1].first));
119  } else if (regex_match(string, match, angleVeto)) {
120  return new AngleConeVeto(Direction(), atof(match[1].first));
121  } else if (regex_match(string, match, rectangularEtaPhiVeto)) {
122  return new RectangularEtaPhiVeto(
123  Direction(), atof(match[1].first), atof(match[2].first), atof(match[3].first), atof(match[4].first));
124  } else if (regex_match(string, match, numCrystal)) {
125  return new NumCrystalVeto(Direction(), atof(match[1].first));
126  } else if (regex_match(string, match, numCrystalEtaPhi)) {
127  return new NumCrystalEtaPhiVeto(Direction(), atof(match[1].first), atof(match[2].first));
128  } else if (regex_match(string, match, otherCandidatesDR)) {
130  evdep = ret;
131  return ret;
132  } else if (regex_match(string, match, otherJetConstituentsDR)) {
134  Direction(), edm::InputTag(match[1]), atof(match[2].first), edm::InputTag(match[3]), atof(match[4].first), iC);
135  evdep = ret;
136  return ret;
137  } else if (regex_match(string, match, otherCand)) {
139  evdep = ret;
140  return ret;
141  } else {
142  throw cms::Exception("Not Implemented") << "Veto " << string << " not implemented yet...";
143  }
144 }
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:543
reco::isodeposit::NumCrystalVeto::NumCrystalVeto
NumCrystalVeto(Direction dir, double iR)
Definition: IsoDepositVetoFactory.cc:27
reco::isodeposit::SwitchingEcalVeto::centerOn
void centerOn(double eta, double phi) override
Definition: IsoDepositVetoFactory.cc:18
reco::isodeposit::AbsThresholdVetoFromTransverse
Definition: IsoDepositVetos.h:51
IsoDepositVetos.h
reco::isodeposit::AngleConeVeto
Definition: IsoDepositVetos.h:74
reco::isodeposit::NumCrystalEtaPhiVeto::veto
bool veto(double eta, double phi, float value) const override
Return "true" if a deposit at specific (eta,phi) with that value must be vetoed in the sum.
Definition: IsoDepositVetoFactory.cc:48
reco::isodeposit::NumCrystalVeto
Definition: IsoDepositVetoFactory.cc:25
EventDependentAbsVetos.h
IsoDepositVetoFactory.h
reco::isodeposit::RectangularEtaPhiVeto
Definition: IsoDepositVetos.h:98
reco::isodeposit::AbsVeto
Definition: IsoDeposit.h:32
reco::isodeposit::AbsThresholdVeto
Definition: IsoDepositVetos.h:41
reco::isodeposit::SwitchingEcalVeto::SwitchingEcalVeto
SwitchingEcalVeto(AbsVeto *veto, bool isBarrel)
Definition: IsoDepositVetoFactory.cc:14
reco::isodeposit::Direction::eta
double eta() const
Definition: IsoDepositDirection.h:34
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
HLT_FULL_cff.dPhi
dPhi
Definition: HLT_FULL_cff.py:13695
reco::isodeposit::SwitchingEcalVeto::veto_
std::unique_ptr< AbsVeto > veto_
Definition: IsoDepositVetoFactory.cc:21
reco::isodeposit::NumCrystalEtaPhiVeto::vetoDir_
Direction vetoDir_
Definition: IsoDepositVetoFactory.cc:64
reco::isodeposit::ConeVeto
Definition: IsoDepositVetos.h:9
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
reco::isodeposit
Definition: IsoDeposit.h:31
reco::isodeposit::NumCrystalVeto::vetoDir_
Direction vetoDir_
Definition: IsoDepositVetoFactory.cc:38
PVValHelper::eta
Definition: PVValidationHelpers.h:70
reco::isodeposit::NumCrystalVeto::veto
bool veto(double eta, double phi, float value) const override
Return "true" if a deposit at specific (eta,phi) with that value must be vetoed in the sum.
Definition: IsoDepositVetoFactory.cc:28
reco::isodeposit::NumCrystalEtaPhiVeto::iEta_
double iEta_
Definition: IsoDepositVetoFactory.cc:65
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
math::XYZVectorD
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
PixelPluginsPhase0_cfi.isBarrel
isBarrel
Definition: PixelPluginsPhase0_cfi.py:17
reco::isodeposit::SwitchingEcalVeto::veto
bool veto(double eta, double phi, float value) const override
Return "true" if a deposit at specific (eta,phi) with that value must be vetoed in the sum.
Definition: IsoDepositVetoFactory.cc:15
reco::isodeposit::SwitchingEcalVeto::barrel_
bool barrel_
Definition: IsoDepositVetoFactory.cc:22
reco::isodeposit::Direction::deltaR
double deltaR(const Direction &dir2) const
Definition: IsoDepositDirection.h:47
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
reco::isodeposit::NumCrystalEtaPhiVeto::NumCrystalEtaPhiVeto
NumCrystalEtaPhiVeto(const math::XYZVectorD &dir, double iEta, double iPhi)
Definition: IsoDepositVetoFactory.cc:44
value
Definition: value.py:1
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
reco::isodeposit::OtherJetConstituentsDeltaRVeto
Definition: EventDependentAbsVetos.h:64
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::isodeposit::ThresholdVeto
Definition: IsoDepositVetos.h:21
reco::isodeposit::AngleCone
Definition: IsoDepositVetos.h:86
reco::isodeposit::NumCrystalEtaPhiVeto
Definition: IsoDepositVetoFactory.cc:42
reco::isodeposit::NumCrystalEtaPhiVeto::iPhi_
double iPhi_
Definition: IsoDepositVetoFactory.cc:65
reco::isodeposit::NumCrystalVeto::iR_
float iR_
Definition: IsoDepositVetoFactory.cc:39
HLT_FULL_cff.dEta
dEta
Definition: HLT_FULL_cff.py:13694
reco::isodeposit::Direction
Definition: IsoDepositDirection.h:19
reco::isodeposit::SwitchingEcalVeto
Definition: IsoDepositVetoFactory.cc:11
reco::isodeposit::NumCrystalEtaPhiVeto::NumCrystalEtaPhiVeto
NumCrystalEtaPhiVeto(Direction dir, double iEta, double iPhi)
Definition: IsoDepositVetoFactory.cc:46
Exception
Definition: hltDiff.cc:245
reco::isodeposit::NumCrystalVeto::centerOn
void centerOn(double eta, double phi) override
Definition: IsoDepositVetoFactory.cc:35
reco::isodeposit::ThresholdVetoFromTransverse
Definition: IsoDepositVetos.h:31
L1TowerCalibrationProducer_cfi.iEta
iEta
Definition: L1TowerCalibrationProducer_cfi.py:60
reco::isodeposit::OtherCandVeto
Definition: EventDependentAbsVetos.h:39
IsoDepositVetoFactory::make
static reco::isodeposit::AbsVeto * make(const char *string, edm::ConsumesCollector &iC)
Definition: IsoDepositVetoFactory.cc:72
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:430
reco::isodeposit::NumCrystalEtaPhiVeto::centerOn
void centerOn(double eta, double phi) override
Definition: IsoDepositVetoFactory.cc:61
reco::isodeposit::OtherCandidatesDeltaRVeto
Definition: EventDependentAbsVetos.h:14
reco::isodeposit::EventDependentAbsVeto
Definition: EventDependentAbsVeto.h:10
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
reco::isodeposit::Direction::phi
double phi() const
Definition: IsoDepositDirection.h:35
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23