Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-18 02:06:41

0001 #include <cassert>
0002 #include <cmath>
0003 #include <iostream>
0004 
0005 #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalLayerTiles.h"
0006 
0007 void runTest(HGCalLayerTiles const& t, int expected, float etaMin, float etaMax, float phiMin, float phiMax) {
0008   auto limits = t.searchBoxEtaPhi(etaMin, etaMax, phiMin, phiMax);
0009 
0010   std::cout << "Limits are: " << limits[0] << " " << limits[1] << " " << limits[2] << " " << limits[3] << std::endl;
0011   assert(limits[0] <= limits[1]);
0012   assert(limits[2] <= limits[3]);
0013 
0014   int entries = 0;
0015   for (int e = limits[0]; e <= limits[1]; ++e) {
0016     for (int p = limits[2]; p <= limits[3]; ++p) {
0017       int phi = (p % HGCalLayerTiles::type::nRowsPhi);
0018       auto global_bin = t.getGlobalBinByBinEtaPhi(e, phi);
0019       entries += t[global_bin].size();
0020     }
0021   }
0022 
0023   std::cout << "Found " << entries << " entries, expected " << expected << std::endl;
0024   assert(entries == expected);
0025 }
0026 
0027 int main(int argc, char* argv[]) {
0028   auto constexpr phiBins = HGCalLayerTiles::type::nRowsPhi;
0029   auto constexpr phi_bin_width = 2. * M_PI / phiBins;
0030   auto constexpr phi_transition_left = M_PI - 3. * phi_bin_width;
0031   auto constexpr phi_transition_right = M_PI + 3. * phi_bin_width;
0032   auto constexpr phi_transition_right2 = -M_PI + 5. * phi_bin_width;
0033   unsigned int constexpr entries_left = 11;
0034   unsigned int constexpr entries_right = 7;
0035   float constexpr eta = 2.0;
0036 
0037   // Force filling using eta/phi vectors
0038   std::vector<bool> isSilicon(entries_left + entries_right, false);
0039   std::vector<float> dummy(entries_left + entries_right, 0.);
0040   std::vector<float> etas(entries_left + entries_right, eta);
0041   std::vector<float> phis_left(entries_left, phi_transition_left);
0042   std::vector<float> phis_right(entries_right, phi_transition_right);
0043   std::vector<float> phis_right2(entries_right, phi_transition_right2);
0044   std::vector<float> phis;
0045   std::vector<float> phis2;
0046   phis.reserve(entries_left + entries_right);
0047   phis.insert(phis.end(), phis_left.begin(), phis_left.end());
0048   phis.insert(phis.end(), phis_right.begin(), phis_right.end());
0049   phis2.reserve(entries_left + entries_right);
0050   phis2.insert(phis2.end(), phis_left.begin(), phis_left.end());
0051   phis2.insert(phis2.end(), phis_right2.begin(), phis_right2.end());
0052 
0053   HGCalLayerTiles t, t2;
0054   t.fill(dummy, dummy, etas, phis, isSilicon);
0055   t2.fill(dummy, dummy, etas, phis2, isSilicon);
0056 
0057   std::cout << "Testing a Tile with " << phiBins << " bins with binwidth: " << phi_bin_width << " at pi transition"
0058             << std::endl;
0059   std::cout << "-M_PI bin: " << t.mPiPhiBin << " M_PI bin: " << t.pPiPhiBin << std::endl;
0060   std::cout << "Filling phi value: " << phi_transition_left << " at left-pi bin: " << t.getPhiBin(phi_transition_left)
0061             << std::endl;
0062   std::cout << "Filling phi value: " << phi_transition_right
0063             << " at right-pi bin: " << t.getPhiBin(phi_transition_right) << std::endl;
0064   std::cout << "Filling phi value: " << phi_transition_right2
0065             << " at right-pi bin: " << t.getPhiBin(phi_transition_right2) << std::endl;
0066 
0067   runTest(t, entries_right + entries_left, 1.95, 2.05, phi_transition_left, phi_transition_right);
0068   runTest(t2, entries_right + entries_left, 1.95, 2.05, phi_transition_left, phi_transition_right2);
0069 
0070   return 0;
0071 }