CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions
RPCConeBuilderFromES Class Reference

#include <L1Trigger/RPCTrigger/interface/RPCConeBuilderFromES.h>

Public Member Functions

L1RpcLogConesVec getConesFromES (edm::Handle< RPCDigiCollection > rpcDigis, edm::ESHandle< L1RPCConeBuilder > coneBuilder, edm::ESHandle< L1RPCConeDefinition > coneDef, edm::ESHandle< L1RPCBxOrConfig > bxOrDef, edm::ESHandle< L1RPCHwConfig > hwConfig, int bx)
 
 RPCConeBuilderFromES ()
 
virtual ~RPCConeBuilderFromES ()
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 41 of file RPCConeBuilderFromES.h.

Constructor & Destructor Documentation

RPCConeBuilderFromES::RPCConeBuilderFromES ( )

Definition at line 29 of file RPCConeBuilderFromES.cc.

29 {}
RPCConeBuilderFromES::~RPCConeBuilderFromES ( )
virtual

Definition at line 36 of file RPCConeBuilderFromES.cc.

36 {}

Member Function Documentation

L1RpcLogConesVec RPCConeBuilderFromES::getConesFromES ( edm::Handle< RPCDigiCollection rpcDigis,
edm::ESHandle< L1RPCConeBuilder coneBuilder,
edm::ESHandle< L1RPCConeDefinition coneDef,
edm::ESHandle< L1RPCBxOrConfig bxOrDef,
edm::ESHandle< L1RPCHwConfig hwConfig,
int  bx 
)

Definition at line 38 of file RPCConeBuilderFromES.cc.

References makePileupJSON::bx, mps_fire::i, mathSSE::lh, sistrip::SpyUtilities::range(), DetId::rawId(), RPCLogHit::setDigiIdx(), and RPCLogCone::setIdx().

Referenced by RPCTrigger::produce().

43  {
44  std::vector<RPCLogHit> logHits;
45  std::vector<RPCLogHit> logHitsFromUncomp;
46 
47  // Build cones from digis
48  // first build loghits
49 
50  short int digiIndex = 0;
52  for (detUnitIt = rpcDigis->begin(); detUnitIt != rpcDigis->end(); ++detUnitIt) {
53  const RPCDetId& id = (*detUnitIt).first;
54 
55  uint32_t rawId = id.rawId();
56 
57  const RPCDigiCollection::Range& range = (*detUnitIt).second;
58 
59  std::pair<L1RPCConeBuilder::TCompressedConVec::const_iterator, L1RPCConeBuilder::TCompressedConVec::const_iterator>
60  compressedConnPair = coneBuilder->getCompConVec(rawId);
61 
62  // iterate over strips
63  for (RPCDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
64  ++digiIndex;
65  if (digiIt->bx() < bxOrDef->getFirstBX() + bx || digiIt->bx() > bxOrDef->getLastBX() + bx) {
66  //if ( digiIt->bx() < hwConfig->getFirstBX() + bx || digiIt->bx() > hwConfig->getLastBX() +bx ){
67  continue;
68  }
69 
70  //std::cout << digiIt->bx() << " D " << rawId << " " << id << " S " << digiIt->strip() << std::endl;
71  // for uncompressed connections
72  std::pair<L1RPCConeBuilder::TStripConVec::const_iterator, L1RPCConeBuilder::TStripConVec::const_iterator> itPair =
73  coneBuilder->getConVec(rawId, digiIt->strip());
74 
75  L1RPCConeBuilder::TStripConVec::const_iterator it = itPair.first;
76  // Iterate over uncompressed connections, convert digis to logHits
77  for (; it != itPair.second; ++it) {
78  //std::cout << " Not empty!" << std::endl;
79  if (hwConfig->isActive(it->m_tower, it->m_PAC)) {
80  RPCLogHit lh(it->m_tower, it->m_PAC, it->m_logplane, it->m_logstrip);
81  lh.setDigiIdx(digiIndex);
82  logHitsFromUncomp.push_back(lh);
83  }
84  }
85 
86  /*
87  bool printOut = false;
88  if (digiIt->strip() == 62 || digiIt->strip() == 63 ){
89  std::cout << "Strip " << digiIt->strip() << std::endl;
90  printOut = true;
91  }
92  */
93 
94  L1RPCConeBuilder::TCompressedConVec::const_iterator itComp = compressedConnPair.first;
95  for (; itComp != compressedConnPair.second; ++itComp) {
96  if (hwConfig->isActive(itComp->m_tower, itComp->m_PAC)) {
97  int logstrip = itComp->getLogStrip(digiIt->strip(), coneDef->getLPSizeVec());
98  if (logstrip != -1) {
99  RPCLogHit lh(itComp->m_tower, itComp->m_PAC, itComp->m_logplane, logstrip);
100  lh.setDigiIdx(digiIndex);
101  logHits.push_back(lh);
102  }
103  /*
104  if (printOut){
105  std::cout << "T " << (int)itComp->m_tower << " P "
106  << (int)itComp->m_PAC << " LP "
107  << (int)itComp->m_logplane << " LS "
108  << (int)logstrip << std::endl;
109  }*/
110  }
111  }
112 
113  } // strip iteration ends
114  }
115 
116  // check if we dont have any preferable uncompressed loghits
117  std::vector<RPCLogHit>::iterator itLHitUncomp = logHitsFromUncomp.begin();
118  std::vector<RPCLogHit>::iterator itLHitComp;
119 
120  // overwrite uncompressed with those coming from compressed
121  for (; itLHitUncomp != logHitsFromUncomp.end(); ++itLHitUncomp) {
122  for (itLHitComp = logHits.begin(); itLHitComp != logHits.end(); ++itLHitComp) {
123  if (itLHitComp->getTower() == itLHitUncomp->getTower() &&
124  itLHitComp->getLogSector() == itLHitUncomp->getLogSector() &&
125  itLHitComp->getLogSegment() == itLHitUncomp->getLogSegment() &&
126  itLHitComp->getlogPlaneNumber() == itLHitUncomp->getlogPlaneNumber()) {
127  // std::cout<< "Overwrite " << std::endl;
128  //std::cout.flush();
129  *itLHitUncomp = *itLHitComp;
130  }
131  }
132  }
133 
134  // copy missing from compressed to uncompressed
135  for (; itLHitUncomp != logHitsFromUncomp.end(); ++itLHitUncomp) {
136  bool present = false;
137  for (unsigned int i = 0; i < logHits.size(); ++i) {
138  if (logHits[i].getTower() == itLHitUncomp->getTower() &&
139  logHits[i].getLogSector() == itLHitUncomp->getLogSector() &&
140  logHits[i].getLogSegment() == itLHitUncomp->getLogSegment() &&
141  logHits[i].getlogPlaneNumber() == itLHitUncomp->getlogPlaneNumber()) {
142  present = true;
143  }
144  }
145  if (!present) {
146  // std::cout<< "Copy " << std::endl;
147  //std::cout.flush();
148 
149  logHits.push_back(*itLHitUncomp);
150  }
151  }
152 
153  // build cones
154  L1RpcLogConesVec ActiveCones;
155 
156  std::vector<RPCLogHit>::iterator p_lhit;
157  for (p_lhit = logHits.begin(); p_lhit != logHits.end(); ++p_lhit) {
158  bool hitTaken = false;
159  L1RpcLogConesVec::iterator p_cone;
160  for (p_cone = ActiveCones.begin(); p_cone != ActiveCones.end(); p_cone++) {
161  hitTaken = p_cone->addLogHit(*p_lhit);
162  if (hitTaken)
163  break;
164  }
165 
166  if (!hitTaken) {
167  RPCLogCone newcone(*p_lhit);
168  newcone.setIdx(ActiveCones.size());
169  ActiveCones.push_back(newcone);
170  }
171  } // for loghits
172 
173  /*
174  for (int tower = -16; tower<17;++tower)
175  {
176  for (int sector = 0; sector<12;++sector)
177  {
178  for (int segment = 0; segment<12;++segment)
179  {
180  for (L1RpcLogConesVec::iterator it = ActiveCones.begin(); it!=ActiveCones.end(); ++it)
181  {
182  if (it->getTower()==tower
183  && it->getLogSector()==sector
184  && it->getLogSegment()==segment)
185  {
186  std::cout << it->toString() << std::endl;
187  }
188  }
189  }
190  }
191  }
192  // */
193 
194  return ActiveCones;
195 }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
bool int lh
Definition: SIMDVec.h:20
const uint16_t range(const Frame &aFrame)
std::pair< const_iterator, const_iterator > Range
std::vector< RPCDigi >::const_iterator const_iterator
std::vector< RPCLogCone > L1RpcLogConesVec
Definition: RPCLogCone.h:119