Add a draw class for the CORRFW (produces a warning, will be fixed
[u/mrichter/AliRoot.git] / PWG3 / dielectron / AliAnalysisTaskDielectronFilter.cxx
1 /*************************************************************************
2 * Copyright(c) 1998-2009, 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 ///////////////////////////////////////////////////////////////////////////
17 //                                                                       //
18 //                        Basic Analysis Task                            //
19 //                                                                       //
20 ///////////////////////////////////////////////////////////////////////////
21
22 #include <TChain.h>
23
24 #include <AliLog.h>
25 #include <AliAODHandler.h>
26 #include <AliAnalysisManager.h>
27 #include <AliVEvent.h>
28
29 #include "AliDielectron.h"
30 #include "AliDielectronHistos.h"
31 #include "AliAnalysisTaskDielectronFilter.h"
32
33 ClassImp(AliAnalysisTaskDielectronFilter)
34
35 //_________________________________________________________________________________
36 AliAnalysisTaskDielectronFilter::AliAnalysisTaskDielectronFilter() :
37   AliAnalysisTaskSE(),
38   fDielectron(0)
39 {
40   //
41   // Constructor
42   //
43 }
44
45 //_________________________________________________________________________________
46 AliAnalysisTaskDielectronFilter::AliAnalysisTaskDielectronFilter(const char *name) :
47   AliAnalysisTaskSE(name),
48   fDielectron(0)
49 {
50   //
51   // Constructor
52   //
53   DefineInput(0,TChain::Class());
54   DefineOutput(1, THashList::Class());
55 }
56
57 //_________________________________________________________________________________
58 void AliAnalysisTaskDielectronFilter::Init()
59 {
60   // Initialization
61   if (fDebug > 1) AliInfo("Init() \n");
62   
63 // require AOD handler
64   AliAODHandler *aodH = (AliAODHandler*)((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
65   if (!aodH) Fatal("Init", "No AOD handler. Halting.");
66   
67 //require dielectron framework 
68   if (!fDielectron) {
69     Error("Init","Dielectron framework class required. Please create and instance with proper cuts and set it via 'SetDielectron' before executing this task!!!");
70     return;
71   }
72   
73   aodH->AddFilteredAOD("AliAOD.Dielectron.root", "DielectronEvents");
74 //   AddAODBranch("AliDielectronCandidates",fDielectron->GetPairArraysPointer(),"deltaAOD.Dielectron.root");
75 }
76
77 //_________________________________________________________________________________
78 void AliAnalysisTaskDielectronFilter::UserExec(Option_t *)
79 {
80   //
81   // Main loop. Called for every event
82   //
83
84   if (!fDielectron) return;
85   
86   //bz for AliKF
87   Double_t bz = InputEvent()->GetMagneticField();
88   AliKFParticle::SetField( bz );
89   
90   fDielectron->Process(InputEvent());
91
92   if(fDielectron->HasCandidates()){
93     AliAODExtension *extDielectron = dynamic_cast<AliAODHandler*>
94       ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler())->GetFilteredAOD("AliAOD.Dielectron.root");
95     extDielectron->SelectEvent();
96     //see if dielectron candidate branch exists, if not create is
97     TTree *t=extDielectron->GetTree();
98     if (!t->GetBranch("dielectrons")){
99       t->Bronch("dielectrons","TObjArray",fDielectron->GetPairArraysPointer());
100     }
101   }
102   
103   PostData(1, const_cast<THashList*>(fDielectron->GetHistogramList()));
104 }
105