]>
Commit | Line | Data |
---|---|---|
04aa997f | 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$ | |
3d1463c8 | 17 | |
18 | //----------------------------------------------------------------------------- | |
04aa997f | 19 | // Class AliMUONGMSSubprocessor |
20 | // ----------------------------- | |
21 | // The shuttle subprocessor for GMS data | |
22 | // Author: Ivana Hrivnacova, IPN Orsay | |
23 | // 16/09/2006 | |
3d1463c8 | 24 | //----------------------------------------------------------------------------- |
04aa997f | 25 | |
26 | #include "AliMUONGMSSubprocessor.h" | |
27 | #include "AliMUONPreprocessor.h" | |
2c1e4958 | 28 | #include "AliMpConstants.h" |
04aa997f | 29 | |
2c1e4958 | 30 | #include "AliAlignObjMatrix.h" |
04aa997f | 31 | #include "AliCDBMetaData.h" |
2c1e4958 | 32 | #include "AliCDBEntry.h" |
04aa997f | 33 | |
34 | #include <TTimeStamp.h> | |
35 | #include <TFile.h> | |
2c1e4958 | 36 | #include <TArrayI.h> |
04aa997f | 37 | #include <TClonesArray.h> |
968ce98e | 38 | #include <TObjString.h> |
04aa997f | 39 | #include <Riostream.h> |
40 | ||
78649106 | 41 | /// \cond CLASSIMP |
04aa997f | 42 | ClassImp(AliMUONGMSSubprocessor) |
78649106 | 43 | /// \endcond |
04aa997f | 44 | |
923a4baf | 45 | const Int_t AliMUONGMSSubprocessor::fgkSystem = AliPreprocessor::kDCS; |
04aa997f | 46 | const TString AliMUONGMSSubprocessor::fgkDataId = "GMS"; |
47 | const TString AliMUONGMSSubprocessor::fgkMatrixArrayName = "GMSarray"; | |
48 | ||
968ce98e | 49 | //______________________________________________________________________________ |
04aa997f | 50 | AliMUONGMSSubprocessor::AliMUONGMSSubprocessor(AliMUONPreprocessor* master) |
51 | : AliMUONVSubprocessor(master, "GMS", "Upload GMS matrices to OCDB"), | |
789260b4 | 52 | fTransformer(0) |
04aa997f | 53 | { |
54 | /// Constructor | |
04aa997f | 55 | } |
56 | ||
968ce98e | 57 | //______________________________________________________________________________ |
04aa997f | 58 | AliMUONGMSSubprocessor::~AliMUONGMSSubprocessor() |
59 | { | |
60 | /// Destructor | |
789260b4 | 61 | |
62 | delete fTransformer; | |
04aa997f | 63 | } |
64 | ||
968ce98e | 65 | |
66 | // | |
67 | // private methods | |
68 | // | |
69 | ||
70 | ||
789260b4 | 71 | //______________________________________________________________________________ |
72 | void AliMUONGMSSubprocessor::Initialize(Int_t /*run*/, | |
73 | UInt_t /*startTime*/, UInt_t /*endTime*/) | |
74 | { | |
75 | /// Instantiate geometry transformer | |
76 | ||
77 | if ( ! fTransformer ) { | |
78 | fTransformer = new AliMUONGeometryTransformer(); | |
79 | fTransformer->CreateModules(); | |
80 | } | |
81 | } | |
82 | ||
968ce98e | 83 | //______________________________________________________________________________ |
84 | UInt_t AliMUONGMSSubprocessor::ProcessFile(const TString& fileName) | |
04aa997f | 85 | { |
86 | /// Convert TGeoHMatrix to AliAlignObjMatrix and fill them into AliTestDataDCS object | |
87 | ||
f6e36ea4 | 88 | Master()->Log(Form("Processing GMS file %s", fileName.Data())); |
2c1e4958 | 89 | |
04aa997f | 90 | // Open root file |
968ce98e | 91 | TFile f(fileName.Data()); |
92 | if ( ! f.IsOpen() ) { | |
f6e36ea4 | 93 | Master()->Log(Form("Cannot open file %s",fileName.Data())); |
d489129d | 94 | return 1; |
968ce98e | 95 | } |
04aa997f | 96 | |
97 | // Get array with matrices | |
98 | TClonesArray* array = (TClonesArray*)f.Get(fgkMatrixArrayName); | |
99 | if ( ! array ) { | |
f6e36ea4 | 100 | Master()->Log(Form("TClonesArray not found in file %s",fileName.Data())); |
d489129d | 101 | return 2; |
2c1e4958 | 102 | } |
103 | ||
104 | // Array to store correspondance between the moduleId | |
105 | // and its corresponding entry in the GMS array. | |
106 | TArrayI moduleIdToGMSIndex; | |
107 | moduleIdToGMSIndex.Set(AliMpConstants::NofGeomModules()); | |
108 | for (Int_t i=0; i<AliMpConstants::NofGeomModules(); i++){ | |
109 | moduleIdToGMSIndex[i]=-1; | |
110 | } | |
04aa997f | 111 | |
112 | // Convert matrices into Alice alignment objects | |
113 | for (Int_t i=0; i<array->GetEntriesFast(); i++ ) { | |
114 | TGeoHMatrix* matrix = (TGeoHMatrix*)array->At(i); | |
789260b4 | 115 | fTransformer->AddMisAlignModule(matrix->GetUniqueID(), *matrix); |
2c1e4958 | 116 | moduleIdToGMSIndex[matrix->GetUniqueID()]=i; |
117 | } | |
789260b4 | 118 | TObject* data = const_cast< TClonesArray*>(fTransformer->GetMisAlignmentData()); |
04aa997f | 119 | |
120 | //Now we have to store the final CDB file | |
f6e36ea4 | 121 | Master()->Log("Storing GMS"); |
04aa997f | 122 | AliCDBMetaData metaData; |
123 | metaData.SetBeamPeriod(0); | |
124 | metaData.SetResponsible(""); | |
125 | metaData.SetComment("This preprocessor fills GMS alignment objects."); | |
2c1e4958 | 126 | |
127 | Bool_t result = Master()->Store("Align", "GMS", data, &metaData, 0, 0); | |
128 | ||
129 | // This section apply the GMS misalignments on top of the misalignments | |
130 | // of the GMS reference run and stores the new misalignment array in the OCDB | |
131 | ||
132 | // Get mis alignment from reference run for GMS | |
133 | AliCDBEntry* cdbEntry = Master()->GetFromOCDB("Align", "Baseline"); | |
134 | if (cdbEntry) { | |
135 | TClonesArray* refArray = (TClonesArray*)cdbEntry->GetObject(); | |
136 | if (refArray) { | |
137 | // Create new misalignment array | |
138 | TClonesArray* newArray = new TClonesArray("AliAlignObjMatrix", 200); | |
139 | for (Int_t i=0; i<refArray->GetEntriesFast(); i++) { | |
140 | AliAlignObjMatrix* refAOMat = (AliAlignObjMatrix*)refArray->At(i); | |
141 | TGeoHMatrix refMat; | |
142 | refAOMat->GetMatrix(refMat); | |
143 | // Need the module containing this module or detection element | |
144 | TString sName = refAOMat->GetSymName(); //Format "/MUON/GMx" or "/MUON/GMx/DEy" | |
145 | Int_t iGM = sName.Index("GM"); | |
146 | Int_t iLS = sName.Last('/'); | |
147 | if (iLS>iGM) { // This is a detection element | |
148 | sName.Remove(iLS,sName.Sizeof()); | |
149 | } | |
150 | sName.Remove(0,iGM+2); | |
151 | Int_t iMod = sName.Atoi(); | |
152 | if (moduleIdToGMSIndex[iMod]>=0) { | |
153 | TGeoHMatrix* gmsMat = (TGeoHMatrix*)array->At(moduleIdToGMSIndex[iMod]); | |
154 | refMat.MultiplyLeft(gmsMat); | |
155 | } | |
156 | else { | |
157 | Master()->Log(Form("Missing GMS entry for module %d",iMod)); | |
158 | } | |
159 | AliAlignObjMatrix* newAOMat = new((*newArray)[i]) AliAlignObjMatrix(*refAOMat); // Copy the reference misalignment object to the new array ... | |
160 | newAOMat->SetMatrix(refMat); // ... and set its matrix | |
161 | } | |
162 | ||
163 | //Now we have also to store this CDB file | |
164 | TString sMDComment(cdbEntry->GetMetaData()->GetComment()); | |
165 | sMDComment += " GMS"; | |
166 | Master()->Log("Storing MisAlignment"); | |
167 | metaData.SetComment(sMDComment); | |
168 | ||
169 | result = result && Master()->Store("Align", "Data", newArray, &metaData, 0, 1); | |
170 | } | |
171 | else { | |
172 | Master()->Log("Empty entry?"); | |
173 | } | |
174 | } | |
175 | else { | |
176 | Master()->Log("Could not get GMS reference misalignment from OCDB! Will not add a new MUON/Align/Data entry!"); | |
177 | } | |
178 | // Done with applying GMS misalignments on top of misalignment of reference run | |
179 | ||
04aa997f | 180 | // Clear MisAlignArray in transformer |
789260b4 | 181 | fTransformer->ClearMisAlignmentData(); |
2c1e4958 | 182 | |
d489129d | 183 | return (result!=kTRUE); |
968ce98e | 184 | } |
185 | ||
186 | // | |
187 | // public methods | |
188 | // | |
189 | ||
190 | ||
191 | //______________________________________________________________________________ | |
192 | UInt_t AliMUONGMSSubprocessor::Process(TMap* /*dcsAliasMap*/) | |
193 | { | |
5ac93e67 | 194 | /// Process GMS alignment files. |
195 | /// Return failure (0) in case procession of some file has failed | |
968ce98e | 196 | |
5ac93e67 | 197 | UInt_t result = 1; |
968ce98e | 198 | TList* sources = Master()->GetFileSources(fgkSystem, fgkDataId); |
199 | TIter next(sources); | |
200 | TObjString* o(0x0); | |
201 | while ( ( o = static_cast<TObjString*>(next()) ) ) { | |
202 | TString fileName(Master()->GetFile(fgkSystem, fgkDataId, o->GetName())); | |
5ac93e67 | 203 | result *= ProcessFile(fileName); |
968ce98e | 204 | } |
205 | delete sources; | |
206 | ||
04aa997f | 207 | return result; |
208 | } | |
209 |