for compile lookup
[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 <TNamed.h>
11 #include "AliT0Dqclass.h"
12
13 ClassImp(AliT0Preprocessor)
14
15 //____________________________________________________
16 AliT0Preprocessor::AliT0Preprocessor(const char* detector, AliShuttleInterface* shuttle) :
17   AliPreprocessor(detector, shuttle)
18 {
19
20 }
21
22 AliT0Preprocessor::~AliT0Preprocessor()
23 {
24
25 }
26
27 UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
28 {
29
30         if(!dcsAliasMap) return 0;
31
32         TObjArray *aliasArr;
33        // AliDCSValue *aValue;
34         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};
35
36         for(int j=0; j<24; j++){
37                 TString aliasName =Form("T0HV%d",j);
38                 // printf("aliasname: %s\n",aliasName.Data());
39                 aliasArr = dynamic_cast<TObjArray*> (dcsAliasMap->GetValue(aliasName.Data()));
40                 if(!aliasArr){
41                         AliError(Form("Alias %s not found!", aliasName.Data()));
42                         continue;
43                 }
44                 AliDCSValue *aValue=dynamic_cast<AliDCSValue*> (aliasArr->At(0));
45                 // printf("I'm here! %f %x\n", aValue->GetFloat(), aValue->GetTimeStamp());
46                hv[j]= aValue->GetFloat()*100;
47                //Float_t timestamp= (Float_t) (aValue->GetTimeStamp());
48                 // printf("hello! hv = %f timestamp = %f\n" ,hv[j], timestamp);
49
50         }
51         Float_t numbers[24];
52
53         AliT0Calc *calibdata = new AliT0Calc(); 
54         
55         const char* TimefileName = GetFile(kDAQ, "TIME", "LDC0");
56         
57         
58         if(TimefileName){
59                 TFile *file = TFile::Open(TimefileName);
60                 if(!file || !file->IsOpen()) 
61                 {
62                   printf("File from DAQ does not exist.");
63                   return 0;
64                 } 
65                 AliT0Dqclass *tempdata = dynamic_cast<AliT0Dqclass*> (file->Get("Time"));
66                 for(Int_t i=0;i<24;i++){
67                         numbers[i] = tempdata->GetTime(i);
68                 //      printf("\nnumbers: %f\n",numbers[i]);
69                 }
70                 file->Close();
71                 delete tempdata;
72         }
73         else {return 0;}
74         calibdata->SetTime(numbers, hv);
75         calibdata->Print();        
76
77         AliCDBMetaData metaData;
78         metaData.SetBeamPeriod(0);
79         metaData.SetResponsible("Tomek&Michal");
80         metaData.SetComment("This preprocessor returns time to be used for reconstruction.");
81         
82         UInt_t result = Store("Calib","Data", calibdata, &metaData);
83         delete calibdata;
84         return result;
85
86 }
87
88