Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "L1Trigger/TrackFindingTracklet/test/INTERNAL/HistImp.h"
0002 #include "L1Trigger/TrackFindingTracklet/interface/slhcevent.h"
0003 #include "L1Trigger/TrackFindingTracklet/interface/Globals.h"
0004 
0005 using namespace std;
0006 using namespace trklet;
0007 
0008 HistImp::HistImp() {
0009   h_file_ = nullptr;
0010   h_layerresid_phi_L3_L1L2_ = nullptr;
0011   h_layerresid_phi_L3_L1L2_match_ = nullptr;
0012   h_layerresid_phif_L3_L1L2_ = nullptr;
0013   h_layerresid_phif_L3_L1L2_match_ = nullptr;
0014   h_layerresid_z_L3_L1L2_ = nullptr;
0015   h_layerresid_z_L3_L1L2_match_ = nullptr;
0016   h_layerresid_zf_L3_L1L2_ = nullptr;
0017   h_layerresid_zf_L3_L1L2_match_ = nullptr;
0018 
0019   h_diskresid_phi_D1_L1L2_ = nullptr;
0020   h_diskresid_phi_D1_L1L2_match_ = nullptr;
0021   h_diskresid_phif_D1_L1L2_ = nullptr;
0022   h_diskresid_phif_D1_L1L2_match_ = nullptr;
0023   h_diskresid_r_D1_L1L2_ = nullptr;
0024   h_diskresid_r_D1_L1L2_match_ = nullptr;
0025   h_diskresid_rf_D1_L1L2_ = nullptr;
0026   h_diskresid_rf_D1_L1L2_match_ = nullptr;
0027 
0028   h_rinv_L1L2_ = nullptr;
0029   h_irinv_L1L2_ = nullptr;
0030   h_rinvres_L1L2_ = nullptr;
0031   h_irinvres_L1L2_ = nullptr;
0032 }
0033 
0034 void HistImp::open() { h_file_ = new TFile("fpgahist.root", "RECREATE"); }
0035 
0036 void HistImp::close() {
0037   if (h_file_) {
0038     h_file_->Write();
0039     h_file_->Close();
0040     h_file_ = nullptr;
0041   }
0042 }
0043 
0044 void HistImp::bookLayerResidual() {
0045   TH1::AddDirectory(kTRUE);
0046 
0047   assert(h_file_ != nullptr);
0048   h_file_->cd();
0049 
0050   h_layerresid_phi_L3_L1L2_ = new TH1F("L3 phiresid L1L2", "L3 phiresid L1L2", 100, -0.5, 0.5);
0051   h_layerresid_phi_L3_L1L2_match_ = new TH1F("L3 phiresid L1L2 Match", "L3 phiresid L1L2 Match", 100, -0.5, 0.5);
0052   h_layerresid_phif_L3_L1L2_ = new TH1F("L3 phiresid float L1L2", "L3 phiresid float L1L2", 100, -0.5, 0.5);
0053   h_layerresid_phif_L3_L1L2_match_ =
0054       new TH1F("L3 phiresid float L1L2 Match", "L3 phiresid float L1L2 Match", 100, -0.5, 0.5);
0055 
0056   h_layerresid_z_L3_L1L2_ = new TH1F("L3 zresid L1L2", "L3 zresid L1L2", 100, -5.0, 5.0);
0057   h_layerresid_z_L3_L1L2_match_ = new TH1F("L3 zresid L1L2 Match", "L3 zresid L1L2 Match", 100, -5.0, 5.0);
0058   h_layerresid_zf_L3_L1L2_ = new TH1F("L3 zresid float L1L2", "L3 zresid float L1L2", 100, -5.0, 5.0);
0059   h_layerresid_zf_L3_L1L2_match_ = new TH1F("L3 zresid float L1L2 Match", "L3 zresid float L1L2 Match", 100, -5.0, 5.0);
0060 }
0061 
0062 void HistImp::bookDiskResidual() {
0063   TH1::AddDirectory(kTRUE);
0064 
0065   assert(h_file_ != nullptr);
0066   h_file_->cd();
0067 
0068   h_diskresid_phi_D1_L1L2_ = new TH1F("D1 phiresid L1L2", "D1 phiresid L1L2", 100, -0.5, 0.5);
0069   h_diskresid_phi_D1_L1L2_match_ = new TH1F("D1 phiresid L1L2 Match", "D1 phiresid L1L2 Match", 100, -0.5, 0.5);
0070   h_diskresid_phif_D1_L1L2_ = new TH1F("D1 phiresid float L1L2", "D1 phiresid float L1L2", 100, -0.5, 0.5);
0071   h_diskresid_phif_D1_L1L2_match_ =
0072       new TH1F("D1 phiresid float L1L2 Match", "D1 phiresid float L1L2 Match", 100, -0.5, 0.5);
0073 
0074   h_diskresid_r_D1_L1L2_ = new TH1F("D1 rresid L1L2", "D1 rresid L1L2", 100, -5.0, 5.0);
0075   h_diskresid_r_D1_L1L2_match_ = new TH1F("D1 rresid L1L2 Match", "D1 rresid L1L2 Match", 100, -5.0, 5.0);
0076   h_diskresid_rf_D1_L1L2_ = new TH1F("D1 rresid float L1L2", "D1 rresid float L1L2", 100, -5.0, 5.0);
0077   h_diskresid_rf_D1_L1L2_match_ = new TH1F("D1 rresid float L1L2 Match", "D1 rresid float L1L2 Match", 100, -5.0, 5.0);
0078 }
0079 
0080 void HistImp::bookTrackletParams() {
0081   TH1::AddDirectory(kTRUE);
0082 
0083   assert(h_file_ != nullptr);
0084   h_file_->cd();
0085 
0086   h_rinv_L1L2_ = new TH1F("Tracklet rinv in L1L2", "Tracklet rinv in L1L2", 140, -0.007, 0.007);
0087   h_irinv_L1L2_ = new TH1F("Tracklet irinv in L1L2", "Tracklet irinv in L1L2", 140, -0.007, 0.007);
0088   h_rinv_matched_L1L2_ = new TH1F("Tracklet rinv in matched L1L2", "Tracklet rinv in matched L1L2", 140, -0.007, 0.007);
0089   h_irinv_matched_L1L2_ =
0090       new TH1F("Tracklet irinv in matched L1L2", "Tracklet irinv in matched L1L2", 140, -0.007, 0.007);
0091   h_rinvres_L1L2_ = new TH1F("Tracklet rinv res in L1L2", "Tracklet rinv res in L1L2", 100, -0.0005, 0.0005);
0092   h_irinvres_L1L2_ = new TH1F("Tracklet irinv res in L1L2", "Tracklet irinv res in L1L2", 100, -0.0005, 0.0005);
0093 
0094   h_phi0_L1L2_ = new TH1F("Tracklet phi0 in L1L2", "Tracklet phi0 in L1L2", 100, 0.0, 1.0);
0095   h_iphi0_L1L2_ = new TH1F("Tracklet iphi0 in L1L2", "Tracklet iphi0 in L1L2", 100, 0.0, 1.0);
0096   h_phi0_matched_L1L2_ = new TH1F("Tracklet phi0 in matched L1L2", "Tracklet phi0 in matched L1L2", 100, 0.0, 1.0);
0097   h_iphi0_matched_L1L2_ = new TH1F("Tracklet iphi0 in matched L1L2", "Tracklet iphi0 in matched L1L2", 100, 0.0, 1.0);
0098   h_phi0global_L1L2_ = new TH1F("Tracklet phi0 global in L1L2", "Tracklet phi0 global in L1L2", 99, -M_PI, M_PI);
0099   h_iphi0global_L1L2_ = new TH1F("Tracklet iphi0 global in L1L2", "Tracklet iphi0 global in L1L2", 99, -M_PI, M_PI);
0100   h_phi0global_matched_L1L2_ =
0101       new TH1F("Tracklet phi0 global in matched L1L2", "Tracklet phi0 global in matched L1L2", 99, -M_PI, M_PI);
0102   h_iphi0global_matched_L1L2_ =
0103       new TH1F("Tracklet iphi0 global in matched L1L2", "Tracklet iphi0 global in matched L1L2", 99, -M_PI, M_PI);
0104   h_phi0res_L1L2_ = new TH1F("Tracklet phi0 res in L1L2", "Tracklet phi0 res in L1L2", 100, -0.5, 0.5);
0105   h_iphi0res_L1L2_ = new TH1F("Tracklet iphi0 res in L1L2", "Tracklet iphi0 res in L1L2", 100, -0.5, 0.5);
0106 
0107   h_eta_L1L2_ = new TH1F("Tracklet eta in L1L2", "Tracklet eta in L1L2", 100, -2.5, 2.5);
0108   h_ieta_L1L2_ = new TH1F("Tracklet ieta in L1L2", "Tracklet ieta in L1L2", 100, -2.5, 2.5);
0109   h_eta_matched_L1L2_ = new TH1F("Tracklet eta in matched L1L2", "Tracklet eta in matched L1L2", 100, -2.5, 2.5);
0110   h_ieta_matched_L1L2_ = new TH1F("Tracklet ieta in matched L1L2", "Tracklet ieta in matched L1L2", 100, -2.5, 2.5);
0111   h_etares_L1L2_ = new TH1F("Tracklet eta res in L1L2", "Tracklet eta res in L1L2", 100, -0.05, 0.05);
0112   h_ietares_L1L2_ = new TH1F("Tracklet ieta res in L1L2", "Tracklet ieta res in L1L2", 100, -0.05, 0.05);
0113 
0114   h_z0_L1L2_ = new TH1F("Tracklet z0 in L1L2", "Tracklet z0 in L1L2", 100, -25.0, 25.0);
0115   h_iz0_L1L2_ = new TH1F("Tracklet iz0 in L1L2", "Tracklet iz0 in L1L2", 100, -25.0, 25.0);
0116   h_z0_matched_L1L2_ = new TH1F("Tracklet z0 in matched L1L2", "Tracklet z0 in matched L1L2", 100, -25.0, 25.0);
0117   h_iz0_matched_L1L2_ = new TH1F("Tracklet iz0 in matched L1L2", "Tracklet iz0 in matched L1L2", 100, -25.0, 25.0);
0118   h_z0res_L1L2_ = new TH1F("Tracklet z0 res in L1L2", "Tracklet z0 res in L1L2", 100, -5.0, 5.0);
0119   h_iz0res_L1L2_ = new TH1F("Tracklet iz0 res in L1L2", "Tracklet iz0 res in L1L2", 100, -5.0, 5.0);
0120 }
0121 
0122 void HistImp::fillTrackletParams(const Settings* settings,
0123                                  Globals* globals,
0124                                  int seedIndex,
0125                                  int iSector,
0126                                  double rinv,
0127                                  double irinv,
0128                                  double phi0,
0129                                  double iphi0,
0130                                  double eta,
0131                                  double ieta,
0132                                  double z0,
0133                                  double iz0,
0134                                  int tp) {
0135   if (seedIndex == 0) {
0136     h_rinv_L1L2_->Fill(rinv);
0137     h_irinv_L1L2_->Fill(irinv);
0138     h_phi0_L1L2_->Fill(phi0);
0139     h_iphi0_L1L2_->Fill(iphi0);
0140     double phi0global = phi0 + iSector * 2 * M_PI / N_SECTOR;
0141     if (phi0global > M_PI)
0142       phi0global -= 2 * M_PI;
0143     if (phi0global < -M_PI)
0144       phi0global += 2 * M_PI;
0145     double iphi0global = iphi0 + iSector * 2 * M_PI / N_SECTOR;
0146     if (iphi0global > M_PI)
0147       iphi0global -= 2 * M_PI;
0148     if (iphi0global < -M_PI)
0149       iphi0global += 2 * M_PI;
0150     h_phi0global_L1L2_->Fill(phi0global);
0151     h_iphi0global_L1L2_->Fill(iphi0global);
0152     h_eta_L1L2_->Fill(eta);
0153     h_ieta_L1L2_->Fill(ieta);
0154     h_z0_L1L2_->Fill(z0);
0155     h_iz0_L1L2_->Fill(iz0);
0156     if (tp != 0) {
0157       h_rinv_matched_L1L2_->Fill(rinv);
0158       h_irinv_matched_L1L2_->Fill(irinv);
0159       h_phi0_matched_L1L2_->Fill(phi0);
0160       h_iphi0_matched_L1L2_->Fill(iphi0);
0161       h_phi0global_matched_L1L2_->Fill(phi0global);
0162       h_iphi0global_matched_L1L2_->Fill(iphi0global);
0163       h_eta_matched_L1L2_->Fill(eta);
0164       h_ieta_matched_L1L2_->Fill(ieta);
0165       h_z0_matched_L1L2_->Fill(z0);
0166       h_iz0_matched_L1L2_->Fill(iz0);
0167       L1SimTrack simtrk = globals->event()->simtrack(tp - 1);
0168       h_rinvres_L1L2_->Fill(rinv - (simtrk.charge() * 0.01 * 0.3 * 3.8 / simtrk.pt()));
0169       h_irinvres_L1L2_->Fill(irinv - (simtrk.charge() * 0.01 * 0.3 * 3.8 / simtrk.pt()));
0170       double simtrkphi0 = simtrk.phi();
0171       double dphiHG = 0.5 * settings->dphisectorHG() - M_PI / N_SECTOR;
0172       double phimin = +dphiHG - M_PI / N_SECTOR;
0173       double phioffset = phimin;
0174       while (iphi0 - phioffset - simtrkphi0 > M_PI / N_SECTOR)
0175         simtrkphi0 += 2 * M_PI / N_SECTOR;
0176       while (iphi0 - phioffset - simtrkphi0 < -M_PI / N_SECTOR)
0177         simtrkphi0 -= 2 * M_PI / N_SECTOR;
0178       h_phi0res_L1L2_->Fill(phi0 - phioffset - simtrkphi0);
0179       h_iphi0res_L1L2_->Fill(iphi0 - phioffset - simtrkphi0);
0180       h_etares_L1L2_->Fill(eta - simtrk.eta());
0181       h_ietares_L1L2_->Fill(ieta - simtrk.eta());
0182       h_z0res_L1L2_->Fill(z0 - simtrk.vz());
0183       h_iz0res_L1L2_->Fill(iz0 - simtrk.vz());
0184     }
0185   }
0186 
0187   return;
0188 }
0189 
0190 void HistImp::FillLayerResidual(
0191     int layer, int seed, double phiresid, double iphiresid, double zresid, double izresid, bool match) {
0192   if (layer == 3) {
0193     if (seed == 0) {
0194       h_layerresid_phi_L3_L1L2_->Fill(iphiresid);
0195       h_layerresid_phif_L3_L1L2_->Fill(phiresid);
0196       h_layerresid_z_L3_L1L2_->Fill(izresid);
0197       h_layerresid_zf_L3_L1L2_->Fill(zresid);
0198       if (match) {
0199         h_layerresid_phi_L3_L1L2_match_->Fill(iphiresid);
0200         h_layerresid_phif_L3_L1L2_match_->Fill(phiresid);
0201         h_layerresid_z_L3_L1L2_match_->Fill(izresid);
0202         h_layerresid_zf_L3_L1L2_match_->Fill(zresid);
0203       }
0204     }
0205   }
0206   return;
0207 }
0208 
0209 void HistImp::FillDiskResidual(
0210     int disk, int seed, double phiresid, double iphiresid, double rresid, double irresid, bool match) {
0211   if (disk == 1) {
0212     if (seed == 0) {
0213       h_diskresid_phi_D1_L1L2_->Fill(iphiresid);
0214       h_diskresid_phif_D1_L1L2_->Fill(phiresid);
0215       h_diskresid_r_D1_L1L2_->Fill(irresid);
0216       h_diskresid_rf_D1_L1L2_->Fill(rresid);
0217       if (match) {
0218         h_diskresid_phi_D1_L1L2_match_->Fill(iphiresid);
0219         h_diskresid_phif_D1_L1L2_match_->Fill(phiresid);
0220         h_diskresid_r_D1_L1L2_match_->Fill(irresid);
0221         h_diskresid_rf_D1_L1L2_match_->Fill(rresid);
0222       }
0223     }
0224   }
0225 
0226   return;
0227 }
0228 
0229 void HistImp::bookSeedEff() {
0230   TH1::AddDirectory(kTRUE);
0231 
0232   assert(h_file_ != nullptr);
0233   h_file_->cd();
0234 
0235   h_eff_eta_L1L2seed_ =
0236       new TEfficiency("Efficincy for L1L2 seeding vs eta", "Efficiency for L1L2 seeding vs eta", 50, -2.5, 2.5);
0237   h_eff_eta_L2L3seed_ =
0238       new TEfficiency("Efficincy for L2L3 seeding vs eta", "Efficiency for L2L3 seeding vs eta", 50, -2.5, 2.5);
0239   h_eff_eta_L3L4seed_ =
0240       new TEfficiency("Efficincy for L3L4 seeding vs eta", "Efficiency for L3L4 seeding vs eta", 50, -2.5, 2.5);
0241   h_eff_eta_L5L6seed_ =
0242       new TEfficiency("Efficincy for L5L6 seeding vs eta", "Efficiency for L5L6 seeding vs eta", 50, -2.5, 2.5);
0243   h_eff_eta_D1D2seed_ =
0244       new TEfficiency("Efficincy for D1D2 seeding vs eta", "Efficiency for D1D2 seeding vs eta", 50, -2.5, 2.5);
0245   h_eff_eta_D3D4seed_ =
0246       new TEfficiency("Efficincy for D3D4 seeding vs eta", "Efficiency for D3D4 seeding vs eta", 50, -2.5, 2.5);
0247   h_eff_eta_D1L1seed_ =
0248       new TEfficiency("Efficincy for D1L1 seeding vs eta", "Efficiency for D1L1 seeding vs eta", 50, -2.5, 2.5);
0249   h_eff_eta_D1L2seed_ =
0250       new TEfficiency("Efficincy for D1L2 seeding vs eta", "Efficiency for D1L2 seeding vs eta", 50, -2.5, 2.5);
0251 }
0252 
0253 void HistImp::fillSeedEff(int seedIndex, double etaTP, bool eff) {
0254   if (seedIndex == 0) {
0255     h_eff_eta_L1L2seed_->Fill(eff, etaTP);
0256   }
0257   if (seedIndex == 1) {
0258     h_eff_eta_L2L3seed_->Fill(eff, etaTP);
0259   }
0260   if (seedIndex == 2) {
0261     h_eff_eta_L3L4seed_->Fill(eff, etaTP);
0262   }
0263   if (seedIndex == 3) {
0264     h_eff_eta_L5L6seed_->Fill(eff, etaTP);
0265   }
0266   if (seedIndex == 4) {
0267     h_eff_eta_D1D2seed_->Fill(eff, etaTP);
0268   }
0269   if (seedIndex == 5) {
0270     h_eff_eta_D3D4seed_->Fill(eff, etaTP);
0271   }
0272   if (seedIndex == 6) {
0273     h_eff_eta_D1L1seed_->Fill(eff, etaTP);
0274   }
0275   if (seedIndex == 7) {
0276     h_eff_eta_D1L2seed_->Fill(eff, etaTP);
0277   }
0278 
0279   return;
0280 }