Commit 8f0f3d4b5a500786cba4ecf904f6ebddc39d655e

Authored by Marcel Hohmann
1 parent 7029bfa5

more stats, TEfficiency plots not saving

DualTrackTagger/include/DualTrackTaggerModule.h
... ... @@ -27,6 +27,7 @@
27 27 #include "TMath.h"
28 28 #include "TH1F.h"
29 29 #include "TString.h"
  30 +#include "TEfficiency.h"
30 31  
31 32 // Include MVA classes - TEST
32 33 #include <analysis/modules/DualTrackTagger/TMVAClassification_BDT5.class.h>
... ... @@ -46,7 +47,6 @@ namespace Belle2 {
46 47  
47 48 virtual ~DualTrackTaggerModule();
48 49  
49   - virtual void defineHisto(); //Define the histograms
50 50  
51 51 virtual void initialize() override;
52 52  
... ... @@ -79,9 +79,21 @@ namespace Belle2 {
79 79 /** Calculates BN#1079 sec 4.1 chi2 */
80 80 virtual double chi2(Particle* p);
81 81  
  82 +
  83 + // ---------------- Functions related to Histos ------------
  84 +
  85 + /** define the histograms - only if MCFlag = true */
  86 + virtual void defineHisto();
  87 +
82 88 /** Used to fill histogram showing # of tracks associated with one MC particle */
83 89 virtual void fill_h_genParticleIndexMulti();
84 90  
  91 + /** Calculate TEfficiency Plots */
  92 + virtual void finalizeHistograms();
  93 +
  94 + /** Fill Basic Histograms */
  95 + virtual void fillHistograms(Particle *p1, Particle *p2, bool taggedDuplicate);
  96 +
85 97 std::vector<Particle*> m_candidateParticles; // particles with low pt
86 98 std::vector<Particle*> m_allParticlesInList; // used for statistics
87 99  
... ... @@ -106,6 +118,15 @@ namespace Belle2 {
106 118 TH1F *h_genParticleIndexMulti;
107 119 TH1F *h_Duplicates;
108 120 TH1F *h_Singles;
  121 + TH1F *h_taggedDuplicate;
  122 +
  123 + TH1F *h_TruePosPt;
  124 + TH1F *h_FalsePosPt;
  125 + TH1F *h_TrueNegPt;
  126 + TH1F *h_FalseNegPt;
  127 +
  128 + TEfficiency *h_effTruePosPt;
  129 + TEfficiency *h_effFalsePosPt;
109 130 };
110 131 }
111 132 #endif
... ...
DualTrackTagger/src/DualTrackTaggerModule.cc
... ... @@ -34,17 +34,6 @@
34 34 {
35 35 }
36 36  
37   - void DualTrackTaggerModule::defineHisto()
38   - {
39   - h_genParticleIndexMulti = new TH1F("h_genParticleIndexMulti","h_genParticleIndexMulti; # of particles with same genParticleIndex",20,0,20);
40   - //h_SameChargeMultAngle = new TH1F("h_SameChargeMultAngle", "h_SameChargeMultAngle; #Angle between two particles - both pos/neg",100,0,TMath::Pi());
41   - //h_OppoChargeMultAngle = new TH1F("h_OppoChargeMultAngle", "h_OppoChargeMultAngle; #Angle between two particles - one pos, one neg",100,0,TMath::Pi());
42   - h_Duplicates = new TH1F("h_Duplicates","h_Duplicates; 0 = Correctly Identified, 1 = Misidentified",2,0,2);
43   - h_Singles = new TH1F("h_Singles","h_Singles; 0 = Correctly Identified, 1 = Misidentified",2,0,2);
44   - //h_pt_dual = new TH1F
45   - //h_pt_sig = new TH1F
46   - }
47   -
48 37 void DualTrackTaggerModule::initialize()
49 38 {
50 39 m_particles.isRequired();
... ... @@ -153,20 +142,7 @@
153 142 } // duplicats
154 143  
155 144 // Fill histograms
156   - if (Variable::genParticleIndex(p1) == Variable::genParticleIndex(p2)) {
157   - if (duplicates) {
158   - h_Duplicates -> Fill(0);
159   - } else {
160   - h_Duplicates -> Fill(1);
161   - }
162   - } else {
163   - if (duplicates) {
164   - h_Singles -> Fill(1);
165   - } else {
166   - h_Singles -> Fill(0);
167   - }
168   - } // different genParticleIndex
169   -
  145 + fillHistograms(p1, p2, duplicates);
170 146 } //p2
171 147 } //p1
172 148 }
... ... @@ -198,7 +174,7 @@
198 174 return false;
199 175 }
200 176 return false;
201   -
  177 +
202 178 } else { // BELLE 2
203 179 // calculate Variables
204 180 double magDiffP = (p1->getMomentum() - p2->getMomentum() ).Mag();
... ... @@ -244,8 +220,29 @@
244 220 return TMath::Power(gamma*Variable::particleDRho(p),2) + TMath::Power(Variable::particleDZ(p),2);
245 221 }
246 222  
  223 +
  224 + void DualTrackTaggerModule::defineHisto()
  225 + {
  226 + h_genParticleIndexMulti = new TH1F("h_genParticleIndexMulti","h_genParticleIndexMulti; # of particles with same genParticleIndex",20,0,20);
  227 + //h_SameChargeMultAngle = new TH1F("h_SameChargeMultAngle", "h_SameChargeMultAngle; #Angle between two particles - both pos/neg",100,0,TMath::Pi());
  228 + //h_OppoChargeMultAngle = new TH1F("h_OppoChargeMultAngle", "h_OppoChargeMultAngle; #Angle between two particles - one pos, one neg",100,0,TMath::Pi());
  229 + h_Duplicates = new TH1F("h_Duplicates","True Duplicates; 0 = Correctly Identified, 1 = False Negative",2,0,2);
  230 + h_Singles = new TH1F("h_Singles","True Single Track Pairs; 0 = Correctly Identified, 1 = False Positive",2,0,2);
  231 + h_taggedDuplicate = new TH1F("h_taggedDuplicate", "Pairs tagged as Duplicate; 0 = correctly Identified, 1 = False Positive",2,0,2);
  232 +
  233 + h_TruePosPt = new TH1F("h_TruePosPt","True Positive Duplicates ;pT",100,0,0.5);
  234 + h_FalsePosPt = new TH1F("h_FalsePosPt","False Positive Duplicates ;pT",100,0,0.5);
  235 + h_TrueNegPt = new TH1F("h_TrueNegPt","True Negative Singles ;pT",100,0,0.5);
  236 + h_FalseNegPt = new TH1F("h_FalseNegPt","False Negative Singles ;pT",100,0,0.5);
  237 +
  238 + h_effTruePosPt = new TEfficiency;
  239 + h_effFalsePosPt = new TEfficiency;
  240 + }
  241 +
247 242 void DualTrackTaggerModule::fill_h_genParticleIndexMulti()
248 243 {
  244 + if (!m_MCFlag) return;
  245 +
249 246 std::vector<std::pair<int,int>> v_MCIndex;
250 247  
251 248 const unsigned int nParticles = m_allParticlesInList.size();
... ... @@ -277,6 +274,59 @@
277 274 }
278 275 }
279 276  
  277 + void DualTrackTaggerModule::fillHistograms(Particle *p1, Particle *p2, bool taggedDuplicate)
  278 + {
  279 + if (!m_MCFlag) return;
  280 +
  281 + bool MCduplicate = Variable::genParticleIndex(p1) == Variable::genParticleIndex(p2);
  282 +
  283 + if (MCduplicate && taggedDuplicate) {
  284 + h_Duplicates -> Fill(0);
  285 + h_taggedDuplicate -> Fill(0);
  286 +
  287 + h_TruePosPt -> Fill(Variable::particlePt(p1));
  288 + h_TruePosPt -> Fill(Variable::particlePt(p2));
  289 + }
  290 +
  291 + if (MCduplicate && !taggedDuplicate) {
  292 + h_Duplicates -> Fill(1);
  293 +
  294 + h_FalseNegPt -> Fill(Variable::particlePt(p1));
  295 + h_FalseNegPt -> Fill(Variable::particlePt(p2));
  296 + }
  297 +
  298 + if (!MCduplicate && taggedDuplicate) {
  299 + h_Singles -> Fill(1);
  300 + h_taggedDuplicate -> Fill(1);
  301 +
  302 + h_FalsePosPt -> Fill(Variable::particlePt(p1));
  303 + h_FalsePosPt -> Fill(Variable::particlePt(p2));
  304 +
  305 + }
  306 +
  307 + if (!MCduplicate && !taggedDuplicate) {
  308 + h_Singles -> Fill(0);
  309 +
  310 + h_TrueNegPt -> Fill(Variable::particlePt(p1));
  311 + h_TrueNegPt -> Fill(Variable::particlePt(p2));
  312 + }
  313 +
  314 + } // fill histograms
  315 +
  316 + void DualTrackTaggerModule::finalizeHistograms()
  317 + {
  318 + if (!m_MCFlag) return;
  319 +
  320 + TH1F *h_AllDuplicatesPt = (TH1F*)h_TruePosPt->Clone();
  321 + h_AllDuplicatesPt -> Add(h_FalseNegPt);
  322 + TH1F *h_AllSinglesPt = (TH1F*)h_FalsePosPt->Clone();
  323 + h_AllSinglesPt -> Add(h_TrueNegPt);
  324 +
  325 +
  326 + h_effTruePosPt = new TEfficiency(*h_TruePosPt, *h_AllDuplicatesPt);
  327 + h_effFalsePosPt = new TEfficiency(*h_FalsePosPt, *h_AllSinglesPt);
  328 + }
  329 +
280 330 //void DualTrackTaggerModule::GroupParticles()
281 331 //{
282 332 //}
... ...