]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerTaskGroup.cxx
Refactoring of the charged particle pt task
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / UserTasks / AliEMCalTriggerTaskGroup.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2014, 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  * Group of analysis components with the same event selection
17  * Analysis components are initialised via the Initialise function, and executed, if
18  * the event is selected, via the function process
19  *
20  *   Author: Markus Fasel
21  */
22 #include <THashList.h>
23 #include <TList.h>
24
25 #include "AliEMCalTriggerTracksAnalysisComponent.h"
26 #include "AliEMCalTriggerEventSelection.h"
27 #include "AliEMCalTriggerTaskGroup.h"
28
29 ClassImp(EMCalTriggerPtAnalysis::AliEMCalTriggerTaskGroup)
30
31 namespace EMCalTriggerPtAnalysis {
32
33 //______________________________________________________________________________
34 AliEMCalTriggerTaskGroup::AliEMCalTriggerTaskGroup() :
35     TNamed(),
36     fAnalysisComponents(NULL),
37     fEventSelection(NULL)
38 {
39   /*
40    * Dummy constructor, not to be used
41    */
42 }
43
44 //______________________________________________________________________________
45 AliEMCalTriggerTaskGroup::AliEMCalTriggerTaskGroup(const char* name) :
46     TNamed(name, ""),
47     fAnalysisComponents(NULL),
48     fEventSelection(NULL)
49 {
50   /*
51    * Main constructor: to be used by the users
52    */
53   fAnalysisComponents = new TObjArray();
54   fAnalysisComponents->SetOwner();
55 }
56
57 //______________________________________________________________________________
58 AliEMCalTriggerTaskGroup::~AliEMCalTriggerTaskGroup() {
59   /*
60    * Destructor
61    */
62   if(fEventSelection) delete fEventSelection;
63   if(fAnalysisComponents) delete fAnalysisComponents;
64 }
65
66 //______________________________________________________________________________
67 TList *AliEMCalTriggerTaskGroup::InitialiseAnalysisComponents() {
68   /*
69    * Initialise all analysis components. Build a global histlist for the full group
70    *
71    * @return: the global histogram list
72    */
73   TIter compIter(fAnalysisComponents);
74   AliEMCalTriggerTracksAnalysisComponent *ana(NULL);
75   // Build a global histogram list
76   TList *histlist = new TList;
77   TObject *htmp(NULL);
78   while((ana = dynamic_cast<AliEMCalTriggerTracksAnalysisComponent *>(compIter()))){
79     ana->CreateHistos();
80     TList *ltmp = ana->GetHistList();
81     TIter hiter(ltmp);
82     while((htmp = hiter())) histlist->Add(htmp);
83   }
84   return histlist;
85 }
86
87 //______________________________________________________________________________
88 void AliEMCalTriggerTaskGroup::Process(const AliEMCalTriggerEventData* const event) {
89   /*
90    * Run analysis of the different groups. Apply event selection if requested;
91    *
92    * @param event: The combined event data
93    */
94   if(fEventSelection && !fEventSelection->IsEventSelected(event)) return;
95   TIter compIter(fAnalysisComponents);
96   AliEMCalTriggerTracksAnalysisComponent *ana(NULL);
97   while((ana = dynamic_cast<AliEMCalTriggerTracksAnalysisComponent *>(compIter())))
98     ana->Process(event);
99 }
100
101 //______________________________________________________________________________
102 void AliEMCalTriggerTaskGroup::AddAnalysisComponent(AliEMCalTriggerTracksAnalysisComponent * const analysis) {
103   /*
104    * Add new analysis component to the task group
105    *
106    * @param analysis: the analysis component to be added
107    */
108   fAnalysisComponents->Add(analysis);
109 }
110
111 } /* namespace EMCalTriggerPtAnalysis */