ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/src/Pattern.cc
Revision: 1.3
Committed: Fri May 24 10:26:12 2013 UTC (11 years, 11 months ago) by konec
Content type: text/plain
Branch: MAIN
Changes since 1.2: +10 -17 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 konec 1.1 #include "UserCode/L1RpcTriggerAnalysis/interface/Pattern.h"
2    
3     #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
4     #include "DataFormats/MuonDetId/interface/RPCDetId.h"
5     #include "DataFormats/MuonDetId/interface/CSCDetId.h"
6     #include "DataFormats/MuonDetId/interface/DTChamberId.h"
7     #include "UserCode/L1RpcTriggerAnalysis/interface/RPCDetIdUtil.h"
8     #include "UserCode/L1RpcTriggerAnalysis/interface/DTphDigiSpec.h"
9     #include "UserCode/L1RpcTriggerAnalysis/interface/CSCDigiSpec.h"
10     #include "UserCode/L1RpcTriggerAnalysis/interface/RPCDigiSpec.h"
11    
12 konec 1.3 Pattern Pattern::addOrCopy( std::pair<uint32_t, unsigned int > aData)
13 konec 1.1 {
14 konec 1.3 for (unsigned int idx=0; idx < theData.size(); ++idx) {
15     if (theData[idx].first == aData.first) {
16     Pattern modified = *this;
17     modified.theData[idx].second = aData.second;
18     return modified;
19 konec 1.1 }
20     }
21     theData.push_back(aData);
22 konec 1.3 return Pattern();
23 konec 1.1 }
24    
25 konec 1.3 void Pattern::add ( std::vector<Pattern> & vpat, std::pair<uint32_t, unsigned int > aData)
26 konec 1.2 {
27     std::vector<Pattern> copied;
28     for (std::vector<Pattern>::iterator ip = vpat.begin(); ip != vpat.end(); ++ip) {
29 konec 1.3 Pattern modified = ip->addOrCopy(aData);
30     if (modified) copied.push_back(modified);
31 konec 1.2 }
32     if (copied.size() != 0) vpat.insert(vpat.end(), copied.begin(), copied.end());
33     }
34    
35    
36    
37 konec 1.1 std::ostream & operator << (std::ostream &out, const Pattern &o)
38     {
39     out <<" Pattern: size: "<<o.size();
40     for (Pattern::DataType::const_iterator it=o.theData.begin(); it!= o.theData.end(); it++) {
41     DetId detId( it->first);
42     switch (detId.subdetId()) {
43     case MuonSubdetId::RPC: { out << std::endl <<" RPC: "<<RPCDigiSpec(it->first, it->second); break; }
44     case MuonSubdetId::DT: { out << std::endl <<" DT: "<<DTphDigiSpec(it->first, it->second); break; }
45     case MuonSubdetId::CSC: { out << std::endl <<" CSC: "<<CSCDigiSpec(it->first, it->second); break; }
46     };
47     }
48     return out;
49     }
50