1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
20 #include <TInterpreter.h>
25 #include "AliAnalysisTaskSE.h"
26 #include "AliAnalysisManager.h"
27 #include "AliAnalysisCuts.h"
28 #include "AliAnalysisDataSlot.h"
29 #include "AliAnalysisDataContainer.h"
31 #include "AliESDEvent.h"
32 #include "AliESDfriend.h"
34 #include "AliAODEvent.h"
35 #include "AliAODHeader.h"
36 #include "AliAODTracklets.h"
37 #include "AliAODCaloCells.h"
38 #include "AliAODMCParticle.h"
39 #include "AliVEvent.h"
40 #include "AliAODHandler.h"
41 #include "AliAODInputHandler.h"
42 #include "AliMCEventHandler.h"
43 #include "AliInputEventHandler.h"
44 #include "AliMultiInputEventHandler.h"
45 #include "AliESDInputHandler.h"
46 #include "AliMCEvent.h"
49 #include "AliAODDimuon.h"
52 ClassImp(AliAnalysisTaskSE)
54 ////////////////////////////////////////////////////////////////////////
55 AliAODHeader* AliAnalysisTaskSE::fgAODHeader = NULL;
56 TClonesArray* AliAnalysisTaskSE::fgAODTracks = NULL;
57 TClonesArray* AliAnalysisTaskSE::fgAODVertices = NULL;
58 TClonesArray* AliAnalysisTaskSE::fgAODV0s = NULL;
59 TClonesArray* AliAnalysisTaskSE::fgAODPMDClusters = NULL;
60 TClonesArray* AliAnalysisTaskSE::fgAODJets = NULL;
61 TClonesArray* AliAnalysisTaskSE::fgAODFMDClusters = NULL;
62 TClonesArray* AliAnalysisTaskSE::fgAODCaloClusters = NULL;
63 TClonesArray* AliAnalysisTaskSE::fgAODMCParticles = NULL;
64 AliAODTracklets* AliAnalysisTaskSE::fgAODTracklets = NULL;
65 AliAODCaloCells* AliAnalysisTaskSE::fgAODEmcalCells = NULL;
66 AliAODCaloCells* AliAnalysisTaskSE::fgAODPhosCells = NULL;
67 TClonesArray* AliAnalysisTaskSE::fgAODDimuons = NULL;
69 AliAnalysisTaskSE::AliAnalysisTaskSE():
79 fCurrentRunNumber(-1),
81 fOfflineTriggerMask(0),
82 fMultiInputHandler(0),
85 // Default constructor
88 AliAnalysisTaskSE::AliAnalysisTaskSE(const char* name):
89 AliAnalysisTask(name, "AnalysisTaskSE"),
98 fCurrentRunNumber(-1),
100 fOfflineTriggerMask(0),
101 fMultiInputHandler(0),
104 // Default constructor
105 DefineInput (0, TChain::Class());
106 DefineOutput(0, TTree::Class());
109 AliAnalysisTaskSE::AliAnalysisTaskSE(const AliAnalysisTaskSE& obj):
110 AliAnalysisTask(obj),
119 fCurrentRunNumber(-1),
121 fOfflineTriggerMask(0),
122 fMultiInputHandler(obj.fMultiInputHandler),
123 fMCEventHandler(obj.fMCEventHandler)
128 fInputEvent = obj.fInputEvent;
129 fESDfriend = obj.fESDfriend;
130 fInputHandler = obj.fInputHandler;
131 fOutputAOD = obj.fOutputAOD;
132 fMCEvent = obj.fMCEvent;
134 fCurrentRunNumber = obj.fCurrentRunNumber;
135 fHistosQA = obj.fHistosQA;
140 AliAnalysisTaskSE& AliAnalysisTaskSE::operator=(const AliAnalysisTaskSE& other)
143 AliAnalysisTask::operator=(other);
144 fDebug = other.fDebug;
145 fEntry = other.fEntry;
146 fInputEvent = other.fInputEvent;
147 fESDfriend = other.fESDfriend;
148 fInputHandler = other.fInputHandler;
149 fOutputAOD = other.fOutputAOD;
150 fMCEvent = other.fMCEvent;
151 fTreeA = other.fTreeA;
152 fCurrentRunNumber = other.fCurrentRunNumber;
153 fHistosQA = other.fHistosQA;
154 fOfflineTriggerMask = other.fOfflineTriggerMask;
155 fMultiInputHandler = other.fMultiInputHandler;
156 fMCEventHandler = other.fMCEventHandler;
160 //______________________________________________________________________________
161 Bool_t AliAnalysisTaskSE::CheckPostData() const
163 // Checks if data was posted to all outputs defined by the task. If task does
164 // not have output slots this returns always kTRUE.
165 AliAnalysisDataContainer *coutput;
166 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
167 for (Int_t islot=1; islot<fNoutputs; islot++) {
168 coutput = GetOutputSlot(islot)->GetContainer();
169 if (!mgr->GetOutputs()->FindObject(coutput)) continue;
170 if (!coutput->GetData()) return kFALSE;
176 void AliAnalysisTaskSE::ConnectInputData(Option_t* /*option*/)
178 // Connect the input data
179 if (fDebug > 1) printf("AnalysisTaskSE::ConnectInputData() \n");
181 // Connect input handlers (multi input handler is handled)
182 ConnectMultiHandler();
185 if ((fInputHandler->GetTree())->GetBranch("ESDfriend."))
186 fESDfriend = ((AliESDInputHandler*)fInputHandler)->GetESDfriend();
188 fInputEvent = fInputHandler->GetEvent();
189 } else if( fMCEvent ) {
190 AliWarning("No Input Event Handler connected, only MC Truth Event Handler") ;
192 AliError("No Input Event Handler connected") ;
195 // Disconnect multi handler
196 DisconnectMultiHandler();
199 void AliAnalysisTaskSE::CreateOutputObjects()
201 // Create the output container
204 if (fDebug > 1) printf("AnalysisTaskSE::CreateOutPutData() \n");
206 AliAODHandler* handler = dynamic_cast<AliAODHandler*>
207 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
209 Bool_t merging = kFALSE;
210 AliAODInputHandler* aodIH = static_cast<AliAODInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
212 if (aodIH->GetMergeEvents()) merging = kTRUE;
215 // Check if AOD replication has been required
217 fOutputAOD = handler->GetAOD();
218 fTreeA = handler->GetTree();
219 if (fOutputAOD && !(handler->IsStandard())) {
220 if ((handler->NeedsHeaderReplication() || merging) && !(fgAODHeader))
222 if (fDebug > 1) AliInfo("Replicating header");
223 fgAODHeader = new AliAODHeader;
224 handler->AddBranch("AliAODHeader", &fgAODHeader);
226 if ((handler->NeedsTracksBranchReplication() || merging) && !(fgAODTracks))
228 if (fDebug > 1) AliInfo("Replicating track branch\n");
229 fgAODTracks = new TClonesArray("AliAODTrack",500);
230 fgAODTracks->SetName("tracks");
231 handler->AddBranch("TClonesArray", &fgAODTracks);
233 if ((handler->NeedsVerticesBranchReplication() || merging) && !(fgAODVertices))
235 if (fDebug > 1) AliInfo("Replicating vertices branch\n");
236 fgAODVertices = new TClonesArray("AliAODVertex",500);
237 fgAODVertices->SetName("vertices");
238 handler->AddBranch("TClonesArray", &fgAODVertices);
240 if ((handler->NeedsV0sBranchReplication()) && !(fgAODV0s))
242 if (fDebug > 1) AliInfo("Replicating V0s branch\n");
243 fgAODV0s = new TClonesArray("AliAODv0",500);
244 fgAODV0s->SetName("v0s");
245 handler->AddBranch("TClonesArray", &fgAODV0s);
247 if ((handler->NeedsTrackletsBranchReplication()) && !(fgAODTracklets))
249 if (fDebug > 1) AliInfo("Replicating Tracklets branch\n");
250 fgAODTracklets = new AliAODTracklets("tracklets","tracklets");
251 handler->AddBranch("AliAODTracklets", &fgAODTracklets);
253 if ((handler->NeedsPMDClustersBranchReplication()) && !(fgAODPMDClusters))
255 if (fDebug > 1) AliInfo("Replicating PMDClusters branch\n");
256 fgAODPMDClusters = new TClonesArray("AliAODPmdCluster",500);
257 fgAODPMDClusters->SetName("pmdClusters");
258 handler->AddBranch("TClonesArray", &fgAODPMDClusters);
260 if ((handler->NeedsJetsBranchReplication() || merging) && !(fgAODJets))
262 if (fDebug > 1) AliInfo("Replicating Jets branch\n");
263 fgAODJets = new TClonesArray("AliAODJet",500);
264 fgAODJets->SetName("jets");
265 handler->AddBranch("TClonesArray", &fgAODJets);
267 if ((handler->NeedsFMDClustersBranchReplication()) && !(fgAODFMDClusters))
269 AliInfo("Replicating FMDClusters branch\n");
270 fgAODFMDClusters = new TClonesArray("AliAODFmdCluster",500);
271 fgAODFMDClusters->SetName("fmdClusters");
272 handler->AddBranch("TClonesArray", &fgAODFMDClusters);
274 if ((handler->NeedsCaloClustersBranchReplication() || merging) && !(fgAODCaloClusters))
276 if (fDebug > 1) AliInfo("Replicating CaloClusters branch\n");
277 fgAODCaloClusters = new TClonesArray("AliAODCaloCluster",500);
278 fgAODCaloClusters->SetName("caloClusters");
279 handler->AddBranch("TClonesArray", &fgAODCaloClusters);
281 fgAODEmcalCells = new AliAODCaloCells("emcalCells","emcalCells",AliVCaloCells::kEMCALCell);
282 handler->AddBranch("AliAODCaloCells", &fgAODEmcalCells);
284 fgAODPhosCells = new AliAODCaloCells("phosCells","phosCells",AliVCaloCells::kPHOSCell);
285 handler->AddBranch("AliAODCaloCells", &fgAODPhosCells);
288 if ((handler->NeedsMCParticlesBranchReplication() || merging) && !(fgAODMCParticles))
290 if (fDebug > 1) AliInfo("Replicating MCParticles branch\n");
291 fgAODMCParticles = new TClonesArray("AliAODMCParticle",500);
292 fgAODMCParticles->SetName("mcparticles");
293 handler->AddBranch("TClonesArray", &fgAODMCParticles);
295 if ((handler->NeedsDimuonsBranchReplication() || merging) && !(fgAODDimuons))
297 if (fDebug > 1) AliInfo("Replicating dimuon branch\n");
298 fgAODDimuons = new TClonesArray("AliAODDimuon",0);
299 fgAODDimuons->SetName("dimuons");
300 handler->AddBranch("TClonesArray", &fgAODDimuons);
303 // cache the pointerd in the AODEvent
304 fOutputAOD->GetStdContent();
307 ConnectMultiHandler();
308 UserCreateOutputObjects();
309 DisconnectMultiHandler();
312 void AliAnalysisTaskSE::Exec(Option_t* option)
315 // Exec analysis of one event
317 ConnectMultiHandler();
320 printf("Task is active %5d\n", IsActive());
322 if (fDebug > 1) AliInfo("AliAnalysisTaskSE::Exec() \n");
324 AliAODHandler* handler = dynamic_cast<AliAODHandler*>
325 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
327 AliAODInputHandler* aodH = dynamic_cast<AliAODInputHandler*>(fInputHandler);
329 // Was event selected ? If no event selection mechanism, the event SHOULD be selected (AG)
330 UInt_t isSelected = AliVEvent::kAny;
331 if( fInputHandler && fInputHandler->GetEventSelection()) {
332 // Get the actual offline trigger mask for the event and AND it with the
333 // requested mask. If no mask requested select by default the event.
334 if (fOfflineTriggerMask)
335 isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();
337 // Functionality below moved in the filter tasks (AG)
338 // if (handler) handler->SetFillAOD(isSelected);
340 if( fInputHandler ) {
341 fEntry = fInputHandler->GetReadEntry();
342 fESDfriend = ((AliESDInputHandler*)fInputHandler)->GetESDfriend();
346 // Notify the change of run number
347 if (InputEvent() && (InputEvent()->GetRunNumber() != fCurrentRunNumber)) {
348 fCurrentRunNumber = InputEvent()->GetRunNumber();
353 fEntry = fMCEvent->Header()->GetEvent();
354 if ( !((Entry()-1)%100) && fDebug > 0)
355 AliInfo(Form("%s ----> Processing event # %lld", CurrentFileName(), Entry()));
360 if (handler && aodH) {
361 fMCEvent = aodH->MCEvent();
362 Bool_t merging = aodH->GetMergeEvents();
364 // Do not analyze merged events if last embedded file has less events than normal event,
365 // skip analysis after last embeded event
367 if(aodH->GetReadEntry() + aodH->GetMergeOffset() >= aodH->GetTreeToMerge()->GetEntriesFast()){
368 //printf("Skip Entry %lld, Offset %d, Tree Entries %d\n",aodH->GetReadEntry(),aodH->GetMergeOffset(), aodH->GetTreeToMerge()->GetEntries());
370 // Do I need to add the lines before the return?
371 // Added protection in case the derived task is not an AOD producer.
372 AliAnalysisDataSlot *out0 = GetOutputSlot(0);
373 if (out0 && out0->IsConnected()) PostData(0, fTreeA);
375 DisconnectMultiHandler();
379 //else printf("MERGE Entry %lld, Offset %d, Tree Entries %d\n",aodH->GetReadEntry(),aodH->GetMergeOffset(), aodH->GetTreeToMerge()->GetEntries());
382 AliAODEvent* aod = dynamic_cast<AliAODEvent*>(InputEvent());
384 if (aod && !(handler->IsStandard()) && !(handler->AODIsReplicated())) {
385 if ((handler->NeedsHeaderReplication() || merging) && (fgAODHeader))
387 // copy the contents by assigment
388 *fgAODHeader = *(aod->GetHeader());
390 if ((handler->NeedsTracksBranchReplication() || (merging && aodH->GetMergeTracks())) && (fgAODTracks))
392 TClonesArray* tracks = aod->GetTracks();
393 new (fgAODTracks) TClonesArray(*tracks);
395 if ((handler->NeedsVerticesBranchReplication() || merging) && (fgAODVertices))
397 TClonesArray* vertices = aod->GetVertices();
398 new (fgAODVertices) TClonesArray(*vertices);
400 if ((handler->NeedsV0sBranchReplication()) && (fgAODV0s))
402 TClonesArray* v0s = aod->GetV0s();
403 new (fgAODV0s) TClonesArray(*v0s);
405 if ((handler->NeedsTrackletsBranchReplication()) && (fgAODTracklets))
407 *fgAODTracklets = *aod->GetTracklets();
409 if ((handler->NeedsPMDClustersBranchReplication()) && (fgAODPMDClusters))
411 TClonesArray* pmdClusters = aod->GetPmdClusters();
412 new (fgAODPMDClusters) TClonesArray(*pmdClusters);
414 if ((handler->NeedsJetsBranchReplication() || (merging &&aodH->GetMergeTracks())) && (fgAODJets))
416 TClonesArray* jets = aod->GetJets();
417 new (fgAODJets) TClonesArray(*jets);
419 if ((handler->NeedsFMDClustersBranchReplication()) && (fgAODFMDClusters))
421 TClonesArray* fmdClusters = aod->GetFmdClusters();
422 new (fgAODFMDClusters) TClonesArray(*fmdClusters);
424 if ((handler->NeedsCaloClustersBranchReplication() ||
425 (merging && (aodH->GetMergeEMCALClusters() || aodH->GetMergePHOSClusters())))
426 && (fgAODCaloClusters))
428 TClonesArray* caloClusters = aod->GetCaloClusters();
429 new (fgAODCaloClusters) TClonesArray(*caloClusters);
432 if ((handler->NeedsMCParticlesBranchReplication() || merging) && (fgAODMCParticles))
434 TClonesArray* mcParticles = (TClonesArray*) (aod->FindListObject("mcparticles"));
436 new (fgAODMCParticles) TClonesArray(*mcParticles);
439 if ((handler->NeedsDimuonsBranchReplication() || (merging && aodH->GetMergeTracks())) && (fgAODDimuons))
441 fgAODDimuons->Clear();
442 TClonesArray& dimuons = *fgAODDimuons;
443 TClonesArray& tracksnew = *fgAODTracks;
445 Int_t nMuonTrack[100];
446 for(Int_t imuon = 0; imuon < 100; imuon++) nMuonTrack[imuon] = 0;
448 for(Int_t ii=0; ii < fgAODTracks->GetEntries(); ii++){
449 AliAODTrack *track = (AliAODTrack*) fgAODTracks->At(ii);
450 if(track->IsMuonTrack()) {
451 nMuonTrack[nMuons]= ii;
457 for(Int_t i = 0; i < nMuons; i++){
458 Int_t index0 = nMuonTrack[i];
459 for(Int_t j = i+1; j < nMuons; j++){
460 Int_t index1 = nMuonTrack[j];
461 tracksnew.At(index0)->ResetBit(kIsReferenced);
462 tracksnew.At(index0)->SetUniqueID(0);
463 tracksnew.At(index1)->ResetBit(kIsReferenced);
464 tracksnew.At(index1)->SetUniqueID(0);
465 new(dimuons[jDimuons++]) AliAODDimuon(tracksnew.At(index0),tracksnew.At(index1));
470 // Additional merging if needed
475 TClonesArray* mcparticles = (TClonesArray*) ((aodH->GetEventToMerge())->FindListObject("mcparticles"));
477 Int_t npart = mcparticles->GetEntries();
478 nc = fgAODMCParticles->GetEntries();
480 for (Int_t i = 0; i < npart; i++) {
481 AliAODMCParticle* particle = (AliAODMCParticle*) mcparticles->At(i);
482 new((*fgAODMCParticles)[nc++]) AliAODMCParticle(*particle);
487 TClonesArray* tracks = aodH->GetEventToMerge()->GetTracks();
488 if(tracks && aodH->GetMergeTracks()){
489 Int_t ntr = tracks->GetEntries();
490 nc = fgAODTracks->GetEntries();
491 for (Int_t i = 0; i < ntr; i++) {
492 AliAODTrack* track = (AliAODTrack*) tracks->At(i);
493 AliAODTrack* newtrack = new((*fgAODTracks)[nc++]) AliAODTrack(*track);
494 newtrack->SetLabel(newtrack->GetLabel() + fgAODMCParticles->GetEntries());
497 for (Int_t i = 0; i < nc; i++)
499 AliAODTrack* track = (AliAODTrack*) fgAODTracks->At(i);
500 track->ResetBit(kIsReferenced);
501 track->SetUniqueID(0);
506 TClonesArray* clusters = aodH->GetEventToMerge()->GetCaloClusters();
507 if( clusters && (aodH->GetMergeEMCALClusters() || aodH->GetMergePHOSClusters())) {
508 Int_t ncl = clusters->GetEntries();
509 nc = fgAODCaloClusters->GetEntries();
510 for (Int_t i = 0; i < ncl; i++) {
511 AliAODCaloCluster* cluster = (AliAODCaloCluster*) clusters->At(i);
512 if(cluster->IsEMCAL() && !aodH->GetMergeEMCALClusters() ) continue;
513 if(cluster->IsPHOS() && !aodH->GetMergePHOSClusters() ) continue;
514 new((*fgAODCaloClusters)[nc++]) AliAODCaloCluster(*cluster);
519 //*fgAODEmcalCells = *(aod->GetEMCALCells()); // This will be valid after 10.Mar.2011.
520 if(aodH->GetMergeEMCALCells()) {
521 AliAODCaloCells* copycells = aod->GetEMCALCells();
522 fgAODEmcalCells->CreateContainer(copycells->GetNumberOfCells());
523 nc = copycells->GetNumberOfCells();
524 while( nc-- ){ fgAODEmcalCells->SetCell(nc,copycells->GetCellNumber(nc),copycells->GetAmplitude(nc)); }
526 AliAODCaloCells* cellsA = aodH->GetEventToMerge()->GetEMCALCells();
528 Int_t ncells = cellsA->GetNumberOfCells();
529 nc = fgAODEmcalCells->GetNumberOfCells();
530 for (Int_t i = 0; i < ncells; i++) {
531 Int_t cn = cellsA->GetCellNumber(i);
532 Int_t pos = fgAODEmcalCells->GetCellPosition(cn);
534 Double_t amp = cellsA->GetAmplitude(i) + fgAODEmcalCells->GetAmplitude(pos);
535 fgAODEmcalCells->SetCell(pos, cn, amp);
537 AliAODCaloCells* copycells1 = new AliAODCaloCells(*fgAODEmcalCells);
538 fgAODEmcalCells->CreateContainer(nc+1);
539 Int_t nn = copycells1->GetNumberOfCells();
540 while( nn-- ){ fgAODEmcalCells->SetCell(nn,copycells1->GetCellNumber(nn),copycells1->GetAmplitude(nn)); }
541 fgAODEmcalCells->SetCell(nc++,cn,cellsA->GetAmplitude(i));
545 fgAODEmcalCells->Sort();
547 } // merge emcal cells
551 //*fgAODPhosCells = *(aod->GetPHOSCells()); // This will be valid after 10.Mar.2011.
552 if(aodH->GetMergePHOSCells()) {
553 AliAODCaloCells* copycells = aod->GetPHOSCells();
554 fgAODPhosCells->CreateContainer(copycells->GetNumberOfCells());
555 nc = copycells->GetNumberOfCells();
556 while( nc-- ){ fgAODPhosCells->SetCell(nc,copycells->GetCellNumber(nc),copycells->GetAmplitude(nc)); }
557 AliAODCaloCells* cellsP = aodH->GetEventToMerge()->GetPHOSCells();
559 Int_t ncellsP = cellsP->GetNumberOfCells();
560 nc = fgAODPhosCells->GetNumberOfCells();
562 for (Int_t i = 0; i < ncellsP; i++) {
563 Int_t cn = cellsP->GetCellNumber(i);
564 Int_t pos = fgAODPhosCells->GetCellPosition(cn);
566 Double_t amp = cellsP->GetAmplitude(i) + fgAODPhosCells->GetAmplitude(pos);
567 fgAODPhosCells->SetCell(pos, cn, amp);
569 AliAODCaloCells* copycells1 = new AliAODCaloCells(*fgAODPhosCells);
570 fgAODPhosCells->CreateContainer(nc+1);
571 Int_t nn = copycells1->GetNumberOfCells();
572 while( nn-- ){ fgAODPhosCells->SetCell(nn,copycells1->GetCellNumber(nn),copycells1->GetAmplitude(nn)); }
573 fgAODPhosCells->SetCell(nc++,cn,cellsP->GetAmplitude(i));
577 fgAODPhosCells->Sort();
579 } // Merge PHOS Cells
583 handler->SetAODIsReplicated();
588 // Call the user analysis
589 if (!fMCEventHandler) {
593 if (isSelected && (fMCEventHandler->InitOk()))
597 // Added protection in case the derived task is not an AOD producer.
598 AliAnalysisDataSlot *out0 = GetOutputSlot(0);
599 if (out0 && out0->IsConnected()) PostData(0, fTreeA);
601 DisconnectMultiHandler();
604 const char* AliAnalysisTaskSE::CurrentFileName()
606 // Returns the current file name
608 return fInputHandler->GetTree()->GetCurrentFile()->GetName();
610 return ((AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()))->TreeK()->GetCurrentFile()->GetName();
614 void AliAnalysisTaskSE::AddAODBranch(const char* cname, void* addobj, const char *fname)
616 // Add a new branch to the aod tree
617 AliAODHandler* handler = dynamic_cast<AliAODHandler*>
618 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
620 handler->AddBranch(cname, addobj, fname);
624 Bool_t AliAnalysisTaskSE::IsStandardAOD() const
626 // Check if the output AOD handler is configured for standard or delta AOD.
627 // Users should first check that AODEvent() returns non-null.
628 AliAODHandler* handler = dynamic_cast<AliAODHandler*>
629 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
631 Error("IsStandardAOD", "No AOD handler. Please use AODEvent() to check this first");
634 return handler->IsStandard();
637 Bool_t AliAnalysisTaskSE::Notify()
639 return (UserNotify());
642 const AliEventTag *AliAnalysisTaskSE::EventTag() const
644 // Returns tag for the current event, if any. The return value should always be checked by the user.
645 if (!fInputHandler) {
646 Error("EventTag", "Input handler not yet available. Call this in UserExec");
649 return fInputHandler->GetEventTag();
652 void AliAnalysisTaskSE::LoadBranches() const
654 // Load all branches declared in fBranchNames data member of the parent class.
655 // Should be called in UserExec.
656 if (!fInputHandler) {
657 Error("LoadBranches", "Input handler not available yet. Call this in UserExec");
660 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
661 if (mgr->GetAutoBranchLoading()) return;
662 TString taskbranches;
663 GetBranches(fInputHandler->GetDataType(), taskbranches);
664 if (taskbranches.IsNull()) return;
665 TObjArray *arr = taskbranches.Tokenize(",");
668 while ((obj=next())) mgr->LoadBranch(obj->GetName());
672 //_________________________________________________________________________________________________
673 void AliAnalysisTaskSE::ConnectMultiHandler()
676 // Connect MultiHandler
678 fInputHandler = (AliInputEventHandler *)((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
679 fMultiInputHandler = dynamic_cast<AliMultiInputEventHandler *>(fInputHandler);
680 if (fMultiInputHandler) {
681 fInputHandler = dynamic_cast<AliInputEventHandler *>(fMultiInputHandler->GetFirstInputEventHandler());
682 fMCEventHandler = dynamic_cast<AliMCEventHandler *>(fMultiInputHandler->GetFirstMCEventHandler());
684 fMCEventHandler = dynamic_cast<AliMCEventHandler *>((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
686 if (fMCEventHandler) fMCEvent = fMCEventHandler->MCEvent();
689 //_________________________________________________________________________________________________
690 void AliAnalysisTaskSE::DisconnectMultiHandler()
693 // Disconnect MultiHandler
695 if (fMultiInputHandler) fInputHandler = fMultiInputHandler;