Avoid multiple deletion of AliTRDltuTrack objects
[u/mrichter/AliRoot.git] / PWG0 / dNdEta / testAnalysis2.C
CommitLineData
dc740de4 1/* $Id$ */
2
75e130df 3//
4// Script to test the dN/dEta analysis using the dNdEtaAnalysis and
5// dNdEtaCorrection classes. Note that there is a cut on the events,
6// so the measurement will be biassed.
7//
8// implementation with TSelector
9//
10
11#include "../CreateESDChain.C"
12
16e24ca3 13void testAnalysis2(Char_t* data, Int_t nRuns=20, Int_t offset=0, Bool_t aMC = kFALSE, Bool_t aDebug = kFALSE, Bool_t aProof = kFALSE)
75e130df 14{
16e24ca3 15 gSystem->Load("libEG");
16 gSystem->Load("libGeom");
17 gSystem->Load("libESD");
75e130df 18 gSystem->Load("libPWG0base");
16e24ca3 19 if (aMC != kFALSE)
20 gSystem->Load("libPWG0dep");
75e130df 21
16e24ca3 22 gROOT->ProcessLine(".L CreatedNdEta.C");
23 gROOT->ProcessLine(".L CreateCuts.C");
10ebe68d 24 gROOT->ProcessLine(".L drawPlots.C");
16e24ca3 25
10ebe68d 26 TChain* chain = CreateESDChain(data, nRuns, offset);;
16e24ca3 27 TVirtualProof* proof = 0;
10ebe68d 28
29 if (aProof != kFALSE)
16e24ca3 30 {
8b3563f4 31 proof = TProof::Open("jgrosseo@lxb6046");
16e24ca3 32
33 if (!proof)
34 {
35 printf("ERROR: PROOF connection not established.\n");
36 return;
37 }
38
39 if (proof->EnablePackage("ESD"))
40 {
41 printf("ERROR: ESD package could not be enabled.\n");
42 return;
43 }
44
45 if (proof->EnablePackage("PWG0base"))
46 {
47 printf("ERROR: PWG0base package could not be enabled.\n");
48 return;
49 }
50
51 if (aMC != kFALSE)
52 {
53 if (proof->EnablePackage("PWG0dep"))
54 {
55 printf("ERROR: PWG0dep package could not be enabled.\n");
56 return;
57 }
58 }
59
847489f7 60 //chain->SetProof(proof);
16e24ca3 61 }
75e130df 62
63 // ########################################################
64 // selection of esd tracks
16e24ca3 65 AliESDtrackCuts* esdTrackCuts = CreateTrackCuts();
66 if (!esdTrackCuts)
dded7a68 67 {
16e24ca3 68 printf("ERROR: esdTrackCuts could not be created\n");
69 return;
dded7a68 70 }
37dbb69e 71
10ebe68d 72 chain->GetUserInfo()->Add(esdTrackCuts);
73 if (proof)
74 proof->AddInput(esdTrackCuts);
16e24ca3 75
847489f7 76 if (aMC == kFALSE)
77 {
8b3563f4 78 AlidNdEtaCorrection* dNdEtaCorrection = new AlidNdEtaCorrection("dndeta_correction", "dndeta_correction");
847489f7 79 dNdEtaCorrection->LoadHistograms("correction_map.root","dndeta_correction");
10ebe68d 80 dNdEtaCorrection->ReduceInformation();
847489f7 81 //dNdEtaCorrection->RemoveEdges(2, 0, 2);
82
10ebe68d 83 chain->GetUserInfo()->Add(dNdEtaCorrection);
84 if (proof)
85 proof->AddInput(dNdEtaCorrection);
847489f7 86 }
87
dc740de4 88 TString selectorName = ((aMC == kFALSE) ? "AlidNdEtaAnalysisESDSelector" : "AlidNdEtaAnalysisMCSelector");
4dd2ad81 89 AliLog::SetClassDebugLevel(selectorName, AliLog::kInfo);
90
10ebe68d 91 selectorName += ".cxx++";
16e24ca3 92
fcf2fb36 93 if (aDebug != kFALSE)
94 selectorName += "g";
95
dafef3c8 96 TStopwatch timer;
97 timer.Start();
98
847489f7 99 Long64_t result = -1;
100
101 if (proof != kFALSE)
102 result = chain->MakeTDSet()->Process(selectorName);
103 else
104 result = chain->Process(selectorName);
105
16e24ca3 106 if (result != 0)
107 {
108 printf("ERROR: Executing process failed with %d.\n", result);
109 return;
110 }
dafef3c8 111
112 timer.Stop();
113 timer.Print();
5fbd0b17 114
10ebe68d 115 dNdEtaAnalysis* fdNdEtaAnalysis = new dNdEtaAnalysis("dndeta", "dndeta");
116
117 TFile* file = TFile::Open(aMC ? "analysis_mc.root" : "analysis_esd.root");
118 if (!file)
119 {
120 cout << "Error. File not found" << endl;
121 return;
122 }
123 fdNdEtaAnalysis->LoadHistograms();
124 fdNdEtaAnalysis->DrawHistograms();
125
126 dNdEta(kTRUE);
75e130df 127}
16e24ca3 128