CMS 3D CMS Logo

CandidateGroup.cc
Go to the documentation of this file.
2 
3 #include <iostream>
4 #include <memory>
5 
6 using namespace dtbayesam;
7 
8 //------------------------------------------------------------------
9 //--- Constructores y destructores
10 //------------------------------------------------------------------
12  nhits_ = 0;
13  nLayerhits_ = 0;
14  nisGood_ = 0;
15  nLayerDown_ = 0;
16  nLayerUp_ = 0;
17  pattern_ = p;
18 }
19 
21 
23 
24 void CandidateGroup::addHit(DTPrimitive dthit, int lay, bool isGood) {
25  //Add a hit, check if the hits layer was fired and if it wasn't add it to the fired layers
26  candHits_.push_back(std::make_shared<DTPrimitive>(dthit));
27  if (quality_ != (quality_ | qualitybits(std::pow(2, lay))))
28  nLayerhits_++;
29  if (isGood)
30  nisGood_++;
32  nhits_++;
33  if (lay <= 3)
34  nLayerDown_++;
35  if (lay >= 4)
36  nLayerUp_++;
37 }
38 
40  //Add a hit, check if the hits layer was fired and if it wasn't add it to the fired layers
41  DTPrimitivePtrs tempHits;
42  nhits_ = 0;
43  nLayerDown_ = 0;
44  nLayerUp_ = 0;
45  nLayerhits_ = 0;
46  nisGood_ = 0;
47  quality_ = qualitybits("00000000");
48  for (auto dt_it = candHits_.begin(); dt_it != candHits_.end(); dt_it++) {
49  if (dthit.layerId() == (*dt_it)->layerId() && dthit.channelId() == (*dt_it)->channelId()) {
50  } else {
51  if (pattern_->latHitIn((*dt_it)->layerId(), (*dt_it)->channelId(), 0) > -5)
52  nisGood_++;
53  if (quality_ != (quality_ | qualitybits(std::pow(2, (*dt_it)->layerId()))))
54  nLayerhits_++;
55  quality_ = quality_ | qualitybits(std::pow(2, (*dt_it)->layerId()));
56  nhits_++;
57  if ((*dt_it)->layerId() <= 3)
58  nLayerDown_++;
59  else if ((*dt_it)->layerId() >= 4)
60  nLayerUp_++;
61  tempHits.push_back(*dt_it);
62  }
63  }
64  candHits_ = tempHits;
65 }
66 
67 bool CandidateGroup::operator>(const CandidateGroup& cOther) const {
68  //First number of good (in pattern) matched hits
69  if (nisGood_ > cOther.nisGood())
70  return true;
71  else if (nisGood_ < cOther.nisGood())
72  return false;
73  //Tehn quality_ is number of layers fired
74  else if (nLayerhits_ > cOther.nLayerhits())
75  return true;
76  else if (nLayerhits_ < cOther.nLayerhits())
77  return false;
78  //Then number of matched hits (if multiple hits in a layer is better)
79  else if (nhits_ > cOther.nhits())
80  return true;
81  else if (nhits_ < cOther.nhits())
82  return false;
83  //Balanced quality_, prefer 3+2 over 4+1 for example
84  else if ((nLayerUp_ - nLayerDown_) > (cOther.nLayerUp() - cOther.nLayerDown()))
85  return true;
86  else if ((nLayerUp_ - nLayerDown_) < (cOther.nLayerUp() - cOther.nLayerDown()))
87  return false;
88  //Last, patterns with less gen hits are better matched
89  else if (pattern_->genHits().size() < (cOther.pattern()->genHits().size()))
90  return true;
91  else if (pattern_->genHits().size() > (cOther.pattern()->genHits().size()))
92  return false;
93  //For a total order relation we need this additional dummy
94  else if (candId_ < cOther.candId())
95  return true;
96  else if (candId_ > cOther.candId())
97  return false;
98 
99  //If we are here, they are basically equal so it doesn't matter who goes first
100  return true;
101 }
102 
103 bool CandidateGroup::operator==(const CandidateGroup& cOther) const {
104  //First number of good hits
105  if (nisGood_ != cOther.nisGood())
106  return false;
107  //First quality_ is number of layers fired
108  else if (nLayerhits_ != cOther.nLayerhits())
109  return false;
110  //Then number of matched hits (if multiple hits in a layer is better)
111  else if (nhits_ != cOther.nhits())
112  return false;
113  //Balanced quality_, prefer 3+2 over 4+1 for example
114  else if ((nLayerUp_ - nLayerDown_) != (cOther.nLayerUp() - cOther.nLayerDown()))
115  return false;
116  //Last, patterns with less gen hits are better matched
117  return true;
118 }
DTPattern::latHitIn
int latHitIn(int slId, int chId, int allowedVariance) const
Definition: DTPattern.cc:38
dtbayesam::CandidateGroup::candHits_
DTPrimitivePtrs candHits_
Definition: CandidateGroup.h:47
dtbayesam::qualitybits
std::bitset< 8 > qualitybits
Definition: CandidateGroup.h:15
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
dtbayesam::CandidateGroup::nhits_
int nhits_
Definition: CandidateGroup.h:49
DTPrimitive::channelId
const int channelId() const
Definition: DTprimitive.h:34
dtbayesam::CandidateGroup::nLayerDown
int nLayerDown() const
Definition: CandidateGroup.h:34
dtbayesam::CandidateGroup::nLayerUp
int nLayerUp() const
Definition: CandidateGroup.h:33
dtbayesam::CandidateGroup::removeHit
void removeHit(DTPrimitive dthit)
Definition: CandidateGroup.cc:39
DTPattern
Definition: DTPattern.h:15
dtbayesam::CandidateGroup::nhits
int nhits() const
Definition: CandidateGroup.h:30
DTPrimitive::layerId
const int layerId() const
Definition: DTprimitive.h:35
dtbayesam::CandidateGroup::~CandidateGroup
~CandidateGroup()
Definition: CandidateGroup.cc:22
dtbayesam::CandidateGroup::addHit
void addHit(DTPrimitive dthit, int lay, bool isGood)
Definition: CandidateGroup.cc:24
DTPrimitive
Definition: DTprimitive.h:9
dtbayesam
Definition: CandidateGroup.h:13
CandidateGroup.h
dtbayesam::CandidateGroup::nLayerDown_
int nLayerDown_
Definition: CandidateGroup.h:52
dtbayesam::CandidateGroup::pattern
const DTPattern * pattern() const
Definition: CandidateGroup.h:37
dtbayesam::CandidateGroup
Definition: CandidateGroup.h:17
dtbayesam::CandidateGroup::operator>
bool operator>(const CandidateGroup &cOther) const
Definition: CandidateGroup.cc:67
dtbayesam::CandidateGroup::candId_
int candId_
Definition: CandidateGroup.h:55
dtbayesam::CandidateGroup::quality_
qualitybits quality_
Definition: CandidateGroup.h:48
dtbayesam::CandidateGroup::CandidateGroup
CandidateGroup()
Definition: CandidateGroup.cc:20
dtbayesam::CandidateGroup::operator==
bool operator==(const CandidateGroup &cOther) const
Definition: CandidateGroup.cc:103
dtbayesam::CandidateGroup::candId
int candId() const
Definition: CandidateGroup.h:29
dtbayesam::CandidateGroup::nisGood
int nisGood() const
Definition: CandidateGroup.h:31
dtbayesam::CandidateGroup::nLayerhits
int nLayerhits() const
Definition: CandidateGroup.h:32
dtbayesam::CandidateGroup::nisGood_
int nisGood_
Definition: CandidateGroup.h:53
dtbayesam::CandidateGroup::pattern_
DTPattern * pattern_
Definition: CandidateGroup.h:54
DTPattern::genHits
const std::vector< RefDTPatternHit > & genHits() const
Definition: DTPattern.h:43
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
dtbayesam::CandidateGroup::nLayerhits_
int nLayerhits_
Definition: CandidateGroup.h:50
DTPrimitivePtrs
std::vector< DTPrimitivePtr > DTPrimitivePtrs
Definition: DTprimitive.h:55
dtbayesam::CandidateGroup::nLayerUp_
int nLayerUp_
Definition: CandidateGroup.h:51