]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/AliT0Preprocessor.cxx
correct Hash in TMap, reading channel names
[u/mrichter/AliRoot.git] / T0 / AliT0Preprocessor.cxx
1 #include "AliT0Preprocessor.h"
2
3 #include "AliCDBMetaData.h"
4 #include "AliDCSValue.h"
5 #include "AliLog.h"
6 #include "AliT0Calc.h"
7
8 #include <TTimeStamp.h>
9 #include <TFile.h>
10 #include <TObjString.h>
11 #include <TNamed.h>
12 #include "AliT0Dqclass.h"
13
14 ClassImp(AliT0Preprocessor)
15
16 //____________________________________________________
17 AliT0Preprocessor::AliT0Preprocessor(AliShuttleInterface* shuttle) :
18   AliPreprocessor("T00", shuttle)
19 {
20
21 }
22
23 AliT0Preprocessor::~AliT0Preprocessor()
24 {
25
26 }
27
28 UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
29 {
30
31         if(!dcsAliasMap) return 1;
32
33         TObjArray *aliasArr;
34        // AliDCSValue *aValue;
35         Float_t hv[24]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
36
37         for(int j=0; j<24; j++){
38                 TString aliasName =Form("T0HV%d",j);
39                 // printf("aliasname: %s\n",aliasName.Data());
40                 aliasArr = dynamic_cast<TObjArray*> (dcsAliasMap->GetValue(aliasName.Data()));
41                 if(!aliasArr){
42                         AliError(Form("Alias %s not found!", aliasName.Data()));
43                         continue;
44                 }
45                 AliDCSValue *aValue=dynamic_cast<AliDCSValue*> (aliasArr->At(0));
46                 // printf("I'm here! %f %x\n", aValue->GetFloat(), aValue->GetTimeStamp());
47                hv[j]= aValue->GetFloat()*100;
48                //Float_t timestamp= (Float_t) (aValue->GetTimeStamp());
49                 // printf("hello! hv = %f timestamp = %f\n" ,hv[j], timestamp);
50
51         }
52         Float_t numbers[24];
53
54         AliT0Calc *calibdata = new AliT0Calc(); 
55         
56         TList* list = GetFileSources(kDAQ, "TIME");
57         if (list)
58         {
59                 TIter iter(list);
60                 TObjString *source;
61                 while ((source = dynamic_cast<TObjString *> (iter.Next()))) 
62                 {
63                         const char* TimefileName = GetFile(kDAQ, "TIME", source->GetName());
64         
65                         if (TimefileName)
66                         {
67                                 Log(Form("File with Id TIME found in source %s!", source->GetName()));
68                                 TFile *file = TFile::Open(TimefileName);
69                                 if(!file || !file->IsOpen()) 
70                                 {
71                                         Log(Form("Error opening file with Id TIME from source %s!", source->GetName()));
72                                         return 1;
73                                 } 
74                                 AliT0Dqclass *tempdata = dynamic_cast<AliT0Dqclass*> (file->Get("Time"));
75                                 if (!tempdata) 
76                                 {
77                                         Log("Could not find key \"Time\" in DAQ file!");
78                                         return 1;
79                                 }
80                                 for(Int_t i=0;i<24;i++){
81                                         numbers[i] = tempdata->GetTime(i);
82                                         //      printf("\nnumbers: %f\n",numbers[i]);
83                                 }
84                                 file->Close();
85                                 delete tempdata;
86                         } else {
87                                 Log(Form("Could not find file with Id TIME in source %s!", source->GetName()));
88                                 return 1;
89                         }
90                         calibdata->SetTime(numbers, hv);
91                         calibdata->Print();
92                 } 
93         } else {
94                 Log("No sources for Id TIME found!");
95         }        
96
97         AliCDBMetaData metaData;
98         metaData.SetBeamPeriod(0);
99         metaData.SetResponsible("Tomek&Michal");
100         metaData.SetComment("This preprocessor returns time to be used for reconstruction.");
101
102         Bool_t result = Store("Calib","Data", calibdata, &metaData);
103         delete calibdata;
104         if(result == kTRUE) 
105           {return 0;}
106         else {return 1;}
107 }
108
109