]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG0/dNdEta/testAnalysis2.C
a lot of work on the analysis
[u/mrichter/AliRoot.git] / PWG0 / dNdEta / testAnalysis2.C
1 /* $Id$ */
2
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
13 void testAnalysis2(Char_t* data, Int_t nRuns=20, Int_t offset=0, Bool_t aMC = kFALSE, Bool_t aDebug = kFALSE, Bool_t aProof = kFALSE)
14 {
15   gSystem->Load("libEG");
16   gSystem->Load("libGeom");
17   gSystem->Load("libESD");
18   gSystem->Load("libPWG0base");
19   if (aMC != kFALSE)
20     gSystem->Load("libPWG0dep");
21
22   gROOT->ProcessLine(".L CreatedNdEta.C");
23   gROOT->ProcessLine(".L CreateCuts.C");
24
25   TChain* chain = 0;
26   TVirtualProof* proof = 0;
27   if (aProof == kFALSE)
28     chain = CreateESDChainFromDir(data, nRuns, offset);
29   else
30   {
31     chain = CreateESDChainFromList(data, nRuns, offset);
32     proof = gROOT->Proof("jgrosseo@lxb6046");
33
34     if (!proof)
35     {
36       printf("ERROR: PROOF connection not established.\n");
37       return;
38     }
39
40     if (proof->EnablePackage("ESD"))
41     {
42       printf("ERROR: ESD package could not be enabled.\n");
43       return;
44     }
45
46     if (proof->EnablePackage("PWG0base"))
47     {
48       printf("ERROR: PWG0base package could not be enabled.\n");
49       return;
50     }
51
52     if (aMC != kFALSE)
53     {
54       if (proof->EnablePackage("PWG0dep"))
55       {
56         printf("ERROR: PWG0dep package could not be enabled.\n");
57         return;
58       }
59     }
60
61     //chain->SetProof(proof);
62   }
63
64   // ########################################################
65   // selection of esd tracks
66   AliESDtrackCuts* esdTrackCuts = CreateTrackCuts();
67   if (!esdTrackCuts)
68   {
69     printf("ERROR: esdTrackCuts could not be created\n");
70     return;
71   }
72
73   chain->GetUserInfo()->Add(esdTrackCuts);
74   if (proof)
75     proof->AddInput(esdTrackCuts);
76
77   if (aMC == kFALSE)
78   {
79     AlidNdEtaCorrection* dNdEtaCorrection = new AlidNdEtaCorrection();
80     dNdEtaCorrection->LoadHistograms("correction_map.root","dndeta_correction");
81     //dNdEtaCorrection->RemoveEdges(2, 0, 2);
82
83     chain->GetUserInfo()->Add(dNdEtaCorrection);
84     if (proof)
85       proof->AddInput(dNdEtaCorrection);
86   }
87
88   TString selectorName = ((aMC == kFALSE) ? "AlidNdEtaAnalysisESDSelector" : "AlidNdEtaAnalysisMCSelector");
89   AliLog::SetClassDebugLevel(selectorName, AliLog::kInfo);
90
91   // workaround for a bug in PROOF that only allows header files for .C files
92   // please create symlink from <selector>.cxx to <selector>.C
93   if (proof != kFALSE)
94     selectorName += ".C+";
95   else
96     selectorName += ".cxx+";
97
98   if (aDebug != kFALSE)
99     selectorName += "g";
100
101   TStopwatch timer;
102   timer.Start();
103
104   Long64_t result = -1;
105
106   if (proof != kFALSE)
107     result = chain->MakeTDSet()->Process(selectorName);
108   else
109     result = chain->Process(selectorName);
110
111   if (result != 0)
112   {
113     printf("ERROR: Executing process failed with %d.\n", result);
114     return;
115   }
116
117   timer.Stop();
118   timer.Print();
119
120   CreatedNdEta(aMC ? kFALSE : kTRUE, aMC ? "analysis_mc.root" : "analysis_esd.root");
121 }
122