]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/SampleLib/AliHLTSamplePreprocessor.cxx
adding an example calibration component and corresponding macro
[u/mrichter/AliRoot.git] / HLT / SampleLib / AliHLTSamplePreprocessor.cxx
1 // $Id: AliHLTSamplePreprocessor.cxx 23039 2007-12-13 20:53:02Z richterm $
2
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * ALICE Experiment at CERN, All rights reserved.                         *
6  *                                                                        *
7  * Primary Authors: Sebastian Bablok <Sebastian.Bablok@ift.uib.no>        *
8  *                  Kenneth Aamodt                                        *
9  *                  for The ALICE HLT Project.                            *
10  *                                                                        *
11  * Permission to use, copy, modify and distribute this software and its   *
12  * documentation strictly for non-commercial purposes is hereby granted   *
13  * without fee, provided that the above copyright notice appears in all   *
14  * copies and that both the copyright notice and this permission notice   *
15  * appear in the supporting documentation. The authors make no claims     *
16  * about the suitability of this software for any purpose. It is          *
17  * provided "as is" without express or implied warranty.                  *
18  **************************************************************************/
19
20 /**
21  * @file   AliHLTSamplePreprocessor.cxx
22  * @author Kenneth Aamodt, Sebastian Bablok
23  * @date   2007-12-06
24  * @brief  HLT Preprocessor plugin for the AliHLTComp library
25  */
26
27 #include "AliHLTSamplePreprocessor.h"
28 #include "AliPreprocessor.h"
29
30 #include <AliCDBMetaData.h>
31 #include <TObjString.h>
32 #include <TString.h>
33 #include <TList.h>
34 #include <TFile.h>
35
36 ClassImp(AliHLTSamplePreprocessor)
37
38 AliHLTSamplePreprocessor::AliHLTSamplePreprocessor()
39 {
40   // see header file for class documentation
41   // or
42   // refer to README to build package
43   // or
44   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
45 }
46
47 const char* AliHLTSamplePreprocessor::fgkTempHistoFileName = "HLTTemperatureHistograms.root";
48
49 AliHLTSamplePreprocessor::~AliHLTSamplePreprocessor()
50 {
51   // see header file for function documentation
52 }
53
54 void AliHLTSamplePreprocessor::Initialize(Int_t /*run*/, UInt_t /*startTime*/, 
55                                           UInt_t /*endTime*/)
56 {
57   // see header file for function documentation
58 }
59
60
61 UInt_t AliHLTSamplePreprocessor::Process(TMap* /*dcsAliasMap*/)
62 {
63   // see header file for function documentation
64   UInt_t retVal = 0;
65   if (GetTempHisto() != 0) {
66     // unable to fetch the temperature histogram from HLT
67     retVal = 1;
68     // but if set to 1, then also file from GetHuffmanTables won't be saved !!!
69   }
70
71   return retVal;
72 }
73
74 UInt_t AliHLTSamplePreprocessor::GetTempHisto()
75 {
76   // see header file for function documentation
77
78         UInt_t retVal = 0;
79     // get Temp Histogram map
80     TList* HLTlist = GetFileSources(AliPreprocessor::kHLT, fgkTempHistoFileName);
81     if (!HLTlist) {
82         Log("Missing list for the HLT");
83    
84         return 1;
85     }
86
87         if (HLTlist->GetSize() == 0) {
88                 Log("No Temperature histogram produced inside the HLT by a DA for this run.");
89                 return retVal; 
90                 // return no error -> DA might not have run, but other file shall be saved.
91         } else if (HLTlist->GetSize() > 1) {
92         Log(Form("Problem on the size of the list: %d (HLT)", HLTlist->GetSize()));
93         return 0; // might have to be changed, when there will be more than one histogram file
94     }
95
96     TObjString* location = (TObjString*) HLTlist->At(0);
97     if (location == 0) {
98         Log("Error in location HLT list.");
99         return 0;
100     }
101     TString localFileName = GetFile(AliPreprocessor::kHLT, fgkTempHistoFileName,
102                 location->String().Data());
103         if (!(localFileName.Length() > 0)) {
104                 Log("Local file name for Temperature Histogram has zero length.");
105                 return 1;
106         }
107         
108 /*
109     TFile localFile(localFileName);
110     AliCDBMetaData meta("Sebastian Bablok");
111
112     if (!(Store("Calib", kTempHistoFileName, (TObject*) &localFile, &meta, 0, kTRUE))) {
113 */
114     if (!(StoreReferenceFile(localFileName.Data(), fgkTempHistoFileName))) {
115         TString msg("Storing of object '");
116         msg += fgkTempHistoFileName;
117         msg += "' to Reference Storage failed!";
118         Log(msg.Data());
119         retVal = 1;
120     }
121
122         return retVal;
123 }