]>
Commit | Line | Data |
---|---|---|
ea199e33 | 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 | ||
8d8e920c | 18 | #include "AliMUONPedestalSubprocessor.h" |
ea199e33 | 19 | |
20 | #include "AliCDBMetaData.h" | |
21 | #include "AliLog.h" | |
22 | #include "AliMUON2DMap.h" | |
8d8e920c | 23 | #include "AliMUON2DStoreValidator.h" |
a8f77ca0 | 24 | #include "AliMUONCalibParamNF.h" |
ea199e33 | 25 | #include "AliMUONPreprocessor.h" |
8d8e920c | 26 | #include "AliMpConstants.h" |
7ca4655f | 27 | #include "AliMpDDLStore.h" |
a8f77ca0 | 28 | #include "TObjString.h" |
8d8e920c | 29 | #include <Riostream.h> |
30 | #include <TList.h> | |
31 | #include <TObjString.h> | |
32 | #include <TSystem.h> | |
33 | #include <sstream> | |
ea199e33 | 34 | |
3d1463c8 | 35 | //----------------------------------------------------------------------------- |
ea199e33 | 36 | /// \class AliMUONPedestalSubprocessor |
37 | /// | |
38 | /// Implementation of AliMUONVSubprocessor class to deal with MUON TRK pedestals. | |
39 | /// | |
40 | /// Pedestals are read in from an ascii file, with the format : \n | |
41 | ///---------------------------------------------------------------------------\n | |
42 | /// BUS_PATCH MANU_ADDR CHANNEL MEAN SIGMA \n | |
43 | ///---------------------------------------------------------------------------\n | |
44 | /// | |
45 | /// \author L. Aphecetche | |
3d1463c8 | 46 | //----------------------------------------------------------------------------- |
ea199e33 | 47 | |
48 | /// \cond CLASSIMP | |
49 | ClassImp(AliMUONPedestalSubprocessor) | |
50 | /// \endcond | |
51 | ||
52 | //_____________________________________________________________________________ | |
53 | AliMUONPedestalSubprocessor::AliMUONPedestalSubprocessor(AliMUONPreprocessor* master) | |
54 | : AliMUONVSubprocessor(master, | |
55 | "Pedestals", | |
56 | "Upload MUON Tracker pedestals to OCDB"), | |
57 | fPedestals(0x0) | |
58 | { | |
71a2d3aa | 59 | /// default ctor |
ea199e33 | 60 | } |
61 | ||
62 | //_____________________________________________________________________________ | |
63 | AliMUONPedestalSubprocessor::~AliMUONPedestalSubprocessor() | |
64 | { | |
71a2d3aa | 65 | /// dtor |
ea199e33 | 66 | delete fPedestals; |
67 | } | |
68 | ||
69 | //_____________________________________________________________________________ | |
70 | void | |
71 | AliMUONPedestalSubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) | |
72 | { | |
73 | /// When starting a new run, reads in the pedestals ASCII files. | |
74 | ||
75 | const Int_t kSystem = AliMUONPreprocessor::kDAQ; | |
76 | const char* kId = "PEDESTALS"; | |
77 | ||
78 | delete fPedestals; | |
79 | fPedestals = new AliMUON2DMap(kTRUE); | |
80 | ||
d2db856e | 81 | Master()->Log(Form("Reading pedestal files for Run %d startTime %ld endTime %ld", |
82 | run,startTime,endTime)); | |
ea199e33 | 83 | |
84 | TList* sources = Master()->GetFileSources(kSystem,kId); | |
85 | TIter next(sources); | |
86 | TObjString* o(0x0); | |
703d8257 | 87 | Int_t n(0); |
88 | ||
ea199e33 | 89 | while ( ( o = static_cast<TObjString*>(next()) ) ) |
90 | { | |
91 | TString fileName(Master()->GetFile(kSystem,kId,o->GetName())); | |
703d8257 | 92 | Int_t ok = ReadFile(fileName.Data()); |
ea199e33 | 93 | if (!ok) |
94 | { | |
d2db856e | 95 | Master()->Log(Form("Could not read file %s",fileName.Data())); |
ea199e33 | 96 | } |
703d8257 | 97 | else |
98 | { | |
99 | n += ok; | |
100 | } | |
101 | } | |
102 | ||
103 | if (!n) | |
104 | { | |
105 | Master()->Log("Failed to read any pedestals"); | |
106 | delete fPedestals; | |
107 | fPedestals = 0; | |
ea199e33 | 108 | } |
109 | delete sources; | |
110 | } | |
111 | ||
112 | //_____________________________________________________________________________ | |
113 | UInt_t | |
114 | AliMUONPedestalSubprocessor::Process(TMap* /*dcsAliasMap*/) | |
115 | { | |
71a2d3aa | 116 | /// Store the pedestals into the CDB |
ea199e33 | 117 | |
a8f77ca0 | 118 | if (!fPedestals) |
119 | { | |
120 | // this is the only reason to fail for the moment : getting no pedestal | |
121 | // at all. | |
d489129d | 122 | return 1; |
a8f77ca0 | 123 | } |
703d8257 | 124 | |
a8f77ca0 | 125 | AliMUON2DStoreValidator validator; |
126 | ||
127 | Master()->Log("Validating"); | |
128 | ||
129 | TObjArray* chambers = validator.Validate(*fPedestals); | |
130 | ||
131 | if (chambers) | |
132 | { | |
133 | // we hereby report what's missing, but this is not a reason to fail ;-) | |
134 | // the only reason to fail would be if we got no pedestal at all | |
135 | TList lines; | |
136 | lines.SetOwner(kTRUE); | |
137 | ||
138 | validator.Report(lines,*chambers); | |
139 | ||
140 | TIter next(&lines); | |
141 | TObjString* line; | |
142 | ||
143 | while ( ( line = static_cast<TObjString*>(next()) ) ) | |
144 | { | |
145 | Master()->Log(line->String().Data()); | |
146 | } | |
147 | } | |
148 | ||
3b32651c | 149 | Master()->Log("Storing pedestals"); |
ea199e33 | 150 | |
151 | AliCDBMetaData metaData; | |
152 | metaData.SetBeamPeriod(0); | |
153 | metaData.SetResponsible("MUON TRK"); | |
154 | metaData.SetComment("Computed by AliMUONPedestalSubprocessor $Id$"); | |
155 | ||
3b32651c | 156 | Bool_t validToInfinity = kTRUE; |
d489129d | 157 | Bool_t result = Master()->Store("Calib", "Pedestals", fPedestals, &metaData, 0, validToInfinity); |
ea199e33 | 158 | |
d489129d | 159 | return ( result != kTRUE ); // return 0 if everything is ok. |
ea199e33 | 160 | } |
161 | ||
162 | //_____________________________________________________________________________ | |
703d8257 | 163 | Int_t |
ea199e33 | 164 | AliMUONPedestalSubprocessor::ReadFile(const char* filename) |
165 | { | |
71a2d3aa | 166 | /// Read the pedestals from an ASCII file. \n |
167 | /// Format of that file is one line per channel : \n | |
168 | ///-------------------------------------------------------------------------\n | |
169 | /// BUS_PATCH MANU_ADDR CHANNEL MEAN SIGMA \n | |
170 | ///-------------------------------------------------------------------------\n | |
171 | /// \n | |
172 | /// Return kFALSE if reading was not successfull. \n | |
173 | /// | |
ea199e33 | 174 | |
d2db856e | 175 | TString sFilename(gSystem->ExpandPathName(filename)); |
ea199e33 | 176 | |
d2db856e | 177 | Master()->Log(Form("Reading %s",sFilename.Data())); |
ea199e33 | 178 | |
d2db856e | 179 | std::ifstream in(sFilename.Data()); |
180 | if (!in.good()) | |
181 | { | |
703d8257 | 182 | return 0; |
d2db856e | 183 | } |
ea199e33 | 184 | char line[80]; |
185 | Int_t busPatchID, manuID, manuChannel; | |
186 | Float_t pedMean, pedSigma; | |
8d8e920c | 187 | static const Int_t kNchannels(AliMpConstants::ManuNofChannels()); |
703d8257 | 188 | Int_t n(0); |
ea199e33 | 189 | |
190 | while ( in.getline(line,80) ) | |
191 | { | |
192 | if ( line[0] == '/' && line[1] == '/' ) continue; | |
193 | std::istringstream sin(line); | |
194 | sin >> busPatchID >> manuID >> manuChannel >> pedMean >> pedSigma; | |
e5ced899 | 195 | Int_t detElemID = AliMpDDLStore::Instance()->GetDEfromBus(busPatchID); |
ea199e33 | 196 | AliDebug(3,Form("BUSPATCH %3d DETELEMID %4d MANU %3d CH %3d MEAN %7.2f SIGMA %7.2f", |
197 | busPatchID,detElemID,manuID,manuChannel,pedMean,pedSigma)); | |
198 | ||
199 | AliMUONVCalibParam* ped = | |
8d8e920c | 200 | static_cast<AliMUONVCalibParam*>(fPedestals->FindObject(detElemID,manuID)); |
ea199e33 | 201 | |
202 | if (!ped) | |
203 | { | |
8d8e920c | 204 | ped = new AliMUONCalibParamNF(2,kNchannels, |
205 | detElemID,manuID, | |
206 | AliMUONVCalibParam::InvalidFloatValue()); | |
207 | fPedestals->Add(ped); | |
ea199e33 | 208 | } |
209 | ped->SetValueAsFloat(manuChannel,0,pedMean); | |
210 | ped->SetValueAsFloat(manuChannel,1,pedSigma); | |
703d8257 | 211 | ++n; |
ea199e33 | 212 | } |
213 | in.close(); | |
703d8257 | 214 | return n; |
ea199e33 | 215 | } |
216 | ||
217 | ||
218 | //_____________________________________________________________________________ | |
219 | void | |
220 | AliMUONPedestalSubprocessor::Print(Option_t* opt) const | |
221 | { | |
222 | /// ouput to screen | |
8d8e920c | 223 | if (fPedestals) fPedestals->Print("",opt); |
ea199e33 | 224 | } |