CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 44 of file RPCConeBuilderFromES.h.

Constructor & Destructor Documentation

RPCConeBuilderFromES::RPCConeBuilderFromES ( )

Definition at line 31 of file RPCConeBuilderFromES.cc.

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

Definition at line 40 of file RPCConeBuilderFromES.cc.

41 {
42 }

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

References i, mathSSE::lh, DetId::rawId(), RPCLogHit::setDigiIdx(), and RPCLogCone::setIdx().

Referenced by RPCTrigger::produce().

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 }
int i
Definition: DBlmapReader.cc:9
bool int lh
Definition: SSEVec.h:55
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
std::vector< DigiType >::const_iterator const_iterator
std::pair< const_iterator, const_iterator > Range
std::vector< RPCLogCone > L1RpcLogConesVec
Definition: RPCLogCone.h:126