CMS 3D CMS Logo

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