+//
+// If requested obtain the vertex position and vertex sigma_z from the CDB
+// This overwrites the settings from the Config.C
+ if (fUseVertexFromCDB) {
+ Double_t vtxPos[3] = {0., 0., 0.};
+ Double_t vtxSig[3] = {0., 0., 0.};
+ AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
+ if (entry) {
+ AliESDVertex* vertex = dynamic_cast<AliESDVertex*> (entry->GetObject());
+ if (vertex) {
+ if(vertex->GetXRes()>2.8) { // > pipe radius --> it's a dummy object, don't use it
+ entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD");
+ if (entry) vertex = dynamic_cast<AliESDVertex*> (entry->GetObject());
+ }
+ }
+ if (vertex) {
+ vertex->GetXYZ(vtxPos);
+ vertex->GetSigmaXYZ(vtxSig);
+ AliInfo("Overwriting Config.C vertex settings !");
+ AliInfo(Form("Vertex position from OCDB entry: x = %13.3f, y = %13.3f, z = %13.3f (sigma = %13.3f)\n",
+ vtxPos[0], vtxPos[1], vtxPos[2], vtxSig[2]));
+
+ AliGenerator *gen = gAlice->GetMCApp()->Generator();
+ gen->SetOrigin(vtxPos[0], vtxPos[1], vtxPos[2]); // vertex position
+ gen->SetSigmaZ(vtxSig[2]);
+ }
+ }
+ }
+