From 917559ee4e98832e2ed1f110c73b9882011da943 Mon Sep 17 00:00:00 2001 From: cblume Date: Thu, 27 Mar 2008 12:36:14 +0000 Subject: [PATCH] Add QA analysis classes --- TRD/qaAnalysis/AliTRDqaAT.cxx | 101 ++++++++ TRD/qaAnalysis/AliTRDqaAT.h | 35 +++ TRD/qaAnalysis/AliTRDqaESDFriends.cxx | 188 ++++++++++++++ TRD/qaAnalysis/AliTRDqaESDFriends.h | 54 ++++ TRD/qaAnalysis/AliTRDqaElectronSpectra.cxx | 283 +++++++++++++++++++++ TRD/qaAnalysis/AliTRDqaElectronSpectra.h | 76 ++++++ TRD/qaAnalysis/AliTRDqaEnergyDeposit.cxx | 219 ++++++++++++++++ TRD/qaAnalysis/AliTRDqaEnergyDeposit.h | 57 +++++ TRD/qaAnalysis/drawEnergyDeposit.C | 45 ++++ TRD/qaAnalysis/runTRDqaAnalysis.C | 81 ++++++ 10 files changed, 1139 insertions(+) create mode 100644 TRD/qaAnalysis/AliTRDqaAT.cxx create mode 100644 TRD/qaAnalysis/AliTRDqaAT.h create mode 100644 TRD/qaAnalysis/AliTRDqaESDFriends.cxx create mode 100644 TRD/qaAnalysis/AliTRDqaESDFriends.h create mode 100644 TRD/qaAnalysis/AliTRDqaElectronSpectra.cxx create mode 100644 TRD/qaAnalysis/AliTRDqaElectronSpectra.h create mode 100644 TRD/qaAnalysis/AliTRDqaEnergyDeposit.cxx create mode 100644 TRD/qaAnalysis/AliTRDqaEnergyDeposit.h create mode 100644 TRD/qaAnalysis/drawEnergyDeposit.C create mode 100644 TRD/qaAnalysis/runTRDqaAnalysis.C diff --git a/TRD/qaAnalysis/AliTRDqaAT.cxx b/TRD/qaAnalysis/AliTRDqaAT.cxx new file mode 100644 index 00000000000..29c3b94d47a --- /dev/null +++ b/TRD/qaAnalysis/AliTRDqaAT.cxx @@ -0,0 +1,101 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id: AliTRDqaAT.cxx $ */ + +// +// This class is a part of a package of high level QA monitoring for TRD. +// In this class provides a commonly used tools as static functions. +// +// S. Radomski +// radomski@physi.uni-heidelberg.de +// March 2008 +// + +#include "AliTRDqaAT.h" + +#include "TMath.h" +#include "TH1D.h" +#include "AliExternalTrackParam.h" + +//______________________________________________________________________________ + +AliTRDqaAT::AliTRDqaAT() { + // + // Dummy contructor + // + +} + +//______________________________________________________________________________ +Int_t AliTRDqaAT::GetSector(const Double_t alpha) +{ + // Gets the sector number + + Double_t size = TMath::DegToRad() * 20.; + Int_t sector = (Int_t)((alpha + TMath::Pi())/size); + return sector; +} + +//______________________________________________________________________________ + +Int_t AliTRDqaAT::GetStack(const AliExternalTrackParam *paramOut) +{ + // + // calculates the stack the track is in + // + + const Double_t l = -0.9; + const Double_t w = (2*l)/5; + + Double_t tan = paramOut->GetZ() / paramOut->GetX(); + Double_t pos = (tan - l) / w; + return (Int_t) pos; +} + +//______________________________________________________________________________ + +void AliTRDqaAT::BuildRatio(TH1D *ratio, TH1D *histN, TH1D*histD) { + // + // Calculate the ratio of two histograms + // error are calculated assuming the histos have the same counts + // + + // calclate + + Int_t nbins = histN->GetXaxis()->GetNbins(); + for(Int_t i=1; iGetBinContent(i); + Double_t valueD = histD->GetBinContent(i); + + if (valueD < 1) { + ratio->SetBinContent(i, 0); + ratio->SetBinError(i, 0); + continue; + } + + Double_t eps = (valueN < valueD-valueN)? valueN : valueD-valueN; + + ratio->SetBinContent(i, valueN/valueD); + ratio->SetBinError(i, TMath::Sqrt(eps)/valueD); + } + + // style + ratio->SetMinimum(-0.1); + ratio->SetMaximum(1.1); + ratio->SetMarkerStyle(20); +} +//__________________________________________________________________________ diff --git a/TRD/qaAnalysis/AliTRDqaAT.h b/TRD/qaAnalysis/AliTRDqaAT.h new file mode 100644 index 00000000000..a9d82bd12b6 --- /dev/null +++ b/TRD/qaAnalysis/AliTRDqaAT.h @@ -0,0 +1,35 @@ +#ifndef ALITRDQAAT_H +#define ALITRDQAAT_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id: AliTRDqaAT.h $ */ + +//////////////////////////////////////////////////////////////////////////// +// // +// TRD analysis tools // +// // +// Author: // +// Sylwester Radomski (radomski@physi.uni-heidelberg.de) // +// // +//////////////////////////////////////////////////////////////////////////// + +#include "AliAnalysisTask.h" + +class TH1D; +class AliExternalTrackParam; + +class AliTRDqaAT : public TObject { + + public: + + AliTRDqaAT(); + virtual ~AliTRDqaAT() {} + + static Int_t GetSector(const Double_t alpha); + static Int_t GetStack(const AliExternalTrackParam *paramOut); + static void BuildRatio(TH1D *ratio, TH1D *histN, TH1D *histD); + + ClassDef(AliTRDqaAT, 0); // TRD analysis tools +}; +#endif // ALITRDQAAT_H diff --git a/TRD/qaAnalysis/AliTRDqaESDFriends.cxx b/TRD/qaAnalysis/AliTRDqaESDFriends.cxx new file mode 100644 index 00000000000..c70cda409ed --- /dev/null +++ b/TRD/qaAnalysis/AliTRDqaESDFriends.cxx @@ -0,0 +1,188 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id: AliTRDqaESDFriends.cxx $ */ + +// +// This class is a part of a package of high level QA monitoring for TRD. +// The residuals of cluster with respect to tracklets are analyzed +// in this class. This class needs ESDfriends.root +// +// S. Radomski +// radomski@physi.uni-heidelberg.de +// March 2008 +// + +#include "AliTRDqaESDFriends.h" + +#include "TMath.h" +#include "TH1D.h" +#include "TH2D.h" +#include "TFile.h" +#include "TTree.h" +#include "TChain.h" + +#include "AliESDEvent.h" +#include "AliESDtrack.h" +#include "AliKalmanTrack.h" +#include "AliESDfriend.h" + +//______________________________________________________________________________ + +AliTRDqaESDFriends::AliTRDqaESDFriends() + : AliAnalysisTask("",""), + fChain(0), + fESD(0), + fOutputContainer(0), + fResiduals(0), + fResidualsAngle(0) +{ + // Dummy default constructor +} +//______________________________________________________________________________ + +AliTRDqaESDFriends:: AliTRDqaESDFriends(AliTRDqaESDFriends& /*trd*/) + : AliAnalysisTask("",""), + fChain(0), + fESD(0), + fOutputContainer(0), + fResiduals(0), + fResidualsAngle(0) +{ + // dummy copy constructor + + //return *this; +} + + +//______________________________________________________________________________ +AliTRDqaESDFriends::AliTRDqaESDFriends(const char *name) + : AliAnalysisTask(name,""), + fChain(0), + fESD(0), + fOutputContainer(0), + fResiduals(0), + fResidualsAngle(0) +{ + // Constructor. + // Input slot #0 works with an Ntuple + DefineInput(0, TChain::Class()); + // Output slot #0 writes into a TH1 container + DefineOutput(0, TObjArray::Class()) ; +} + +//______________________________________________________________________________ +void AliTRDqaESDFriends::ConnectInputData(const Option_t *) +{ + // Initialisation of branch container and histograms + + //AliInfo(Form("*** Initialization of %s", GetName())) ; + + fChain = (TChain*)GetInputData(0); + fESD = new AliESDEvent(); + fESD->ReadFromTree(fChain); +} + +//________________________________________________________________________ +void AliTRDqaESDFriends::CreateOutputObjects() +{ + // build histograms + + fResiduals = new TH1D("residuals", ";residuals (cm)", 1000, -1, 1); + fResidualsAngle = new TH2D("residualsAngle", ";angle (rad);residuals (cm)", 100, -1, 1, 100, -1, 1); + + Int_t c = 0; + fOutputContainer = new TObjArray(50); + + fOutputContainer->AddAt(fResiduals, c++); + fOutputContainer->AddAt(fResidualsAngle, c++); + + printf("n hist = %d\n", c); +} +//______________________________________________________________________________ +void AliTRDqaESDFriends::Exec(Option_t *) +{ + // Process one event + + //Long64_t entry = fChain->GetReadEntry() ; + + // Processing of one event + + if (!fESD) { + //AliError("fESD is not connected to the input!") ; + return ; + } + + Int_t nTracks = fESD->GetNumberOfTracks(); + //fNTracks->Fill(nTracks); + + // track loop + for(Int_t i=0; iGetTrack(i); + const AliExternalTrackParam *paramOut = track->GetOuterParam(); + const AliExternalTrackParam *paramIn = track->GetInnerParam(); + + // long track .. + if (!paramIn) continue; + if (!paramOut) continue; + + UInt_t status = track->GetStatus(); + if (!(status & AliESDtrack::kTRDrefit)) continue; + if (!(status & AliESDtrack::kTRDpid)) continue; + if (track->GetTRDpidQuality() < 6) continue; + + // standard selection + + // fESD->GetList()->Print(); + //AliESDfriend *f = (AliESDfriend*)fESD->FindListObject("ESDfriend"); + //if (f) f->Print(); + // AliKalmanTrack *trdTrack = track->GetTRDtrack(); + //if (trdTrack) trdTrack->Print(); + } + + PostData(0, fOutputContainer); +} + +//______________________________________________________________________________ +void AliTRDqaESDFriends::Terminate(Option_t *) +{ + // retrieve histograms + fOutputContainer = (TObjArray*)GetOutputData(0); + + // post processing + + + // save the results + TFile *file = new TFile("outESDFriends.root", "RECREATE"); + fOutputContainer->Write(); + + file->Flush(); + file->Close(); + delete file; + + //for(Int_t i=0; iGetEntries(); i++) { + // TObject *obj = fOu + // } +} + +//______________________________________________________________________________ diff --git a/TRD/qaAnalysis/AliTRDqaESDFriends.h b/TRD/qaAnalysis/AliTRDqaESDFriends.h new file mode 100644 index 00000000000..a1ce4565980 --- /dev/null +++ b/TRD/qaAnalysis/AliTRDqaESDFriends.h @@ -0,0 +1,54 @@ +#ifndef ALITRDQAESDFRIENDS_H +#define ALITRDQAESDFRIENDS_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id: AliTRDqaESDFriends.h $ */ + +// +// This class is a part of a package of high level QA monitoring for TRD. +// The residuals of cluster with respect to tracklets are analyzed +// in this class. This class needs ESDfriends.root +// +// S. Radomski +// radomski@physi.uni-heidelberg.de +// March 2008 +// + +#include "AliAnalysisTask.h" + +class TTree; +class AliESDEvent; +class TH1D; +class TH2D; +class AliExternalTrackParam; + +class AliTRDqaESDFriends : public AliAnalysisTask { + +public: + AliTRDqaESDFriends(); + AliTRDqaESDFriends(const char *name); + AliTRDqaESDFriends(AliTRDqaESDFriends& trd); + AliTRDqaESDFriends& operator = (const AliTRDqaESDFriends& /*g*/) { return *this; }; + virtual ~AliTRDqaESDFriends() {} + + virtual void Exec(Option_t * opt = ""); + virtual void ConnectInputData(Option_t *); + virtual void CreateOutputObjects(); + virtual void Terminate(Option_t * opt = ""); + +protected: + + TTree * fChain; //!pointer to the analyzed TTree or TChain + AliESDEvent * fESD; //! Declaration of leave types + + TObjArray * fOutputContainer; //! output data container + + // histograms + TH1D *fResiduals; // residuals distribution + TH2D *fResidualsAngle; // diferential resisuals distribution + //TH2D *fResidualsAngleChamber[540]; // per chamber + + ClassDef(AliTRDqaESDFriends, 0); // a TRD analysis task +}; +#endif // ALITRDQAESDFRIENDS_H diff --git a/TRD/qaAnalysis/AliTRDqaElectronSpectra.cxx b/TRD/qaAnalysis/AliTRDqaElectronSpectra.cxx new file mode 100644 index 00000000000..d953f00f348 --- /dev/null +++ b/TRD/qaAnalysis/AliTRDqaElectronSpectra.cxx @@ -0,0 +1,283 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id: AliTRDqaElectronSpectra.cxx $ */ + +// +// This class is a part of a package of high level QA monitoring for TRD. +// +// The transverse momentum spectrum is analyzed stack-by-stack +// for all tracks, and for electron tracks. +// Tracks have to pass quality cuts. +// Electrons are waighted with the PID LQ +// +// S. Radomski +// radomski@physi.uni-heidelberg.de +// March 2008 +// + +#include "AliTRDqaElectronSpectra.h" +#include "AliTRDqaAT.h" + +#include "TMath.h" +#include "TH1D.h" +#include "TH2D.h" +#include "TFile.h" +#include "TTree.h" +#include "TChain.h" + +#include "AliESDEvent.h" +#include "AliESDtrack.h" + +//______________________________________________________________________________ + +AliTRDqaElectronSpectra::AliTRDqaElectronSpectra() + : AliAnalysisTask("",""), + fChain(0), + fESD(0), + fOutputContainer(0), + fStatus(0), + fSector(0), + fTheta(0), + fStack(0), + fnTracks(0), + fnElTracks(0), + fTracksRatio(0), + fPt(0), + fPtElectron(0), + fMeanPt(0), + fMeanPtElectron(0), + fPtStack(0), + fPtStackElectron(0), + fElectronLQ(0) +{ + // + // default dummy constructor + // + +} +//______________________________________________________________________________ + +AliTRDqaElectronSpectra:: AliTRDqaElectronSpectra(AliTRDqaElectronSpectra& /*trd*/) + : AliAnalysisTask("",""), + fChain(0), + fESD(0), + fOutputContainer(0), + fStatus(0), + fSector(0), + fTheta(0), + fStack(0), + fnTracks(0), + fnElTracks(0), + fTracksRatio(0), + fPt(0), + fPtElectron(0), + fMeanPt(0), + fMeanPtElectron(0), + fPtStack(0), + fPtStackElectron(0), + fElectronLQ(0) +{ + // + // Dummy copy constructor + // + + //return *this; +} + + +//______________________________________________________________________________ +AliTRDqaElectronSpectra::AliTRDqaElectronSpectra(const char *name) + : AliAnalysisTask(name,""), + fChain(0), + fESD(0), + fOutputContainer(0), + fStatus(0), + fSector(0), + fTheta(0), + fStack(0), + fnTracks(0), + fnElTracks(0), + fTracksRatio(0), + fPt(0), + fPtElectron(0), + fMeanPt(0), + fMeanPtElectron(0), + fPtStack(0), + fPtStackElectron(0), + fElectronLQ(0) +{ + // Constructor. + // Input slot #0 works with an Ntuple + DefineInput(0, TChain::Class()); + // Output slot #0 writes into a TH1 container + DefineOutput(0, TObjArray::Class()) ; +} + +//______________________________________________________________________________ +void AliTRDqaElectronSpectra::ConnectInputData(const Option_t *) +{ + // Initialisation of branch container and histograms + + //AliInfo(Form("*** Initialization of %s", GetName())) ; + + fChain = (TChain*)GetInputData(0); + fESD = new AliESDEvent(); + fESD->ReadFromTree(fChain); +} + +//________________________________________________________________________ +void AliTRDqaElectronSpectra::CreateOutputObjects() +{ + // build histograms + + fStatus = new TH1D("status", ";status bit", 32, -0.5, 31.5); + fSector = new TH1D("sector", ";sector", 18, -0.5, 17.5); + fTheta = new TH1D("theta", ";theta (rad)", 100, -1, 1); + fStack = new TH1D("stack", ";stack", 90, -0.5, 89.5); + + fnTracks = new TH1D("tracks", ";stack;number of tracks", 90, -0.5, 89.5); + fnElTracks = new TH1D("elTracks", ";stack;number of electron tracks", 90, -0.5, 89.5); + fTracksRatio = new TH1D("fractionElectrons", ";stack;fraction of electron tracks", 90, -0.5, 89.5); + + fPt = new TH1D("pt", "p_{T} (GeV/c)", 50, 0, 10); + fPtElectron = new TH1D("ptElectron", "p_{T} (GeV/c)", 50, 0, 10); + + fMeanPt = new TH1D("meanPt", "; (GeV/c)", 100, 0, 5); + fMeanPtElectron = new TH1D("meanPtElectron", "; (GeV/c)", 100, 0, 5); + + fPtStack = new TH2D("stackPt", ";stack;p_{T} (GeV/c)", 90, -0.5, 89.5, 50, 0, 10); + fPtStackElectron = new TH2D("stackPtEl", ";stack;p_{T} (GeV/c)", 90, -0.5, 89.5, 50, 0, 10); + + fElectronLQ = new TH1D("elLQ", ";likelyhood", 100, 0, 1); + + Int_t c = 0; + fOutputContainer = new TObjArray(50); + + fOutputContainer->AddAt(fStatus, c++); + fOutputContainer->AddAt(fSector, c++); + fOutputContainer->AddAt(fTheta, c++); + fOutputContainer->AddAt(fStack, c++); + + fOutputContainer->AddAt(fnTracks, c++); + fOutputContainer->AddAt(fnElTracks, c++); + fOutputContainer->AddAt(fTracksRatio, c++); + + fOutputContainer->AddAt(fPt, c++); + fOutputContainer->AddAt(fPtElectron, c++); + + fOutputContainer->AddAt(fMeanPt, c++); + fOutputContainer->AddAt(fMeanPtElectron, c++); + + fOutputContainer->AddAt(fPtStack, c++); + fOutputContainer->AddAt(fPtStackElectron, c++); + + fOutputContainer->AddAt(fElectronLQ, c++); + + printf("n hist = %d\n", c); +} +//______________________________________________________________________________ +void AliTRDqaElectronSpectra::Exec(Option_t *) +{ + // Process one event + Long64_t entry = fChain->GetReadEntry() ; + if (!(entry%10)) Info("Exec", "Entry = %ld", entry); + + // Processing of one event + + if (!fESD) { + //AliError("fESD is not connected to the input!") ; + return ; + } + + Int_t nTracks = fESD->GetNumberOfTracks(); + //fNTracks->Fill(nTracks); + + // track loop + for(Int_t i=0; iGetTrack(i); + const AliExternalTrackParam *paramOut = track->GetOuterParam(); + const AliExternalTrackParam *paramIn = track->GetInnerParam(); + + // long track .. + if (!paramIn) continue; + if (!paramOut) continue; + + UInt_t status = track->GetStatus(); + if (!(status & AliESDtrack::kTRDrefit)) continue; + if (!(status & AliESDtrack::kTRDpid)) continue; + if (track->GetTRDpidQuality() < 6) continue; + + Int_t sm = AliTRDqaAT::GetSector(paramOut->GetAlpha()); + Int_t stack = 5*sm + AliTRDqaAT::GetStack(paramOut); + Double_t lq = track->GetTRDpid(AliPID::kElectron); + Double_t pt = paramOut->Pt(); + + //TH1D *fStatus; // track status + fSector->Fill(sm); + fStack->Fill(stack); + fElectronLQ->Fill(lq); + + fTheta->Fill(paramOut->GetZ() / paramOut->GetX()); + + fnTracks->Fill(stack); + fnElTracks->Fill(stack, lq); + + fPt->Fill(pt); + fPtElectron->Fill(pt, lq); + + fPtStack->Fill(stack, pt); + fPtStackElectron->Fill(stack, pt, lq); + } + + PostData(0, fOutputContainer); +} + +//______________________________________________________________________________ +void AliTRDqaElectronSpectra::Terminate(Option_t *) +{ + // save histograms + fOutputContainer = (TObjArray*)GetOutputData(0); + + // build ratios + fnTracks = (TH1D*)fOutputContainer->FindObject("tracks"); + fnElTracks = (TH1D*)fOutputContainer->FindObject("elTracks"); + fTracksRatio = (TH1D*)fOutputContainer->FindObject("fractionElectrons"); + + AliTRDqaAT::BuildRatio(fTracksRatio, fnElTracks, fnTracks); + + // save the results + + TFile *file = new TFile("outElSpectra.root", "RECREATE"); + fOutputContainer->Write(); + + file->Flush(); + file->Close(); + delete file; + + //for(Int_t i=0; iGetEntries(); i++) { + // TObject *obj = fOu + // } +} + +//______________________________________________________________________________ diff --git a/TRD/qaAnalysis/AliTRDqaElectronSpectra.h b/TRD/qaAnalysis/AliTRDqaElectronSpectra.h new file mode 100644 index 00000000000..2bcb8eceac8 --- /dev/null +++ b/TRD/qaAnalysis/AliTRDqaElectronSpectra.h @@ -0,0 +1,76 @@ +#ifndef ALITRDQAELECTRONSPECTRA_H +#define ALITRDQAELECTRONSPECTRA_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id: AliTRDqaElectronSpectra.h $ */ + +// +// This class is a part of a package of high level QA monitoring for TRD. +// +// The transverse momentum spectrum is analyzed stack-by-stack +// for all tracks, and for electron tracks. +// Tracks have to pass quality cuts. +// Electrons are waighted with the PID LQ +// +// S. Radomski +// radomski@physi.uni-heidelberg.de +// March 2008 +// + +#include "AliAnalysisTask.h" + +class TTree; +class AliESDEvent; +class TH1D; +class TH2D; +class AliExternalTrackParam; + +class AliTRDqaElectronSpectra : public AliAnalysisTask { + + public: + + AliTRDqaElectronSpectra(); + AliTRDqaElectronSpectra(const char *name); + AliTRDqaElectronSpectra(AliTRDqaElectronSpectra& trd); + AliTRDqaElectronSpectra& operator = (const AliTRDqaElectronSpectra& /*g*/) { return *this; }; + virtual ~AliTRDqaElectronSpectra() {} + + virtual void Exec(Option_t * opt = ""); + virtual void ConnectInputData(Option_t *); + virtual void CreateOutputObjects(); + virtual void Terminate(Option_t * opt = ""); + + private: + + TTree * fChain; //!pointer to the analyzed TTree or TChain + AliESDEvent * fESD; //! Declaration of leave types + + TObjArray * fOutputContainer; //! output data container + + // histograms + + TH1D *fStatus; // track status + TH1D *fSector; // sector + TH1D *fTheta; // theta to decide on stack + TH1D *fStack; // stack ID + + TH1D *fnTracks; // number of tracks in a stack + TH1D *fnElTracks; // number of electrons tracks in a stack + TH1D *fTracksRatio; // fraction of electron tracks in a stack + + TH1D *fPt; // transverse momentum distribution + TH1D *fPtElectron; // transverse momentum of electrons + + TH1D *fMeanPt; // all tracks + TH1D *fMeanPtElectron; // electrons + + TH2D *fPtStack; // pt distribution per stack + TH2D *fPtStackElectron; // for electrons + + TH1D *fElectronLQ; // electron likehood + + + ClassDef(AliTRDqaElectronSpectra, 0); // a TRD analysis task +}; +#endif // ALITRDQAELECTRONSPECTRA_H diff --git a/TRD/qaAnalysis/AliTRDqaEnergyDeposit.cxx b/TRD/qaAnalysis/AliTRDqaEnergyDeposit.cxx new file mode 100644 index 00000000000..aab57496d87 --- /dev/null +++ b/TRD/qaAnalysis/AliTRDqaEnergyDeposit.cxx @@ -0,0 +1,219 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id: AliTRDqaEnergyDeposit.cxx $ */ + +// +// This class is a part of a package of high level QA monitoring for TRD. +// In this class the dEdX is analyzed as a function of the particle type, +// momentum and chamber. +// +// S. Radomski +// radomski@physi.uni-heidelberg.de +// March 2008 +// + +#include "AliTRDqaEnergyDeposit.h" + +#include "TMath.h" +#include "TH1D.h" +#include "TH2D.h" +#include "TFile.h" +#include "TTree.h" +#include "TChain.h" + +#include "AliESDEvent.h" +#include "AliESDtrack.h" +#include "AliKalmanTrack.h" + +//______________________________________________________________________________ + +AliTRDqaEnergyDeposit::AliTRDqaEnergyDeposit() + : AliAnalysisTask("",""), + fChain(0), + fESD(0), + fOutputContainer(0) +{ + // Dummy default constructor +} +//______________________________________________________________________________ + +AliTRDqaEnergyDeposit:: AliTRDqaEnergyDeposit(AliTRDqaEnergyDeposit& /*trd*/) + : AliAnalysisTask("",""), + fChain(0), + fESD(0), + fOutputContainer(0) +{ + // Dummy copy constructor + + //return *this; +} + +//______________________________________________________________________________ +AliTRDqaEnergyDeposit::AliTRDqaEnergyDeposit(const char *name) + : AliAnalysisTask(name,""), + fChain(0), + fESD(0), + fOutputContainer(0) +{ + // Constructor. + // Input slot #0 works with an Ntuple + DefineInput(0, TChain::Class()); + // Output slot #0 writes into a TH1 container + DefineOutput(0, TObjArray::Class()) ; +} + +//______________________________________________________________________________ +void AliTRDqaEnergyDeposit::ConnectInputData(const Option_t *) +{ + // Initialisation of branch container and histograms + + //AliInfo(Form("*** Initialization of %s", GetName())) ; + + fChain = (TChain*)GetInputData(0); + fESD = new AliESDEvent(); + fESD->ReadFromTree(fChain); +} + +//________________________________________________________________________ +void AliTRDqaEnergyDeposit::CreateOutputObjects() +{ + // build histograms + + // prepare the scale from 0.5 to 10 GeV + const Int_t knbinsx = 50; + Double_t scalex[knbinsx+1]; + Double_t dd = (TMath::Log(10) - TMath::Log(0.5)) / knbinsx; + for(Int_t ix=0; ixAddAt(fSignalPtSum[i], c++); + + for(Int_t j=0; jAddAt(fSignalPtType[idx], c++); + + fProb[idx] = new TH1D(Form("prob%s%d", charge[i], j), ";LQ", 100, 0, 1); + fOutputContainer->AddAt(fProb[idx], c++); + } + } + + printf("n hist = %d\n", c); +} +//______________________________________________________________________________ +void AliTRDqaEnergyDeposit::Exec(Option_t *) +{ + // Process one event + + // Long64_t entry = fChain->GetReadEntry() ; + + // Processing of one event + + if (!fESD) { + //AliError("fESD is not connected to the input!") ; + return ; + } + + Int_t nTracks = fESD->GetNumberOfTracks(); + //fNTracks->Fill(nTracks); + + // track loop + for(Int_t i=0; iGetTrack(i); + const AliExternalTrackParam *paramOut = track->GetOuterParam(); + const AliExternalTrackParam *paramIn = track->GetInnerParam(); + + // long track .. + if (!paramIn) continue; + if (!paramOut) continue; + + UInt_t status = track->GetStatus(); + if (!(status & AliESDtrack::kTRDrefit)) continue; + if (!(status & AliESDtrack::kTRDpid)) continue; + if (track->GetTRDpidQuality() < 6) continue; + + // standard selection + + Int_t idx = (track->GetSign() > 0) ? 0 : 1; + Double_t pt = paramOut->Pt(); + + Double_t signal = 0; + for(Int_t i=0; i<6; i++) + signal += track->GetTRDsignals(i, -1); + signal /= 6; + + fSignalPtSum[idx]->Fill(pt, signal); + + for(Int_t i=0; iGetTRDpid(i); + fProb[AliPID::kSPECIES*idx+i]->Fill(lq); + fSignalPtType[AliPID::kSPECIES*idx+i]->Fill(pt, signal, lq); + } + } + + PostData(0, fOutputContainer); +} + +//______________________________________________________________________________ +void AliTRDqaEnergyDeposit::Terminate(Option_t *) +{ + // retrieve histograms + fOutputContainer = (TObjArray*)GetOutputData(0); + + // post processing + + + // save the results + TFile *file = new TFile("outEnergyDeposit.root", "RECREATE"); + fOutputContainer->Write(); + + file->Flush(); + file->Close(); + delete file; + + //for(Int_t i=0; iGetEntries(); i++) { + // TObject *obj = fOu + // } +} + +//______________________________________________________________________________ diff --git a/TRD/qaAnalysis/AliTRDqaEnergyDeposit.h b/TRD/qaAnalysis/AliTRDqaEnergyDeposit.h new file mode 100644 index 00000000000..48229afb7af --- /dev/null +++ b/TRD/qaAnalysis/AliTRDqaEnergyDeposit.h @@ -0,0 +1,57 @@ +#ifndef ALITRDQAENERGYDEPOSIT_H +#define ALITRDQAENERGYDEPOSIT_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id: AliTRDqaEnergyDeposit.h $ */ + +// +// This class is a part of a package of high level QA monitoring for TRD. +// In this class the dEdX is analyzed as a function of the particle type, +// momentum and chamber. +// +// S. Radomski +// radomski@physi.uni-heidelberg.de +// March 2008 +// + +#include "AliAnalysisTask.h" + +class TTree; +class AliESDEvent; +class TH1D; +class TH2D; +class AliExternalTrackParam; + +class AliTRDqaEnergyDeposit : public AliAnalysisTask { + +public: + AliTRDqaEnergyDeposit(); + AliTRDqaEnergyDeposit(const char *name); + AliTRDqaEnergyDeposit(AliTRDqaEnergyDeposit& trd); + AliTRDqaEnergyDeposit& operator = (const AliTRDqaEnergyDeposit& /*g*/) { return *this; }; + virtual ~AliTRDqaEnergyDeposit() {} + + virtual void Exec(Option_t * opt = ""); + virtual void ConnectInputData(Option_t *); + virtual void CreateOutputObjects(); + virtual void Terminate(Option_t * opt = ""); + +protected: + + TTree *fChain; //!pointer to the analyzed TTree or TChain + AliESDEvent *fESD; //! Declaration of leave types + + TObjArray *fOutputContainer; //! output data container + + // histogrms + + //TH2D *fSignalPt[2]; // pt-dedx distribution for pos and neg + TH2D *fSignalPtSum[2]; // pt-dedx distribution for pos and neg + TH2D *fSignalPtType[2*5]; // weight with the PID probability + TH1D *fProb[2*5]; // probabilities + //TH2D *fSignalPtChamber[2*540]; + + ClassDef(AliTRDqaEnergyDeposit, 0); // a TRD analysis task +}; +#endif // ALITRDQAENERGYDEPOSIT_H diff --git a/TRD/qaAnalysis/drawEnergyDeposit.C b/TRD/qaAnalysis/drawEnergyDeposit.C new file mode 100644 index 00000000000..945c7f78fd5 --- /dev/null +++ b/TRD/qaAnalysis/drawEnergyDeposit.C @@ -0,0 +1,45 @@ + +void drawEnergyDeposit(const char *filename) { + + gROOT->SetStyle("Plain"); + gStyle->SetPadRightMargin(0.01); + gStyle->SetPadTopMargin(0.01); + gStyle->SetPadLeftMargin(0.07); + gStyle->SetPadBottomMargin(0.07); + gStyle->SetOptStat(0); + TGaxis::SetMaxDigits(3); + + TFile *file = new TFile(filename, "READ"); + if (file->IsZombie()) return; + + TCanvas *c = new TCanvas(); + c->Divide(5, 4, 0.001, 0.001); + + for(int i=0; i<5; i++) { + TH1 *hist = (TH1*)file->Get(Form("probPos%d", i)); + c->cd(i+1); + gPad->SetLogy(); + hist->Draw(); + } + + for(int i=0; i<5; i++) { + TH1 *hist = (TH1*)file->Get(Form("ptSigPos%d", i)); + c->cd(i+6); + gPad->SetLogx(); + hist->Draw("col"); + } + + for(int i=0; i<5; i++) { + TH1 *hist = (TH1*)file->Get(Form("probNeg%d", i)); + c->cd(i+11); + gPad->SetLogy(); + hist->Draw(); + } + + for(int i=0; i<5; i++) { + TH1 *hist = (TH1*)file->Get(Form("ptSigNeg%d", i)); + c->cd(i+16); + gPad->SetLogx(); + hist->Draw("col"); + } +} diff --git a/TRD/qaAnalysis/runTRDqaAnalysis.C b/TRD/qaAnalysis/runTRDqaAnalysis.C new file mode 100644 index 00000000000..0b66d275733 --- /dev/null +++ b/TRD/qaAnalysis/runTRDqaAnalysis.C @@ -0,0 +1,81 @@ + +void runTRDqaAnalysis(const char *chainName, int limit = 0) { + // + // runs the analysis train + // parameters: + // chainName -- a name of a file with a list of ESDs + // limit -- number of files to be processed + // + // + + gSystem->Load("libANALYSIS.so"); + gSystem->Load("libTRDqaAnalysis.so"); + + // Setup chain + TChain *chain = new TChain("esdTree"); + //chain->SetBranchStatus("*",0); + //chain->SetBranchStatus("*fTracks*",1); + //esdTree->SetBranchStatus("ESDfriend*",1); + + int nfiles = 0; + fstream coll(chainName, ios_base::in); + TString line; + while (line.ReadLine(coll)) { + cout << line.Data() << endl; + chain->Add(line.Data()); + nfiles++; + if (limit && nfiles > limit) break; + } + + // Create an analysis manager + AliAnalysisManager *mgr = new AliAnalysisManager("qaTasks", "No safety"); + AliAnalysisTask *tasks[3]; + AliAnalysisDataContainer *out[3]; + + tasks[0] = new AliTRDqaElectronSpectra("trdElectronSpectra"); + tasks[1] = new AliTRDqaESDFriends("trdESDFriends"); + tasks[2] = new AliTRDqaEnergyDeposit("trdEnergyDeposit"); + + AliAnalysisDataContainer *cinput = + mgr->CreateContainer("inputESD", TTree::Class(), AliAnalysisManager::kInputContainer); + + out[0] = mgr->CreateContainer("oES", TObjArray::Class(), AliAnalysisManager::kOutputContainer); + out[1] = mgr->CreateContainer("oEF", TObjArray::Class(), AliAnalysisManager::kOutputContainer); + out[2] = mgr->CreateContainer("oED", TObjArray::Class(), AliAnalysisManager::kOutputContainer); + + // register + for(int i=0; i<3; i++) { + mgr->AddTask(tasks[i]); + mgr->ConnectInput(tasks[i],0,cinput); + mgr->ConnectOutput(tasks[i],0,out[i]); + } + + // Connect input data + cout << "connect to data" << endl; + cinput->SetData(chain); + Long_t t0 = gSystem->Now(); + + TStopwatch sw; + sw.Start(); + + cout << "Initializing" << endl; + if (mgr->InitAnalysis()) { + mgr->PrintStatus(); + mgr->StartAnalysis("local", chain); + } + + sw.Stop(); + sw.Print(); + + Long_t t1 = gSystem->Now(); + double time = 1e-3 * (t1-t0); + + //cout << "Size = " << mgr->GetNBytes()*1e-6 << " MB" << endl; + //cout << "Time = " << time << " s" << endl; + //cout << "Speed = " << 1e-6*mgr->GetNBytes()/time << " MB/s" << endl; + //cout << "Events = " << mgr->GetNEvents()/time << " Events/s" << endl; + + //gSystem->Exit(0); + + +} -- 2.39.3