]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnMiniMonitor.cxx
Added a temptative task for monitors
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnMiniMonitor.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 ////////////////////////////////////////////////////////////////////////////////
17 //
18 //  This class contains all code which is used to compute any of the values
19 //  which can be of interest within a resonance analysis. Besides the obvious
20 //  invariant mass, it allows to compute other utility values on all possible
21 //  targets, in order to allow a wide spectrum of binning and checks.
22 //  When needed, this object can also define a binning in the variable which
23 //  it is required to compute, which is used for initializing axes of output
24 //  histograms (see AliRsnFunction).
25 //  The value computation requires this object to be passed the object whose
26 //  informations will be used. This object can be of any allowed input type
27 //  (track, pair, event), then this class must inherit from AliRsnTarget.
28 //  Then, when value computation is attempted, a check on target type is done
29 //  and computation is successful only if expected target matches that of the
30 //  passed object.
31 //  In some cases, the value computation can require a support external object,
32 //  which must then be passed to this class. It can be of any type inheriting
33 //  from TObject.
34 //
35 //  authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
36 //           M. Vala (martin.vala@cern.ch)
37 //
38 ////////////////////////////////////////////////////////////////////////////////
39
40 #include "Riostream.h"
41
42 #include "TH1.h"
43 #include "TH2.h"
44 #include "TH3.h"
45
46 #include "AliLog.h"
47 #include "AliPID.h"
48 #include "AliPIDResponse.h"
49
50 #include "AliRsnDaughter.h"
51 #include "AliRsnEvent.h"
52
53 #include "AliRsnMiniMonitor.h"
54
55 ClassImp(AliRsnMiniMonitor)
56
57 //__________________________________________________________________________________________________
58 AliRsnMiniMonitor::AliRsnMiniMonitor() :
59    TNamed(), 
60    fType(kTypes), 
61    fCutID(-1), 
62    fListID(-1), 
63    fList(0x0)
64 {
65 //
66 // Dummy constructor
67 //
68 }
69
70 //__________________________________________________________________________________________________
71 AliRsnMiniMonitor::AliRsnMiniMonitor(const char *name, EType type, Int_t cutID) :
72    TNamed(name, ""), 
73    fType(type), 
74    fCutID(cutID), 
75    fListID(-1), 
76    fList(0x0)
77 {
78 //
79 // Default constructor
80 //
81 }
82    
83 //__________________________________________________________________________________________________
84 AliRsnMiniMonitor::AliRsnMiniMonitor(const AliRsnMiniMonitor& copy) :
85    TNamed(copy), 
86    fType(copy.fType), 
87    fCutID(copy.fCutID), 
88    fListID(copy.fListID), 
89    fList(copy.fList)
90 {
91 //
92 // Copy constructor
93 //
94 }
95    
96 //__________________________________________________________________________________________________
97 AliRsnMiniMonitor& AliRsnMiniMonitor::operator=(const AliRsnMiniMonitor& copy) 
98 {
99 //
100 // Assignment operator
101 //
102    
103    TNamed::operator=(copy); 
104    fType = copy.fType; 
105    fCutID = copy.fCutID; 
106    fListID = copy.fListID; 
107    fList = copy.fList; 
108    
109    return (*this); 
110 }
111
112 //__________________________________________________________________________________________________
113 Bool_t AliRsnMiniMonitor::Init(const char *name, TList *list)
114 {
115 //
116 // Initialize this output histogram and put into the passed list
117 //
118
119    // name
120    TString sname(name);
121    sname += '_';
122    sname += GetName();
123    
124    // check list
125    fList = list;
126    if (!list) {
127       AliError("No list!");
128       return kFALSE;
129    }
130    
131    // reset histogram
132    TH1 *histogram = 0x0;
133
134    switch (fType) {
135       case kdEdxTPCvsP: 
136          sname += "_TPCsignal";
137          histogram = new TH2F(sname.Data(), "", 500, 0.0, 5.0, 1000, 0.0, 1000.0);
138          break;
139       case ktimeTOFvsP:
140          sname += "_TOFsignal";
141          histogram = new TH2F(sname.Data(), "", 500, 0.0, 5.0, 1000, 0.0, 200000.0);
142          break;
143       default:
144          AliError("Wrong enum type");
145          return kFALSE;
146    }
147    
148    // add to list
149    if (histogram && fList) {
150       histogram->Sumw2();
151       fList->Add(histogram);
152       fListID = fList->IndexOf(histogram);
153       AliInfo(Form("Histogram '%s' added to list in slot #%d", histogram->GetName(), fListID));
154       return kTRUE;
155    }
156    
157    return kFALSE;
158 }
159
160 //_____________________________________________________________________________
161 Bool_t AliRsnMiniMonitor::Fill(AliRsnDaughter *track, AliRsnEvent *event)
162 {
163 //
164 // Fill the histogram
165 //
166
167    // retrieve object from list
168    if (!fList) {
169       AliError("List pointer is NULL");
170       return kFALSE;
171    }
172    TObject *obj = fList->At(fListID);
173    if (!obj) {
174       AliError("List object is NULL");
175       return kFALSE;
176    }
177
178    Double_t valueX, valueY;
179    AliVTrack *vtrack = track->Ref2Vtrack();
180    
181    AliPIDResponse *pid = event->GetPIDResponse();
182
183    switch (fType) {
184       case kdEdxTPCvsP: 
185          if (!vtrack) {
186             AliWarning("Required vtrack for this value");
187             return kFALSE;
188          }
189          valueX = vtrack->GetTPCmomentum();
190          valueY = vtrack->GetTPCsignal();
191          ((TH2F*)obj)->Fill(valueX, valueY);
192          return kTRUE;
193       case ktimeTOFvsP:
194          if (!vtrack) {
195             AliWarning("Required vtrack for this value");
196             return kFALSE;
197          }
198          valueX = vtrack->P();
199          //valueY = vtrack->GetTOFsignal();
200          valueY = 1E20;
201          if (pid) valueY = pid->NumberOfSigmasTOF(vtrack, AliPID::kKaon);
202          ((TH2F*)obj)->Fill(valueX, valueY);
203          return kTRUE;
204       default:
205          AliError("Invalid value type");
206          return kFALSE;
207    }
208 }