Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:30:31

0001 #include "L1Trigger/RegionalCaloTrigger/interface/L1RCTNeighborMap.h"
0002 
0003 #include <vector>
0004 using std::vector;
0005 
0006 vector<int> L1RCTNeighborMap::north(int crate, int card, int region) {
0007   std::vector<int> north(3);
0008   int newregion(0), newcard(0), newcrate(0);
0009   if (card == 0 || card == 2 || card == 4) {
0010     newcard = card + 1;
0011     newregion = region;
0012     if (crate != 0 && crate != 9)
0013       newcrate = crate - 1;
0014     else
0015       newcrate = crate + 8;
0016   } else if (card == 1 || card == 3 || card == 5) {
0017     newcard = card - 1;
0018     newregion = region;
0019     newcrate = crate;
0020   } else if (card == 6) {
0021     if (region == 0) {
0022       newcard = card;
0023       newregion = region + 1;
0024       if (crate != 0 && crate != 9)
0025         newcrate = crate - 1;
0026       else
0027         newcrate = crate + 8;
0028     } else {
0029       newcard = card;
0030       newregion = region - 1;
0031       newcrate = crate;
0032     }
0033   }
0034   north.at(0) = newcrate;
0035   north.at(1) = newcard;
0036   north.at(2) = newregion;
0037   return north;
0038 }
0039 
0040 vector<int> L1RCTNeighborMap::south(int crate, int card, int region) {
0041   int newcrate(0), newcard(0), newregion(0);
0042   std::vector<int> south(3);
0043   if (card == 0 || card == 2 || card == 4) {
0044     newcard = card + 1;
0045     newregion = region;
0046     newcrate = crate;
0047   } else if (card == 1 || card == 3 || card == 5) {
0048     newcard = card - 1;
0049     newregion = region;
0050     if (crate != 8 && crate != 17)
0051       newcrate = crate + 1;
0052     else
0053       newcrate = crate - 8;
0054   } else if (card == 6) {
0055     if (region == 0) {
0056       newcrate = crate;
0057       newcard = card;
0058       newregion = region + 1;
0059     } else {
0060       newcard = card;
0061       newregion = region - 1;
0062       if (crate != 8 && crate != 17)
0063         newcrate = crate + 1;
0064       else
0065         newcrate = crate - 8;
0066     }
0067   }
0068   south.at(0) = newcrate;
0069   south.at(1) = newcard;
0070   south.at(2) = newregion;
0071   return south;
0072 }
0073 
0074 vector<int> L1RCTNeighborMap::west(int crate, int card, int region) {
0075   int newcrate(0), newcard(0), newregion(0);
0076   std::vector<int> west(3);
0077   if (crate < 9) {
0078     newcrate = crate;
0079     if (card != 6) {
0080       if (region == 0) {
0081         newcard = card;
0082         newregion = region + 1;
0083       } else {
0084         if (card != 4 && card != 5) {
0085           newcard = card + 2;
0086           newregion = region - 1;
0087         } else if (card == 4) {
0088           newcard = 6;
0089           newregion = 0;
0090         } else if (card == 5) {
0091           newcard = 6;
0092           newregion = 1;
0093         }
0094       }
0095     } else {
0096       newcrate = -1;
0097       newcard = -1;
0098       newregion = -1;
0099     }
0100   } else {
0101     if (card == 0 || card == 1) {
0102       if (region == 0) {
0103         newcrate = crate - 9;
0104         newregion = region;
0105         newcard = card;
0106       } else {
0107         newcrate = crate;
0108         newregion = region - 1;
0109         newcard = card;
0110       }
0111     } else if (card != 6) {
0112       newcrate = crate;
0113       if (region == 0) {
0114         newcard = card - 2;
0115         newregion = region + 1;
0116       } else {
0117         newcard = card;
0118         newregion = region - 1;
0119       }
0120     } else if (card == 6) {
0121       newcrate = crate;
0122       newregion = 1;
0123       if (region == 0)
0124         newcard = 4;
0125       else
0126         newcard = 5;
0127     }
0128   }
0129   west.at(0) = newcrate;
0130   west.at(1) = newcard;
0131   west.at(2) = newregion;
0132   return west;
0133 }
0134 
0135 vector<int> L1RCTNeighborMap::east(int crate, int card, int region) {
0136   int newcrate(0), newcard(0), newregion(0);
0137   std::vector<int> east(3);
0138   if (crate < 9) {
0139     if (card != 0 && card != 1 && card != 6) {
0140       newcrate = crate;
0141       if (region == 0) {
0142         newregion = region + 1;
0143         newcard = card - 2;
0144       } else {
0145         newregion = region - 1;
0146         newcard = card;
0147       }
0148     } else if (card == 0 || card == 1) {
0149       newcard = card;
0150       if (region == 0) {
0151         newcrate = crate + 9;
0152         newregion = region;
0153       } else {
0154         newcrate = crate;
0155         newregion = region - 1;
0156       }
0157     } else if (card == 6) {
0158       newcrate = crate;
0159       newregion = 1;
0160       if (region == 0)
0161         newcard = 4;
0162       else
0163         newcard = 5;
0164     }
0165   } else {
0166     newcrate = crate;
0167     if (card != 6) {
0168       if (region == 0) {
0169         newcard = card;
0170         newregion = region + 1;
0171       } else {
0172         if (card != 4 && card != 5) {
0173           newcard = card + 2;
0174           newregion = region - 1;
0175         } else if (card == 4) {
0176           newcard = 6;
0177           newregion = 0;
0178         } else if (card == 5) {
0179           newcard = 6;
0180           newregion = 1;
0181         }
0182       }
0183     } else {
0184       newcrate = -1;
0185       newcard = -1;
0186       newregion = -1;
0187     }
0188   }
0189   east.at(0) = newcrate;
0190   east.at(1) = newcard;
0191   east.at(2) = newregion;
0192   return east;
0193 }
0194 
0195 vector<int> L1RCTNeighborMap::se(int crate, int card, int region) {
0196   int newcrate(0), newcard(0), newregion(0);
0197   std::vector<int> se(3);
0198   if (crate < 9) {
0199     if (card == 0) {
0200       if (region == 0) {
0201         newcrate = crate + 9;
0202         newregion = region;
0203         newcard = 1;
0204       } else {
0205         newcrate = crate;
0206         newregion = 0;
0207         newcard = 1;
0208       }
0209     } else if (card == 1) {
0210       if (region == 0) {
0211         if (crate != 8)
0212           newcrate = crate + 10;
0213         else
0214           newcrate = 9;
0215         newregion = 0;
0216         newcard = 0;
0217       } else {
0218         if (crate != 8)
0219           newcrate = crate + 1;
0220         else
0221           newcrate = 0;
0222         newregion = 0;
0223         newcard = 0;
0224       }
0225     } else if (card == 2 || card == 4) {
0226       newcrate = crate;
0227       newregion = !region;
0228       newcard = card - 1 + 2 * region;
0229     } else if (card == 5 || card == 3) {
0230       newregion = !region;
0231       newcard = card - 3 + 2 * region;
0232       if (crate != 8)
0233         newcrate = crate + 1;
0234       else
0235         newcrate = 0;
0236     } else if (card == 6) {
0237       if (region == 0) {
0238         newcard = 5;
0239         newregion = 1;
0240         newcrate = crate;
0241       } else {
0242         newcard = 4;
0243         newregion = 1;
0244         if (crate != 8)
0245           newcrate = crate + 1;
0246         else
0247           newcrate = 0;
0248       }
0249     }
0250   } else {
0251     if (card == 0 || card == 2) {
0252       newregion = !region;
0253       newcrate = crate;
0254       newcard = card + 2 * region + 1;
0255     } else if (card == 1 || card == 3) {
0256       newregion = !region;
0257       newcard = card - 1 + 2 * region;
0258       if (crate != 17)
0259         newcrate = crate + 1;
0260       else
0261         newcrate = 9;
0262     } else if (card == 4) {
0263       newcrate = crate;
0264       if (region == 0) {
0265         newregion = 1;
0266         newcard = 5;
0267       } else {
0268         newregion = 1;
0269         newcard = 6;
0270       }
0271     } else if (card == 5) {
0272       if (region == 0) {
0273         newcard = 4;
0274         newregion = 1;
0275       } else {
0276         newcard = 6;
0277         newregion = 0;
0278       }
0279       if (crate != 17)
0280         newcrate = crate + 1;
0281       else
0282         newcrate = 9;
0283     } else if (card == 6) {
0284       newcard = -1;
0285       newregion = -1;
0286       newcrate = -1;
0287     }
0288   }
0289 
0290   se.at(0) = newcrate;
0291   se.at(1) = newcard;
0292   se.at(2) = newregion;
0293   return se;
0294 }
0295 
0296 vector<int> L1RCTNeighborMap::sw(int crate, int card, int region) {
0297   int newcrate(0), newcard(0), newregion(0);
0298   std::vector<int> sw(3);
0299   if (crate > 8) {
0300     if (card == 0) {
0301       if (region == 0) {
0302         newcrate = crate - 9;
0303         newregion = region;
0304         newcard = 1;
0305       } else {
0306         newcrate = crate;
0307         newregion = 0;
0308         newcard = 1;
0309       }
0310     } else if (card == 1) {
0311       if (region == 0) {
0312         if (crate != 17)
0313           newcrate = crate - 8;
0314         else
0315           newcrate = 0;
0316         newregion = 0;
0317         newcard = 0;
0318       } else {
0319         if (crate != 17)
0320           newcrate = crate + 1;
0321         else
0322           newcrate = 9;
0323         newregion = 0;
0324         newcard = 0;
0325       }
0326     } else if (card == 2 || card == 4) {
0327       newcrate = crate;
0328       newregion = !region;
0329       newcard = card - 1 + 2 * region;
0330     } else if (card == 5 || card == 3) {
0331       newregion = !region;
0332       newcard = card - 3 + 2 * region;
0333       if (crate != 17)
0334         newcrate = crate + 1;
0335       else
0336         newcrate = 9;
0337     } else if (card == 6) {
0338       if (region == 0) {
0339         newcard = 5;
0340         newregion = 1;
0341         newcrate = crate;
0342       } else {
0343         newcard = 4;
0344         newregion = 1;
0345         if (crate != 17)
0346           newcrate = crate + 1;
0347         else
0348           newcrate = 9;
0349       }
0350     }
0351   } else {
0352     if (card == 0 || card == 2) {
0353       newregion = !region;
0354       newcrate = crate;
0355       newcard = card + 1 + 2 * region;
0356     } else if (card == 1 || card == 3) {
0357       newregion = !region;
0358       newcard = card - 1 + 2 * region;
0359       if (crate != 8)
0360         newcrate = crate + 1;
0361       else
0362         newcrate = 0;
0363     } else if (card == 4) {
0364       newcrate = crate;
0365       if (region == 0) {
0366         newregion = 1;
0367         newcard = 5;
0368       } else {
0369         newregion = 1;
0370         newcard = 6;
0371       }
0372     } else if (card == 5) {
0373       if (region == 0) {
0374         newcard = 4;
0375         newregion = 1;
0376       } else {
0377         newcard = 6;
0378         newregion = 0;
0379       }
0380       if (crate != 8)
0381         newcrate = crate + 1;
0382       else
0383         newcrate = 0;
0384     } else if (card == 6) {
0385       newcard = -1;
0386       newregion = -1;
0387       newcrate = -1;
0388     }
0389   }
0390 
0391   sw.at(0) = newcrate;
0392   sw.at(1) = newcard;
0393   sw.at(2) = newregion;
0394   return sw;
0395 }
0396 
0397 vector<int> L1RCTNeighborMap::ne(int crate, int card, int region) {
0398   int newcrate(0), newcard(0), newregion(0);
0399   std::vector<int> ne(3);
0400   if (crate < 9) {
0401     if (card == 0) {
0402       newregion = 0;
0403       newcard = 1;
0404       if (region == 0) {
0405         if (crate != 0)
0406           newcrate = crate + 8;
0407         else
0408           newcrate = 17;
0409       } else {
0410         if (crate != 0)
0411           newcrate = crate - 1;
0412         else
0413           newcrate = 8;
0414       }
0415     } else if (card == 1) {
0416       newregion = 0;
0417       newcard = 0;
0418       if (region == 0)
0419         newcrate = crate + 9;
0420       else
0421         newcrate = crate;
0422     } else if (card == 2 || card == 4) {
0423       newregion = !region;
0424       newcard = card - 1 + 2 * region;
0425       if (crate != 0)
0426         newcrate = crate - 1;
0427       else
0428         newcrate = 8;
0429     } else if (card == 5 || card == 3) {
0430       newregion = !region;
0431       newcard = card - 3 + 2 * region;
0432       newcrate = crate;
0433     } else if (card == 6) {
0434       newregion = 1;
0435       if (region == 0) {
0436         newcard = 5;
0437         if (crate != 0)
0438           newcrate = crate - 1;
0439         else
0440           newcrate = 8;
0441       } else {
0442         newcard = 4;
0443         newcrate = crate;
0444       }
0445     }
0446   } else {
0447     if (card == 0 || card == 2) {
0448       newregion = !region;
0449       newcard = card + 1 + 2 * region;
0450       if (crate != 9)
0451         newcrate = crate - 1;
0452       else
0453         newcrate = 17;
0454     } else if (card == 1 || card == 3) {
0455       newregion = !region;
0456       newcard = card - 1 + 2 * region;
0457       newcrate = crate;
0458     } else if (card == 4) {
0459       newregion = 1;
0460       if (crate != 9)
0461         newcrate = crate - 1;
0462       else
0463         newcrate = 17;
0464       if (region == 0)
0465         newcard = 5;
0466       else
0467         newcard = 6;
0468     } else if (card == 5) {
0469       newregion = !region;
0470       newcrate = crate;
0471       if (region == 0)
0472         newcard = 4;
0473       else
0474         newcard = 6;
0475     } else if (card == 6) {
0476       newcrate = -1;
0477       newcard = -1;
0478       newregion = -1;
0479     }
0480   }
0481   ne.at(0) = newcrate;
0482   ne.at(1) = newcard;
0483   ne.at(2) = newregion;
0484   return ne;
0485 }
0486 
0487 vector<int> L1RCTNeighborMap::nw(int crate, int card, int region) {
0488   int newcrate(0), newcard(0), newregion(0);
0489   std::vector<int> nw(3);
0490   if (crate > 8) {
0491     if (card == 0) {
0492       newregion = 0;
0493       newcard = 1;
0494       if (region == 0) {
0495         if (crate != 9)
0496           newcrate = crate - 10;
0497         else
0498           newcrate = 8;
0499       } else {
0500         if (crate != 9)
0501           newcrate = crate - 1;
0502         else
0503           newcrate = 17;
0504       }
0505     } else if (card == 1) {
0506       newregion = 0;
0507       newcard = 0;
0508       if (region == 0)
0509         newcrate = crate - 9;
0510       else
0511         newcrate = crate;
0512     } else if (card == 2 || card == 4) {
0513       newregion = !region;
0514       newcard = card - 1 + 2 * region;
0515       if (crate != 9)
0516         newcrate = crate - 1;
0517       else
0518         newcrate = 17;
0519     } else if (card == 5 || card == 3) {
0520       newregion = !region;
0521       newcard = card - 3 + 2 * region;
0522       newcrate = crate;
0523     } else if (card == 6) {
0524       newregion = 1;
0525       if (region == 0) {
0526         newcard = 5;
0527         if (crate != 9)
0528           newcrate = crate - 1;
0529         else
0530           newcrate = 17;
0531       } else {
0532         newcard = 4;
0533         newcrate = crate;
0534       }
0535     }
0536   } else {
0537     if (card == 0 || card == 2) {
0538       newregion = !region;
0539       newcard = card + 1 + 2 * region;
0540       if (crate != 0)
0541         newcrate = crate - 1;
0542       else
0543         newcrate = 8;
0544     } else if (card == 1 || card == 3) {
0545       newregion = !region;
0546       newcard = card - 1 + 2 * region;
0547       newcrate = crate;
0548     } else if (card == 4) {
0549       newregion = 1;
0550       if (crate != 0)
0551         newcrate = crate - 1;
0552       else
0553         newcrate = 8;
0554       if (region == 0)
0555         newcard = 5;
0556       else
0557         newcard = 6;
0558     } else if (card == 5) {
0559       newregion = !region;
0560       newcrate = crate;
0561       if (region == 0)
0562         newcard = 4;
0563       else
0564         newcard = 6;
0565     } else if (card == 6) {
0566       newcrate = -1;
0567       newcard = -1;
0568       newregion = -1;
0569     }
0570   }
0571   nw.at(0) = newcrate;
0572   nw.at(1) = newcard;
0573   nw.at(2) = newregion;
0574   return nw;
0575 }