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