Kaynağa Gözat

Optimizes selection of "good" sim electrons. adds tm_coor plot.

Caleb 6 yıl önce
ebeveyn
işleme
86718ee0ba
3 değiştirilmiş dosya ile 35 ekleme ve 33 silme
  1. 4 4
      looper/analysis/config.yaml
  2. 30 28
      looper/analysis/tracking_eff.cpp
  3. 1 1
      looper/filval

+ 4 - 4
looper/analysis/config.yaml

@@ -120,8 +120,8 @@ hist-params:
         high_x: 3.0
     phi:
         nbins_x: 30
-        low_x: -3.2
-        high_x: 3.2
+        low_x: -3.14159
+        high_x: 3.14159
 
     pt_fine:
         nbins_x: 300
@@ -133,8 +133,8 @@ hist-params:
         high_x: 3.0
     phi_fine:
         nbins_x: 300
-        low_x: -3.2
-        high_x: 3.2
+        low_x: -3.14159
+        high_x: 3.14159
 
     gsf_tracks_nmatch_sim_tracks:
         label_x: "nMatchedSimTracks"

+ 30 - 28
looper/analysis/tracking_eff.cpp

@@ -19,6 +19,8 @@ SimVertexCollection sim_vertices;
 TrackCollection gsf_tracks;
 SuperClusterCollection scls;
 
+std::vector<SimTrack> sim_els;
+
 void register_objects(TrackingDataSet& tds){
     seeds.init(&tds);
     sim_tracks.init(&tds);
@@ -62,11 +64,6 @@ bool is_good_sim(const SimTrack& sim_track) {
            abs(sim_track.eta())<3.0;         // inside ECAL acceptance
 };
 
-//bool is_good_fake(const SimTrack& sim_track) {
-//    const auto& vertex = sim_vertices[sim_track.parentVtxIdx()];
-//    return abs(sim_track.pdgId()) != 11 and sim_track.q() != 0 and in_lum_region(vertex);
-//};
-
 bool is_good_seed(const Seed& seed, float hoe_cut) {
     return seed.isECALDriven() and seed.hoe() < hoe_cut;
 }
@@ -98,6 +95,13 @@ double deltaR(const SimTrack& sim_track, const Track& gsf_track) {
                 pow(sim_track.phi() - gsf_track.phi(), 2.0));
 }
 
+void update_sim_els() {
+    sim_els.clear();
+    for (const SimTrack sim_track: sim_tracks) {
+        if (is_good_sim(sim_track)) sim_els.push_back(sim_track);
+    }
+}
+
 
 auto get_match_stats(bool dRMatch) {
     int nSimTrack = 0;
@@ -112,16 +116,15 @@ auto get_match_stats(bool dRMatch) {
     vector<float> matched_dpT;
     std::map<int, std::vector<int>> sim_matches;
     std::map<int, std::vector<int>> gsf_matches;
-    for(const auto& sim_track : sim_tracks)
-        if (is_good_sim(sim_track)) sim_matches[sim_track.idx] = {};
+    for(const auto& sim_track : sim_els)
+        sim_matches[sim_track.idx] = {};
     for(const auto& gsf_track : gsf_tracks)
         gsf_matches[gsf_track.idx] = {};
 
     nSimTrack = sim_matches.size();
     nGSFTrack = gsf_matches.size();
 
-    for (const auto& sim_track : sim_tracks) {
-        if (!is_good_sim(sim_track)) continue;
+    for (const auto& sim_track : sim_els) {
         if (dRMatch) {
             for (const auto& gsf_track : gsf_tracks) {
                 float dR = deltaR(sim_track, gsf_track);
@@ -394,8 +397,13 @@ void run(){
     auto& reco_eta = *tds.register_container<ContainerTH1<float>>("reco_eta", THParams::lookup("eta_fine"));
     auto& reco_phi = *tds.register_container<ContainerTH1<float>>("reco_phi", THParams::lookup("phi_fine"));
 
+
+    auto& tm_corr = *tds.register_container<ContainerTH2<int>>("tm_corr", THParams(2, -0.5, 1.5, 2, -0.5, 1.5));
+
     while (tds.next()) {
 
+        update_sim_els();
+
         n_seeds.fill(seeds.size());
         size_t _n_good_seeds = 0;
         for (const auto& seed : seeds) {
@@ -408,12 +416,10 @@ void run(){
         }
         n_good_seeds.fill(_n_good_seeds);
 
-        for (const auto& sim_track : sim_tracks) {
-            if (is_good_sim(sim_track)) {
-                good_sim_kinems.pt->fill(sim_track.pt());
-                good_sim_kinems.eta->fill(sim_track.eta());
-                good_sim_kinems.phi->fill(sim_track.phi());
-            }
+        for (const auto& sim_track : sim_els) {
+            good_sim_kinems.pt->fill(sim_track.pt());
+            good_sim_kinems.eta->fill(sim_track.eta());
+            good_sim_kinems.phi->fill(sim_track.phi());
         }
 
         for (const auto& gsf_track : gsf_tracks) {
@@ -450,8 +456,7 @@ void run(){
         for(float dR : std::get<8>(match_stats)) matched_dR_dR.fill(dR);
         for(float dpT : std::get<9>(match_stats)) matched_dpT_dR.fill(dpT);
 
-        for (const auto& sim_track : sim_tracks) {
-            if (!is_good_sim(sim_track)) continue;
+        for (const auto& sim_track : sim_els) {
             sim_pt.fill(sim_track.pt());
             sim_eta.fill(sim_track.eta());
             sim_phi.fill(sim_track.phi());
@@ -463,8 +468,7 @@ void run(){
             reco_phi.fill(reco_track.phi());
         }
 
-        for (const auto& sim_track : sim_tracks) {
-            if (!is_good_sim(sim_track)) continue;
+        for (const auto& sim_track : sim_els) {
             if (seeds.size() == 0) continue;
             for (const auto &seed_idx : sim_track.seedIdx()) {
                 const Seed& seed = seeds[seed_idx];
@@ -474,8 +478,7 @@ void run(){
         }
 
         // Seeding Efficiency
-        for (const auto& sim_track : sim_tracks) {
-            if (!is_good_sim(sim_track)) continue;
+        for (const auto& sim_track : sim_els) {
             if (seeds.size() == 0) continue;
 
             bool matched = false;
@@ -495,8 +498,7 @@ void run(){
         }
 
         // Tracking Efficiency
-        for (const auto& sim_track : sim_tracks) {
-            if (!is_good_sim(sim_track)) continue;
+        for (const auto& sim_track : sim_els) {
             if (gsf_tracks.size() == 0) continue;
             bool matched = false;
             for (const auto& track_idx : sim_track.trkIdx()) {
@@ -536,7 +538,7 @@ void run(){
             if (!is_good_seed(seed, hoe_cut)) continue;
             bool match = false;
             for (const auto& sim_track_idx : seed.simTrkIdx()) {
-                if(is_good_sim(sim_tracks[sim_track_idx])) {
+                if (is_good_sim(sim_tracks[sim_track_idx])) {
                     match = true;
                     break;
                 }
@@ -570,9 +572,9 @@ void run(){
 
             // dR-matching
             matched = false;
-            for (const auto& sim_track : sim_tracks) {
+            for (const auto& sim_track : sim_els) {
                 double dR = deltaR(sim_track, gsf_track);
-                if (is_good_sim(sim_track) and dR < 0.2) {
+                if (dR < 0.2) {
                     matched = true;
                     break;
                 }
@@ -601,8 +603,7 @@ void run(){
         std::set<size_t> tm_scls; // Set of super-clusters with well matched sim-electrons
         for (const auto &scl : scls) {
             Vec4 p4 = scl_p4(scl);
-            for(const auto& sim_track : sim_tracks) {
-                if (!is_good_sim(sim_track)) continue;
+            for(const auto& sim_track : sim_els) {
                 if (deltaR(p4.eta(), p4.phi(), sim_track) > 0.2) continue;
                 if (((p4.Et() - sim_track.pt()) / p4.Et()) > 0.1) continue;
                 tm_scls.insert(scl.idx);
@@ -678,6 +679,7 @@ void run(){
             } else {
                 tm_types = {NoMatch};
             }
+            tm_corr.fill(is_seed_sim_matched, is_track_sim_matched);
 
             vector<int>   hits_valid;
             vector<float> hits_dRz;

+ 1 - 1
looper/filval

@@ -1 +1 @@
-Subproject commit a83921cf4b2033e4278b43fa69f7059cd76a0bf1
+Subproject commit 1316fbe1dba82784d3ba92f2005f2abf5c1dc054