]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHPreprocessor.cxx
First operational version of AliRICHProprocessor
[u/mrichter/AliRoot.git] / RICH / AliRICHPreprocessor.cxx
1 #include "AliRICHPreprocessor.h" //header
2
3 #include <AliCDBMetaData.h>
4 #include <AliDCSValue.h>      
5 #include <TObjArray.h>        //Test()
6 #include <TObjString.h>       //Test()
7 #include <AliCDBManager.h>    //Test()
8 #include <AliCDBEntry.h>      //Test()
9 #include <AliTestShuttle.h>   //Test()
10 #include <TRandom.h>          //Test()
11 #include <TF1.h>              //Process()
12 #include <TGraph.h>           //Process()
13
14 ClassImp(AliRICHPreprocessor)
15
16
17
18 const char *AliRICHPreprocessor::fgkAliasName[AliRICHPreprocessor::fgkNalias]={"HMP_DET/HMP_MP0/HMP_MP0_LIQ_LOOP.actual.sensors.Rad1In_Temp",
19                                                                                "HMP_DET/HMP_MP0/HMP_MP0_LIQ_LOOP.actual.sensors.Rad1Out_Temp"};
20
21
22
23
24 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
25 void AliRICHPreprocessor::Initialize(Int_t run, UInt_t startTime,UInt_t endTime)
26 {
27   AliPreprocessor::Initialize(run, startTime, endTime);
28 }
29 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30 UInt_t AliRICHPreprocessor::Process(TMap* pDcsMap)
31 {
32 //  
33   TList* list = GetFileSources(kDAQ, "MAP"); //first analyse a set of pedestal files
34   if (list){
35     Log("The following sources produced files with the id MAP");
36     list->Print();
37     delete list;
38   }
39
40   if(!pDcsMap)  return 0;                    //no DCS map provided 
41
42   TObjArray result; result.SetOwner(kTRUE);  //result is a array of TF1
43     
44   
45   for(Int_t iAlias=0;iAlias<fgkNalias;iAlias++){//aliases loop
46     TObjArray *pOA=(TObjArray*)pDcsMap->GetValue(fgkAliasName[iAlias]);
47     if(!pOA) continue;                                                    //no data points for this alias
48     TF1 *pF1=new TF1("t11","[0]+[1]*x+[2]*sin([3]*x)",0,10);
49     
50     TGraph *pGr=new TGraph; pGr->GetXaxis()->SetTimeDisplay(kTRUE);       //tmp graph of sensor data versus time 
51
52     TIter next(pOA);  AliDCSValue *pDcsVal; Int_t i=0;
53     while(pDcsVal=(AliDCSValue*)next())                           //loop over data points for this sensor and fill the graph
54       pGr->SetPoint(i++,pDcsVal->GetTimeStamp(),pDcsVal->GetSimpleValue().GetFloat());
55     
56     
57     pGr->Fit(pF1);                                                        //do fit
58     delete pGr;
59     result.Add(pF1);
60   }
61   
62   AliCDBMetaData metaData; metaData.SetBeamPeriod(0); metaData.SetResponsible("AliRICHPreprocessor"); metaData.SetComment("SIMULATED");
63
64   return Store(&result, &metaData); //use AliPreprocessor::Store(), not allowed to use AliCDBManager directly
65
66 }//Process()
67 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
68 void AliRICHPreprocessor::Test()
69 {
70   
71   AliCDBManager::Instance()->SetDefaultStorage("local://$HOME/TestCDB"); // initialize location of CDB
72
73   AliTestShuttle* pShuttle = new AliTestShuttle();   
74   pShuttle->SetDCSInput(SimulateDcsMap());                                           //DCS map format alias->TObjArray of AliDCSValue    
75   pShuttle->AddInputFile(AliTestShuttle::kDAQ, "RICH", "MAP", "LDC1", "map1.root");  //????? real gain map
76   pShuttle->AddInputFile(AliTestShuttle::kDAQ, "RICH", "MAP", "LDC2", "map2.root");  //how to crrespond LDC id and staff from AliRICHDigit ????
77   pShuttle->AddInputFile(AliTestShuttle::kDAQ, "RICH", "MAP", "LDC3", "map3.root");
78   pShuttle->AddInputFile(AliTestShuttle::kDAQ, "RICH", "MAP", "LDC4", "map4.root");
79   pShuttle->AddInputFile(AliTestShuttle::kDAQ, "RICH", "MAP", "LDC5", "map5.root");
80   pShuttle->AddInputFile(AliTestShuttle::kDAQ, "RICH", "MAP", "LDC6", "map6.root");
81   pShuttle->AddInputFile(AliTestShuttle::kDAQ, "RICH", "MAP", "LDC7", "map7.root");
82   
83   AliPreprocessor* pp = new AliRICHPreprocessor(pShuttle);                           //start test, actual invocation of Process will be done from shuttle
84   pShuttle->Process();                                    
85   delete pp;
86   
87   
88   
89 //read array of TF1 stored in CDB  
90   AliCDBEntry *pEntry=AliCDBManager::Instance()->Get("RICH/SHUTTLE/Data",0);
91   if(!pEntry) Printf("ERROR file is not retrieved!!!");
92 }//Test()
93 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
94 TMap* AliRICHPreprocessor::SimulateDcsMap()
95 {
96   TMap*      pDcsMap = new TMap;       pDcsMap->SetOwner(1);
97   
98   for(Int_t iAlias=0;iAlias<fgkNalias;iAlias++){//loop on aliases
99     TObjArray* pOA  = new TObjArray;  pOA->SetOwner(1); //values are supposed to be arranged in TObjArray
100     for (Int_t timeStamp=0;timeStamp<1000;timeStamp+=10) {
101       AliSimpleValue* pSimVal = new AliSimpleValue(Float_t(20*gRandom->Gaus()));                    //T sensor provides floats
102       AliDCSValue*    pDcsVal = new AliDCSValue(*pSimVal, timeStamp);      
103       pOA->Add(pDcsVal);                                                                            //add new data point to array
104     }
105     pDcsMap->Add(new TObjString(fgkAliasName[iAlias]),pOA);                                         //add new array of data points to the map
106   }//aliases loop
107   return pDcsMap;
108 }
109 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++