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