+/**************************************************************************
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+* *
+* Author: The ALICE Off-line Project. *
+* Contributors are mentioned in the code where appropriate. *
+* *
+* Permission to use, copy, modify and distribute this software and its *
+* documentation strictly for non-commercial purposes is hereby granted *
+* without fee, provided that the above copyright notice appears in all *
+* copies and that both the copyright notice and this permission notice *
+* appear in the supporting documentation. The authors make no claims *
+* about the suitability of this software for any purpose. It is *
+* provided "as is" without express or implied warranty. *
+**************************************************************************/
+
+// $Id$
+
//-----------------------------------------------------------------------------
/// \class AliMUONAlignmentTask
/// AliAnalysisTask to align the MUON spectrometer.
#include <TChain.h>
#include <TClonesArray.h>
#include <TGeoGlobalMagField.h>
+#include <TGeoManager.h>
#include <Riostream.h>
#include "AliAnalysisTask.h"
#include "AliESDMuonTrack.h"
#include "AliMagF.h"
#include "AliCDBManager.h"
+#include "AliGRPManager.h"
#include "AliCDBMetaData.h"
#include "AliCDBId.h"
#include "AliGeomManager.h"
// }
//________________________________________________________________________
-AliMUONAlignmentTask::AliMUONAlignmentTask(const char *name, const char *geofilename)
+AliMUONAlignmentTask::AliMUONAlignmentTask(const char *name, const char *geofilename, const char *defaultocdb, const char *misalignocdb)
: AliAnalysisTask(name, ""),
fESD(0x0),
fAlign(0x0),
fGeoFilename(geofilename),
+ fMisAlignOCDB(misalignocdb),
+ fDefaultOCDB(defaultocdb),
fTransform(0x0),
fTrackTot(0),
fTrackOk(0),
+ fLastRunNumber(-1),
fMSDEx(0x0),
fMSDEy(0x0),
fMSDEz(0x0),
fESD(0x0),
fAlign(0x0),
fGeoFilename(""),
+ fMisAlignOCDB(""),
+ fDefaultOCDB(""),
fTransform(0x0),
fTrackTot(0),
fTrackOk(0),
+ fLastRunNumber(-1),
fMSDEx(0x0),
fMSDEy(0x0),
fMSDEz(0x0),
fTransform = obj.fTransform;
fTrackTot = obj.fTrackTot;
fTrackOk = obj.fTrackOk;
+ fLastRunNumber = obj.fLastRunNumber;
fMSDEx = obj.fMSDEx;
fMSDEy = obj.fMSDEy;
fMSDEz = obj.fMSDEz;
fESD = other.fESD;
fAlign = other.fAlign;
fGeoFilename = other.fGeoFilename;
+ fMisAlignOCDB = other.fMisAlignOCDB;
+ fDefaultOCDB = other.fDefaultOCDB;
fTransform = other.fTransform;
fTrackTot = other.fTrackTot;
fTrackOk = other.fTrackOk;
+ fLastRunNumber = other.fLastRunNumber;
fMSDEx = other.fMSDEx;
fMSDEy = other.fMSDEy;
fMSDEz = other.fMSDEz;
{
/// Local initialization, called once per task on the client machine
/// where the analysis train is assembled
- AliMpCDB::LoadMpSegmentation();
-
- // Import TGeo geometry (needed by AliMUONTrackExtrap::ExtrapToVertex)
- if ( ! AliGeomManager::GetGeometry() ) {
- AliGeomManager::LoadGeometry(fGeoFilename.Data());
- if (! AliGeomManager::GetGeometry() ) {
- Error("MUONAlignment", "getting geometry from file %s failed", fGeoFilename.Data());
- return;
- }
- }
-
- // set mag field
- // waiting for mag field in CDB
- if (!TGeoGlobalMagField::Instance()->GetField()) {
- printf("Loading field map...\n");
- AliMagF* field = new AliMagF("Maps","Maps",2,0.,0., 10.,AliMagF::k5kG);
- TGeoGlobalMagField::Instance()->SetField(field);
- }
- // set the magnetic field for track extrapolations
- AliMUONTrackExtrap::SetField();
+ fLastRunNumber = 0;
+ // Prepare(fGeoFilename.Data(),fDefaultOCDB.Data(),fMisAlignOCDB.Data());
+ Prepare(fGeoFilename.Data(),"local://$ALICE_ROOT/OCDB",fMisAlignOCDB.Data());
+ fLastRunNumber = -1;
// Set initial values here, good guess may help convergence
// St 1
}
Double_t trackParams[8] = {0.,0.,0.,0.,0.,0.,0.,0.};
-
-
+ printf("ESD RunNumber %d , fLastRunNumber %d\n",fESD->GetRunNumber(),fLastRunNumber);
+ if (fESD->GetRunNumber()!=fLastRunNumber){
+ fLastRunNumber = fESD->GetRunNumber();
+ Prepare(fGeoFilename.Data(),fDefaultOCDB.Data(),fMisAlignOCDB.Data());
+ }
Int_t nTracks = Int_t(fESD->GetNumberOfMuonTracks());
// if (!event%100) cout << " there are " << nTracks << " tracks in event " << event << endl;
// fBenMom->Fill(1./invBenMom);
if (TMath::Abs(invBenMom)<=1.04) {
AliMUONTrack track;
+ printf("cero\n");
AliMUONESDInterface::ESDToMUON(*esdTrack, track);
+ printf("uno %p\n", fAlign);
fAlign->ProcessTrack(&track);
+ printf("dos\n");
fAlign->LocalFit(fTrackOk++,trackParams,0);
+ printf("tres\n");
}
fTrackTot++;
+ cout << "Processed " << fTrackTot << " Tracks." << endl;
}
// Post final data. Write histo list to a file with option "RECREATE"
}
//________________________________________________________________________
-void AliMUONAlignmentTask::Terminate(const Option_t*)
+void AliMUONAlignmentTask::FinishTaskOutput()
{
/// Called once per task on the client machine at the end of the analysis.
cout << "Done with GlobalFit " << endl;
- // Update pointers reading them from the output slot
- fList = (TList*)GetOutputData(0);
- fMSDEx = (TGraphErrors*)fList->At(0);
- fMSDEy = (TGraphErrors*)fList->At(1);
- fMSDEz = (TGraphErrors*)fList->At(2);
- fMSDEp = (TGraphErrors*)fList->At(3);
+// // Update pointers reading them from the output slot
+// fList = (TList*)GetOutputData(0);
+// fMSDEx = (TGraphErrors*)fList->At(0);
+// fMSDEy = (TGraphErrors*)fList->At(1);
+// fMSDEz = (TGraphErrors*)fList->At(2);
+// fMSDEp = (TGraphErrors*)fList->At(3);
// Store results
Double_t DEid[156] = {0};
// Post final data. Write histo list to a file with option "RECREATE"
PostData(0,fList);
-
// Re Align
AliMUONGeometryTransformer *newTransform = fAlign->ReAlign(fTransform,fParameters,true);
newTransform->WriteTransformations("transform2ReAlign.dat");
// CDB manager
AliCDBManager* cdbManager = AliCDBManager::Instance();
- cdbManager->SetDefaultStorage("local://ReAlignCDB");
+ cdbManager->SetDefaultStorage(fDefaultOCDB.Data());
+ cdbManager->SetSpecificStorage("MUON/Align/Data",fMisAlignOCDB.Data());
AliCDBMetaData* cdbData = new AliCDBMetaData();
cdbData->SetResponsible("Dimuon Offline project");
}
+//________________________________________________________________________
+void AliMUONAlignmentTask::Terminate(const Option_t*)
+{
+ /// Called once per task on the client machine at the end of the analysis.
+
+}
+
+//-----------------------------------------------------------------------
+void AliMUONAlignmentTask::Prepare(const char* geoFilename, const char* defaultOCDB, const char* misAlignOCDB)
+{
+ /// Set the geometry, the magnetic field, the mapping and the reconstruction parameters
+
+ // Load mapping
+ AliCDBManager* man = AliCDBManager::Instance();
+ man->SetDefaultStorage(defaultOCDB);
+ man->SetSpecificStorage("MUON/Align/Data",misAlignOCDB);
+ man->Print();
+ man->SetRun(fLastRunNumber);
+ if ( ! AliMpCDB::LoadDDLStore() ) {
+ Error("MUONRefit","Could not access mapping from OCDB !");
+ exit(-1);
+ }
+
+ // Import TGeo geometry (needed by AliMUONTrackExtrap::ExtrapToVertex)
+ if (!gGeoManager) {
+ AliGeomManager::LoadGeometry(geoFilename);
+ if (!gGeoManager) {
+ Error("AliMUONReAlignTask", "getting geometry from file %s failed", "generated/galice.root");
+ return;
+ }
+ }
+
+ // set mag field
+ if (!TGeoGlobalMagField::Instance()->GetField()) {
+ printf("Loading field map...\n");
+ AliGRPManager *grpMan = new AliGRPManager();
+ grpMan->ReadGRPEntry();
+ grpMan->SetMagField();
+ delete grpMan;
+ }
+ // set the magnetic field for track extrapolations
+ AliMUONTrackExtrap::SetField();
+
+}