3 #include "AliPhysicsSelectionTask.h"
10 #include <AliESDEvent.h>
11 #include <AliHeader.h>
13 #include "AliPhysicsSelection.h"
14 #include "AliAnalysisManager.h"
15 #include "AliInputEventHandler.h"
17 //#include "AliBackgroundSelection.h"
19 ClassImp(AliPhysicsSelectionTask)
21 AliPhysicsSelectionTask::AliPhysicsSelectionTask() :
22 AliAnalysisTaskSE("AliPhysicsSelectionTask"),
28 // Default event handler
32 AliPhysicsSelectionTask::AliPhysicsSelectionTask(const char* opt) :
33 AliAnalysisTaskSE("AliPhysicsSelectionTask"),
36 fPhysicsSelection(new AliPhysicsSelection())
39 // Constructor. Initialization of pointers
41 AliInputEventHandler* handler = dynamic_cast<AliInputEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
43 handler->SetEventSelection(fPhysicsSelection);
44 AliInfo("Physics Event Selection enabled.");
46 AliError("No input event handler connected to analysis manager. No Physics Event Selection.");
48 // Define input and output slots here
49 DefineOutput(1, TList::Class());
50 fBranchNames = "ESD:AliESDRun.,AliESDHeader.,AliMultiplicity.,AliESDVZERO.,"
51 "AliESDZDC.,SPDVertex.,PrimaryVertex.,TPCVertex.,Tracks,SPDPileupVertices";
53 AliLog::SetClassDebugLevel("AliPhysicsSelectionTask", AliLog::kWarning);
56 AliPhysicsSelectionTask::~AliPhysicsSelectionTask()
62 // histograms are in the output list and deleted when the output
63 // list is deleted by the TSelector dtor
65 if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
71 void AliPhysicsSelectionTask::UserCreateOutputObjects()
73 // create result objects and add to output list
75 Printf("AliPhysicsSelectionTask::CreateOutputObjects");
80 if (!fPhysicsSelection)
81 fPhysicsSelection = new AliPhysicsSelection;
83 fOutput->Add(fPhysicsSelection);
84 // All tasks must post data once for all outputs (AG)
88 void AliPhysicsSelectionTask::UserExec(Option_t*)
92 // AliPhysicsSelection::IsCollisionCandidate is called from the event handler
93 // post the data here anyway!
97 void AliPhysicsSelectionTask::FinishTaskOutput()
99 // This gets called at the end of the processing on the worker. It allows dumping
100 // statistics printed by the physics selection object to the statistics message
101 // handled by the analysis manager.
102 if (fPhysicsSelection) fPhysicsSelection->Print("STAT");
105 void AliPhysicsSelectionTask::Terminate(Option_t *)
107 // The Terminate() function is the last function to be called during
108 // a query. It always runs on the client, it can be used to present
109 // the results graphically or save the results to file.
111 fOutput = dynamic_cast<TList*> (GetOutputData(1));
113 Printf("ERROR: fOutput not available");
117 fPhysicsSelection = dynamic_cast<AliPhysicsSelection*> (fOutput->FindObject("AliPhysicsSelection"));
120 TFile* fout = new TFile("event_stat.root", "RECREATE");
122 if (fPhysicsSelection)
124 fPhysicsSelection->Print();
125 fPhysicsSelection->SaveHistograms();
131 Printf("Writting result to event_stat.root");