]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnPairManager.cxx
Class version updated.
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPairManager.cxx
1 //
2 // Class AliRsnPairManager
3 //
4 // A collection of pairs for an analysis.
5 // The function of this collection is just for purposes of well-sorting
6 // the analyzed pairs into upper-level groups, in the case of a wide
7 // analysis containing many resonances at once, or different settings for the same one.
8 //
9 // Each PairMgr will result in a separate list of histograms, which
10 // can be seen as a folder in the output file, whose name is given by this object.
11 //
12 // author: M. Vala (email: martin.vala@cern.ch)
13 //
14
15 #include "AliLog.h"
16
17 #include "AliRsnPairManager.h"
18
19 ClassImp(AliRsnPairManager)
20
21 //_____________________________________________________________________________
22 AliRsnPairManager::AliRsnPairManager(const char*name) :
23   AliRsnVManager(name)
24 {
25 //
26 // Default constructor
27 //
28
29   AliDebug(AliLog::kDebug +2, "<-");
30   AliDebug(AliLog::kDebug +2, "->");
31 }
32
33 //_____________________________________________________________________________
34 //void AliRsnPairManager::Add(AliRsnPair *pair)
35 void AliRsnPairManager::Add(TObject *objPair)
36 {
37 //
38 // Adds a new AliRsnPair to the list owned by this object.
39 //
40
41   AliDebug(AliLog::kDebug+2, "<-");
42   AliRsnPair *pair = dynamic_cast<AliRsnPair*>(objPair);
43
44   if (!pair) {
45     AliWarning(Form("Pair is %p. Skipping ...", pair));
46     return;
47   }
48
49   AliDebug(AliLog::kDebug+1, Form("Adding %s [%d entries] ...", pair->GetPairName().Data(), fArray.GetEntries()));
50   fArray.Add((AliRsnPair*)pair);
51
52   AliDebug(AliLog::kDebug+2, "->");
53 }
54
55 //_____________________________________________________________________________
56 void AliRsnPairManager::Print(Option_t* /*dummy*/) const
57 {
58 //
59 // Overload of TObject::Print() method.
60 // With respect to the other print method, adds a title string.
61 //
62
63   AliDebug(AliLog::kDebug+2,"<-");
64
65   AliInfo(Form("\t\t======== Pair Manager %s ========", GetName()));
66   PrintArray();
67
68   AliDebug(AliLog::kDebug+2,"->");
69 }
70
71 //_____________________________________________________________________________
72 void AliRsnPairManager::PrintArray() const
73 {
74 //
75 // Prints all pairs
76 //
77
78   AliDebug(AliLog::kDebug+2,"<-");
79
80   AliRsnPair *pair = 0;
81   TObjArrayIter next(&fArray);
82   while ((pair = (AliRsnPair*)next())) pair->Print();
83
84   AliDebug(AliLog::kDebug+2,"->");
85 }
86
87 //_____________________________________________________________________________
88 TList* AliRsnPairManager::InitAllPairs()
89 {
90 //
91 // Initialize all pairs, and builds a TList of histograms
92 // which are created by each of them, in order to link it
93 // to the output handler in the AnalysisTasks.
94 //
95
96   AliDebug(AliLog::kDebug+2, "<-");
97
98   TList *list = new TList();
99   list->SetName(GetName());
100   list->SetOwner();
101
102   AliRsnPair *pair = 0;
103   TObjArrayIter next(&fArray);
104
105   Int_t i = 0;
106   while ((pair = (AliRsnPair*)next())) {
107     if (!pair) continue;
108     AliDebug(AliLog::kDebug+1, Form("InitAllPairs of the PairManager(%s) [%d] ...", pair->GetPairName().Data(), i++));
109     list->Add(pair->GenerateHistograms(GetName()));
110   }
111
112   AliDebug(AliLog::kDebug+2, "->");
113   return list;
114 }
115
116 //_____________________________________________________________________________
117 void AliRsnPairManager::ProcessAllPairs
118 (AliRsnPIDIndex *pidIndexes1, AliRsnEvent *ev1, AliRsnPIDIndex *pidIndexes2, AliRsnEvent *ev2)
119 {
120 //
121 // Processes one (single-event analysis) or two (event-mixing) events
122 // to fill histograms in all stored pairs.
123 //
124
125   AliDebug(AliLog::kDebug+2, "<-");
126
127   AliRsnPair *pair = 0;
128   TObjArrayIter next(&fArray);
129
130   Int_t i=0;
131   while ((pair = (AliRsnPair*)next())) {
132     if (!pair) continue;
133     AliDebug(AliLog::kDebug+1, Form("ProcessAllPairs of the PairManager(%s) [%d] ...", pair->GetPairName().Data(), i++));
134     pair->LoopPair(pidIndexes1, ev1, pidIndexes2, ev2);
135   }
136
137   AliDebug(AliLog::kDebug+2, "->");
138 }