]>
Commit | Line | Data |
---|---|---|
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 | //----------------------------------------------------------------------------- | |
19 | // Class AliMUONGMSSubprocessor | |
20 | // ----------------------------- | |
21 | // The shuttle subprocessor for GMS data | |
22 | // Author: Ivana Hrivnacova, IPN Orsay | |
23 | // 16/09/2006 | |
24 | //----------------------------------------------------------------------------- | |
25 | ||
26 | #include "AliMUONGMSSubprocessor.h" | |
27 | #include "AliMUONPreprocessor.h" | |
28 | ||
29 | #include "AliCDBMetaData.h" | |
30 | ||
31 | #include <TTimeStamp.h> | |
32 | #include <TFile.h> | |
33 | #include <TClonesArray.h> | |
34 | #include <TObjString.h> | |
35 | #include <Riostream.h> | |
36 | ||
37 | /// \cond CLASSIMP | |
38 | ClassImp(AliMUONGMSSubprocessor) | |
39 | /// \endcond | |
40 | ||
41 | const Int_t AliMUONGMSSubprocessor::fgkSystem = AliPreprocessor::kDCS; | |
42 | const TString AliMUONGMSSubprocessor::fgkDataId = "GMS"; | |
43 | const TString AliMUONGMSSubprocessor::fgkMatrixArrayName = "GMSarray"; | |
44 | ||
45 | //______________________________________________________________________________ | |
46 | AliMUONGMSSubprocessor::AliMUONGMSSubprocessor(AliMUONPreprocessor* master) | |
47 | : AliMUONVSubprocessor(master, "GMS", "Upload GMS matrices to OCDB"), | |
48 | fTransformer(0) | |
49 | { | |
50 | /// Constructor | |
51 | } | |
52 | ||
53 | //______________________________________________________________________________ | |
54 | AliMUONGMSSubprocessor::~AliMUONGMSSubprocessor() | |
55 | { | |
56 | /// Destructor | |
57 | ||
58 | delete fTransformer; | |
59 | } | |
60 | ||
61 | ||
62 | // | |
63 | // private methods | |
64 | // | |
65 | ||
66 | ||
67 | //______________________________________________________________________________ | |
68 | void AliMUONGMSSubprocessor::Initialize(Int_t /*run*/, | |
69 | UInt_t /*startTime*/, UInt_t /*endTime*/) | |
70 | { | |
71 | /// Instantiate geometry transformer | |
72 | ||
73 | if ( ! fTransformer ) { | |
74 | fTransformer = new AliMUONGeometryTransformer(); | |
75 | fTransformer->CreateModules(); | |
76 | } | |
77 | } | |
78 | ||
79 | //______________________________________________________________________________ | |
80 | UInt_t AliMUONGMSSubprocessor::ProcessFile(const TString& fileName) | |
81 | { | |
82 | /// Convert TGeoHMatrix to AliAlignObjMatrix and fill them into AliTestDataDCS object | |
83 | ||
84 | Master()->Log(Form("Processing GMS file %s", fileName.Data())); | |
85 | ||
86 | // Open root file | |
87 | TFile f(fileName.Data()); | |
88 | if ( ! f.IsOpen() ) { | |
89 | Master()->Log(Form("Cannot open file %s",fileName.Data())); | |
90 | return 1; | |
91 | } | |
92 | ||
93 | // Get array with matrices | |
94 | TClonesArray* array = (TClonesArray*)f.Get(fgkMatrixArrayName); | |
95 | if ( ! array ) { | |
96 | Master()->Log(Form("TClonesArray not found in file %s",fileName.Data())); | |
97 | return 2; | |
98 | } | |
99 | ||
100 | // Convert matrices into Alice alignment objects | |
101 | for (Int_t i=0; i<array->GetEntriesFast(); i++ ) { | |
102 | TGeoHMatrix* matrix = (TGeoHMatrix*)array->At(i); | |
103 | fTransformer->AddMisAlignModule(matrix->GetUniqueID(), *matrix); | |
104 | } | |
105 | TObject* data = const_cast< TClonesArray*>(fTransformer->GetMisAlignmentData()); | |
106 | ||
107 | //Now we have to store the final CDB file | |
108 | Master()->Log("Storing GMS"); | |
109 | AliCDBMetaData metaData; | |
110 | metaData.SetBeamPeriod(0); | |
111 | metaData.SetResponsible(""); | |
112 | metaData.SetComment("This preprocessor fills GMS alignment objects."); | |
113 | ||
114 | Bool_t result = Master()->Store("SHUTTLE", "GMS", data, &metaData, 0, 0); | |
115 | ||
116 | // Clear MisAlignArray in transformer | |
117 | fTransformer->ClearMisAlignmentData(); | |
118 | ||
119 | return (result!=kTRUE); | |
120 | } | |
121 | ||
122 | // | |
123 | // public methods | |
124 | // | |
125 | ||
126 | ||
127 | //______________________________________________________________________________ | |
128 | UInt_t AliMUONGMSSubprocessor::Process(TMap* /*dcsAliasMap*/) | |
129 | { | |
130 | /// Process GMS alignment files. | |
131 | /// Return failure (0) in case procession of some file has failed | |
132 | ||
133 | UInt_t result = 1; | |
134 | TList* sources = Master()->GetFileSources(fgkSystem, fgkDataId); | |
135 | TIter next(sources); | |
136 | TObjString* o(0x0); | |
137 | while ( ( o = static_cast<TObjString*>(next()) ) ) { | |
138 | TString fileName(Master()->GetFile(fgkSystem, fgkDataId, o->GetName())); | |
139 | result *= ProcessFile(fileName); | |
140 | } | |
141 | delete sources; | |
142 | ||
143 | return result; | |
144 | } | |
145 |