Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-18 02:03:30

0001 #include <cassert>
0002 #include <cmath>
0003 #include <iostream>
0004 
0005 #include "DataFormats/HGCalReco/interface/TICLLayerTile.h"
0006 
0007 using namespace ticl;
0008 
0009 void runTest(TICLLayerTile const& t, int expected, float etaMin, float etaMax, float phiMin, float phiMax) {
0010   auto limits = t.searchBoxEtaPhi(etaMin, etaMax, phiMin, phiMax);
0011 
0012   std::cout << "Limits are: " << limits[0] << " " << limits[1] << " " << limits[2] << " " << limits[3] << std::endl;
0013   assert(limits[0] <= limits[1]);
0014   assert(limits[2] <= limits[3]);
0015 
0016   int entries = 0;
0017   for (int e = limits[0]; e <= limits[1]; ++e) {
0018     for (int p = limits[2]; p <= limits[3]; ++p) {
0019       int phi = (p % TICLLayerTile::type::nPhiBins);
0020       auto global_bin = t.globalBin(e, phi);
0021       entries += t[global_bin].size();
0022     }
0023   }
0024 
0025   std::cout << "Found " << entries << " entries, expected " << expected << std::endl;
0026   assert(entries == expected);
0027 }
0028 
0029 int main(int argc, char* argv[]) {
0030   auto constexpr phiBins = TICLLayerTile::type::nPhiBins;
0031   auto constexpr phi_bin_width = 2. * M_PI / phiBins;
0032   auto constexpr phi_transition_left = M_PI - phi_bin_width;
0033   auto constexpr phi_transition_right = M_PI + phi_bin_width;
0034   auto constexpr phi_transition_right2 = -M_PI + 3. * phi_bin_width;
0035   unsigned int constexpr entries_left = 11;
0036   unsigned int constexpr entries_right = 7;
0037   float constexpr eta = 2.0;
0038 
0039   TICLLayerTile t, t2;
0040   std::cout << "Testing a Tile with " << phiBins << " bins with binwidth: " << phi_bin_width << " at bin transition"
0041             << std::endl;
0042   std::cout << "Filling left-pi bin: " << t.phiBin(phi_transition_left) << std::endl;
0043   std::cout << "Filling right-pi bin: " << t.phiBin(phi_transition_right) << std::endl;
0044   std::cout << "Filling right2-pi bin: " << t.phiBin(phi_transition_right2) << std::endl;
0045 
0046   for (unsigned int i = 0; i < entries_left; ++i) {
0047     t.fill(eta, phi_transition_left, i);
0048     t2.fill(eta, phi_transition_left, i);
0049   }
0050 
0051   for (unsigned int i = 0; i < entries_right; ++i) {
0052     t.fill(eta, phi_transition_right, i);
0053     t2.fill(eta, phi_transition_right2, i);
0054   }
0055 
0056   runTest(t, entries_left + entries_right, 1.95, 2.05, phi_transition_left, phi_transition_right);
0057   runTest(t2, entries_left + entries_right, 1.95, 2.05, phi_transition_left, phi_transition_right2);
0058 
0059   return 0;
0060 }