First big commit of the mchview program and its accompanying library,
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackerOCDBDataMaker.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
7 * Permission to use, copy, modify and distribute this software and its   *
8 * documentation strictly for non-commercial purposes is hereby granted   *
9 * without fee, provided that the above copyright notice appears in all   *
10 * copies and that both the copyright notice and this permission notice   *
11 * appear in the supporting documentation. The authors make no claims     *
12 * about the suitability of this software for any purpose. It is          *
13 * provided "as is" without express or implied warranty.                  *
14 **************************************************************************/
15
16 // $Id$
17
18 #include "AliMUONTrackerOCDBDataMaker.h"
19
20 #include "AliMUONTrackerData.h"
21 #include "AliCDBManager.h"
22 #include "AliCDBStorage.h"
23 #include "AliMUONCalibrationData.h"
24 #include "AliMUONVStore.h"
25 #include "AliLog.h"
26 #include <TString.h>
27
28 ///\class AliMUONTrackerOCDBDataMaker
29 ///
30 /// Producer of AliMUONVTrackerData from OCDB data
31 ///
32 ///\author Laurent Aphecetche, Subatech
33
34 ///\cond CLASSIMP
35 ClassImp(AliMUONTrackerOCDBDataMaker)
36 ///\endcond
37
38 //_____________________________________________________________________________
39 AliMUONTrackerOCDBDataMaker::AliMUONTrackerOCDBDataMaker(const char* ocdbPath,
40                                                            Int_t runNumber,
41                                                            const char* type)
42 : AliMUONVTrackerDataMaker(),
43   fIsValid(kTRUE),
44   fIsOwner(kTRUE),
45   fData(0x0),
46   fSource(Form("%s-%010d-%s",ocdbPath,runNumber,type))
47 {
48     /// Ctor
49     AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
50     
51     AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
52     
53     AliMUONVStore* store(0x0);
54     
55     TString stype(type);
56     stype.ToUpper();
57     
58     if ( stype == "PEDESTALS" )
59     {
60       fData = new AliMUONTrackerData(Form("PED%d",runNumber),"Pedestals",2,kFALSE);
61       fData->SetDimensionName(0,"Mean");
62       fData->SetDimensionName(1,"Sigma");
63       store = AliMUONCalibrationData::CreatePedestals(runNumber);
64     }
65     else if ( stype == "GAINS" ) 
66     {
67       fData = new AliMUONTrackerData(Form("GAIN%d",runNumber),"Gains",5,kFALSE);
68       fData->SetDimensionName(0,"a0");
69       fData->SetDimensionName(1,"a1");
70       fData->SetDimensionName(2,"thres");
71       fData->SetDimensionName(3,"qual");
72       fData->SetDimensionName(4,"sat");
73       store = AliMUONCalibrationData::CreateGains(runNumber);
74     }
75     else if ( stype == "CAPACITANCES" )
76     {
77       fData = new AliMUONTrackerData(Form("CAPA%d",runNumber),"Capacitances",2,kFALSE);
78       fData->SetDimensionName(0,"Capa");
79       fData->SetDimensionName(1,"Injection gain");
80       store = AliMUONCalibrationData::CreateCapacitances(runNumber);
81     }
82     
83     AliCDBManager::Instance()->SetDefaultStorage(storage);
84
85     if (!store)
86     {
87       fIsValid = kFALSE;
88       delete fData;
89       fData = 0x0;
90       AliError("Could not create store");
91       return;
92     }
93     
94     fData->Add(*store);
95 }
96
97 //_____________________________________________________________________________
98 AliMUONTrackerOCDBDataMaker::~AliMUONTrackerOCDBDataMaker()
99 {
100   /// dtor
101   if ( fIsOwner) delete fData;
102 }