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 {
16  return (fabs(eta) < 1.479) == (barrel_) ? veto_->veto(eta,phi,value) : false;
17  }
18  virtual void centerOn(double eta, double phi) {
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 {
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) { vetoDir_ = Direction(eta,phi); }
37  private:
39  };
40 
41  class NumCrystalEtaPhiVeto : public AbsVeto {
42  public:
43  NumCrystalEtaPhiVeto(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 {
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) { vetoDir_ = Direction(eta,phi); }
64  private:
66  double iEta_, iPhi_;
67  };
68 
69 } }
70 
71 // ---------- THEN THE ACTUAL FACTORY CODE ------------
73 IsoDepositVetoFactory::make(const char *string) {
75  std::auto_ptr<reco::isodeposit::AbsVeto> ret(make(string,evdep));
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  otherCand("^(.*?):(.*)"),
100  number("^(\\d+\\.?|\\d*\\.\\d*)$");
101  boost::cmatch match;
102 
103  evdep = 0; // by default it does not depend on this
104  if (regex_match(string, match, ecalSwitch)) {
105  return new SwitchingEcalVeto(make(match[2].first), (match[1] == "Barrel") );
106  } else if (regex_match(string, match, threshold)) {
107  return new ThresholdVeto(atof(match[1].first));
108  } else if (regex_match(string, match, thresholdtransverse)) {
109  return new ThresholdVetoFromTransverse(atof(((std::string)match[1]).c_str()));
110  } else if (regex_match(string, match, absthreshold)) {
111  return new AbsThresholdVeto(atof(match[1].first));
112  } else if (regex_match(string, match, absthresholdtransverse)) {
113  return new AbsThresholdVetoFromTransverse(atof(((std::string)match[1]).c_str()));
114  } else if (regex_match(string, match, cone)) {
115  return new ConeVeto(Direction(), atof(match[1].first));
116  } else if (regex_match(string, match, number)) {
117  return new ConeVeto(Direction(), atof(match[1].first));
118  } else if (regex_match(string, match, angleCone)) {
119  return new AngleCone(Direction(), atof(match[1].first));
120  } else if (regex_match(string, match, angleVeto)) {
121  return new AngleConeVeto(Direction(), atof(match[1].first));
122  } else if (regex_match(string, match, rectangularEtaPhiVeto)) {
123  return new RectangularEtaPhiVeto(Direction(),
124  atof(match[1].first), atof(match[2].first),
125  atof(match[3].first), atof(match[4].first));
126  } else if (regex_match(string, match, numCrystal)) {
127  return new NumCrystalVeto(Direction(), atof(match[1].first));
128  } else if (regex_match(string, match, numCrystalEtaPhi)) {
129  return new NumCrystalEtaPhiVeto(Direction(),atof(match[1].first),atof(match[2].first));
130  } else if (regex_match(string, match, otherCandidatesDR)) {
132  atof(match[2].first));
133  evdep = ret;
134  return ret;
135  } else if (regex_match(string, match, otherCand)) {
137  make(match[2].first));
138  evdep = ret;
139  return ret;
140  } else {
141  throw cms::Exception("Not Implemented") << "Veto " << string << " not implemented yet...";
142  }
143 }
virtual void centerOn(double eta, double phi)
virtual bool veto(double eta, double phi, float value) const
Return &quot;true&quot; if a deposit at specific (eta,phi) with that value must be vetoed in the sum...
virtual void centerOn(double eta, double phi)
NumCrystalEtaPhiVeto(math::XYZVectorD dir, double iEta, double iPhi)
T eta() const
virtual void centerOn(double eta, double phi)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:9
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
virtual bool veto(double eta, double phi, float value) const
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:94
NumCrystalEtaPhiVeto(Direction dir, double iEta, double iPhi)
virtual bool veto(double eta, double phi, float value) const
Return &quot;true&quot; if a deposit at specific (eta,phi) with that value must be vetoed in the sum...
#define M_PI
Definition: BFit3D.cc:3
static reco::isodeposit::AbsVeto * make(const char *string)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
dbl *** dir
Definition: mlp_gen.cc:35
NumCrystalVeto(Direction dir, double iR)
SwitchingEcalVeto(AbsVeto *veto, bool isBarrel)
double deltaR(const Direction &dir2) const
Definition: DDAxes.h:10