]>
Commit | Line | Data |
---|---|---|
285664fe | 1 | // $Id$ |
2 | // | |
980821ba | 3 | // Emcal physics selection task. |
285664fe | 4 | // |
5 | // | |
6 | ||
be94a07d | 7 | #include <TFile.h> |
8 | #include <TH1F.h> | |
9 | #include <TH2F.h> | |
10 | #include <TROOT.h> | |
11 | #include "AliAnalysisDataContainer.h" | |
12 | #include "AliAnalysisDataSlot.h" | |
13 | #include "AliAnalysisManager.h" | |
14 | #include "AliEmcalPhysicsSelection.h" | |
15 | #include "AliEmcalPhysicsSelectionTask.h" | |
16 | #include "AliESDEvent.h" | |
17 | #include "AliInputEventHandler.h" | |
18 | #include "AliLog.h" | |
19 | ||
20 | ClassImp(AliEmcalPhysicsSelectionTask) | |
21 | ||
22 | //__________________________________________________________________________________________________ | |
23 | AliEmcalPhysicsSelectionTask::AliEmcalPhysicsSelectionTask() : | |
24 | AliPhysicsSelectionTask(), | |
25 | fDoWriteHistos(1), | |
26 | fNCalled(0), | |
27 | fNAccepted(0), | |
fb81cdb7 | 28 | fHAcc(0), |
29 | fHEvtTypes(0) | |
be94a07d | 30 | { |
31 | // Default constructor. | |
32 | } | |
33 | ||
34 | //__________________________________________________________________________________________________ | |
35 | AliEmcalPhysicsSelectionTask::AliEmcalPhysicsSelectionTask(const char* opt) : | |
36 | AliPhysicsSelectionTask(), | |
37 | fDoWriteHistos(1), | |
38 | fNCalled(0), | |
39 | fNAccepted(0), | |
fb81cdb7 | 40 | fHAcc(0), |
41 | fHEvtTypes(0) | |
be94a07d | 42 | { |
43 | // Constructor. | |
44 | ||
45 | fOption = opt; | |
46 | fPhysicsSelection = new AliEmcalPhysicsSelection; | |
47 | ||
48 | AliInputEventHandler* handler = dynamic_cast<AliInputEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
49 | if (handler) { | |
50 | handler->SetEventSelection(fPhysicsSelection); | |
51 | AliInfo("Physics Event Selection enabled."); | |
52 | } else { | |
53 | AliError("No input event handler connected to analysis manager. No Physics Event Selection."); | |
54 | } | |
55 | // Define input and output slots here | |
56 | DefineOutput(1, TList::Class()); | |
e51eba5c | 57 | fBranchNames = "ESD:AliESDRun.,AliESDHeader.,AliMultiplicity.,AliESDVZERO.," |
58 | "AliESDZDC.,SPDVertex.,PrimaryVertex.,TPCVertex.,Tracks,SPDPileupVertices"; | |
be94a07d | 59 | |
60 | AliLog::SetClassDebugLevel("AliEmcalPhysicsSelectionTask", AliLog::kWarning); | |
61 | } | |
62 | ||
63 | //__________________________________________________________________________________________________ | |
64 | void AliEmcalPhysicsSelectionTask::UserCreateOutputObjects() | |
65 | { | |
66 | // User create outputs. | |
67 | ||
68 | AliPhysicsSelectionTask::UserCreateOutputObjects(); | |
69 | fHAcc = new TH1D("hEvCount",";0=rej/1=acc;#",2,-0.5,1.5); | |
70 | fOutput->Add(fHAcc); | |
31e6d0e8 | 71 | fHEvtTypes = new TH1D("hEvtTypes",";#",10,-0.5,9.5); |
6311acf7 | 72 | fHEvtTypes->GetXaxis()->SetBinLabel(1, "All"); |
73 | fHEvtTypes->GetXaxis()->SetBinLabel(2, "MB"); | |
74 | fHEvtTypes->GetXaxis()->SetBinLabel(3, "FO"); | |
75 | fHEvtTypes->GetXaxis()->SetBinLabel(4, "EMC"); | |
76 | fHEvtTypes->GetXaxis()->SetBinLabel(5, "EJE"); | |
77 | fHEvtTypes->GetXaxis()->SetBinLabel(6, "EGA"); | |
78 | fHEvtTypes->GetXaxis()->SetBinLabel(7, "Good"); | |
79 | fHEvtTypes->GetXaxis()->SetBinLabel(8, "HC"); | |
80 | fHEvtTypes->GetXaxis()->SetBinLabel(9, "HT"); | |
81 | fHEvtTypes->GetXaxis()->SetBinLabel(10, "LED"); | |
fb81cdb7 | 82 | fOutput->Add(fHEvtTypes); |
be94a07d | 83 | if (!fDoWriteHistos) { |
84 | fOutput->Remove(fPhysicsSelection); | |
85 | } | |
86 | } | |
87 | ||
88 | //__________________________________________________________________________________________________ | |
89 | void AliEmcalPhysicsSelectionTask::UserExec(const Option_t *opt) | |
90 | { | |
91 | // User exec. | |
92 | ||
93 | AliPhysicsSelectionTask::UserExec(opt); | |
94 | ||
95 | ++fNCalled; | |
96 | ||
97 | UInt_t res = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected(); | |
98 | if (res>0) { | |
99 | ++fNAccepted; | |
100 | fHAcc->Fill(1); | |
101 | } else { | |
102 | fHAcc->Fill(0); | |
103 | } | |
fb81cdb7 | 104 | |
57f305da | 105 | AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager(); |
106 | am->LoadBranch("AliESDHeader."); | |
6311acf7 | 107 | AliVHeader *header = InputEvent()->GetHeader(); |
57f305da | 108 | TString title(header->GetTitle()); |
109 | if (title.Length()>0) { | |
110 | UInt_t offline = header->GetUniqueID(); | |
111 | if (offline!=res) { | |
112 | AliWarning(Form("Stored offline trigger not equal computed: %ud %ud", offline, res)); | |
113 | } | |
114 | } | |
115 | ||
fb81cdb7 | 116 | AliEmcalPhysicsSelection *ps=static_cast<AliEmcalPhysicsSelection *>(fPhysicsSelection); |
117 | fHEvtTypes->Fill(0); | |
118 | if (res&AliVEvent::kAnyINT) | |
119 | fHEvtTypes->Fill(1); | |
120 | if (ps->IsFastOnly()) | |
121 | fHEvtTypes->Fill(2); | |
122 | if ((res&AliVEvent::kEMC1) || (res&AliVEvent::kEMC7)) | |
123 | fHEvtTypes->Fill(3); | |
31e6d0e8 | 124 | if (res&AliVEvent::kEMCEJE) |
fb81cdb7 | 125 | fHEvtTypes->Fill(4); |
31e6d0e8 | 126 | if (res&AliVEvent::kEMCEGA) |
fb81cdb7 | 127 | fHEvtTypes->Fill(5); |
31e6d0e8 | 128 | if (ps->IsGoodEvent()) |
fb81cdb7 | 129 | fHEvtTypes->Fill(6); |
31e6d0e8 | 130 | if (res&AliEmcalPhysicsSelection::kEmcalHC) |
fb81cdb7 | 131 | fHEvtTypes->Fill(7); |
31e6d0e8 | 132 | if (res&AliEmcalPhysicsSelection::kEmcalHT) |
133 | fHEvtTypes->Fill(8); | |
134 | if (ps->IsLedEvent()) | |
135 | fHEvtTypes->Fill(9); | |
be94a07d | 136 | } |
137 | ||
138 | //__________________________________________________________________________________________________ | |
139 | void AliEmcalPhysicsSelectionTask::Terminate(Option_t *) | |
140 | { | |
141 | // The Terminate() function is the last function to be called during | |
142 | // a query. It always runs on the client, it can be used to present | |
143 | // the results graphically or save the results to file. | |
144 | ||
145 | AliInfo(Form("Called %d times, accepted %d events", fNCalled, fNAccepted)); | |
146 | ||
147 | if (!fDoWriteHistos) | |
148 | return; | |
149 | ||
150 | fOutput = dynamic_cast<TList*> (GetOutputData(1)); | |
151 | if (!fOutput) { | |
152 | AliError("fOutput not available"); | |
153 | return; | |
154 | } | |
155 | ||
156 | AliAnalysisDataSlot *oslot = GetOutputSlot(1); | |
157 | if (!oslot) | |
158 | return; | |
159 | ||
160 | AliAnalysisDataContainer *ocont = oslot->GetContainer(); | |
161 | if (!ocont) | |
162 | return; | |
163 | ||
164 | TFile *file = OpenFile(1); | |
165 | if (!file) | |
166 | return; | |
167 | ||
168 | TDirectory::TContext context(file); | |
169 | if (AliAnalysisManager::GetAnalysisManager()->IsProofMode()) { | |
170 | fPhysicsSelection = dynamic_cast<AliPhysicsSelection*> (fOutput->FindObject("AliPhysicsSelection")); | |
171 | } | |
172 | if (fPhysicsSelection) { | |
173 | //fPhysicsSelection->Print(); | |
174 | fPhysicsSelection->SaveHistograms(Form("%sHists",ocont->GetName())); | |
175 | AliInfo(Form("Writing result to %s",file->GetName())); | |
176 | } | |
177 | fOutput->Remove(fPhysicsSelection); | |
178 | } |