CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCConeBuilderFromES.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RPCTrigger
4 // Class : RPCConeBuilderFromES
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Mon Mar 3 13:34:20 CET 2008
11 //
12 
13 // system include files
14 
15 // user include files
17 
18 
19 //
20 // constants, enums and typedefs
21 //
22 
23 //
24 // static data member definitions
25 //
26 
27 //
28 // constructors and destructor
29 //
31 {
32 }
33 
34 // RPCConeBuilderFromES::RPCConeBuilderFromES(const RPCConeBuilderFromES& rhs)
35 // {
36 // // do actual copying here;
37 // }
38 
40 {
41 }
42 
47  edm::ESHandle<L1RPCHwConfig> hwConfig, int bx)
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 }
221 
int i
Definition: DBlmapReader.cc:9
L1RpcLogConesVec getConesFromES(edm::Handle< RPCDigiCollection > rpcDigis, edm::ESHandle< L1RPCConeBuilder > coneBuilder, edm::ESHandle< L1RPCConeDefinition > coneDef, edm::ESHandle< L1RPCBxOrConfig > bxOrDef, edm::ESHandle< L1RPCHwConfig > hwConfig, int bx)
bool int lh
Definition: SIMDVec.h:19
void setDigiIdx(int)
Definition: RPCLogHit.cc:48
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void setIdx(int index)
Definition: RPCLogCone.cc:196
std::vector< RPCDigi >::const_iterator const_iterator
std::pair< const_iterator, const_iterator > Range
std::vector< RPCLogCone > L1RpcLogConesVec
Definition: RPCLogCone.h:126