]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGPP/TRD/info/AliTRDtrendValue.cxx
do not keep digits with null energy, speed up in case of 2 maxima clusters with...
[u/mrichter/AliRoot.git] / PWGPP / TRD / info / AliTRDtrendValue.cxx
CommitLineData
61f6b45e 1////////////////////////////////////////////////////////////////////////////
2// //
3// Trend Value Incapsulation //
4// //
5// Authors: //
6// Alexandru Bercuci <A.Bercuci@gsi.de> //
7// //
8////////////////////////////////////////////////////////////////////////////
9
3240bb4a 10#include "TString.h"
11#include "TObjString.h"
12#include "TObjArray.h"
13
14#include "AliLog.h"
15#include "AliTRDtrendValue.h"
16
17ClassImp(AliTRDtrendValue)
18
19
20//____________________________________________
21AliTRDtrendValue::AliTRDtrendValue()
22 : TNamed("none", "none")
23 ,fAlarmLevel(0)
24 ,fValue(0.)
25 ,fResponsible()
26 ,fNnotifiable(0)
27{
61f6b45e 28// Constructor. Reset all fields.
3240bb4a 29 memset(fLimits, 0, 2*(kNlevels+1)*sizeof(Double_t));
7fe4e88b 30 for(Int_t ilevel(kNlevels); ilevel--; ) snprintf(fAlarmMessage[ilevel], 1024, " ");
3240bb4a 31}
32
33//____________________________________________
34AliTRDtrendValue::AliTRDtrendValue(Char_t *n, Char_t *t)
35 : TNamed("none", t)
36 ,fAlarmLevel(0)
37 ,fValue(0.)
38 ,fResponsible()
39 ,fNnotifiable(0)
40{
61f6b45e 41// Constructor. Define name and title for trend variable.
3240bb4a 42 TString s(n);
43 TObjArray *names(s.Tokenize("_"));
44 if(names->GetEntriesFast()!=2){
45 AliError(Form("Wrong trend value name format. Trend value name should be of the form \"trendClass_trendValue\" with only one \"_\" character."));
46 } else SetName(n);
47
48 memset(fLimits, 0, 2*(kNlevels+1)*sizeof(Double_t));
7fe4e88b 49 for(Int_t ilevel(kNlevels); ilevel--; ) snprintf(fAlarmMessage[ilevel], 1024, " ");
3240bb4a 50}
51
52//____________________________________________
53Int_t AliTRDtrendValue::GetAlarmLevel()
54{
55 // check value against limits and do some more work
56 fAlarmLevel=kNlevels-1;
57 for(Int_t ilevel(0); ilevel<kNlevels+1; ilevel++)
58 if(fValue<fLimits[2*ilevel+1] &&
59 fValue>=fLimits[2*ilevel]){
60 fAlarmLevel = ilevel;
61 break;
62 }
63
64 return fAlarmLevel;
65}
66
67//____________________________________________
68const char* AliTRDtrendValue::GetAlarmMessage() const
69{
61f6b45e 70// Check if value triggered alarm
3240bb4a 71 if(!fAlarmLevel) return "OK";
72 else return fAlarmMessage[fAlarmLevel-1];
73}
74
75//____________________________________________
76const char* AliTRDtrendValue::GetClassName() const
77{
61f6b45e 78// Check task to which value belong
3240bb4a 79 TString s(TNamed::GetName());
80 TObjArray *names(s.Tokenize("_"));
81 if(names->GetEntriesFast()!=2){
82 AliError(Form("Wrong trend value name format."));
83 return NULL;
84 }
85
86 return ((TObjString*)names->At(0))->String().Data();
87}
88
89//____________________________________________
90const char* AliTRDtrendValue::GetValueName() const
91{
61f6b45e 92// value name
3240bb4a 93 TString s(TNamed::GetName());
94 TObjArray *names(s.Tokenize("_"));
95 if(names->GetEntriesFast()!=2){
96 AliError(Form("Wrong trend value name format."));
97 return NULL;
98 }
99 return ((TObjString*)names->At(1))->String().Data();
100}
101
102//____________________________________________
103const char* AliTRDtrendValue::GetResponsible(Char_t *n, Char_t *mail) const
104{
61f6b45e 105// Get responsible with name and mail
7fe4e88b 106 if(n) snprintf(n, 100, "%s", fResponsible.fNameR);
107 if(mail) snprintf(mail, 200, "%s", fResponsible.fMail);
61f6b45e 108 return Form("%s <%s>", fResponsible.fNameR, fResponsible.fMail);
3240bb4a 109}
110
111//____________________________________________
112const char* AliTRDtrendValue::GetNotifiable(Int_t in, Char_t *n, Char_t *mail) const
113{
61f6b45e 114// Get noticible person "in" with name and mail
3240bb4a 115 if(in<0||in>=fNnotifiable) return NULL;
7fe4e88b 116 if(n) snprintf(n, 100, "%s", fNotifiable[in].fNameR);
117 if(mail) snprintf(mail, 200, "%s", fNotifiable[in].fMail);
61f6b45e 118 return Form("%s <%s>", fNotifiable[in].fNameR, fNotifiable[in].fMail);
3240bb4a 119}
120
121//____________________________________________
122void AliTRDtrendValue::SetNotifiable(const Char_t *name, const Char_t *mail)
123{
61f6b45e 124// add noticible person to DB
3240bb4a 125 if(fNnotifiable==kNnotifiable){
126 AliWarning(Form("Could not add %s for notification. Only %d persons can be registered for notification.", name, kNnotifiable));
127 return;
128 }
7fe4e88b 129 snprintf(fNotifiable[fNnotifiable].fNameR, 100, "%s", name);
130 snprintf(fNotifiable[fNnotifiable].fMail, 200, "%s", mail);
3240bb4a 131 fNnotifiable++;
132}
133
134//____________________________________________
135void AliTRDtrendValue::SetResponsible(const Char_t *name, const Char_t *mail)
136{
61f6b45e 137// set responsible person for trend
7fe4e88b 138 snprintf(fResponsible.fNameR, 100, "%s", name);
139 snprintf(fResponsible.fMail, 200, "%s", mail);
3240bb4a 140}
141
142//____________________________________________
143void AliTRDtrendValue::Print(Option_t */*o*/) const
144{
145// name - title
146// value - limits
147// alarm level, message
148// responsible
149
150 printf(" %s [%s] - %s\n", GetValueName(), GetClassName(), GetTitle());
151 printf("*** %f limits[%f %f]\n", fValue, fLimits[0], fLimits[1]);
152 if(fAlarmLevel){
153 printf("*** Alarm level : %d limits[%f %f]\n", fAlarmLevel, fLimits[2*fAlarmLevel], fLimits[2*fAlarmLevel+1]);
154 printf("*** Alarm message : %s\n", GetAlarmMessage());
155 }
61f6b45e 156 printf("*** Responsible %s <%s>\n", fResponsible.fNameR, fResponsible.fMail);
3240bb4a 157 if(fNnotifiable){
158 printf("*** Notifiable person(s) ***\n");
159 for(Int_t i(0); i<fNnotifiable; i++)
61f6b45e 160 printf(" %s <%s>\n", fNotifiable[i].fNameR, fNotifiable[i].fMail);
3240bb4a 161 }
162}
163
164//____________________________________________
165AliTRDtrendValue::AliTRDtrendValueResponsible::AliTRDtrendValueResponsible(Char_t *n, Char_t *m)
166{
61f6b45e 167// define person with mail and mail
7fe4e88b 168 if(n) snprintf(fNameR, 100, "%s", n); else snprintf(fNameR, 100, " ");
169 if(m) snprintf(fMail, 200, "%s", m); else snprintf(fMail, 200, " ");
3240bb4a 170}