]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCNoiseMap.cxx
correcting memory leaks on error conditions
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCNoiseMap.cxx
1 // $Id$
2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project        * 
4 //* ALICE Experiment at CERN, All rights reserved.                         *
5 //*                                                                        *
6 //* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no>          *
7 //*                  for The ALICE HLT Project.                            *
8 //*                                                                        *
9 //* Permission to use, copy, modify and distribute this software and its   *
10 //* documentation strictly for non-commercial purposes is hereby granted   *
11 //* without fee, provided that the above copyright notice appears in all   *
12 //* copies and that both the copyright notice and this permission notice   *
13 //* appear in the supporting documentation. The authors make no claims     *
14 //* about the suitability of this software for any purpose. It is          *
15 //* provided "as is" without express or implied warranty.                  *
16 //**************************************************************************
17
18 /** @file   AliHLTTPCNoiseMap.cxx
19     @author Kalliopi Kanaki
20     @date   
21     @brief  Class for reading the noise map from HCDB.
22 */
23
24 #if __GNUC__>= 3
25 using namespace std;
26 #endif
27
28 #include "AliHLTTPCNoiseMap.h"
29
30 #include "AliCDBEntry.h"
31 #include "AliCDBManager.h"
32 #include "AliCDBStorage.h"
33 #include "AliCDBPath.h"
34
35 #include "TObjString.h"
36
37 ClassImp(AliHLTTPCNoiseMap)
38
39 AliHLTTPCNoiseMap::AliHLTTPCNoiseMap(){ 
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 AliHLTTPCNoiseMap* AliHLTTPCNoiseMap::pNoiseMapInstance = 0; // initialize pointer
48
49 AliHLTTPCNoiseMap* AliHLTTPCNoiseMap::Instance(){
50 // see header file for class documentation
51
52   if (pNoiseMapInstance == 0){  
53       pNoiseMapInstance = new AliHLTTPCNoiseMap; // create sole instance
54   }
55   return pNoiseMapInstance; // address of sole instance
56 }
57
58 AliTPCCalPad* AliHLTTPCNoiseMap::ReadNoiseMap(Int_t runNo){
59 // see header file for class documentation
60   const char* pathNoiseMap = "TPC/Calib/PadNoise";
61   AliTPCCalPad *padNoise = NULL;
62
63   if(pathNoiseMap){    
64     
65     //AliCDBPath path(pathNoiseMap);
66     //AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path); // read from the default storage 
67     // for local testing purposes
68     
69     AliCDBStorage *stor = AliCDBManager::Instance()->GetDefaultStorage();
70     if(!stor){
71        HLTError("Cannot get HCDB default storage.");
72        return NULL;
73     }
74     
75     AliCDBPath path(pathNoiseMap);
76     Int_t version    = stor->GetLatestVersion(pathNoiseMap, runNo);
77     Int_t subVersion = stor->GetLatestSubVersion(pathNoiseMap, runNo, version);
78     
79     //HLTInfo("RunNo %d, version %d, subversion %d", runNo, version, subVersion);
80     
81     AliCDBEntry *pEntry = stor->Get(path, runNo, version, subVersion);
82         
83     if(pEntry){ 
84        padNoise = (AliTPCCalPad*)pEntry->GetObject();
85        if(padNoise){
86          TObjString *pString = dynamic_cast<TObjString*>(pEntry->GetObject());
87          if(pString){ 
88             HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); }
89          }
90     } // end if pEntry 
91     else { 
92        HLTError("cannot fetch object \"%s\" from CDB", pathNoiseMap); 
93     } 
94   } // end if pathNoiseMap
95   return padNoise;
96   
97 }