ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/src/Pattern.cc
Revision: 1.5
Committed: Tue Jun 25 10:49:35 2013 UTC (11 years, 10 months ago) by akalinow
Content type: text/plain
Branch: MAIN
Changes since 1.4: +5 -2 lines
Log Message:
* initial cleanup by AK

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.4 bool Pattern::operator==(const Pattern& o) const
13     {
14 akalinow 1.5 unsigned int thissize = theData.size();
15     if (thissize != o.size()) return false;
16    
17 konec 1.4 for (unsigned int idx=0; idx<thissize; idx++) {
18     if (theData[idx].first != o.theData[idx].first) return false;
19     if (theData[idx].second != o.theData[idx].second) return false;
20     }
21 akalinow 1.5
22 konec 1.4 return true;
23     }
24    
25 konec 1.3 Pattern Pattern::addOrCopy( std::pair<uint32_t, unsigned int > aData)
26 konec 1.1 {
27 akalinow 1.5
28 konec 1.3 for (unsigned int idx=0; idx < theData.size(); ++idx) {
29     if (theData[idx].first == aData.first) {
30     Pattern modified = *this;
31     modified.theData[idx].second = aData.second;
32     return modified;
33 konec 1.4 // if (*this == modified) return Pattern(); // nothing to do
34     // else return modified; // really duplicate
35 konec 1.1 }
36     }
37     theData.push_back(aData);
38 konec 1.3 return Pattern();
39 konec 1.1 }
40    
41 konec 1.3 void Pattern::add ( std::vector<Pattern> & vpat, std::pair<uint32_t, unsigned int > aData)
42 konec 1.2 {
43     std::vector<Pattern> copied;
44     for (std::vector<Pattern>::iterator ip = vpat.begin(); ip != vpat.end(); ++ip) {
45 konec 1.3 Pattern modified = ip->addOrCopy(aData);
46 konec 1.4 if (modified && (find(copied.begin(), copied.end(), modified) == copied.end()) ) copied.push_back(modified);
47 konec 1.2 }
48     if (copied.size() != 0) vpat.insert(vpat.end(), copied.begin(), copied.end());
49     }
50    
51    
52    
53 konec 1.1 std::ostream & operator << (std::ostream &out, const Pattern &o)
54     {
55     out <<" Pattern: size: "<<o.size();
56     for (Pattern::DataType::const_iterator it=o.theData.begin(); it!= o.theData.end(); it++) {
57     DetId detId( it->first);
58     switch (detId.subdetId()) {
59     case MuonSubdetId::RPC: { out << std::endl <<" RPC: "<<RPCDigiSpec(it->first, it->second); break; }
60     case MuonSubdetId::DT: { out << std::endl <<" DT: "<<DTphDigiSpec(it->first, it->second); break; }
61     case MuonSubdetId::CSC: { out << std::endl <<" CSC: "<<CSCDigiSpec(it->first, it->second); break; }
62     };
63     }
64     return out;
65     }
66