CMS 3D CMS Logo

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 43 of file RPCConeBuilderFromES.h.

Constructor & Destructor Documentation

RPCConeBuilderFromES::RPCConeBuilderFromES ( )

Definition at line 30 of file RPCConeBuilderFromES.cc.

31 {
32 }
RPCConeBuilderFromES::~RPCConeBuilderFromES ( )
virtual

Definition at line 39 of file RPCConeBuilderFromES.cc.

40 {
41 }

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 43 of file RPCConeBuilderFromES.cc.

References L1RPCConeBuilder::getCompConVec(), L1RPCConeBuilder::getConVec(), L1RPCBxOrConfig::getFirstBX(), L1RPCBxOrConfig::getLastBX(), L1RPCConeDefinition::getLPSizeVec(), mps_fire::i, L1RPCHwConfig::isActive(), mathSSE::lh, DetId::rawId(), RPCLogHit::setDigiIdx(), and RPCLogCone::setIdx().

Referenced by RPCTrigger::produce().

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