#include "AliMUONGMSSubprocessor.h"
#include "AliMUONPreprocessor.h"
#include "AliMpConstants.h"
#include "AliAlignObjMatrix.h"
#include "AliGeomManager.h"
#include "AliCDBMetaData.h"
#include "AliCDBEntry.h"
#include <TTimeStamp.h>
#include <TFile.h>
#include <TArrayI.h>
#include <TClonesArray.h>
#include <TGeoManager.h>
#include <TObjString.h>
#include <Riostream.h>
ClassImp(AliMUONGMSSubprocessor)
const Int_t AliMUONGMSSubprocessor::fgkSystem = AliPreprocessor::kDCS;
const TString& AliMUONGMSSubprocessor::GetDataId()
{
static const TString kDataId = "GMS";
return kDataId;
}
const TString& AliMUONGMSSubprocessor::GetMatrixArrayName()
{
static const TString kMatrixArrayName = "GMSarray";
return kMatrixArrayName;
}
AliMUONGMSSubprocessor::AliMUONGMSSubprocessor(AliMUONPreprocessor* master)
: AliMUONVSubprocessor(master, "GMS", "Upload GMS matrices to OCDB"),
fTransformer(0)
{
}
AliMUONGMSSubprocessor::~AliMUONGMSSubprocessor()
{
delete fTransformer;
}
Bool_t AliMUONGMSSubprocessor::Initialize(Int_t ,
UInt_t , UInt_t )
{
if ( ! fTransformer ) {
fTransformer = new AliMUONGeometryTransformer();
fTransformer->CreateModules();
}
return kTRUE;
}
UInt_t AliMUONGMSSubprocessor::ProcessFile(const TString& fileName)
{
Master()->Log(Form("Processing GMS file %s", fileName.Data()));
TFile f(fileName.Data());
if ( ! f.IsOpen() ) {
Master()->Log(Form("Cannot open file %s",fileName.Data()));
return 1;
}
TClonesArray* array = (TClonesArray*)f.Get(GetMatrixArrayName());
if ( ! array ) {
Master()->Log(Form("TClonesArray not found in file %s",fileName.Data()));
return 2;
}
TArrayI moduleIdToGMSIndex;
moduleIdToGMSIndex.Set(AliMpConstants::NofGeomModules());
for (Int_t i=0; i<AliMpConstants::NofGeomModules(); i++){
moduleIdToGMSIndex[i]=-1;
}
Bool_t useGlobalDelta = kTRUE;
AliCDBEntry* geoEntry = Master()->GetGeometryFromOCDB();
TGeoManager *lGeometry = 0x0;
if (geoEntry) {
lGeometry = (TGeoManager*) geoEntry->GetObject();
if (lGeometry) {
AliGeomManager::SetGeometry(lGeometry);
useGlobalDelta = kFALSE;
}
}
AliMUONGeometryTransformer *lTransformer = new AliMUONGeometryTransformer();
AliCDBEntry* cdbEntry = Master()->GetFromOCDB("Align", "Baseline");
TClonesArray* refArray = 0x0;
if (cdbEntry) {
refArray = (TClonesArray*)cdbEntry->GetObject();
if (lGeometry && refArray) {
AliGeomManager::ApplyAlignObjsToGeom(*refArray);
lTransformer->LoadGeometryData();
}
}
for (Int_t i=0; i<array->GetEntriesFast(); i++ ) {
TGeoHMatrix* matrix = (TGeoHMatrix*)array->At(i);
printf("GMS local %i at %i \n",matrix->GetUniqueID(),i);
matrix->Print();
fTransformer->AddMisAlignModule(matrix->GetUniqueID(), *matrix, kTRUE);
lTransformer->AddMisAlignModule(matrix->GetUniqueID(), *matrix, useGlobalDelta);
moduleIdToGMSIndex[matrix->GetUniqueID()]=i;
}
TClonesArray* data = const_cast< TClonesArray*>(fTransformer->GetMisAlignmentData());
Master()->Log("Storing GMS");
AliCDBMetaData metaData;
metaData.SetBeamPeriod(0);
metaData.SetResponsible("");
metaData.SetComment("This preprocessor fills GMS alignment objects.");
Bool_t result = Master()->Store("Align", "GMS", (TObject*)data, &metaData, 0, 0);
if (geoEntry) {
lGeometry = (TGeoManager*) geoEntry->GetObject();
}
if (lGeometry) {
TGeoManager::UnlockGeometry();
AliGeomManager::SetGeometry(lGeometry);
useGlobalDelta = kFALSE;
}
AliAlignObjMatrix* refAOMat = 0x0;
TClonesArray* matLocalArray = new TClonesArray("TGeoHMatrix",200);
if (lGeometry && refArray) {
refArray->Sort();
for (Int_t i=0; i<refArray->GetEntriesFast(); i++) {
refAOMat = (AliAlignObjMatrix*)refArray->At(i);
refAOMat->Print("");
TGeoHMatrix* reflMat = new((*matLocalArray)[i]) TGeoHMatrix();
refAOMat->GetLocalMatrix(*reflMat);
printf("ref misalignment local \n");
reflMat->Print();
}
}
AliAlignObjMatrix* newAOMat = 0x0;
data = const_cast< TClonesArray*>(lTransformer->GetMisAlignmentData());
if (geoEntry && cdbEntry) {
if (lGeometry && refArray) {
TClonesArray* newArray = new TClonesArray("AliAlignObjMatrix", 200);
for (Int_t i=0; i<refArray->GetEntriesFast(); i++) {
refAOMat = (AliAlignObjMatrix*)refArray->At(i);
TGeoHMatrix refMat;
refAOMat->GetMatrix(refMat);
newAOMat = new((*newArray)[i]) AliAlignObjMatrix(*refAOMat);
TString sName = refAOMat->GetSymName();
Int_t iGM = sName.Index("GM");
Int_t iLS = sName.Last('/');
if (iLS<iGM) {
sName.Remove(0,iGM+2);
Int_t iMod = sName.Atoi();
if (moduleIdToGMSIndex[iMod]>=0) {
AliAlignObjMatrix* gmsAOMat = (AliAlignObjMatrix*)data->At(moduleIdToGMSIndex[iMod]);
TGeoHMatrix gmsMat;
gmsAOMat->GetMatrix(gmsMat);
printf("GMS global delta %i %i\n",iMod,moduleIdToGMSIndex[iMod]);
gmsMat.Print();
printf("ref misalignment \n");
refMat.Print();
refMat.MultiplyLeft(&gmsMat);
printf("new misalignment gms*ref\n");
refMat.Print();
}
else {
Master()->Log(Form("Missing GMS entry for module %d",iMod));
}
newAOMat->SetMatrix(refMat);
}
else {
newAOMat->SetLocalMatrix(*(TGeoHMatrix*)matLocalArray->At(i));
}
}
TString sMDComment(cdbEntry->GetMetaData()->GetComment());
sMDComment += " GMS";
Master()->Log("Storing MisAlignment");
metaData.SetComment(sMDComment);
result = result && Master()->Store("Align", "Data", newArray, &metaData, 0, 1);
}
else {
if (!refArray)
Master()->Log("Empty entry?");
if (!lGeometry)
Master()->Log("Couldn't find TGeoManager in the specified CDB entry?");
}
}
else {
if (!geoEntry)
Master()->Log("Could not get Geometry from OCDB! Will not add a new MUON/Align/Data entry!");
if (!cdbEntry)
Master()->Log("Could not get GMS reference misalignment from OCDB! Will not add a new MUON/Align/Data entry!");
}
fTransformer->ClearMisAlignmentData();
return (result!=kTRUE);
}
UInt_t AliMUONGMSSubprocessor::Process(TMap* )
{
UInt_t result = 1;
TList* sources = Master()->GetFileSources(fgkSystem, GetDataId());
TIter next(sources);
TObjString* o(0x0);
while ( ( o = static_cast<TObjString*>(next()) ) ) {
TString fileName(Master()->GetFile(fgkSystem, GetDataId(), o->GetName()));
result *= ProcessFile(fileName);
}
delete sources;
return result;
}
AliMUONGMSSubprocessor.cxx:1 AliMUONGMSSubprocessor.cxx:2 AliMUONGMSSubprocessor.cxx:3 AliMUONGMSSubprocessor.cxx:4 AliMUONGMSSubprocessor.cxx:5 AliMUONGMSSubprocessor.cxx:6 AliMUONGMSSubprocessor.cxx:7 AliMUONGMSSubprocessor.cxx:8 AliMUONGMSSubprocessor.cxx:9 AliMUONGMSSubprocessor.cxx:10 AliMUONGMSSubprocessor.cxx:11 AliMUONGMSSubprocessor.cxx:12 AliMUONGMSSubprocessor.cxx:13 AliMUONGMSSubprocessor.cxx:14 AliMUONGMSSubprocessor.cxx:15 AliMUONGMSSubprocessor.cxx:16 AliMUONGMSSubprocessor.cxx:17 AliMUONGMSSubprocessor.cxx:18 AliMUONGMSSubprocessor.cxx:19 AliMUONGMSSubprocessor.cxx:20 AliMUONGMSSubprocessor.cxx:21 AliMUONGMSSubprocessor.cxx:22 AliMUONGMSSubprocessor.cxx:23 AliMUONGMSSubprocessor.cxx:24 AliMUONGMSSubprocessor.cxx:25 AliMUONGMSSubprocessor.cxx:26 AliMUONGMSSubprocessor.cxx:27 AliMUONGMSSubprocessor.cxx:28 AliMUONGMSSubprocessor.cxx:29 AliMUONGMSSubprocessor.cxx:30 AliMUONGMSSubprocessor.cxx:31 AliMUONGMSSubprocessor.cxx:32 AliMUONGMSSubprocessor.cxx:33 AliMUONGMSSubprocessor.cxx:34 AliMUONGMSSubprocessor.cxx:35 AliMUONGMSSubprocessor.cxx:36 AliMUONGMSSubprocessor.cxx:37 AliMUONGMSSubprocessor.cxx:38 AliMUONGMSSubprocessor.cxx:39 AliMUONGMSSubprocessor.cxx:40 AliMUONGMSSubprocessor.cxx:41 AliMUONGMSSubprocessor.cxx:42 AliMUONGMSSubprocessor.cxx:43 AliMUONGMSSubprocessor.cxx:44 AliMUONGMSSubprocessor.cxx:45 AliMUONGMSSubprocessor.cxx:46 AliMUONGMSSubprocessor.cxx:47 AliMUONGMSSubprocessor.cxx:48 AliMUONGMSSubprocessor.cxx:49 AliMUONGMSSubprocessor.cxx:50 AliMUONGMSSubprocessor.cxx:51 AliMUONGMSSubprocessor.cxx:52 AliMUONGMSSubprocessor.cxx:53 AliMUONGMSSubprocessor.cxx:54 AliMUONGMSSubprocessor.cxx:55 AliMUONGMSSubprocessor.cxx:56 AliMUONGMSSubprocessor.cxx:57 AliMUONGMSSubprocessor.cxx:58 AliMUONGMSSubprocessor.cxx:59 AliMUONGMSSubprocessor.cxx:60 AliMUONGMSSubprocessor.cxx:61 AliMUONGMSSubprocessor.cxx:62 AliMUONGMSSubprocessor.cxx:63 AliMUONGMSSubprocessor.cxx:64 AliMUONGMSSubprocessor.cxx:65 AliMUONGMSSubprocessor.cxx:66 AliMUONGMSSubprocessor.cxx:67 AliMUONGMSSubprocessor.cxx:68 AliMUONGMSSubprocessor.cxx:69 AliMUONGMSSubprocessor.cxx:70 AliMUONGMSSubprocessor.cxx:71 AliMUONGMSSubprocessor.cxx:72 AliMUONGMSSubprocessor.cxx:73 AliMUONGMSSubprocessor.cxx:74 AliMUONGMSSubprocessor.cxx:75 AliMUONGMSSubprocessor.cxx:76 AliMUONGMSSubprocessor.cxx:77 AliMUONGMSSubprocessor.cxx:78 AliMUONGMSSubprocessor.cxx:79 AliMUONGMSSubprocessor.cxx:80 AliMUONGMSSubprocessor.cxx:81 AliMUONGMSSubprocessor.cxx:82 AliMUONGMSSubprocessor.cxx:83 AliMUONGMSSubprocessor.cxx:84 AliMUONGMSSubprocessor.cxx:85 AliMUONGMSSubprocessor.cxx:86 AliMUONGMSSubprocessor.cxx:87 AliMUONGMSSubprocessor.cxx:88 AliMUONGMSSubprocessor.cxx:89 AliMUONGMSSubprocessor.cxx:90 AliMUONGMSSubprocessor.cxx:91 AliMUONGMSSubprocessor.cxx:92 AliMUONGMSSubprocessor.cxx:93 AliMUONGMSSubprocessor.cxx:94 AliMUONGMSSubprocessor.cxx:95 AliMUONGMSSubprocessor.cxx:96 AliMUONGMSSubprocessor.cxx:97 AliMUONGMSSubprocessor.cxx:98 AliMUONGMSSubprocessor.cxx:99 AliMUONGMSSubprocessor.cxx:100 AliMUONGMSSubprocessor.cxx:101 AliMUONGMSSubprocessor.cxx:102 AliMUONGMSSubprocessor.cxx:103 AliMUONGMSSubprocessor.cxx:104 AliMUONGMSSubprocessor.cxx:105 AliMUONGMSSubprocessor.cxx:106 AliMUONGMSSubprocessor.cxx:107 AliMUONGMSSubprocessor.cxx:108 AliMUONGMSSubprocessor.cxx:109 AliMUONGMSSubprocessor.cxx:110 AliMUONGMSSubprocessor.cxx:111 AliMUONGMSSubprocessor.cxx:112 AliMUONGMSSubprocessor.cxx:113 AliMUONGMSSubprocessor.cxx:114 AliMUONGMSSubprocessor.cxx:115 AliMUONGMSSubprocessor.cxx:116 AliMUONGMSSubprocessor.cxx:117 AliMUONGMSSubprocessor.cxx:118 AliMUONGMSSubprocessor.cxx:119 AliMUONGMSSubprocessor.cxx:120 AliMUONGMSSubprocessor.cxx:121 AliMUONGMSSubprocessor.cxx:122 AliMUONGMSSubprocessor.cxx:123 AliMUONGMSSubprocessor.cxx:124 AliMUONGMSSubprocessor.cxx:125 AliMUONGMSSubprocessor.cxx:126 AliMUONGMSSubprocessor.cxx:127 AliMUONGMSSubprocessor.cxx:128 AliMUONGMSSubprocessor.cxx:129 AliMUONGMSSubprocessor.cxx:130 AliMUONGMSSubprocessor.cxx:131 AliMUONGMSSubprocessor.cxx:132 AliMUONGMSSubprocessor.cxx:133 AliMUONGMSSubprocessor.cxx:134 AliMUONGMSSubprocessor.cxx:135 AliMUONGMSSubprocessor.cxx:136 AliMUONGMSSubprocessor.cxx:137 AliMUONGMSSubprocessor.cxx:138 AliMUONGMSSubprocessor.cxx:139 AliMUONGMSSubprocessor.cxx:140 AliMUONGMSSubprocessor.cxx:141 AliMUONGMSSubprocessor.cxx:142 AliMUONGMSSubprocessor.cxx:143 AliMUONGMSSubprocessor.cxx:144 AliMUONGMSSubprocessor.cxx:145 AliMUONGMSSubprocessor.cxx:146 AliMUONGMSSubprocessor.cxx:147 AliMUONGMSSubprocessor.cxx:148 AliMUONGMSSubprocessor.cxx:149 AliMUONGMSSubprocessor.cxx:150 AliMUONGMSSubprocessor.cxx:151 AliMUONGMSSubprocessor.cxx:152 AliMUONGMSSubprocessor.cxx:153 AliMUONGMSSubprocessor.cxx:154 AliMUONGMSSubprocessor.cxx:155 AliMUONGMSSubprocessor.cxx:156 AliMUONGMSSubprocessor.cxx:157 AliMUONGMSSubprocessor.cxx:158 AliMUONGMSSubprocessor.cxx:159 AliMUONGMSSubprocessor.cxx:160 AliMUONGMSSubprocessor.cxx:161 AliMUONGMSSubprocessor.cxx:162 AliMUONGMSSubprocessor.cxx:163 AliMUONGMSSubprocessor.cxx:164 AliMUONGMSSubprocessor.cxx:165 AliMUONGMSSubprocessor.cxx:166 AliMUONGMSSubprocessor.cxx:167 AliMUONGMSSubprocessor.cxx:168 AliMUONGMSSubprocessor.cxx:169 AliMUONGMSSubprocessor.cxx:170 AliMUONGMSSubprocessor.cxx:171 AliMUONGMSSubprocessor.cxx:172 AliMUONGMSSubprocessor.cxx:173 AliMUONGMSSubprocessor.cxx:174 AliMUONGMSSubprocessor.cxx:175 AliMUONGMSSubprocessor.cxx:176 AliMUONGMSSubprocessor.cxx:177 AliMUONGMSSubprocessor.cxx:178 AliMUONGMSSubprocessor.cxx:179 AliMUONGMSSubprocessor.cxx:180 AliMUONGMSSubprocessor.cxx:181 AliMUONGMSSubprocessor.cxx:182 AliMUONGMSSubprocessor.cxx:183 AliMUONGMSSubprocessor.cxx:184 AliMUONGMSSubprocessor.cxx:185 AliMUONGMSSubprocessor.cxx:186 AliMUONGMSSubprocessor.cxx:187 AliMUONGMSSubprocessor.cxx:188 AliMUONGMSSubprocessor.cxx:189 AliMUONGMSSubprocessor.cxx:190 AliMUONGMSSubprocessor.cxx:191 AliMUONGMSSubprocessor.cxx:192 AliMUONGMSSubprocessor.cxx:193 AliMUONGMSSubprocessor.cxx:194 AliMUONGMSSubprocessor.cxx:195 AliMUONGMSSubprocessor.cxx:196 AliMUONGMSSubprocessor.cxx:197 AliMUONGMSSubprocessor.cxx:198 AliMUONGMSSubprocessor.cxx:199 AliMUONGMSSubprocessor.cxx:200 AliMUONGMSSubprocessor.cxx:201 AliMUONGMSSubprocessor.cxx:202 AliMUONGMSSubprocessor.cxx:203 AliMUONGMSSubprocessor.cxx:204 AliMUONGMSSubprocessor.cxx:205 AliMUONGMSSubprocessor.cxx:206 AliMUONGMSSubprocessor.cxx:207 AliMUONGMSSubprocessor.cxx:208 AliMUONGMSSubprocessor.cxx:209 AliMUONGMSSubprocessor.cxx:210 AliMUONGMSSubprocessor.cxx:211 AliMUONGMSSubprocessor.cxx:212 AliMUONGMSSubprocessor.cxx:213 AliMUONGMSSubprocessor.cxx:214 AliMUONGMSSubprocessor.cxx:215 AliMUONGMSSubprocessor.cxx:216 AliMUONGMSSubprocessor.cxx:217 AliMUONGMSSubprocessor.cxx:218 AliMUONGMSSubprocessor.cxx:219 AliMUONGMSSubprocessor.cxx:220 AliMUONGMSSubprocessor.cxx:221 AliMUONGMSSubprocessor.cxx:222 AliMUONGMSSubprocessor.cxx:223 AliMUONGMSSubprocessor.cxx:224 AliMUONGMSSubprocessor.cxx:225 AliMUONGMSSubprocessor.cxx:226 AliMUONGMSSubprocessor.cxx:227 AliMUONGMSSubprocessor.cxx:228 AliMUONGMSSubprocessor.cxx:229 AliMUONGMSSubprocessor.cxx:230 AliMUONGMSSubprocessor.cxx:231 AliMUONGMSSubprocessor.cxx:232 AliMUONGMSSubprocessor.cxx:233 AliMUONGMSSubprocessor.cxx:234 AliMUONGMSSubprocessor.cxx:235 AliMUONGMSSubprocessor.cxx:236 AliMUONGMSSubprocessor.cxx:237 AliMUONGMSSubprocessor.cxx:238 AliMUONGMSSubprocessor.cxx:239 AliMUONGMSSubprocessor.cxx:240 AliMUONGMSSubprocessor.cxx:241 AliMUONGMSSubprocessor.cxx:242 AliMUONGMSSubprocessor.cxx:243 AliMUONGMSSubprocessor.cxx:244 AliMUONGMSSubprocessor.cxx:245 AliMUONGMSSubprocessor.cxx:246 AliMUONGMSSubprocessor.cxx:247 AliMUONGMSSubprocessor.cxx:248 AliMUONGMSSubprocessor.cxx:249 AliMUONGMSSubprocessor.cxx:250 AliMUONGMSSubprocessor.cxx:251 AliMUONGMSSubprocessor.cxx:252 AliMUONGMSSubprocessor.cxx:253 AliMUONGMSSubprocessor.cxx:254 AliMUONGMSSubprocessor.cxx:255 AliMUONGMSSubprocessor.cxx:256 AliMUONGMSSubprocessor.cxx:257 AliMUONGMSSubprocessor.cxx:258 AliMUONGMSSubprocessor.cxx:259 AliMUONGMSSubprocessor.cxx:260 AliMUONGMSSubprocessor.cxx:261 AliMUONGMSSubprocessor.cxx:262 AliMUONGMSSubprocessor.cxx:263 AliMUONGMSSubprocessor.cxx:264 AliMUONGMSSubprocessor.cxx:265 AliMUONGMSSubprocessor.cxx:266 AliMUONGMSSubprocessor.cxx:267 AliMUONGMSSubprocessor.cxx:268 AliMUONGMSSubprocessor.cxx:269 AliMUONGMSSubprocessor.cxx:270 AliMUONGMSSubprocessor.cxx:271 AliMUONGMSSubprocessor.cxx:272 AliMUONGMSSubprocessor.cxx:273 AliMUONGMSSubprocessor.cxx:274 AliMUONGMSSubprocessor.cxx:275 AliMUONGMSSubprocessor.cxx:276 AliMUONGMSSubprocessor.cxx:277 AliMUONGMSSubprocessor.cxx:278 AliMUONGMSSubprocessor.cxx:279 AliMUONGMSSubprocessor.cxx:280 AliMUONGMSSubprocessor.cxx:281 AliMUONGMSSubprocessor.cxx:282 AliMUONGMSSubprocessor.cxx:283 AliMUONGMSSubprocessor.cxx:284 AliMUONGMSSubprocessor.cxx:285 AliMUONGMSSubprocessor.cxx:286 AliMUONGMSSubprocessor.cxx:287 AliMUONGMSSubprocessor.cxx:288 AliMUONGMSSubprocessor.cxx:289 AliMUONGMSSubprocessor.cxx:290 AliMUONGMSSubprocessor.cxx:291 AliMUONGMSSubprocessor.cxx:292 AliMUONGMSSubprocessor.cxx:293 AliMUONGMSSubprocessor.cxx:294 AliMUONGMSSubprocessor.cxx:295 AliMUONGMSSubprocessor.cxx:296 AliMUONGMSSubprocessor.cxx:297 AliMUONGMSSubprocessor.cxx:298 AliMUONGMSSubprocessor.cxx:299 AliMUONGMSSubprocessor.cxx:300 AliMUONGMSSubprocessor.cxx:301 AliMUONGMSSubprocessor.cxx:302 AliMUONGMSSubprocessor.cxx:303 AliMUONGMSSubprocessor.cxx:304 AliMUONGMSSubprocessor.cxx:305 AliMUONGMSSubprocessor.cxx:306 AliMUONGMSSubprocessor.cxx:307 AliMUONGMSSubprocessor.cxx:308 AliMUONGMSSubprocessor.cxx:309