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