ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/src/Pattern.cc
Revision: 1.6
Committed: Tue Jun 25 11:06:03 2013 UTC (11 years, 10 months ago) by akalinow
Content type: text/plain
Branch: MAIN
CVS Tags: Artur_28_06_2013
Changes since 1.5: +26 -22 lines
Log Message:
*some further interface modifications 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 akalinow 1.6 bool Pattern::operator==(const Pattern& o) const{
13     unsigned int thissize = theData.size();
14     if (thissize != o.size()) return false;
15    
16     for (auto it = theData.cbegin(); it != theData.cend(); ++it){
17     auto itComp = o.theData.find(it->first);
18     if(itComp==o.theData.cend()) return false;
19     if(itComp->second!=it->second) return false;
20     }
21 akalinow 1.5
22 konec 1.4 return true;
23     }
24    
25 akalinow 1.6 Pattern Pattern::addOrCopy( std::pair<uint32_t, unsigned int > aData){
26 akalinow 1.5
27 akalinow 1.6 auto it = theData.find(aData.first);
28     if(it!= theData.cend()){
29     Pattern modified = *this;
30     modified.theData[aData.first] = aData.second;
31     return modified;
32 konec 1.1 }
33 akalinow 1.6 theData[aData.first] = aData.second;
34 konec 1.3 return Pattern();
35 konec 1.1 }
36    
37 konec 1.3 void Pattern::add ( std::vector<Pattern> & vpat, std::pair<uint32_t, unsigned int > aData)
38 konec 1.2 {
39 akalinow 1.6 /*
40 konec 1.2 std::vector<Pattern> copied;
41     for (std::vector<Pattern>::iterator ip = vpat.begin(); ip != vpat.end(); ++ip) {
42 konec 1.3 Pattern modified = ip->addOrCopy(aData);
43 konec 1.4 if (modified && (find(copied.begin(), copied.end(), modified) == copied.end()) ) copied.push_back(modified);
44 konec 1.2 }
45     if (copied.size() != 0) vpat.insert(vpat.end(), copied.begin(), copied.end());
46 akalinow 1.6 */
47    
48     //Use indexing to avoid problem with iterator invalidation afer adding new elements to vector
49     uint32_t vSize = vpat.size();
50     for(uint32_t index = 0;index<vSize;++index){
51     Pattern modified = vpat[index].addOrCopy(aData);
52     if (modified && (find(vpat.begin(), vpat.end(), modified) == vpat.end()) ) vpat.push_back(modified);
53     }
54 konec 1.2 }
55    
56    
57 konec 1.1 std::ostream & operator << (std::ostream &out, const Pattern &o)
58     {
59     out <<" Pattern: size: "<<o.size();
60 akalinow 1.6 for (auto it = o.theData.cbegin(); it != o.theData.cend(); ++it){
61 konec 1.1 DetId detId( it->first);
62     switch (detId.subdetId()) {
63     case MuonSubdetId::RPC: { out << std::endl <<" RPC: "<<RPCDigiSpec(it->first, it->second); break; }
64     case MuonSubdetId::DT: { out << std::endl <<" DT: "<<DTphDigiSpec(it->first, it->second); break; }
65     case MuonSubdetId::CSC: { out << std::endl <<" CSC: "<<CSCDigiSpec(it->first, it->second); break; }
66     };
67     }
68     return out;
69     }
70