DiHadronPID: Added task for calculating efficiencies. (Misha Veldhoen <Misha.Veldhoen...
authormiweber <miweber@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 10 Jun 2013 12:27:38 +0000 (12:27 +0000)
committermiweber <miweber@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 10 Jun 2013 12:27:38 +0000 (12:27 +0000)
PWGCF/CMakelibPWGCFCorrelationsDPhi.pkg
PWGCF/Correlations/DPhi/DiHadronPID/AliAnalysisTaskCompareAODTrackCuts.cxx [new file with mode: 0644]
PWGCF/Correlations/DPhi/DiHadronPID/AliAnalysisTaskCompareAODTrackCuts.h [new file with mode: 0644]
PWGCF/Correlations/macros/DiHadronPID/AddTaskCompareAODTrackCuts_DiHadronPIDEff.C [new file with mode: 0644]
PWGCF/PWGCFCorrelationsDPhiLinkDef.h

index 98409a3..6b550f0 100644 (file)
@@ -40,6 +40,7 @@ set ( SRCS
     Correlations/DPhi/DiHadronPID/AliAODEventCutsDiHadronPID.cxx
     Correlations/DPhi/DiHadronPID/AliHistToolsDiHadronPID.cxx
     Correlations/DPhi/DiHadronPID/AliAnalysisTaskDiHadronPID.cxx 
+    Correlations/DPhi/DiHadronPID/AliAnalysisTaskCompareAODTrackCuts.cxx
     Correlations/DPhi/FourierDecomposition/AliPool.cxx
     Correlations/DPhi/FourierDecomposition/AliDhcTask.cxx
     Correlations/DPhi/FourierDecomposition/AliMuonEffMC.cxx
diff --git a/PWGCF/Correlations/DPhi/DiHadronPID/AliAnalysisTaskCompareAODTrackCuts.cxx b/PWGCF/Correlations/DPhi/DiHadronPID/AliAnalysisTaskCompareAODTrackCuts.cxx
new file mode 100644 (file)
index 0000000..7181355
--- /dev/null
@@ -0,0 +1,490 @@
+/************************************************************************* \r
+* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. * \r
+*                                                                        * \r
+* Author: The ALICE Off-line Project.                                    * \r
+* Contributors are mentioned in the code where appropriate.              * \r
+*                                                                        * \r
+* Permission to use, copy, modify and distribute this software and its   * \r
+* documentation strictly for non-commercial purposes is hereby granted   * \r
+* without fee, provided that the above copyright notice appears in all   * \r
+* copies and that both the copyright notice and this permission notice   * \r
+* appear in the supporting documentation. The authors make no claims     * \r
+* about the suitability of this software for any purpose. It is          * \r
+* provided "as is" without express or implied warranty.                  * \r
+**************************************************************************/\r
+\r
+// -----------------------------------------------------------------------\r
+//  In this analysis task we compare multiple AOD filtermasks.\r
+// -----------------------------------------------------------------------\r
+//  Author: Misha Veldhoen (misha.veldhoen@cern.ch)\r
+\r
+#include <iostream>\r
+\r
+// Basic Includes\r
+#include "TH1F.h"\r
+#include "TH2F.h"\r
+#include "TH3F.h"\r
+#include "TFile.h"\r
+#include "TFormula.h"\r
+#include "TChain.h"\r
+#include "TObject.h"\r
+#include "TRandom3.h"\r
+\r
+// Analysis Includes\r
+#include "AliAnalysisManager.h"\r
+#include "AliAnalysisTaskSE.h"\r
+#include "AliInputEventHandler.h"\r
+\r
+// PID includes.\r
+#include "AliPIDResponse.h"\r
+\r
+// AOD includes.\r
+#include "AliAODEvent.h"\r
+#include "AliAODTrack.h"\r
+#include "AliAODHandler.h"\r
+#include "AliAODVertex.h"\r
+#include "AliAODInputHandler.h"\r
+#include "AliAODMCParticle.h"\r
+#include "AliAODMCHeader.h"\r
+\r
+// Includes from own library\r
+#include "AliTrackDiHadronPID.h"\r
+#include "AliAODTrackCutsDiHadronPID.h"\r
+#include "AliAODEventCutsDiHadronPID.h"\r
+\r
+// AnalysisTask Header\r
+#include "AliAnalysisTaskCompareAODTrackCuts.h"\r
+\r
+using namespace std;\r
+\r
+ClassImp(AliAnalysisTaskCompareAODTrackCuts);\r
+\r
+// -----------------------------------------------------------------------\r
+AliAnalysisTaskCompareAODTrackCuts::AliAnalysisTaskCompareAODTrackCuts():\r
+       AliAnalysisTaskSE(),\r
+       fPIDResponse(0x0),\r
+       fOutputList(0x0),\r
+       fIsMC(kFALSE),\r
+       fVerbose(kFALSE),\r
+       fCalculateTOFMismatch(kFALSE),  \r
+       fMismatchMethod(0),     \r
+       fEventCuts(0x0),\r
+       fTrackCuts(0x0),\r
+       fInclusiveTimes(0x0),\r
+       fExternalTOFfile(0x0),\r
+       fInclusiveTimesIn(0x0),\r
+       fT0Fill(0x0),\r
+       fLvsEta(0x0),\r
+       fCurrentAODEvent(0x0),\r
+       fCurrentAODTrack(0x0),\r
+       fCurrentDiHadronPIDTrack(0x0),\r
+       fGlobalTracksArray(0x0)\r
+\r
+{\r
+\r
+       if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}\r
+\r
+       // Default Constructor.\r
+       for (Int_t ii = 0; ii<200; ii++) {fLvsEtaProj[ii] = 0x0;}\r
+       for (Int_t ii = 0; ii<100; ii++) {fInclusiveTimesInProj[ii] = 0x0;}\r
+\r
+}\r
+\r
+// -----------------------------------------------------------------------\r
+AliAnalysisTaskCompareAODTrackCuts::AliAnalysisTaskCompareAODTrackCuts(const char* name):\r
+       AliAnalysisTaskSE(name),\r
+       fPIDResponse(0x0),\r
+       fOutputList(0x0),\r
+       fIsMC(kFALSE),\r
+       fVerbose(kFALSE),\r
+       fCalculateTOFMismatch(kFALSE),  \r
+       fMismatchMethod(0),     \r
+       fEventCuts(0x0),\r
+       fTrackCuts(0x0),\r
+       fInclusiveTimes(0x0),\r
+       fExternalTOFfile(0x0),\r
+       fInclusiveTimesIn(0x0),\r
+       fT0Fill(0x0),\r
+       fLvsEta(0x0),\r
+       fCurrentAODEvent(0x0),\r
+       fCurrentAODTrack(0x0),\r
+       fCurrentDiHadronPIDTrack(0x0),\r
+       fGlobalTracksArray(0x0)\r
+\r
+{\r
+\r
+       if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}\r
+\r
+       // Named Constructor. \r
+       fTrackCuts = new TObjArray();\r
+       fTrackCuts->SetName("fTrackCuts");\r
+\r
+       for (Int_t ii = 0; ii<200; ii++) {fLvsEtaProj[ii] = 0x0;}\r
+       for (Int_t ii = 0; ii<100; ii++) {fInclusiveTimesInProj[ii] = 0x0;}\r
+\r
+       DefineInput(0,TChain::Class());\r
+       DefineOutput(1, TList::Class());\r
+\r
+}\r
+\r
+// -----------------------------------------------------------------------\r
+AliAnalysisTaskCompareAODTrackCuts::~AliAnalysisTaskCompareAODTrackCuts() {\r
+\r
+       if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}\r
+\r
+}\r
+\r
+// -----------------------------------------------------------------------\r
+void AliAnalysisTaskCompareAODTrackCuts::UserCreateOutputObjects() {\r
+\r
+       if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}\r
+\r
+       // Getting a pointer to the analysis manager and input handler.\r
+       AliAnalysisManager* manager = AliAnalysisManager::GetAnalysisManager();\r
+       AliInputEventHandler* inputHandler = dynamic_cast<AliInputEventHandler*> (manager->GetInputEventHandler());\r
+       \r
+       // Getting the pointer to the PID response object.\r
+       fPIDResponse = inputHandler->GetPIDResponse();\r
+\r
+       // Create the output list.\r
+       fOutputList = new TList();\r
+       fOutputList->SetOwner(kTRUE);\r
+\r
+       // Adding Event Cuts to the output.\r
+       fEventCuts->CreateHistos();                             // Generating all requested histograms. \r
+       fOutputList->Add(fEventCuts);                   \r
+\r
+       // Adding Track Cuts to the output.\r
+       for (Int_t iCuts = 0; iCuts < fTrackCuts->GetEntries(); iCuts++) {\r
+               AliAODTrackCutsDiHadronPID* currentcuts = (AliAODTrackCutsDiHadronPID*)fTrackCuts->At(iCuts);\r
+               currentcuts->CreateHistos();            // Generating all requested histograms.\r
+               fOutputList->Add(currentcuts);          \r
+       }\r
+\r
+       // Creating inclusive times histogram.\r
+       fInclusiveTimes = new TH2F("fInclusiveTimes","Inclusive Times;#eta;t (ps)",100,0,1.,1500,10000.,25000.);\r
+       fOutputList->Add(fInclusiveTimes);\r
+\r
+       // Creating Global Tracks Array\r
+       fGlobalTracksArray = new TObjArray();\r
+\r
+       // Loading the appropriate external mismatch histograms.\r
+       if (fCalculateTOFMismatch) LoadExternalMismatchHistos(fMismatchMethod);\r
+\r
+       PostData(1,fOutputList);\r
+\r
+}\r
+\r
+// -----------------------------------------------------------------------\r
+void AliAnalysisTaskCompareAODTrackCuts::FillGlobalTracksArray() {\r
+\r
+       if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}\r
+\r
+       // Initialize the mapping for corresponding PID tracks.\r
+       // See AliAnalysisTaskESDFilter.cxx for explanation about the mapping\r
+       // between TPC-Only and Global tracks\r
+               \r
+       // Create TObjArray for Global Tracks.\r
+\r
+       //cout<<"Global Tracks Array: "<<fGlobalTracksArray<<endl;\r
+\r
+       // Clear previous tracks...\r
+       fGlobalTracksArray->Clear();\r
+\r
+       //if (fGlobalTracksArray) delete fGlobalTracksArray;\r
+       //fGlobalTracksArray = new TObjArray();\r
+\r
+       AliAODTrack* track = 0x0;\r
+               \r
+       for (Int_t iTrack = 0; iTrack < fCurrentAODEvent->GetNumberOfTracks(); iTrack++) {      \r
+\r
+               track = fCurrentAODEvent->GetTrack(iTrack);\r
+        if (track->GetID()>-1) fGlobalTracksArray->AddAtAndExpand(track,track->GetID());\r
+       }\r
+\r
+}\r
+\r
+// -----------------------------------------------------------------------\r
+AliAODTrack* AliAnalysisTaskCompareAODTrackCuts::GetGlobalTrack(AliAODTrack* track) {\r
+\r
+       // Returns Global Track corresponding to a TPC-Only Track.\r
+       if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}\r
+\r
+       if (track->GetID() >= 0) {\r
+               cout<<"AliAnalysisTaskCompareAODTrackCuts::GetGlobalTrack -> Input Track is not TPC-Only."<<endl;\r
+               return 0x0;\r
+       }\r
+\r
+       if (!fGlobalTracksArray) {\r
+               cout<<"AliAnalysisTaskCompareAODTrackCuts::GetGlobalTrack -> Global Tracks Array Does not Exist."<<endl;\r
+               return 0x0;\r
+       }\r
+\r
+    AliAODTrack* globaltrack = (AliAODTrack*)(fGlobalTracksArray->At(-track->GetID()-1));\r
+       if (!globaltrack) {\r
+               cout<<"AliAnalysisTaskCompareAODTrackCuts::GetGlobalTrack -> No Global Track Found."<<endl;\r
+               return 0x0;\r
+       }\r
+\r
+       return globaltrack;\r
+       \r
+}\r
+\r
+// -----------------------------------------------------------------------\r
+void AliAnalysisTaskCompareAODTrackCuts::UserExec(Option_t*) {\r
+\r
+       if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}\r
+\r
+       // Input Current Event.\r
+       fCurrentAODEvent = dynamic_cast<AliAODEvent*>(InputEvent());\r
+       if (!fCurrentAODEvent) {\r
+               cout<<"AliAnalysisTaskCompareAODTrackCuts::UserExec -> AOD Event not found."<<endl;\r
+               return;\r
+       }\r
+\r
+       // Check Event Cuts Object.\r
+       if (!fEventCuts) AliFatal("No Event Cuts Object Found!");\r
+\r
+       // Perform Event Cuts.\r
+       if (!fEventCuts->IsSelected(fCurrentAODEvent)) {return;}\r
+\r
+       // Check Track Cuts Array.\r
+       if (!fTrackCuts) AliFatal("No Track Cuts Array Found!");\r
+       if (fTrackCuts->GetEntries() == 0) AliFatal("Track Cuts Array is Empty!");\r
+\r
+       // If MC, then fill MC reconstructed QA histograms.\r
+       TClonesArray* mcArray = 0x0;\r
+       TObjArray* mcArrayLabel = 0x0; \r
+       if (fIsMC) {\r
+               \r
+               mcArray = dynamic_cast<TClonesArray*>(fCurrentAODEvent->FindListObject(AliAODMCParticle::StdBranchName()));\r
+       if (!mcArray) {\r
+               AliFatal("No MC array found in the AOD.");\r
+               return;\r
+       }\r
+\r
+       mcArrayLabel = new TObjArray(10000);\r
+\r
+       // Loop over MC particles.\r
+       for (Int_t iParticle = 0; iParticle < mcArray->GetEntriesFast(); iParticle++) {\r
+               \r
+                       // Put the MC Particle in the Label array.\r
+                       AliAODMCParticle* CurrentAODMCParticle = (AliAODMCParticle*) mcArray->At(iParticle);\r
+                       mcArrayLabel->AddAtAndExpand(CurrentAODMCParticle,CurrentAODMCParticle->Label());\r
+               //cout<<"Index: "<<iParticle<<" Label: "<<CurrentAODMCParticle->Label()<<endl;\r
+\r
+                       //if (CurrentAODMCParticle->Label()!=iParticle) cout<<"Index unequal to particle's label!"<<endl;\r
+\r
+                       // Loop over all Track Cuts.\r
+                       for (Int_t iCuts = 0; iCuts < fTrackCuts->GetEntries(); iCuts++) {\r
+                               ((AliAODTrackCutsDiHadronPID*)fTrackCuts->At(iCuts))->IsSelectedGeneratedMC(CurrentAODMCParticle);\r
+                       }\r
+               }\r
+       }\r
+\r
+       //for (Int_t ii=0; ii<200; ii++) cout<<fLvsEtaProj[ii]<<endl;           \r
+\r
+       // Create mapping to Global Tracks.\r
+       FillGlobalTracksArray();\r
+\r
+       // Tell the track cuts object that a new event has started.\r
+       for (Int_t iCuts = 0; iCuts < fTrackCuts->GetEntries(); iCuts++) {\r
+               AliAODTrackCutsDiHadronPID* currentcuts = (AliAODTrackCutsDiHadronPID*)fTrackCuts->At(iCuts);\r
+               if (fVerbose) AliInfo(Form("Starting new event for cuts: %s",currentcuts->GetName()));\r
+               currentcuts->StartNewEvent();\r
+       }\r
+\r
+       // Loop over all reconstructed tracks.\r
+       for (Int_t iTrack = 0; iTrack < fCurrentAODEvent->GetNumberOfTracks(); iTrack++) {\r
+\r
+               // Get the Current Track.\r
+               fCurrentAODTrack = (AliAODTrack*)fCurrentAODEvent->GetTrack(iTrack);\r
+               if (!fCurrentAODTrack) {\r
+                       cout<<"AliAnalysisTaskCompareAODTrackCuts::UserExec -> AOD Track not found."<<endl;\r
+                       continue;\r
+               }\r
+\r
+               // Ignore muon tracks.\r
+               if (fCurrentAODTrack->IsMuonTrack()) {continue;}\r
+\r
+               // Copy Track info into AliTrackDiHadronPID object.\r
+               fCurrentDiHadronPIDTrack = 0x0;\r
+\r
+               // Check if we can indeed find a MC particle corresponding to the reconstructed track.\r
+               /*\r
+               AliAODMCParticle* MCparticleCheck = (AliAODMCParticle*)mcArrayLabel->At(TMath::Abs(fCurrentAODTrack->GetLabel()));\r
+               Double_t MCPt1 = -999.;\r
+               if (MCparticleCheck) MCPt1 = MCparticleCheck->Pt();\r
+               AliAODMCParticle* MCparticleCheck2 = (AliAODMCParticle*)mcArray->At(TMath::Abs(fCurrentAODTrack->GetLabel()));  \r
+               Double_t MCPt2 = -999.;\r
+               if (MCparticleCheck2) MCPt2 = MCparticleCheck2->Pt();\r
+\r
+               cout<<"AOD track abs label: "<<TMath::Abs(fCurrentAODTrack->GetLabel())<<" MC particle with same label found: "<<(Bool_t)MCparticleCheck<<" and with same index: "<<(Bool_t)MCparticleCheck2<<endl;\r
+               cout<<"AOD track pt: "<<fCurrentAODTrack->Pt()<<" same label pt: "<<MCPt1<<" same index pt: "<<MCPt2<<endl;\r
+               //if (!MCparticleCheck) cout<<"MC Particle for a reconstructed track not found."<<endl;\r
+*/\r
+               // Check if it's a TPC-Only or Global Track.\r
+               if (fCurrentAODTrack->GetID() < 0) {\r
+                       // Q: Do we really need to create the arraylabel object or is the original MC array already nicely ordered. (NOTE THAT WE TAKE THE MC PARTICLES FROM THE mcArray)\r
+                       if (fIsMC) fCurrentDiHadronPIDTrack = new AliTrackDiHadronPID(fCurrentAODTrack,GetGlobalTrack(fCurrentAODTrack),(AliAODMCParticle*)mcArray->At(TMath::Abs(fCurrentAODTrack->GetLabel())),fPIDResponse);\r
+                       else fCurrentDiHadronPIDTrack = new AliTrackDiHadronPID(fCurrentAODTrack,GetGlobalTrack(fCurrentAODTrack),0x0,fPIDResponse);\r
+               } else {\r
+                       if (fIsMC) fCurrentDiHadronPIDTrack = new AliTrackDiHadronPID(fCurrentAODTrack,0x0,(AliAODMCParticle*)mcArray->At(TMath::Abs(fCurrentAODTrack->GetLabel())),fPIDResponse);\r
+                       else fCurrentDiHadronPIDTrack = new AliTrackDiHadronPID(fCurrentAODTrack,0x0,0x0,fPIDResponse);\r
+               }\r
+\r
+               if (!fCurrentDiHadronPIDTrack) {\r
+                       cout<<"AliAnalysisTaskCompareAODTrackCuts::UserExec -> Copying to DiHadronPIDTrack failed."<<endl;\r
+                       continue;\r
+               }\r
+\r
+               // Filling random times histogram:\r
+               ULong_t requestedflags = (UInt_t)(AliAODTrack::kTOFout)|(UInt_t)(AliAODTrack::kTIME);\r
+               ULong_t trackflags = fCurrentDiHadronPIDTrack->GetFlags();\r
+               if (requestedflags&trackflags) {fInclusiveTimes->Fill(TMath::Abs(fCurrentDiHadronPIDTrack->Eta()),fCurrentDiHadronPIDTrack->GetTOFsignal());}\r
+\r
+               Double_t rndhittime = -1.e21;\r
+               if (fCalculateTOFMismatch) rndhittime = GenerateRandomHit(fMismatchMethod,fCurrentDiHadronPIDTrack->Eta());\r
+\r
+               // Loop over all Track Cuts.\r
+               for (Int_t iCuts = 0; iCuts < fTrackCuts->GetEntries(); iCuts++) {\r
+                       if (fIsMC) ((AliAODTrackCutsDiHadronPID*)fTrackCuts->At(iCuts))->IsSelectedReconstructedMC(fCurrentDiHadronPIDTrack);\r
+                       else ((AliAODTrackCutsDiHadronPID*)fTrackCuts->At(iCuts))->IsSelectedData(fCurrentDiHadronPIDTrack,rndhittime);\r
+               }\r
+\r
+               // Delete Current DiHadronPIDTrack.\r
+               delete fCurrentDiHadronPIDTrack;\r
+               fCurrentDiHadronPIDTrack = 0x0;\r
+\r
+       }\r
+\r
+       // Tell the track cuts object that the event has been processed.\r
+       for (Int_t iCuts = 0; iCuts < fTrackCuts->GetEntries(); iCuts++) {\r
+               ((AliAODTrackCutsDiHadronPID*)fTrackCuts->At(iCuts))->EventIsDone(fIsMC);\r
+       }\r
+       \r
+       PostData(1,fOutputList);\r
+\r
+} \r
+\r
+// -----------------------------------------------------------------------\r
+Bool_t AliAnalysisTaskCompareAODTrackCuts::LoadExternalMismatchHistos(Int_t mismatchmethod) {\r
+\r
+       if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}\r
+\r
+       // Inputted histograms are loaded and projected properly.\r
+       if ((mismatchmethod < 0)||(mismatchmethod > 1)) {return 0;}\r
+\r
+       if (mismatchmethod == 0) {\r
+\r
+               AliInfo(Form("Loading histograms in file TOFmismatchHistos.root..."));\r
+\r
+               //fExternalTOFfile = TFile::Open("TOFmismatchHistos.root");\r
+               fExternalTOFfile = new TFile("TOFmismatchHistos.root","read");\r
+               fLvsEta = (TH2F*)fExternalTOFfile->Get("hLvsEta");\r
+               fT0Fill = (TH1F*)fExternalTOFfile->Get("hNewT0Fill");\r
+\r
+               // Make projections on the L axis.\r
+               for (Int_t ii = 0; ii < fLvsEta->GetNbinsX(); ii++) {\r
+\r
+                       fLvsEtaProj[ii] = (TH1F*)fLvsEta->ProjectionY(Form("fLvsEtaProj_%i",ii),ii+1,ii+1);\r
+                       fLvsEtaProj[ii]->SetDirectory(0);\r
+\r
+               }\r
+\r
+       }\r
+\r
+       if (mismatchmethod == 1) {\r
+\r
+               AliInfo(Form("Loading histograms in file InclusiveTimes.root..."));\r
+\r
+               //fExternalTOFfile = TFile::Open("InclusiveTimes.root");\r
+               fExternalTOFfile = new TFile("InclusiveTimes.root","read");\r
+               fInclusiveTimesIn = (TH2F*)fExternalTOFfile->Get("fInclusiveTimesIn");\r
+\r
+               // Make projections on the time axis.\r
+               for (Int_t ii = 0; ii < fInclusiveTimesIn->GetNbinsX(); ii++) {\r
+\r
+                       fInclusiveTimesInProj[ii] = (TH1F*)fInclusiveTimesIn->ProjectionY(Form("fInclusiveTimesInProj_%i",ii),ii+1,ii+1);\r
+                       fInclusiveTimesInProj[ii]->SetDirectory(0);\r
+\r
+               }\r
+       }\r
+\r
+       return 0;\r
+\r
+}\r
+\r
+// -----------------------------------------------------------------------\r
+Bool_t AliAnalysisTaskCompareAODTrackCuts::UnLoadExternalMismatchHistos() {\r
+\r
+       if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}\r
+\r
+       AliInfo("Unloading external histo's");\r
+\r
+       for (Int_t ii = 0; ii < 100; ii++){\r
+               if (fLvsEtaProj[ii]) {\r
+                       delete fLvsEtaProj[ii]; \r
+                       fLvsEtaProj[ii] = 0x0;\r
+               }\r
+       } \r
+       for (Int_t ii = 0; ii < 200; ii++) {\r
+               if (fInclusiveTimesInProj[ii]) {\r
+                       delete fInclusiveTimesInProj[ii]; \r
+                       fInclusiveTimesInProj[ii] = 0x0;\r
+                       }\r
+               }\r
+\r
+       if (fExternalTOFfile) {fExternalTOFfile->Close();}\r
+       \r
+       return 0;\r
+\r
+}\r
+\r
+// -----------------------------------------------------------------------\r
+Double_t AliAnalysisTaskCompareAODTrackCuts::GenerateRandomHit(Int_t mismatchmethod, Double_t eta) {\r
+\r
+       if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}\r
+\r
+       if ((mismatchmethod < 0)||(mismatchmethod > 1)) {return -1.e21;}\r
+       if (TMath::Abs(eta) > 0.8) {return -1.e21;}\r
+\r
+       Double_t rndhittime = -1.e21;\r
+\r
+       // Method as in Roberto's code.\r
+       if (mismatchmethod == 0) {\r
+\r
+               Int_t etabin = (Int_t)((eta+1.)*100.);\r
+\r
+               Double_t currentRndLength = fLvsEtaProj[etabin]->GetRandom(); // in cm.\r
+\r
+               Double_t currentRndTime = currentRndLength / (TMath::C() * 1.e2 / 1.e12);\r
+               Double_t t0fill = -1.26416e+04;\r
+\r
+               rndhittime = fT0Fill->GetRandom() - t0fill + currentRndTime;\r
+\r
+       }\r
+\r
+       // Using length inclusive time distributions.\r
+       if (fMismatchMethod == 1) {\r
+               \r
+               Double_t abseta = TMath::Abs(eta);\r
+               Int_t etabin = (Int_t)(abseta*100.);\r
+               rndhittime = fInclusiveTimesInProj[etabin]->GetRandom();\r
+               \r
+       }\r
+\r
+       return rndhittime;\r
+\r
+}\r
+\r
+// -----------------------------------------------------------------------\r
+void AliAnalysisTaskCompareAODTrackCuts::Terminate(Option_t*) {\r
+\r
+       if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}\r
+\r
+       if (fCalculateTOFMismatch) UnLoadExternalMismatchHistos();\r
+\r
+}\r
+\r
+// -----------------------------------------------------------------------
\ No newline at end of file
diff --git a/PWGCF/Correlations/DPhi/DiHadronPID/AliAnalysisTaskCompareAODTrackCuts.h b/PWGCF/Correlations/DPhi/DiHadronPID/AliAnalysisTaskCompareAODTrackCuts.h
new file mode 100644 (file)
index 0000000..3a667bd
--- /dev/null
@@ -0,0 +1,104 @@
+#ifndef ALIANALYSISTASKCOMPAREAODTRACKCUTS_H\r
+#define ALIANALYSISTASKCOMPAREAODTRACKCUTS_H\r
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * \r
+* See cxx source for full Copyright notice */ \r
+/* $Id$ */\r
+\r
+class AliAnalysisTaskCompareAODTrackCuts : public AliAnalysisTaskSE {\r
+\r
+// Basic AnalysisTask Functions.\r
+public:\r
+       AliAnalysisTaskCompareAODTrackCuts();\r
+       AliAnalysisTaskCompareAODTrackCuts(const char* name);\r
+       virtual ~AliAnalysisTaskCompareAODTrackCuts();\r
+       \r
+private:\r
+       AliAnalysisTaskCompareAODTrackCuts(const AliAnalysisTaskCompareAODTrackCuts&);\r
+       AliAnalysisTaskCompareAODTrackCuts& operator=(const AliAnalysisTaskCompareAODTrackCuts&);               \r
+\r
+public:\r
+       virtual void UserCreateOutputObjects(); \r
+       virtual void UserExec(Option_t*);\r
+       virtual void Terminate(Option_t*);      \r
+\r
+// Mismatch related functions.\r
+       Bool_t LoadExternalMismatchHistos(Int_t mismatchmethod);                        // For each mismatch method, external histo's are needed.\r
+       Bool_t UnLoadExternalMismatchHistos();\r
+       Double_t GenerateRandomHit(Int_t mismatchmethod, Double_t eta);         // Generates a random time for a certain eta.\r
+\r
+// Run over MC or not.\r
+       void SetMC(Bool_t isMC = kTRUE) {fIsMC = isMC;} \r
+       void SetVerbose(Bool_t verbose = kTRUE) {fVerbose = verbose;}\r
+       void SetCalculateTOFMismatch(Bool_t calculatetofmismatch = kTRUE, Int_t method = 0) {\r
+               fCalculateTOFMismatch = calculatetofmismatch;\r
+               fMismatchMethod = method;               // 0 = Roberto's method, 1 - From the inclusive times.\r
+       }\r
+\r
+// Managing Event Cuts.\r
+    void SetEventCuts(AliAODEventCutsDiHadronPID* eventcuts) {\r
+       if (!eventcuts) {\r
+                       cout<<"ERROR: No Event Cuts Object"<<endl;\r
+               return;\r
+       }\r
+       fEventCuts = eventcuts;\r
+    }\r
+\r
+// Managing Track Cuts.\r
+    void AddTrackCuts(AliAODTrackCutsDiHadronPID* trackcuts) {\r
+\r
+       if (!trackcuts) return;\r
+       if (!fTrackCuts) {\r
+               cout<<"ERROR: No Track Cuts array available! Check your constructor."<<endl;\r
+               return;\r
+       }\r
+\r
+       fTrackCuts->AddLast(trackcuts);\r
+    }\r
+\r
+private:\r
+       void FillGlobalTracksArray();\r
+       AliAODTrack* GetGlobalTrack(AliAODTrack* track);\r
+\r
+private:\r
+\r
+       // PID Response Object.\r
+       AliPIDResponse*                                 fPIDResponse;                           //! PID Response.\r
+\r
+       // Output List.\r
+       TList*                                                  fOutputList;                            //! Output List.\r
+\r
+       // Settings (streamed!).\r
+       Bool_t                                                  fIsMC;                                          // ran over MC or not.\r
+       Bool_t                                                  fVerbose;                                       // Verbose mode.\r
+       Bool_t                                                  fCalculateTOFMismatch;          // Compute mismatch or not. (Needs input histograms!)\r
+       Int_t                                                   fMismatchMethod;                        // 0 - Roberto's method, 1 - From inclusive times.\r
+\r
+       // Event Cut Object (streamed!).\r
+       AliAODEventCutsDiHadronPID*             fEventCuts;                                     // Event Cuts.\r
+       \r
+       // Array of Track Cut Objects (streamed!).\r
+       TObjArray*                                              fTrackCuts;                                     // TObjArray with all Track Cut Objects.\r
+\r
+       // Inclusive track times.\r
+       TH2F*                                                   fInclusiveTimes;                        //!\r
+\r
+       // Histograms and files to be loaded for the mismatch calculation.                      \r
+       TFile*                                                  fExternalTOFfile;                       //!\r
+       TH2F*                                                   fInclusiveTimesIn;                      //!\r
+       TH1F*                                                   fInclusiveTimesInProj[100];     //!\r
+       TH1F*                                                   fT0Fill;                                        //!\r
+       TH2F*                                                   fLvsEta;                                        //!\r
+       TH1F*                                                   fLvsEtaProj[200];                       //!\r
+\r
+\r
+       // Event and Track related objects.\r
+       AliAODEvent*                                    fCurrentAODEvent;                       //!\r
+       AliAODTrack*                                    fCurrentAODTrack;                       //!\r
+       AliTrackDiHadronPID*                    fCurrentDiHadronPIDTrack;       //!\r
+       TObjArray*                                              fGlobalTracksArray;                     //! Array of Global Tracks.\r
+\r
+       ClassDef(AliAnalysisTaskCompareAODTrackCuts,1);\r
+\r
+};\r
+\r
+#endif
\ No newline at end of file
diff --git a/PWGCF/Correlations/macros/DiHadronPID/AddTaskCompareAODTrackCuts_DiHadronPIDEff.C b/PWGCF/Correlations/macros/DiHadronPID/AddTaskCompareAODTrackCuts_DiHadronPIDEff.C
new file mode 100644 (file)
index 0000000..a9e761d
--- /dev/null
@@ -0,0 +1,112 @@
+// Made to run over the trigger and associated tracks.\r
+\r
+AliAnalysisTaskCompareAODTrackCuts* AddTaskCompareAODTrackCuts_DiHadronPIDEff(\r
+       Double_t MinCentrality = 5.,\r
+       Double_t MaxCentrality = 0.,\r
+       const char* CentralityEstimator = "V0M",\r
+       Double_t maxVertexZ = 7.,\r
+       Double_t maxEta = 0.8,\r
+       Double_t minAssociatedPt = 0.2,\r
+       Double_t maxAssociatedPt = 5.0,\r
+       Double_t minTriggerPt = 5.,\r
+       Double_t maxTriggerPt = 10.,\r
+       Bool_t requestAllSingleTrackHistos = kTRUE,\r
+       Int_t FilterMaskTrigger = 7,\r
+       Int_t FilterMaskAssociated = 10,\r
+       Bool_t isPbPb = kTRUE,\r
+       Bool_t isMC = kTRUE,\r
+       Int_t DebugLevel = 0,\r
+       const char* outputFileName = 0,\r
+       const char* containerName = "DiHadronPIDEff",\r
+       const char* folderName = "PWGCF_DiHadronPID") \r
+\r
+{\r
+\r
+       // Get a pointer to the analysis manager.\r
+    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
+    if (!mgr) {\r
+        cout<<"AddTaskDiHadronPID.C -> No analysis manager found."<<endl;\r
+        return 0x0;\r
+    }\r
+\r
+    // Creating the analysis task.\r
+    AliAnalysisTaskCompareAODTrackCuts* EfficiencyTask = new AliAnalysisTaskCompareAODTrackCuts(containerName);\r
+    EfficiencyTask->SetVerbose(kFALSE);\r
+    EfficiencyTask->SetMC(IsMC);\r
+    EfficiencyTask->SetCalculateTOFMismatch(kTRUE,0);\r
+\r
+        // Configure and add Event Cuts.\r
+       AliAODEventCutsDiHadronPID* eventcuts = new AliAODEventCutsDiHadronPID("EventCuts");\r
+       eventcuts->SetTrigger(AliVEvent::kMB);\r
+       eventcuts->SetCentrality(MaxCentrality, MinCentrality);\r
+       eventcuts->SetMaxVertexZ(maxVertexZ);\r
+       eventcuts->SetCentralityEstimator(CentralityEstimator);\r
+       eventcuts->SetIsPbPb(isPbPb);\r
+       eventcuts->SetDebugLevel(DebugLevel);\r
+       EfficiencyTask->SetEventCuts(eventcuts);\r
+\r
+       // Configure and add track cuts for trigger.\r
+       AliAODTrackCutsDiHadronPID* triggercuts = new AliAODTrackCutsDiHadronPID("TrackCutsTrigger");\r
+       triggercuts->SetIsMC(isMC);\r
+       triggercuts->SetFilterMask(1<<FilterMaskTrigger);\r
+       triggercuts->SetPtRange(minTriggerPt,maxTriggerPt);\r
+       triggercuts->SetMaxEta(maxEta);\r
+       triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllCharged);\r
+       triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPositive);\r
+       triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegative);\r
+       if (requestAllSingleTrackHistos) {\r
+               triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllPion);\r
+               triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPosPion);\r
+               triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegPion);                                     \r
+               triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllKaon);\r
+               triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPosKaon);\r
+               triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegKaon);             \r
+               triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllProton);\r
+               triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPosProton);\r
+               triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegProton);\r
+       }       \r
+       triggercuts->SetDebugLevel(DebugLevel);\r
+       EfficiencyTask->AddTrackCuts(triggercuts);\r
+\r
+       // Configure and add track cuts for associateds.\r
+       AliAODTrackCutsDiHadronPID* associatedscuts = new AliAODTrackCutsDiHadronPID("TrackCutsAssociated");\r
+       associatedscuts->SetIsMC(isMC);\r
+       associatedscuts->SetFilterMask(1<<FilterMaskAssociated);\r
+       associatedscuts->SetPtRange(minAssociatedPt,maxAssociatedPt);\r
+       associatedscuts->SetMaxEta(maxEta);\r
+       ULong_t associatedflags = (UInt_t)(AliAODTrack::kTOFout)|(UInt_t)(AliAODTrack::kTIME);  \r
+       associatedscuts->SetDemandFlags(associatedflags);\r
+       associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllCharged);\r
+       associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPositive);\r
+       associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegative);\r
+       if (requestAllSingleTrackHistos) {\r
+               associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllPion);\r
+               associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPosPion);\r
+               associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegPion);                                 \r
+               associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllKaon);\r
+               associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPosKaon);\r
+               associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegKaon);         \r
+               associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllProton);\r
+               associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPosProton);\r
+               associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegProton);\r
+       }\r
+       associatedscuts->SetDebugLevel(DebugLevel);\r
+       EfficiencyTask->AddTrackCuts(associatedscuts);\r
+\r
+       // Add the task.\r
+       mgr->AddTask(EfficiencyTask);\r
+    \r
+       // Data containers.\r
+       AliAnalysisDataContainer* cinput  = mgr->GetCommonInputContainer();\r
+       mgr->ConnectInput(EfficiencyTask, 0, cinput); \r
+       \r
+       if (!outputFileName) {outputFileName = AliAnalysisManager::GetCommonFileName();}\r
+       \r
+       AliAnalysisDataContainer* coutput1 = mgr->CreateContainer(containerName, TList::Class(),\r
+                         AliAnalysisManager::kOutputContainer,Form("%s:%s", outputFileName, folderName));\r
+       \r
+       mgr->ConnectOutput(EfficiencyTask,1,coutput1);\r
+       \r
+       return EfficiencyTask;\r
+\r
+}\r
index 052d430..91a5762 100644 (file)
@@ -18,6 +18,7 @@
 #pragma link C++ class AliAODEventCutsDiHadronPID+;
 #pragma link C++ class AliHistToolsDiHadronPID+;
 #pragma link C++ class AliAnalysisTaskDiHadronPID+;
+#pragma link C++ class AliAnalysisTaskCompareAODTrackCuts+;
 #pragma link C++ class AliEvtPoolManager+;
 #pragma link C++ class AliEvtPool+;
 #pragma link C++ class AliMiniTrack+;