30 #include "AliAlignObjMatrix.h"
31 #include "AliGeomManager.h"
32 #include "AliCDBMetaData.h"
33 #include "AliCDBEntry.h"
35 #include <TTimeStamp.h>
38 #include <TClonesArray.h>
39 #include <TGeoManager.h>
40 #include <TObjString.h>
41 #include <Riostream.h>
57 static const TString kDataId =
"GMS";
65 static const TString kMatrixArrayName =
"GMSarray";
66 return kMatrixArrayName;
112 Master()->
Log(Form(
"Processing GMS file %s", fileName.Data()));
115 TFile
f(fileName.Data());
116 if ( !
f.IsOpen() ) {
117 Master()->
Log(Form(
"Cannot open file %s",fileName.Data()));
124 Master()->
Log(Form(
"TClonesArray not found in file %s",fileName.Data()));
130 TArrayI moduleIdToGMSIndex;
133 moduleIdToGMSIndex[i]=-1;
136 Bool_t useGlobalDelta = kTRUE;
139 TGeoManager *lGeometry = 0x0;
141 lGeometry = (TGeoManager*) geoEntry->GetObject();
144 AliGeomManager::SetGeometry(lGeometry);
145 useGlobalDelta = kFALSE;
155 TClonesArray* refArray = 0x0;
157 refArray = (TClonesArray*)cdbEntry->GetObject();
158 if (lGeometry && refArray) {
159 AliGeomManager::ApplyAlignObjsToGeom(*refArray);
165 for (Int_t i=0; i<array->GetEntriesFast(); i++ ) {
166 TGeoHMatrix* matrix = (TGeoHMatrix*)array->At(i);
167 printf(
"GMS local %i at %i \n",matrix->GetUniqueID(),i);
171 moduleIdToGMSIndex[matrix->GetUniqueID()]=i;
178 AliCDBMetaData metaData;
179 metaData.SetBeamPeriod(0);
180 metaData.SetResponsible(
"");
181 metaData.SetComment(
"This preprocessor fills GMS alignment objects.");
183 Bool_t result =
Master()->
Store(
"Align",
"GMS", (TObject*)data, &metaData, 0, 0);
190 lGeometry = (TGeoManager*) geoEntry->GetObject();
194 TGeoManager::UnlockGeometry();
196 AliGeomManager::SetGeometry(lGeometry);
197 useGlobalDelta = kFALSE;
200 AliAlignObjMatrix* refAOMat = 0x0;
202 TClonesArray* matLocalArray =
new TClonesArray(
"TGeoHMatrix",200);
203 if (lGeometry && refArray) {
206 for (Int_t i=0; i<refArray->GetEntriesFast(); i++) {
207 refAOMat = (AliAlignObjMatrix*)refArray->At(i);
209 TGeoHMatrix* reflMat =
new((*matLocalArray)[i]) TGeoHMatrix();
210 refAOMat->GetLocalMatrix(*reflMat);
211 printf(
"ref misalignment local \n");
216 AliAlignObjMatrix* newAOMat = 0x0;
219 if (geoEntry && cdbEntry) {
220 if (lGeometry && refArray) {
222 TClonesArray* newArray =
new TClonesArray(
"AliAlignObjMatrix", 200);
223 for (Int_t i=0; i<refArray->GetEntriesFast(); i++) {
224 refAOMat = (AliAlignObjMatrix*)refArray->At(i);
226 refAOMat->GetMatrix(refMat);
227 newAOMat =
new((*newArray)[i]) AliAlignObjMatrix(*refAOMat);
229 TString sName = refAOMat->GetSymName();
230 Int_t iGM = sName.Index(
"GM");
231 Int_t iLS = sName.Last(
'/');
233 sName.Remove(0,iGM+2);
234 Int_t iMod = sName.Atoi();
235 if (moduleIdToGMSIndex[iMod]>=0) {
236 AliAlignObjMatrix* gmsAOMat = (AliAlignObjMatrix*)data->At(moduleIdToGMSIndex[iMod]);
238 gmsAOMat->GetMatrix(gmsMat);
239 printf(
"GMS global delta %i %i\n",iMod,moduleIdToGMSIndex[iMod]);
241 printf(
"ref misalignment \n");
243 refMat.MultiplyLeft(&gmsMat);
244 printf(
"new misalignment gms*ref\n");
248 Master()->
Log(Form(
"Missing GMS entry for module %d",iMod));
250 newAOMat->SetMatrix(refMat);
253 newAOMat->SetLocalMatrix(*(TGeoHMatrix*)matLocalArray->At(i));
258 TString sMDComment(cdbEntry->GetMetaData()->GetComment());
259 sMDComment +=
" GMS";
261 metaData.SetComment(sMDComment);
263 result = result &&
Master()->
Store(
"Align",
"Data", newArray, &metaData, 0, 1);
269 Master()->
Log(
"Couldn't find TGeoManager in the specified CDB entry?");
274 Master()->
Log(
"Could not get Geometry from OCDB! Will not add a new MUON/Align/Data entry!");
276 Master()->
Log(
"Could not get GMS reference misalignment from OCDB! Will not add a new MUON/Align/Data entry!");
283 return (result!=kTRUE);
301 while ( ( o = static_cast<TObjString*>(next()) ) ) {
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
AliCDBEntry * GetFromOCDB(const char *pathLevel2, const char *pathLevel3)
Publish AliPreprocessor::GetFromOCDB function.
AliMUONPreprocessor * Master() const
Return the pointer to our master.
virtual ~AliMUONGMSSubprocessor()
AliCDBEntry * GetGeometryFromOCDB()
Publish AliPreprocessor::GetFromOCDB function.
TFile f("CalibObjects.root")
virtual UInt_t Process(TMap *)
Process this sub-task.
static const TString & GetMatrixArrayName()
The shuttle subprocessor for GMS data.
static const Int_t fgkSystem
The data system.
virtual Bool_t Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
Base class for a shuttle sub-task for MUON (either TRK or TRG)
static const TString & GetDataId()
static Int_t NofGeomModules()
Return number of geometry modules.
UInt_t ProcessFile(const TString &filename)
void Log(const char *message)
Publish AliPreprocessor::Log function.
AliMUONGMSSubprocessor(AliMUONPreprocessor *master)
TList * GetFileSources(Int_t system, const char *id)
Publish AliPreprocessor::GetFileSources function.
Bool_t Store(const char *pathLevel2, const char *pathLevel3, TObject *object, AliCDBMetaData *metaData, Int_t validityStart=0, Bool_t validityInfinite=kFALSE)
Publish AliPreprocessor::Store function.
AliMUONGeometryTransformer * fTransformer
Geometry transformer.
Shuttle preprocessor for MUON subsystems (TRK and TRG)