Implementation of DCS FXS interface. Common design of all FXS interface methods .
[u/mrichter/AliRoot.git] / SHUTTLE / test / TestHMPIDPreprocessor.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 // Prototype of HMPID Preprocessor
18 //
19
20 #include "TestHMPIDPreprocessor.h"
21
22 #include "AliCDBMetaData.h"
23 #include "AliDCSValue.h"
24 #include "AliLog.h"
25 #include "AliShuttleInterface.h"
26
27 #include <TTimeStamp.h>
28 #include <TObjString.h>
29 #include <TSystem.h>
30
31 ClassImp(TestHMPIDPreprocessor)
32
33 //________________________________________________________________________________________
34 TestHMPIDPreprocessor::TestHMPIDPreprocessor():
35         AliPreprocessor("HMP",0)
36 {
37 // default constructor - Don't use this!
38
39 }
40
41 //________________________________________________________________________________________
42 TestHMPIDPreprocessor::TestHMPIDPreprocessor(AliShuttleInterface* shuttle):
43         AliPreprocessor("HMP", shuttle)
44 {
45 // constructor - shuttle must be instantiated!
46
47 }
48
49 //________________________________________________________________________________________
50 void TestHMPIDPreprocessor::Initialize(Int_t run, UInt_t startTime,
51         UInt_t endTime) 
52 {
53 // Initialize preprocessor
54
55         AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
56                 TTimeStamp(startTime).AsString(),
57                 TTimeStamp(endTime).AsString()));
58
59         fRun = run;
60         fStartTime = startTime;
61         fEndTime = endTime;
62 }
63
64 //________________________________________________________________________________________
65 UInt_t TestHMPIDPreprocessor::Process(TMap* /*valueMap*/)
66 {
67 // process data retrieved by the Shuttle
68
69         //TIter iter(valueMap);
70         //TPair* aPair;
71         //while ((aPair = (TPair*) iter.Next())) {
72                 //aPair->Print();
73         //}
74         //AliCDBMetaData metaData;
75         //metaData.SetComment("This is a test!");
76
77         // return Store(valueMap, &metaData);
78
79         // DAQ
80         TList* filesources = GetFileSources(AliShuttleInterface::kDAQ, "DAQFile");
81
82         if(!filesources) {
83                 AliError(Form("No sources found for thresholds.txt for run %d !", fRun));
84                 return 0;
85         }
86
87         AliInfo("Here's the list of sources for thresholds.txt");
88         filesources->Print();
89
90         TIter iter(filesources);
91         TObjString* source;
92         int i=0;
93         UInt_t result = 0;
94         while((source=dynamic_cast<TObjString*> (iter.Next()))){
95                 printf("\n\n Getting file #%d\n",++i);
96                 //if(i==1) continue;
97                 TString filename = GetFile(AliShuttleInterface::kDAQ, "DAQFile", source->GetName());
98                 if(!filename.Length()) {
99                         AliError(Form("Error: retrieval of file from source %s failed!", source->GetName()));
100                         delete filesources;
101                         return 0;
102                 }
103                 TString command = Form("more %s",filename.Data());
104                 gSystem->Exec(command.Data());
105
106                 // STORAGE! The First file name will be stored into CDB, the second into reference storage
107                 TObjString filenameObj(filename);
108                 AliCDBMetaData metaData;
109                 if(i==1) result = Store("Calib", "DAQData", &filenameObj, &metaData);
110                 if(i==2) result = StoreReferenceData("Calib", "RefData", &filenameObj, &metaData);
111
112         }
113         delete filesources;
114         
115         // DCS
116         TString filename = GetFile(AliShuttleInterface::kDCS, "DCSFile", 0);
117         if(!filename.Length()) {
118                 AliError(Form("Error: retrieval of file from DCS failed!"));
119                 return 0;
120         }
121         TString command = Form("more %s", filename.Data());
122         gSystem->Exec(command.Data());
123
124         // STORAGE! The First file name will be stored into CDB, the second into reference storage
125         TObjString filenameObj(filename);
126         AliCDBMetaData metaData;
127         result = Store("Calib", "DCSData", &filenameObj, &metaData);
128
129         // HLT
130         filesources = GetFileSources(AliShuttleInterface::kHLT, "HLTFile");
131
132         if(!filesources) {
133                 Log(Form("No sources found for HLTFile for run %d !", fRun));
134                 return 0;
135         }
136
137         AliInfo("Here's the list of sources for HLTFile");
138         filesources->Print();
139
140         TIter iter2(filesources);
141         i = 0;
142         while((source=dynamic_cast<TObjString*> (iter2.Next()))){
143                 printf("\n\n Getting file #%d\n",++i);
144                 //if(i==1) continue;
145                 TString filename = GetFile(AliShuttleInterface::kHLT, "HLTFile", source->GetName());
146                 if(!filename.Length()) {
147                         AliError(Form("Error: retrieval of file from source %s failed!", source->GetName()));
148                         delete filesources;
149                         return 0;
150                 }
151                 TString command = Form("more %s",filename.Data());
152                 gSystem->Exec(command.Data());
153
154                 // STORAGE! The First file name will be stored into CDB, the second into reference storage
155                 TObjString filenameObj(filename);
156                 AliCDBMetaData metaData;
157                 if(i==1) result = Store("Calib", "HLTData", &filenameObj, &metaData);
158                 if(i==2) result = StoreReferenceData("Calib", "RefHLTData", &filenameObj, &metaData);
159
160         }
161         delete filesources;
162         
163
164         return result;
165 }
166