ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/src/Pattern.cc
(Generate patch)

Comparing UserCode/L1RpcTriggerAnalysis/src/Pattern.cc (file contents):
Revision 1.6 by akalinow, Tue Jun 25 11:06:03 2013 UTC vs.
Revision 1.7 by akalinow, Thu Jul 11 11:25:22 2013 UTC

# Line 9 | Line 9
9   #include "UserCode/L1RpcTriggerAnalysis/interface/CSCDigiSpec.h"
10   #include "UserCode/L1RpcTriggerAnalysis/interface/RPCDigiSpec.h"
11  
12 + /////////////////////////////////////////////////
13 + /////////////////////////////////////////////////
14 + uint32_t Pattern::rotateDetId(uint32_t rawId, int step){
15 +
16 +  ///Assume 60deg steps
17 +  while(step<0){step+=6;}
18 +
19 +  uint32_t rawIdRotated = rawId;
20 +
21 +  DetId detId(rawId);
22 +  switch (detId.subdetId()){    
23 +  case MuonSubdetId::RPC: {
24 +    RPCDetId rpcDet(rawId);
25 +    ///Barrel has 30deg sectors
26 +    if(rpcDet.region()==0) step*=2;
27 +    RPCDetId rpcDetRotated(rpcDet.region(),
28 +                           rpcDet.ring(),
29 +                           rpcDet.station(),
30 +                           (rpcDet.sector()+step-1)%12+1,
31 +                           rpcDet.layer(),
32 +                           rpcDet.subsector(),
33 +                           rpcDet.roll());
34 +    return rpcDetRotated.rawId();      
35 +  }
36 +  case MuonSubdetId::DT: {
37 +    ///Barrel has 30deg sectors
38 +    step*=2;
39 +    DTChamberId dtDet(rawId);
40 +    DTChamberId dtDetRotated(dtDet.wheel(),
41 +                             dtDet.station(),
42 +                             (dtDet.sector()+step)%12);
43 +    return dtDetRotated.rawId();      
44 +    break;
45 +  }
46 +  case MuonSubdetId::CSC: {
47 +    CSCDetId cscDet(rawId);
48 +    //Most CSC chambers are 10deg wide
49 +    int cscFactor = 6;
50 +    int maxChamber = 36;
51 +    ///Some are 20deg wide
52 +    if(cscDet.station()>1 && cscDet.ring()==1){
53 +        cscFactor = 3;
54 +        maxChamber = 18;
55 +      }
56 +    int cscStep = step*cscFactor;
57 +    CSCDetId cscDetRotated(cscDet.endcap(),
58 +                           cscDet.station(),
59 +                           cscDet.ring(),
60 +                           (cscDet.chamber()+cscStep-1)%maxChamber+1,
61 +                           cscDet.layer());
62 +    return cscDetRotated.rawId();      
63 +  }
64 +  }  
65 +  return rawIdRotated;
66 + }
67 + /////////////////////////////////////////////////
68 + /////////////////////////////////////////////////
69 + Pattern Pattern::getRotated(int step) const{
70 +
71 +  Pattern rotated;
72 +  
73 +  for (auto it = theData.cbegin(); it != theData.cend(); ++it){
74 +    rotated.add(std::pair<uint32_t,  unsigned int >(rotateDetId(it->first,step),it->second));
75 +  }
76 +  return rotated;
77 + }
78 + /////////////////////////////////////////////////
79 + /////////////////////////////////////////////////
80   bool Pattern::operator==(const Pattern& o) const{
81    unsigned int thissize = theData.size();
82    if (thissize != o.size()) return false;
# Line 34 | Line 102 | Pattern Pattern::addOrCopy( std::pair<ui
102    return Pattern();
103   }
104  
105 < void Pattern::add (  std::vector<Pattern> & vpat, std::pair<uint32_t,  unsigned int > aData)
105 > void Pattern::add (std::vector<Pattern> & vpat, std::pair<uint32_t,  unsigned int > aData)
106   {
39  /*
40  std::vector<Pattern> copied;
41  for (std::vector<Pattern>::iterator ip = vpat.begin(); ip != vpat.end(); ++ip) {
42    Pattern modified =  ip->addOrCopy(aData);
43    if (modified && (find(copied.begin(), copied.end(), modified) == copied.end()) ) copied.push_back(modified);
44  }
45  if (copied.size() != 0) vpat.insert(vpat.end(), copied.begin(), copied.end());
46  */
47
107    //Use indexing to avoid problem with iterator invalidation afer adding new elements to vector
108    uint32_t vSize = vpat.size();
109    for(uint32_t index = 0;index<vSize;++index){
# Line 60 | Line 119 | std::ostream & operator << (std::ostream
119    for (auto it = o.theData.cbegin(); it != o.theData.cend(); ++it){
120      DetId detId( it->first);
121      switch (detId.subdetId()) {
122 <      case MuonSubdetId::RPC: { out << std::endl <<" RPC: "<<RPCDigiSpec(it->first, it->second);  break; }
123 <      case MuonSubdetId::DT:  { out << std::endl <<" DT:  "<<DTphDigiSpec(it->first, it->second); break; }
124 <      case MuonSubdetId::CSC: { out << std::endl <<" CSC: "<<CSCDigiSpec(it->first, it->second);  break; }
122 >    case MuonSubdetId::RPC: { out << std::endl <<RPCDetId(it->first)<<" "<<RPCDigiSpec(it->first, it->second);  break; }
123 >    case MuonSubdetId::DT:  { out << std::endl <<DTChamberId(it->first)<<" "<<DTphDigiSpec(it->first, it->second); break; }
124 >    case MuonSubdetId::CSC: { out << std::endl <<CSCDetId(it->first)<<" "<<CSCDigiSpec(it->first, it->second);  break; }
125      };
126    }
127    return out;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines