Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:55

0001 
0002 #include <iostream>
0003 #include <fstream>
0004 #include <iomanip>
0005 
0006 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h"
0007 
0008 using std::cout;
0009 using std::endl;
0010 using std::ofstream;
0011 using std::setw;
0012 
0013 // print the region map and region-associated data (rct/gct card/input numbers)
0014 
0015 void makePlot(ofstream& of, int plot);
0016 
0017 int main() {
0018   /* === obsolete ===
0019   // GCT card number
0020   ofstream gctCardPlot("gctCardPlot.txt");
0021   makePlot(gctCardPlot, 0);
0022      ================= */
0023 
0024   /* === obsolete ===
0025   // GCT region number
0026   ofstream gctRgnPlot("gctRgnPlot.txt");
0027   makePlot(gctRgnPlot, 1);
0028      ================= */
0029 
0030   // RCT crate number
0031   ofstream rctCratePlot("rctCratePlot.txt");
0032   makePlot(rctCratePlot, 2);
0033 
0034   // RCT card number
0035   ofstream rctCardPlot("rctCardPlot.txt");
0036   makePlot(rctCardPlot, 3);
0037 
0038   // RCT region number
0039   ofstream rctRgnPlot("rctRgnPlot.txt");
0040   makePlot(rctRgnPlot, 4);
0041 
0042   // RCT phi
0043   ofstream rctPhiPlot("rctPhiPlot.txt");
0044   makePlot(rctPhiPlot, 5);
0045 
0046   // RCT eta
0047   ofstream rctEtaPlot("rctEtaPlot.txt");
0048   makePlot(rctEtaPlot, 6);
0049 
0050   // forward
0051   ofstream fwdRgnPlot("fwdRgnPlot.txt");
0052   makePlot(fwdRgnPlot, 7);
0053 
0054   // test RCT constructors
0055   for (unsigned crate = 0; crate < 18; crate++) {
0056     for (unsigned card = 0; card < 7; card++) {
0057       for (unsigned rgn = 0; rgn < 2; rgn++) {
0058         L1CaloRegionDetId r(crate, card, rgn);
0059         if ((r.rctCrate() != crate) || (r.rctCard() != card) || (r.rctRegion() != rgn)) {
0060           cout << "Error! : RCT crate " << crate << " card " << card << " region " << rgn << endl;
0061         }
0062       }
0063     }
0064   }
0065 
0066   // test HF constructors
0067   for (unsigned crate = 0; crate < 18; crate++) {
0068     for (unsigned rgn = 0; rgn < 8; rgn++) {
0069       L1CaloRegionDetId r(crate, 999, rgn);
0070       if ((r.rctCrate() != crate) || (r.rctRegion() != rgn)) {
0071         cout << "Error! : RCT crate " << crate << " HF region " << rgn << endl;
0072       }
0073     }
0074   }
0075 
0076   return 0;
0077 }
0078 
0079 void makePlot(ofstream& of, int plot) {
0080   // print header line
0081   of << "     ieta->" << endl;
0082   of << "    : ";
0083   for (int ieta = 0; ieta < 22; ieta++) {
0084     of << setw(3) << ieta << " ";
0085   }
0086   of << endl;
0087 
0088   // main loop
0089   for (int iphi = 0; iphi < 18; iphi++) {
0090     of << setw(3) << iphi << "  : ";
0091 
0092     for (int ieta = 0; ieta < 22; ieta++) {
0093       L1CaloRegionDetId rgn(ieta, iphi);
0094 
0095       switch (plot) {
0096         /* === obsolete ===
0097       case 0 : 
0098     of << setw(3) << rgn.gctCard() << " "; break;
0099          ================ */
0100         /* === obsolete ===
0101       case 1 : 
0102     of << setw(3) << rgn.gctRegion() << " "; break;
0103          ================ */
0104         case 2:
0105           of << setw(3) << rgn.rctCrate() << " ";
0106           break;
0107         case 3:
0108           of << setw(3) << rgn.rctCard() << " ";
0109           break;
0110         case 4:
0111           of << setw(3) << rgn.rctRegion() << " ";
0112           break;
0113         case 5:
0114           of << setw(3) << rgn.rctPhi() << " ";
0115           break;
0116         case 6:
0117           of << setw(3) << rgn.rctEta() << " ";
0118           break;
0119         case 7:
0120           of << setw(3) << (rgn.isHf() ? 1 : 0) << " ";
0121           break;
0122 
0123         default:
0124           break;
0125       }
0126     }
0127 
0128     of << endl;
0129   }
0130 }