]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/AliAnalysisTaskSE.cxx
AliMultiInputEventHandler added and used in AliAnalysisTaskSE
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskSE.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Id$ */
17  
18 #include <TROOT.h>
19 #include <TSystem.h>
20 #include <TInterpreter.h>
21 #include <TChain.h>
22 #include <TFile.h>
23 #include <TList.h>
24
25 #include "AliAnalysisTaskSE.h"
26 #include "AliAnalysisManager.h"
27 #include "AliAnalysisCuts.h"
28 #include "AliAnalysisDataSlot.h"
29
30 #include "AliESDEvent.h"
31 #include "AliESDfriend.h"
32 #include "AliESD.h"
33 #include "AliAODEvent.h"
34 #include "AliAODHeader.h"
35 #include "AliAODTracklets.h"
36 #include "AliAODCaloCells.h"
37 #include "AliAODMCParticle.h"
38 #include "AliVEvent.h"
39 #include "AliAODHandler.h"
40 #include "AliAODInputHandler.h"
41 #include "AliMCEventHandler.h"
42 #include "AliInputEventHandler.h"
43 #include "AliMultiInputEventHandler.h"
44 #include "AliESDInputHandler.h"
45 #include "AliMCEvent.h"
46 #include "AliStack.h"
47 #include "AliLog.h"
48 #include "AliAODDimuon.h"
49
50
51 ClassImp(AliAnalysisTaskSE)
52
53 ////////////////////////////////////////////////////////////////////////
54 AliAODHeader*    AliAnalysisTaskSE::fgAODHeader         = NULL;
55 TClonesArray*    AliAnalysisTaskSE::fgAODTracks         = NULL;
56 TClonesArray*    AliAnalysisTaskSE::fgAODVertices       = NULL;
57 TClonesArray*    AliAnalysisTaskSE::fgAODV0s            = NULL;
58 TClonesArray*    AliAnalysisTaskSE::fgAODPMDClusters    = NULL;
59 TClonesArray*    AliAnalysisTaskSE::fgAODJets           = NULL;
60 TClonesArray*    AliAnalysisTaskSE::fgAODFMDClusters    = NULL;
61 TClonesArray*    AliAnalysisTaskSE::fgAODCaloClusters   = NULL;
62 TClonesArray*    AliAnalysisTaskSE::fgAODMCParticles    = NULL;
63 AliAODTracklets* AliAnalysisTaskSE::fgAODTracklets      = NULL;
64 AliAODCaloCells* AliAnalysisTaskSE::fgAODEmcalCells     = NULL;
65 AliAODCaloCells* AliAnalysisTaskSE::fgAODPhosCells      = NULL;
66 TClonesArray*    AliAnalysisTaskSE::fgAODDimuons        = NULL;
67
68 AliAnalysisTaskSE::AliAnalysisTaskSE():
69     AliAnalysisTask(),
70     fDebug(0),
71     fEntry(0),
72     fInputEvent(0x0),
73     fESDfriend(0x0),
74     fInputHandler(0x0),
75     fOutputAOD(0x0),
76     fMCEvent(0x0),
77     fTreeA(0x0),
78     fCurrentRunNumber(-1),
79     fHistosQA(0x0),
80     fOfflineTriggerMask(0),
81     fMultiInputHandler(0),
82     fMCEventHandler(0)
83 {
84   // Default constructor
85 }
86
87 AliAnalysisTaskSE::AliAnalysisTaskSE(const char* name):
88     AliAnalysisTask(name, "AnalysisTaskSE"),
89     fDebug(0),
90     fEntry(0),
91     fInputEvent(0x0),
92     fESDfriend(0x0),
93     fInputHandler(0x0),
94     fOutputAOD(0x0),
95     fMCEvent(0x0),
96     fTreeA(0x0),
97     fCurrentRunNumber(-1),
98     fHistosQA(0x0),
99     fOfflineTriggerMask(0),
100     fMultiInputHandler(0),
101     fMCEventHandler(0)
102 {
103   // Default constructor
104     DefineInput (0, TChain::Class());
105     DefineOutput(0,  TTree::Class());
106 }
107
108 AliAnalysisTaskSE::AliAnalysisTaskSE(const AliAnalysisTaskSE& obj):
109     AliAnalysisTask(obj),
110     fDebug(0),
111     fEntry(0),
112     fInputEvent(0x0),
113     fESDfriend(0x0),
114     fInputHandler(0x0),
115     fOutputAOD(0x0),
116     fMCEvent(0x0),
117     fTreeA(0x0),
118     fCurrentRunNumber(-1),
119     fHistosQA(0x0),
120     fOfflineTriggerMask(0),
121     fMultiInputHandler(obj.fMultiInputHandler),
122     fMCEventHandler(obj.fMCEventHandler)
123 {
124 // Copy constructor
125     fDebug            = obj.fDebug;
126     fEntry            = obj.fEntry;
127     fInputEvent       = obj.fInputEvent;
128     fESDfriend        = obj.fESDfriend;
129     fInputHandler     = obj.fInputHandler;
130     fOutputAOD        = obj.fOutputAOD;
131     fMCEvent          = obj.fMCEvent;
132     fTreeA            = obj.fTreeA;    
133     fCurrentRunNumber = obj.fCurrentRunNumber;
134     fHistosQA         = obj.fHistosQA;
135
136 }
137
138
139 AliAnalysisTaskSE& AliAnalysisTaskSE::operator=(const AliAnalysisTaskSE& other)
140 {
141 // Assignment
142     AliAnalysisTask::operator=(other);
143     fDebug            = other.fDebug;
144     fEntry            = other.fEntry;
145     fInputEvent       = other.fInputEvent;
146     fESDfriend        = other.fESDfriend;
147     fInputHandler     = other.fInputHandler;
148     fOutputAOD        = other.fOutputAOD;
149     fMCEvent          = other.fMCEvent;
150     fTreeA            = other.fTreeA;    
151     fCurrentRunNumber = other.fCurrentRunNumber;
152     fHistosQA         = other.fHistosQA;
153     fOfflineTriggerMask = other.fOfflineTriggerMask;
154     fMultiInputHandler  = other.fMultiInputHandler;
155     fMCEventHandler     = other.fMCEventHandler;
156     return *this;
157 }
158
159
160 void AliAnalysisTaskSE::ConnectInputData(Option_t* /*option*/)
161 {
162 // Connect the input data
163     if (fDebug > 1) printf("AnalysisTaskSE::ConnectInputData() \n");
164
165    // Connect input handlers (multi input handler is handled)
166    ConnectMultiHandler();
167
168     if (fInputHandler) {
169         if ((fInputHandler->GetTree())->GetBranch("ESDfriend."))
170             fESDfriend = ((AliESDInputHandler*)fInputHandler)->GetESDfriend();
171
172         fInputEvent = fInputHandler->GetEvent();
173     } else if( fMCEvent ) {
174          AliWarning("No Input Event Handler connected, only MC Truth Event Handler") ; 
175     } else {
176          AliError("No Input Event Handler connected") ; 
177          return ; 
178     }
179     // Disconnect multi handler
180     DisconnectMultiHandler();
181 }
182
183 void AliAnalysisTaskSE::CreateOutputObjects()
184 {
185 // Create the output container
186 //
187 //  Default AOD
188     if (fDebug > 1) printf("AnalysisTaskSE::CreateOutPutData() \n");
189
190     AliAODHandler* handler = dynamic_cast<AliAODHandler*> 
191          ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
192     
193     Bool_t merging = kFALSE;
194     AliAODInputHandler* aodIH = static_cast<AliAODInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
195     if (aodIH) {
196         if (aodIH->GetMergeEvents()) merging = kTRUE;
197     }
198     
199
200     // Check if AOD replication has been required
201     
202     if (handler) {
203         fOutputAOD   = handler->GetAOD();
204         fTreeA = handler->GetTree();
205         if (fOutputAOD && !(handler->IsStandard())) {
206             if ((handler->NeedsHeaderReplication()) && !(fgAODHeader)) 
207                 {
208                  if (fDebug > 1) AliInfo("Replicating header");
209                  fgAODHeader = new AliAODHeader;
210                  handler->AddBranch("AliAODHeader", &fgAODHeader);
211                 }
212             if ((handler->NeedsTracksBranchReplication() || merging) && !(fgAODTracks))      
213             {   
214                 if (fDebug > 1) AliInfo("Replicating track branch\n");
215                 fgAODTracks = new TClonesArray("AliAODTrack",500);
216                 fgAODTracks->SetName("tracks");
217                 handler->AddBranch("TClonesArray", &fgAODTracks);
218             }    
219             if ((handler->NeedsVerticesBranchReplication() || merging) && !(fgAODVertices))
220             {
221                 if (fDebug > 1) AliInfo("Replicating vertices branch\n");
222                 fgAODVertices = new TClonesArray("AliAODVertex",500);
223                 fgAODVertices->SetName("vertices");
224                 handler->AddBranch("TClonesArray", &fgAODVertices);
225             }   
226             if ((handler->NeedsV0sBranchReplication()) && !(fgAODV0s))    
227             {   
228                 if (fDebug > 1) AliInfo("Replicating V0s branch\n");
229                 fgAODV0s = new TClonesArray("AliAODv0",500);
230                 fgAODV0s->SetName("v0s");
231                 handler->AddBranch("TClonesArray", &fgAODV0s);
232             }
233             if ((handler->NeedsTrackletsBranchReplication()) && !(fgAODTracklets))        
234             {   
235                 if (fDebug > 1) AliInfo("Replicating Tracklets branch\n");
236                 fgAODTracklets = new AliAODTracklets("tracklets","tracklets");
237                 handler->AddBranch("AliAODTracklets", &fgAODTracklets);
238             }
239             if ((handler->NeedsPMDClustersBranchReplication()) && !(fgAODPMDClusters))    
240             {   
241                 if (fDebug > 1) AliInfo("Replicating PMDClusters branch\n");
242                 fgAODPMDClusters = new TClonesArray("AliAODPmdCluster",500);
243                 fgAODPMDClusters->SetName("pmdClusters");
244                 handler->AddBranch("TClonesArray", &fgAODPMDClusters);
245             }
246             if ((handler->NeedsJetsBranchReplication() || merging) && !(fgAODJets))       
247             {   
248                 if (fDebug > 1) AliInfo("Replicating Jets branch\n");
249                 fgAODJets = new TClonesArray("AliAODJet",500);
250                 fgAODJets->SetName("jets");
251                 handler->AddBranch("TClonesArray", &fgAODJets);
252             }
253             if ((handler->NeedsFMDClustersBranchReplication()) && !(fgAODFMDClusters))    
254             {   
255                 AliInfo("Replicating FMDClusters branch\n");
256                 fgAODFMDClusters = new TClonesArray("AliAODFmdCluster",500);
257                 fgAODFMDClusters->SetName("fmdClusters");
258                 handler->AddBranch("TClonesArray", &fgAODFMDClusters);
259             }
260             if ((handler->NeedsCaloClustersBranchReplication() || merging) && !(fgAODCaloClusters))       
261             {   
262                 if (fDebug > 1) AliInfo("Replicating CaloClusters branch\n");
263                 fgAODCaloClusters = new TClonesArray("AliAODCaloCluster",500);
264                 fgAODCaloClusters->SetName("caloClusters");
265                 handler->AddBranch("TClonesArray", &fgAODCaloClusters);
266
267                 fgAODEmcalCells = new AliAODCaloCells();
268                 fgAODEmcalCells->SetName("emcalCells");
269                 handler->AddBranch("AliAODCaloCells", &fgAODEmcalCells);
270
271                 fgAODPhosCells = new AliAODCaloCells();
272                 fgAODPhosCells->SetName("phosCells");
273                 handler->AddBranch("AliAODCaloCells", &fgAODPhosCells);
274             }
275             if ((handler->NeedsMCParticlesBranchReplication() || merging) && !(fgAODMCParticles))         
276             {   
277                 if (fDebug > 1) AliInfo("Replicating MCParticles branch\n");
278                 fgAODMCParticles = new TClonesArray("AliAODMCParticle",500);
279                 fgAODMCParticles->SetName("mcparticles");
280                 handler->AddBranch("TClonesArray", &fgAODMCParticles);
281             }
282             if ((handler->NeedsDimuonsBranchReplication() || merging) && !(fgAODDimuons))      
283             {   
284                 if (fDebug > 1) AliInfo("Replicating dimuon branch\n");
285                 fgAODDimuons = new TClonesArray("AliAODDimuon",0);
286                 fgAODDimuons->SetName("dimuons");
287                 handler->AddBranch("TClonesArray", &fgAODDimuons);
288             }    
289
290             // cache the pointerd in the AODEvent
291             fOutputAOD->GetStdContent();
292         }
293     }
294     UserCreateOutputObjects();
295 }
296
297 void AliAnalysisTaskSE::Exec(Option_t* option)
298 {
299 //
300 // Exec analysis of one event
301
302     ConnectMultiHandler();
303
304     if ( fDebug >= 10)
305       printf("Task is active %5d\n", IsActive());
306     
307     if (fDebug > 1) AliInfo("AliAnalysisTaskSE::Exec() \n");
308 //
309     AliAODHandler* handler = dynamic_cast<AliAODHandler*> 
310         ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
311
312     AliAODInputHandler* aodH = dynamic_cast<AliAODInputHandler*>(fInputHandler);
313 //
314 // Was event selected ? If no event selection mechanism, the event SHOULD be selected (AG)
315     UInt_t isSelected = AliVEvent::kAny;
316     if( fInputHandler && fInputHandler->GetEventSelection()) {
317       // Get the actual offline trigger mask for the event and AND it with the
318       // requested mask. If no mask requested select by default the event.
319       if (fOfflineTriggerMask)
320          isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();
321     }
322 //  Functionality below moved in the filter tasks (AG)
323 //    if (handler) handler->SetFillAOD(isSelected);
324
325     if( fInputHandler ) {
326         fEntry = fInputHandler->GetReadEntry();
327         fESDfriend = ((AliESDInputHandler*)fInputHandler)->GetESDfriend();
328     }
329     
330
331 // Notify the change of run number
332     if (InputEvent() && (InputEvent()->GetRunNumber() != fCurrentRunNumber)) {
333         fCurrentRunNumber = InputEvent()->GetRunNumber();
334         NotifyRun();
335     }    
336            
337     else if( fMCEvent )
338        fEntry = fMCEvent->Header()->GetEvent(); 
339     if ( !((Entry()-1)%100) && fDebug > 0) 
340          AliInfo(Form("%s ----> Processing event # %lld", CurrentFileName(), Entry()));
341
342     
343     
344
345     if (handler && aodH) {
346         fMCEvent = aodH->MCEvent();
347         Bool_t merging = aodH->GetMergeEvents();
348         
349         if (!(handler->IsStandard()) && !(handler->AODIsReplicated())) {
350             if ((handler->NeedsHeaderReplication()) && (fgAODHeader))
351             {
352               // copy the contents by assigment
353               *fgAODHeader =  *(dynamic_cast<AliAODHeader*>(InputEvent()->GetHeader()));
354             }
355             if ((handler->NeedsTracksBranchReplication() || merging) && (fgAODTracks))
356             {
357                 TClonesArray* tracks = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetTracks();
358                 new (fgAODTracks) TClonesArray(*tracks);
359             }
360             if ((handler->NeedsVerticesBranchReplication() || merging) && (fgAODVertices))
361             {
362                 TClonesArray* vertices = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetVertices();
363                 new (fgAODVertices) TClonesArray(*vertices);
364             }
365             if ((handler->NeedsV0sBranchReplication()) && (fgAODV0s))
366             {
367                 TClonesArray* v0s = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetV0s();
368                 new (fgAODV0s) TClonesArray(*v0s);
369             }
370             if ((handler->NeedsTrackletsBranchReplication()) && (fgAODTracklets))
371             {
372               *fgAODTracklets = *(dynamic_cast<AliAODEvent*>(InputEvent()))->GetTracklets();
373             }
374             if ((handler->NeedsPMDClustersBranchReplication()) && (fgAODPMDClusters))
375             {
376                 TClonesArray* pmdClusters = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetPmdClusters();
377                 new (fgAODPMDClusters) TClonesArray(*pmdClusters);
378             }
379             if ((handler->NeedsJetsBranchReplication() || merging) && (fgAODJets))
380             {
381                 TClonesArray* jets = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetJets();
382                 new (fgAODJets) TClonesArray(*jets);
383             }
384             if ((handler->NeedsFMDClustersBranchReplication()) && (fgAODFMDClusters))
385             {
386                 TClonesArray* fmdClusters = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetFmdClusters();
387                 new (fgAODFMDClusters) TClonesArray(*fmdClusters);
388             }
389             if ((handler->NeedsCaloClustersBranchReplication() || merging) && (fgAODCaloClusters))
390             {
391                 TClonesArray* caloClusters = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetCaloClusters();
392                 new (fgAODCaloClusters) TClonesArray(*caloClusters);
393             }
394
395             if ((handler->NeedsMCParticlesBranchReplication() || merging) && (fgAODMCParticles))
396             {
397                 TClonesArray* mcParticles = (TClonesArray*) ((dynamic_cast<AliAODEvent*>(InputEvent()))->FindListObject("mcparticles"));
398                 new (fgAODMCParticles) TClonesArray(*mcParticles);
399             }
400             
401             if ((handler->NeedsDimuonsBranchReplication() || merging) && (fgAODDimuons))
402             {
403                 fgAODDimuons->Clear();
404                 TClonesArray& dimuons = *fgAODDimuons;
405                 TClonesArray& tracksnew = *fgAODTracks;
406                 
407                 Int_t nMuonTrack[100]; 
408                 for(Int_t imuon = 0; imuon < 100; imuon++) nMuonTrack[imuon] = 0;
409                 Int_t nMuons=0;
410                 for(Int_t ii=0; ii < fgAODTracks->GetEntries(); ii++){
411                     AliAODTrack *track = (AliAODTrack*) fgAODTracks->At(ii);
412                     if(track->IsMuonTrack()) {
413                         nMuonTrack[nMuons]= ii;
414                         nMuons++;
415                     }  
416                 }
417                 Int_t jDimuons=0;
418                 if(nMuons >= 2){
419                     for(Int_t i = 0; i < nMuons; i++){
420                         Int_t index0 = nMuonTrack[i];
421                         for(Int_t j = i+1; j < nMuons; j++){
422                             Int_t index1 = nMuonTrack[j];
423                             tracksnew.At(index0)->ResetBit(kIsReferenced);
424                             tracksnew.At(index0)->SetUniqueID(0); 
425                             tracksnew.At(index1)->ResetBit(kIsReferenced);
426                             tracksnew.At(index1)->SetUniqueID(0);
427                             new(dimuons[jDimuons++]) AliAODDimuon(tracksnew.At(index0),tracksnew.At(index1));
428                         }
429                     }    
430                 }
431             }
432             
433             // Additional merging if needed
434             if (merging) {
435                 // mcParticles
436                 TClonesArray* mcparticles = (TClonesArray*) ((aodH->GetEventToMerge())->FindListObject("mcparticles"));
437                 Int_t npart = mcparticles->GetEntries();
438                 Int_t nc = fgAODMCParticles->GetEntries();
439                 Int_t nc0 = nc;
440                 
441                 for (Int_t i = 0; i < npart; i++) {
442                     AliAODMCParticle* particle = (AliAODMCParticle*) mcparticles->At(i);
443                     new((*fgAODMCParticles)[nc++]) AliAODMCParticle(*particle);
444                 }
445                 
446                 // tracks
447                 TClonesArray* tracks = aodH->GetEventToMerge()->GetTracks();
448                 Int_t ntr = tracks->GetEntries();
449                 nc  = fgAODTracks->GetEntries();        
450                 for (Int_t i = 0; i < ntr; i++) {
451                     AliAODTrack*    track = (AliAODTrack*) tracks->At(i);
452                     AliAODTrack* newtrack = new((*fgAODTracks)[nc++]) AliAODTrack(*track);
453                     newtrack->SetLabel(newtrack->GetLabel() + nc0);
454                 }
455
456                 for (Int_t i = 0; i < nc; i++) 
457                 {
458                     AliAODTrack* track = (AliAODTrack*) fgAODTracks->At(i);
459                     track->ResetBit(kIsReferenced);
460                     track->SetUniqueID(0);
461                 }
462                 
463                 
464                 // clusters
465                 TClonesArray* clusters = aodH->GetEventToMerge()->GetCaloClusters();
466                 Int_t ncl  = clusters->GetEntries();
467                 nc         =  fgAODCaloClusters->GetEntries();
468                 for (Int_t i = 0; i < ncl; i++) {
469                     AliAODCaloCluster*    cluster = (AliAODCaloCluster*) clusters->At(i);
470                     new((*fgAODCaloClusters)[nc++]) AliAODCaloCluster(*cluster);
471                 }
472                 // cells
473                 AliAODCaloCells* cellsA = aodH->GetEventToMerge()->GetEMCALCells();
474                 Int_t ncells  = cellsA->GetNumberOfCells();
475                 nc = fgAODEmcalCells->GetNumberOfCells();
476                 
477                 for (Int_t i  = 0; i < ncells; i++) {
478                     Int_t cn  = cellsA->GetCellNumber(i);
479                     Int_t pos = fgAODEmcalCells->GetCellPosition(cn);
480                     if (pos >= 0) {
481                         Double_t amp = cellsA->GetAmplitude(i) + fgAODEmcalCells->GetAmplitude(pos);
482                         fgAODEmcalCells->SetCell(pos, cn, amp);
483                     } else {
484                         Double_t amp = cellsA->GetAmplitude(i);
485                         fgAODEmcalCells->SetCell(nc++, cn, amp);
486                         fgAODEmcalCells->Sort();
487                     }
488                 }
489                 
490                 
491             } // merging
492             
493             handler->SetAODIsReplicated();
494         }
495     }
496
497 // Call the user analysis    
498     if (!fMCEventHandler) {
499         if (isSelected) 
500             UserExec(option);
501     } else {
502         if (isSelected && (fMCEventHandler->InitOk())) 
503             UserExec(option);
504     }
505     
506 // Added protection in case the derived task is not an AOD producer.
507     AliAnalysisDataSlot *out0 = GetOutputSlot(0);
508     if (out0 && out0->IsConnected()) PostData(0, fTreeA);    
509     
510     DisconnectMultiHandler();
511 }
512
513 const char* AliAnalysisTaskSE::CurrentFileName()
514 {
515 // Returns the current file name    
516     if( fInputHandler )
517       return fInputHandler->GetTree()->GetCurrentFile()->GetName();
518     else if( fMCEvent )
519       return ((AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()))->TreeK()->GetCurrentFile()->GetName();
520     else return "";
521 }
522
523 void AliAnalysisTaskSE::AddAODBranch(const char* cname, void* addobj, const char *fname)
524 {
525     // Add a new branch to the aod tree
526     AliAODHandler* handler = dynamic_cast<AliAODHandler*> 
527         ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
528     if (handler) {
529         handler->AddBranch(cname, addobj, fname);
530     }
531 }
532
533 Bool_t AliAnalysisTaskSE::IsStandardAOD() const
534 {
535 // Check if the output AOD handler is configured for standard or delta AOD.
536 // Users should first check that AODEvent() returns non-null.
537     AliAODHandler* handler = dynamic_cast<AliAODHandler*> 
538          ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
539     if (!handler) {
540        Error("IsStandardAOD", "No AOD handler. Please use AODEvent() to check this first");
541        return kTRUE;
542     }
543     return handler->IsStandard();   
544 }
545
546 Bool_t AliAnalysisTaskSE::Notify()
547 {
548     return (UserNotify());
549 }
550
551 const AliEventTag *AliAnalysisTaskSE::EventTag() const
552 {
553 // Returns tag for the current event, if any. The return value should always be checked by the user.
554    if (!fInputHandler) {
555       Error("EventTag", "Input handler not yet available. Call this in UserExec");
556       return NULL;
557    }
558    return fInputHandler->GetEventTag();
559 }
560
561 void AliAnalysisTaskSE::LoadBranches() const
562 {
563 // Load all branches declared in fBranchNames data member of the parent class.
564 // Should be called in UserExec.
565   if (!fInputHandler) {
566      Error("LoadBranches", "Input handler not available yet. Call this in UserExec");
567      return;
568   }
569   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
570   if (mgr->GetAutoBranchLoading()) return;
571   TString taskbranches;
572   GetBranches(fInputHandler->GetDataType(), taskbranches);
573   if (taskbranches.IsNull()) return;
574   TObjArray *arr = taskbranches.Tokenize(",");
575   TIter next(arr);
576   TObject *obj;
577   while ((obj=next())) mgr->LoadBranch(obj->GetName());
578 }
579
580
581 //_________________________________________________________________________________________________
582 void AliAnalysisTaskSE::ConnectMultiHandler()
583 {
584    //
585    // Connect MultiHandler
586    //
587    fInputHandler = (AliInputEventHandler *)((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
588    fMultiInputHandler = dynamic_cast<AliMultiInputEventHandler *>(fInputHandler);
589    if (fMultiInputHandler) {
590 //     fMultiInputHandler = (AliMultiInputEventHandler*)fInputHandler;
591       fInputHandler = dynamic_cast<AliInputEventHandler *>(fMultiInputHandler->GetFirstInputEventHandler());
592       fMCEventHandler = dynamic_cast<AliMCEventHandler *>(fMultiInputHandler->GetFirstMCEventHandler());
593    }
594    if (fMCEventHandler) fMCEvent = fMCEventHandler->MCEvent();
595 }
596
597 //_________________________________________________________________________________________________
598 void AliAnalysisTaskSE::DisconnectMultiHandler()
599 {
600    //
601    // Disconnect MultiHandler
602    //
603    if (fMultiInputHandler) fInputHandler = fMultiInputHandler;
604 }