]>
Commit | Line | Data |
---|---|---|
78167ba7 | 1 | /* $Id$ */ |
2 | ||
3 | #include "AliPhysicsSelectionTask.h" | |
4 | ||
5 | #include <TFile.h> | |
6 | #include <TH1F.h> | |
7 | #include <TH2F.h> | |
8 | ||
9 | #include <AliLog.h> | |
10 | #include <AliESDEvent.h> | |
11 | #include <AliHeader.h> | |
12 | ||
13 | #include "AliPhysicsSelection.h" | |
14 | #include "AliAnalysisManager.h" | |
15 | #include "AliInputEventHandler.h" | |
16 | ||
17 | //#include "AliBackgroundSelection.h" | |
18 | ||
19 | ClassImp(AliPhysicsSelectionTask) | |
20 | ||
21 | AliPhysicsSelectionTask::AliPhysicsSelectionTask() : | |
22 | AliAnalysisTaskSE("AliPhysicsSelectionTask"), | |
23 | fOutput(0), | |
24 | fOption(""), | |
25 | fPhysicsSelection(0) | |
26 | { | |
27 | // | |
28 | // Default event handler | |
29 | // | |
30 | } | |
31 | ||
32 | AliPhysicsSelectionTask::AliPhysicsSelectionTask(const char* opt) : | |
33 | AliAnalysisTaskSE("AliPhysicsSelectionTask"), | |
34 | fOutput(0), | |
35 | fOption(opt), | |
36 | fPhysicsSelection(new AliPhysicsSelection()) | |
37 | { | |
38 | // | |
39 | // Constructor. Initialization of pointers | |
40 | // | |
41 | AliInputEventHandler* handler = dynamic_cast<AliInputEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
42 | if (handler) { | |
43 | handler->SetEventSelection(fPhysicsSelection); | |
44 | AliInfo("Physics Event Selection enabled."); | |
45 | } else { | |
46 | AliError("No input event handler connected to analysis manager. No Physics Event Selection."); | |
47 | } | |
48 | // Define input and output slots here | |
49 | DefineOutput(1, TList::Class()); | |
50 | ||
51 | AliLog::SetClassDebugLevel("AliPhysicsSelectionTask", AliLog::kWarning); | |
52 | } | |
53 | ||
54 | AliPhysicsSelectionTask::~AliPhysicsSelectionTask() | |
55 | { | |
56 | // | |
57 | // Destructor | |
58 | // | |
59 | ||
60 | // histograms are in the output list and deleted when the output | |
61 | // list is deleted by the TSelector dtor | |
62 | ||
63 | if (fOutput) { | |
64 | delete fOutput; | |
65 | fOutput = 0; | |
66 | } | |
67 | } | |
68 | ||
69 | void AliPhysicsSelectionTask::UserCreateOutputObjects() | |
70 | { | |
71 | // create result objects and add to output list | |
72 | ||
73 | Printf("AliPhysicsSelectionTask::CreateOutputObjects"); | |
74 | ||
75 | fOutput = new TList; | |
76 | fOutput->SetOwner(); | |
77 | ||
78 | if (!fPhysicsSelection) | |
79 | fPhysicsSelection = new AliPhysicsSelection; | |
80 | ||
81 | fOutput->Add(fPhysicsSelection); | |
82 | } | |
83 | ||
84 | void AliPhysicsSelectionTask::UserExec(Option_t*) | |
85 | { | |
86 | // process the event | |
87 | ||
38c52e61 | 88 | // AliPhysicsSelection::IsCollisionCandidate is called from the event handler |
89 | // post the data here anyway! | |
78167ba7 | 90 | PostData(1, fOutput); |
78167ba7 | 91 | } |
92 | ||
93 | void AliPhysicsSelectionTask::Terminate(Option_t *) | |
94 | { | |
95 | // The Terminate() function is the last function to be called during | |
96 | // a query. It always runs on the client, it can be used to present | |
97 | // the results graphically or save the results to file. | |
98 | ||
99 | fOutput = dynamic_cast<TList*> (GetOutputData(1)); | |
100 | if (!fOutput) | |
101 | Printf("ERROR: fOutput not available"); | |
102 | ||
103 | if (fOutput) | |
104 | { | |
105 | fPhysicsSelection = dynamic_cast<AliPhysicsSelection*> (fOutput->FindObject("AliPhysicsSelection")); | |
106 | } | |
107 | ||
108 | TFile* fout = new TFile("event_stat.root", "RECREATE"); | |
109 | ||
110 | if (fPhysicsSelection) | |
111 | { | |
112 | fPhysicsSelection->Print(); | |
decf6fd4 | 113 | fPhysicsSelection->SaveHistograms(); |
78167ba7 | 114 | } |
115 | ||
116 | fout->Write(); | |
117 | fout->Close(); | |
118 | ||
119 | Printf("Writting result to event_stat.root"); | |
120 | } |