Commit 9c1342db authored by Jochen Meyer's avatar Jochen Meyer Committed by Graeme Stewart
Browse files

Updating MboyPerformance-07-85-00 (MboyPerformance-07-85-00)

parent d96e3b80
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#define AANTEvent_cxx
#include "AANTEvent.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
void AANTEvent::Loop()
{
// In a ROOT session, you can do:
// Root > .L AANTEvent.C
// Root > AANTEvent t
// Root > t.GetEntry(12); // Fill t data members with entry number 12
// Root > t.Show(); // Show values of entry 12
// Root > t.Show(16); // Read and show values of entry 16
// Root > t.Loop(); // Loop on all entries
//
// This is the loop skeleton where:
// jentry is the global entry number in the chain
// ientry is the entry number in the current Tree
// Note that the argument to GetEntry must be:
// jentry for TChain::GetEntry
// ientry for TTree::GetEntry and TBranch::GetEntry
//
// To read only selected branches, Insert statements like:
// METHOD1:
// fChain->SetBranchStatus("*",0); // disable all branches
// fChain->SetBranchStatus("branchname",1); // activate branchname
// METHOD2: replace line
// fChain->GetEntry(jentry); //read all branches
//by b_branchname->GetEntry(ientry); //read only this branch
if (fChain == 0) return;
Long64_t nentries = fChain->GetEntriesFast();
Long64_t nbytes = 0, nb = 0;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
// if (Cut(ientry) < 0) continue;
}
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
//
// Author : Saclay Muon Software Group SaMuSoG
// Date : 30/03/00
//
// The AANTMisc header contains all this Bxxxxy stuff
//
#ifndef AANTMisc_H
#define AANTMisc_H
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <TH1.h>
#include <TH2.h>
#include <TF1.h>
#include <TMath.h>
#include <TProfile.h>
#include <TCanvas.h>
#include <TLegend.h>
#include <TGraph.h>
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "Analysis.h"
#include <iostream>
Assoc* Analysis::p_assocMB = new Assoc("mboy", "IP");
Assoc* Analysis::p_assocMS = new Assoc("mboy", "MS");
Assoc* Analysis::p_assocST = new Assoc("stac");
Assoc* Analysis::p_assocMU = new Assoc("mtag");
int Analysis::m_Nassoc = 0;
char* Analysis::m_comment = 0;
Analysis::Analysis():HasEvt() {
m_PI = 3.14159265;
m_LARGPS = 800;
m_HAUTPS = 600;
}
Analysis::~Analysis() {}
void Analysis::setComment(char* comm) { m_comment = comm; }
void Analysis::setAssoCuts(int nsigAng, int nsigMom) {
p_assocMS->setCuts(nsigAng, nsigMom);
p_assocMB->setCuts(nsigAng, nsigMom);
p_assocST->setCuts(nsigAng, nsigMom);
p_assocMU->setCuts(nsigAng, nsigMom);
}
void Analysis::doAssoc() {
p_assocMS->associe();
p_assocMB->associe();
p_assocST->associe();
p_assocMU->associe();
m_Nassoc++;
if(m_Nassoc < 10) {
cout << "============" << p_evt->Run << " " << p_evt->Event << "=============" << endl;
p_assocMB->InfoAssociation();
p_assocMS->InfoAssociation();
p_assocST->InfoAssociation();
p_assocMU->InfoAssociation();
}
}
void Analysis::closeAssoc() {
p_assocMB->close();
p_assocMS->close();
p_assocST->close();
p_assocMU->close();
}
bool Analysis::isInsideAcceptance(Assoc* asso, float eta) {
if(strcmp(asso->m_type, "mboy") != 0 || strcmp(asso->m_lieu, "ID") == 0) {
return (fabs(eta) < 2.5);
} else {
return (fabs(eta) < 2.7);
}
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef Analysis_h
#define Analysis_h
#include "HasEvt.h"
#include "TString.h"
#include "AANTMisc.h"
#include "Assoc.h"
class Analysis : public HasEvt {
public:
Analysis();
virtual ~Analysis( );
public:
///////////////////////////////////
virtual void initialize(char* option) = 0 ;
virtual void execute() = 0 ;
virtual void finalize() = 0 ;
void setAssoCuts(int nsigAng, int nsigMom);
bool isInsideAcceptance(Assoc* asso, float eta);
static void setComment(char* comm);
static void doAssoc();
static void closeAssoc();
float m_PI ;
int m_LARGPS ;
int m_HAUTPS ;
static char* m_comment;
static Assoc* p_assocMB;
static Assoc* p_assocMS;
static Assoc* p_assocST;
static Assoc* p_assocMU;
static Assoc* p_assocID;
static Assoc* p_assocMI;
static int m_Nassoc;
};
#endif //
This diff is collapsed.
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: $
#ifndef Assoc_h
#define Assoc_h
#include "HasEvt.h"
// Include files
#include "AANTMisc.h"
/** @class Assoc Assoc.h source/Assoc.h
*
*
* @author SaMuSoG
* @date 2005-06-03
*/
class Assoc: public HasEvt {
public:
Assoc(char * s, char * v = "IP");
~Assoc( );
public:
///////////////////////////////////
// Perform Association
void associe();
void setCuts(int nsigAng, int nsigMom);
// Is the simulated track a muon
bool isMuonSimul(int i);
bool isMuonDirect(int i);
// Is the track NOT a muon candidate
bool isFake(int i);
// Is the track within Angular cut but fails Chi2 cut
bool isDuplicated(int i);
// Is the track outside angular cut
bool isAdditional(int i);
// Is the track a muon (within anglura and chi2 cuts)
bool isMuon(int i);
// Is the track irec inside cone of isim
bool isInsideCone(int irec, int isim);
int getNsim();
int getNrec();
// Get associated gen Muon
int getSim(int i);
int getConeSim(int i);
// get associated rec Muon
int getRec(int i);
int getNCone(int i);
// Close
void close();
// Book Histos
void BookHistos();
// Dump info on Association
void InfoAssociation();
float getEtaSim(int isim);
float getD0Sim(int isim);
float getZ0Sim(int isim);
float getPhiSim(int isim);
float getThetaSim(int isim);
float getChargeSurPSim(int isim);
float getEtaRec(int irec);
float getD0Rec(int irec);
float getZ0Rec(int irec);
float getPhiRec(int irec);
float getThetaRec(int irec);
float getChargeSurPRec(int irec);
float getPtRec(int irec);
float getDeltaD0(int irec, int isim);
float getDeltaZ0(int irec, int isim);
float getDeltaPhi(int irec, int isim);
float getDeltaEta(int irec, int isim);
float getDeltaTheta(int irec, int isim);
float getDeltaUnSurP(int irec, int isim);
float getDeltaPSurPnoSign(int irec, int isim);
float getDeltaPSurP(int irec, int isim);
float getDeltaP(int irec, int isim);
float getPullD0(int irec, int isim);
float getPullZ0(int irec, int isim);
float getPullPhi(int irec, int isim);
float getPullTheta(int irec, int isim);
float getPullUnSurP(int irec, int isim);
char * m_type;
char * m_lieu;
private:
///////////////////////////////////
// Association type definition
// char * m_type;
// char * m_lieu;
//
// Cuts
float m_AngCut;
float m_MomCut;
// Sim stuff
int m_Nsim ;
int m_NassoCone[4000]; // Nb of associated muons (angular cut)
int m_listAssoCone[4000][50]; // list of associated muons (angular cut)
// Rec stuff
int m_Nrec ;
int m_coneRec[4000];
int m_assoRec[4000];
float m_PI ;
int m_NMAX ;
};
#endif //
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef Efficiency_h
#define Efficiency_h
#include "Analysis.h"
#include "AANTMisc.h"
class Efficiency : public Analysis {
public:
Efficiency();
virtual ~Efficiency();
public:
///////////////////////////////////
virtual void initialize(char* option);
virtual void execute();
virtual void finalize();
private:
///////////////////////////////////
// Methods
void beginEfficiencies();
void efficiencies();
void endEfficiencies();
int getEtaBin(float eta);
int getEtaZone(float eta);
// Data
bool m_Debug;
int m_nevt ;
};
#endif //
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "Fakes.h"
#include "TH2.h"
#include "TProfile.h"
#include "TF1.h"
#include "TDatime.h"
#include "TStyle.h"
#include "TCanvas.h"
#include "math.h"
#include "TMath.h"
#include <iostream>
#include "TPostScript.h"
#include "TPaveLabel.h"
#include "TPaveText.h"
#include "TGraph.h"
#include "TGaxis.h"
#include "TLegend.h"
#include "TPaveStats.h"
#include "TGraphErrors.h"
const int nzon = 3;
const float etazon[nzon+2] = { 0.0, 1.0, 2.0, 2.7, 9.9 };
TH1F *simuVSphi[10][nzon];
TH1F *fakeVSphi[10][nzon];
TH1F *chistaMuon, *chistaFake, *chidofMuon, *chidofFake;
TH1F *chicanMuon, *chicanFake, *chifitMuon, *chifitFake, *chiverMuon, *chiverFake;
TH2F *chifitVsdofMuon, *chifitVsdofFake;
TH1F *erphipMB, *ertetpMB, *erphivMB, *ertetvMB, *errqspMB;
TH1F *erphipST, *ertetpST, *erphivST, *ertetvST, *errqspST;
TH1F *erred0IP, *errez0IP, *errphiIP, *errtetIP, *errqspIP;
Fakes::Fakes():Analysis() {
m_nevt = 0;
m_Nassoc = 3;
p_assoc[0] = p_assocMB; m_sing[0] = 0;
p_assoc[1] = p_assocST; m_sing[1] = 0;
p_assoc[2] = p_assocMS; m_sing[2] = 0;
}
Fakes::~Fakes() {}
void Fakes::initialize(char* option) {
printf("Starting Fakes\n");
for (int i=0; i<m_Nassoc; i++) bookHistos(i);
chistaMuon = new TH1F("chistaMuon", "chistaMuon", 100, 0., 1000.);
chistaFake = new TH1F("chistaFake", "chistaFake", 100, 0., 1000.);
chidofMuon = new TH1F("chidofMuon", "chidofMuon", 100, 0., 50.);
chidofFake = new TH1F("chidofFake", "chidofFake", 100, 0., 50.);
chicanMuon = new TH1F("chicanMuon", "chicanMuon", 100, 0., 500.);
chicanFake = new TH1F("chicanFake", "chicanFake", 100, 0., 500.);
chifitMuon = new TH1F("chifitMuon", "chifitMuon", 100, 0., 200.);
chifitFake = new TH1F("chifitFake", "chifitFake", 100, 0., 200.);
chiverMuon = new TH1F("chiverMuon", "chiverMuon", 100, 0., 100.);
chiverFake = new TH1F("chiverFake", "chiverFake", 100, 0., 100.);
erphipMB = new TH1F("erphipMB", "erphipMB", 100, -6., 2.);
ertetpMB = new TH1F("ertetpMB", "ertetpMB", 100, -6., 2.);
erphivMB = new TH1F("erphivMB", "erphivMB", 100, -6., 2.);
ertetvMB = new TH1F("ertetvMB", "ertetvMB", 100, -6., 2.);
errqspMB = new TH1F("errqspMB", "errqspMB", 100, -8., 0.);
erphipST = new TH1F("erphipST", "erphipST", 100, -6., 2.);
ertetpST = new TH1F("ertetpST", "ertetpST", 100, -6., 2.);
erphivST = new TH1F("erphivST", "erphivST", 100, -6., 2.);
ertetvST = new TH1F("ertetvST", "ertetvST", 100, -6., 2.);
errqspST = new TH1F("errqspST", "errqspST", 100, -8., 0.);
erred0IP = new TH1F("erred0IP", "erred0IP", 100, -2., 6.);
errez0IP = new TH1F("errez0IP", "errez0IP", 100, -2., 6.);
errphiIP = new TH1F("errphiIP", "errphiIP", 100, -5., 3.);
errtetIP = new TH1F("errtetIP", "errtetIP", 100, -6., 2.);
errqspIP = new TH1F("errqspIP", "errqspIP", 100, -8., 0.);
chifitVsdofMuon = new TH2F("chifitVsdofMuon", "chifitVsdofMuon", 40,0.,80., 50,0.,200);
chifitVsdofFake = new TH2F("chifitVsdofFake", "chifitVsdofFake", 40,0.,80., 50,0.,200);
}
void Fakes::execute() {
for (int i=0; i<m_Nassoc; i++) checkAssoc(i);
for (int i=0; i<m_Nassoc; i++) studyFakes(i);
m_nevt++;
Assoc* asso = p_assocMS;
for (int irec=0; irec<asso->getNrec(); irec++) {
float chi2 = (p_evt->MboyTrkMS_Chistat)->at(irec);
if( asso->isFake(irec)) chistaFake->Fill(chi2);
else if(asso->isMuon(irec)) chistaMuon->Fill(chi2);
chi2 = chi2 / (p_evt->MboyTrkMS_Ndof)->at(irec);
if( asso->isFake(irec)) chidofFake->Fill(chi2);
else if(asso->isMuon(irec)) chidofMuon->Fill(chi2);
chi2 = (p_evt->MboyTrkMS_Chican)->at(irec);
if( asso->isFake(irec)) chicanFake->Fill(chi2);
else if(asso->isMuon(irec)) chicanMuon->Fill(chi2);
chi2 = (p_evt->MboyTrkMS_Chifit)->at(irec);
if( asso->isFake(irec)) chifitFake->Fill(chi2);
else if(asso->isMuon(irec)) chifitMuon->Fill(chi2);
int ndof = (p_evt->MboyTrkMS_Ndof)->at(irec);
if( asso->isFake(irec)) chifitVsdofFake->Fill(ndof,chi2);
else if(asso->isMuon(irec)) chifitVsdofMuon->Fill(ndof,chi2);
if( asso->isFake(irec)) chifitFake->Fill(chi2);
else if(asso->isMuon(irec)) chifitMuon->Fill(chi2);
chi2 = (p_evt->MboyTrkMS_Chiver)->at(irec);
if( asso->isFake(irec)) chiverFake->Fill(chi2);
else if(asso->isMuon(irec)) chiverMuon->Fill(chi2);
}
for (int irec=0; irec<p_evt->MboyTrkMS_NTrk; irec++) {
ertetpMB->Fill( log10( sqrt( (p_evt->MboyTrkMS_Cov11)->at(irec) ) ) );
erphipMB->Fill( log10( sqrt( (p_evt->MboyTrkMS_Cov22)->at(irec) ) ) );
ertetvMB->Fill( log10( sqrt( (p_evt->MboyTrkMS_Cov33)->at(irec) ) ) );
erphivMB->Fill( log10( sqrt( (p_evt->MboyTrkMS_Cov44)->at(irec) ) ) );
errqspMB->Fill( log10( sqrt( (p_evt->MboyTrkMS_Cov55)->at(irec) ) ) );
for (int ista=0; ista<p_evt->staco_nmuon; ista++) {
if(fabs(p_assocMB->getThetaRec(irec)-(p_evt->staco_ThetaMS)->at(ista))<0.00001 &&
fabs(p_assocMB->getPhiRec(irec)-(p_evt->staco_PhiMS)->at(ista))<0.00001) {
ertetpST->Fill( log10( sqrt( (p_evt->MboyTrkMS_Cov11)->at(irec) ) ) );
erphipST->Fill( log10( sqrt( (p_evt->MboyTrkMS_Cov22)->at(irec) ) ) );
ertetvST->Fill( log10( sqrt( (p_evt->MboyTrkMS_Cov33)->at(irec) ) ) );
erphivST->Fill( log10( sqrt( (p_evt->MboyTrkMS_Cov44)->at(irec) ) ) );
errqspST->Fill( log10( sqrt( (p_evt->MboyTrkMS_Cov55)->at(irec) ) ) );
}
}
erred0IP->Fill( log10( sqrt( (p_evt->MboyESD_covr11)->at(irec) ) ) );
errez0IP->Fill( log10( sqrt( (p_evt->MboyESD_covr22)->at(irec) ) ) );
errphiIP->Fill( log10( sqrt( (p_evt->MboyESD_covr33)->at(irec) ) ) );
errtetIP->Fill( log10( sqrt( (p_evt->MboyESD_covr44)->at(irec) ) ) );
errqspIP->Fill( log10( sqrt( (p_evt->MboyESD_covr55)->at(irec) ) ) );
}
}
void Fakes::finalize() {
for (int i=0; i<m_Nassoc; i++) closeHistos(i);
}
void Fakes::bookHistos(int i) {
char titre[80], nom[80];
char* type = p_assoc[i]->m_type;
char* lieu = p_assoc[i]->m_lieu;
sprintf(nom , "pullPhiAsso%s%s", type, lieu);
sprintf(titre, "pullPhi asso %s %s (%s)", type, lieu, m_comment);
p_pullPhi[i] = new TH1F(nom, titre, 100, -10., 10.);
sprintf(nom , "pullThetaAsso%s%s", type, lieu);
sprintf(titre, "pullTheta asso %s %s (%s)", type, lieu, m_comment);
p_pullTheta[i] = new TH1F(nom, titre, 100, -10., 10.);
sprintf(nom , "p_pullPAsso%s%s", type, lieu);
sprintf(titre, "p_pullP asso %s %s (%s)", type, lieu, m_comment);
p_pullP[i] = new TH1F(nom, titre, 100, -10., 10.);
sprintf(nom , "Nfake%s%s", type, lieu);
sprintf(titre, "Nfake %s %s (%s)", type, lieu, m_comment);
p_histNfake[i] = new TH1F(nom, titre, 20, -0.5, 19.5);
sprintf(nom , "Naddi%s%s", type, lieu);
sprintf(titre, "Naddi %s %s (%s)", type, lieu, m_comment);
p_histNaddi[i] = new TH1F(nom, titre, 20, -0.5, 19.5);
sprintf(nom , "Ndupli%s%s", type, lieu);
sprintf(titre, "Ndupli %s %s (%s)", type, lieu, m_comment);
p_histNdupli[i] = new TH1F(nom, titre, 20, -0.5, 19.5);
sprintf(nom , "Nmuon%s%s", type, lieu);
sprintf(titre, "Nmuon %s %s (%s)", type, lieu, m_comment);
p_histNmuon[i] = new TH1F(nom, titre, 20, -0.5, 19.5);
sprintf(nom , "fakeVSmuon%s%s", type, lieu);
sprintf(titre, "fake vs muon %s %s (%s)", type, lieu, m_comment);
p_histFake[i] = new TH2F(nom, titre, 10,0.,10., 10,0.,10.);
sprintf(nom , "simuVSeta%s%s", type, lieu);
p_simuVSeta[i] = new TH1F(nom, nom, 60, 0.0, 3.0);
sprintf(nom , "fakeVSeta%s%s", type, lieu);
sprintf(titre, "fakes vs eta %s %s (%s)", type, lieu, m_comment);
p_fakeVSeta[i] = new TH1F(nom, titre, 60, 0.0, 3.0);
for (int izon=0; izon<nzon; izon++) {
sprintf(nom , "simuVSphi%s%s%d", type, lieu, izon);
simuVSphi[i][izon] = new TH1F(nom, nom, 32, -180., 180.);
sprintf(nom , "fakeVSphi%s%s%d", type, lieu, izon);
sprintf(titre, "fakes vs phi %s %s (%s) %.1f<abs(eta)<%.1f", type, lieu, m_comment, etazon[izon], etazon[izon+1]);
fakeVSphi[i][izon] = new TH1F(nom, titre, 32, -180., 180.);
}
}
void Fakes::closeHistos(int i) {
Assoc* assoc = p_assoc[i];
TCanvas* canvas;
bool psOuvert = false;
char psfile[80], nom[80];
gStyle->SetOptStat(111110);
sprintf(nom , "Fakes%s%s", assoc->m_type, assoc->m_lieu);
if(m_sing[i] > 10) {
canvas = new TCanvas(nom, nom, 300, 10, 800, 600);
canvas->Divide(3, 2);
canvas->cd(1); gPad->SetLogy(1); p_pullPhi[i]->Draw();
canvas->cd(2); gPad->SetLogy(1); p_pullTheta[i]->Draw();
canvas->cd(3); gPad->SetLogy(1); p_pullP[i]->Draw();
canvas->cd(4); p_pullPhi[i]->Draw();
canvas->cd(5); p_pullTheta[i]->Draw();
canvas->cd(6); p_pullP[i]->Draw();
canvas->Update();
sprintf(psfile, "%s%s.ps(", nom, m_comment);
canvas->Print(psfile);
psOuvert = true;
delete canvas;
}