3 #include "AliCDBRunRange.h"
4 #include "AliCDBManager.h"
5 #include "AliCDBMetaData.h"
6 #include "AliCDBStorage.h"
7 #include "AliTRDcalibDB.h"
8 #include "AliTRDtrendingManager.h"
10 ClassImp(AliTRDtrendingManager)
12 AliTRDtrendingManager* AliTRDtrendingManager::fgInstance=NULL;
13 Bool_t AliTRDtrendingManager::fgTerminated = kFALSE;
15 //____________________________________________
16 AliTRDtrendingManager* AliTRDtrendingManager::Instance()
19 // Singleton implementation
20 // Returns an instance of this class, it is created if neccessary
22 if (fgTerminated != kFALSE) return NULL;
25 fgInstance = new AliTRDtrendingManager();
26 AliTRDcalibDB *trd(AliTRDcalibDB::Instance());
28 AliWarningGeneral("AliTRDtrendingManager", "TRD OCDB manager not initialized. No trending DB available.");
30 const TObjArray *trendMap(NULL/*trd->GetTrendMap()*/);
32 AliWarningGeneral("AliTRDtrendingManager", "No TRD trending DB available for TRD.");
33 } else fgInstance->fEntries=(TObjArray*)trendMap->Clone();
40 //____________________________________________
41 void AliTRDtrendingManager::Terminate()
44 // Singleton implementation
45 // Deletes the instance of this class and sets the terminated flag,
46 // instances cannot be requested anymore
47 // This function can be called several times.
52 if (fgInstance != NULL) {
58 //____________________________________________
59 AliTRDtrendingManager::AliTRDtrendingManager()
64 fRunRange[0] = 0; fRunRange[1] = AliCDBRunRange::Infinity();
67 //____________________________________________
68 AliTRDtrendingManager::~AliTRDtrendingManager()
70 if(fValue) delete fValue;
71 if(fEntries) delete fEntries;
74 //____________________________________________
75 void AliTRDtrendingManager::AddValue(
79 ,Double_t limits[2*(AliTRDtrendValue::kNlevels+1)]
80 ,Char_t *messages[AliTRDtrendValue::kNlevels]
85 // Expert Function !!!
86 // Add a trend value to the map already loaded
87 // If no map loaded create a new one from scratch
89 // class_name : name of the performance task
90 // name : name of the value to be trended
91 // title : description of the value to be trended
92 // limits : array of acceptance limits for this value. The array is organized as follows :
93 // - field 0 and 1 normal limits
94 // - field 2 and 3 first level of alarm
96 // - field 8 and 9 fourth level of alarm
97 // messages : array of alarm messages for each alarm level
98 // responsible: name and email of the responsible person. Format "name/email"
99 // notifiables: name and email of the notifiable persons. Format "name1/email1, name2/email2, etc"
101 AliWarning("*** EXPERT FUNCTION *** This function is adding one trending value to the current DB. Continue if you know what yout do!");
103 // create new trending value`
104 if(!fValue) fValue = new AliTRDtrendValue(Form("%s_%s", class_name, name), title);
105 else new(fValue) AliTRDtrendValue(Form("%s_%s", class_name, name), title);
106 fValue->SetLimits(limits);
107 for(Int_t ilevel(AliTRDtrendValue::kNlevels); ilevel--;) fValue->SetAlarm(ilevel, messages[ilevel]);
108 TString s(responsible);
109 TObjArray *r=s.Tokenize("/");
110 if(r->GetEntriesFast()!=2){
111 AliWarning("Responsible name/email incorrectly formated.");
113 fValue->SetResponsible(((TObjString*)r->At(0))->String().Data(), ((TObjString*)r->At(1))->String().Data());
117 TObjArray *n=s.Tokenize(",");
118 for(Int_t in(0); in<TMath::Min(AliTRDtrendValue::kNnotifiable, n->GetEntriesFast()); in++){
119 TString ss(((TObjString*)n->At(in))->String());
121 if(r->GetEntriesFast()!=2){
122 AliWarning(Form("Notifiable person name/email incorrectly formated for [%s].", ss.Data()));
124 fValue->SetNotifiable(((TObjString*)r->At(0))->String().Data(), ((TObjString*)r->At(1))->String().Data());
128 // if no trending map defined create one
130 AliInfo("No trending map loaded. Create one from scratch.");
131 fEntries = new TObjArray(50);
132 fEntries->SetOwner();
135 fEntries->AddLast(new AliTRDtrendValue(*fValue));
138 //____________________________________________
139 AliTRDtrendValue* AliTRDtrendingManager::GetValue(Char_t *class_name, Char_t *value_name)
142 AliError("No trending map defined.");
145 AliTRDtrendValue *val((AliTRDtrendValue*)fEntries->FindObject(Form("%s_%s", class_name, value_name)));
147 AliError(Form("Missing trending value %s [%s]", value_name, class_name));
153 //____________________________________________
154 Bool_t AliTRDtrendingManager::ModifyValue(
164 // Expert Function !!!
165 // Modify a trend value in the map already loaded
166 // see function AddValue() for explanation of input format.
169 AliError("No trending map loaded.");
172 AliWarning("*** EXPERT FUNCTION *** This function is modifying one trending value to the current DB. Continue if you know what yout do!");
174 AliTRDtrendValue *val((AliTRDtrendValue*)fEntries->FindObject(Form("%s_%s", class_name, name)));
176 AliError(Form("Missing trending value %s [%s]", name, class_name));
180 val->SetTitle(title);
181 if(limits) val->SetLimits(limits);
183 for(Int_t ilevel(AliTRDtrendValue::kNlevels); ilevel--;) val->SetAlarm(ilevel, messages[ilevel]);
190 if(r->GetEntriesFast()!=2){
191 AliWarning("Responsible name/email incorrectly formated.");
193 val->SetResponsible(((TObjString*)r->At(0))->String().Data(), ((TObjString*)r->At(1))->String().Data());
198 TObjArray *n=s.Tokenize(",");
199 for(Int_t in(0); in<TMath::Min(AliTRDtrendValue::kNnotifiable, n->GetEntriesFast()); in++){
200 TString ss(((TObjString*)n->At(in))->String());
202 if(r->GetEntriesFast()!=2){
203 AliWarning(Form("Notifiable person name/email incorrectly formated for [%s].", ss.Data()));
205 val->SetNotifiable(((TObjString*)r->At(0))->String().Data(), ((TObjString*)r->At(1))->String().Data());
212 //____________________________________________
213 void AliTRDtrendingManager::Print(Option_t *o) const
216 AliError("No trending map available.");
220 for(Int_t iv(0); iv<fEntries->GetEntriesFast(); iv++){
221 ((AliTRDtrendValue*)fEntries->At(iv))->Print(o);
225 //____________________________________________
226 void AliTRDtrendingManager::Save()
228 // Saving TRD trending DB to $ALICE_ROOT/OCDB.
230 AliWarning("Saving TRD trending DB to $ALICE_ROOT/OCDB.");
232 AliCDBMetaData *metaData= new AliCDBMetaData();
233 metaData->SetObjectClassName("TObjArray");
234 metaData->SetResponsible("Alexander Wilk");
235 metaData->SetBeamPeriod(1);
236 metaData->SetAliRootVersion("05-21-01"); //root version
237 metaData->SetComment("TRD trending ");
239 AliCDBId id("TRD/Calib/Trend", fRunRange[0], fRunRange[1]);
240 AliCDBManager *man = AliCDBManager::Instance();
241 AliCDBStorage *gStorLoc = man->GetStorage("local://$ALICE_ROOT/OCDB");
245 gStorLoc->Put(fEntries, id, metaData);