#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;
fMSDEp = obj.fMSDEp;
fList = obj.fList;
+
+ // initialize parameters ...
+ for(Int_t k=0;k<4*156;k++) {
+ fParameters[k]=obj.fParameters[k];
+ fErrors[k]=obj.fErrors[k];
+ fPulls[k]=obj.fPulls[k];
+ }
+
}
//________________________________________________________________________
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;
fMSDEp = other.fMSDEp;
fList = other.fList;
+
+ // initialize parameters ...
+ for(Int_t k=0;k<4*156;k++) {
+ fParameters[k]=other.fParameters[k];
+ fErrors[k]=other.fErrors[k];
+ fPulls[k]=other.fPulls[k];
+ }
return *this;
}
{
/// 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.};
-
-
+ 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;
fAlign->LocalFit(fTrackOk++,trackParams,0);
}
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};
- Double_t MSDEx[156] = {0};
- Double_t MSDEy[156] = {0};
- Double_t MSDEz[156] = {0};
- Double_t MSDEp[156] = {0};
- Double_t DEidErr[156] = {0};
- Double_t MSDExErr[156] = {0};
- Double_t MSDEyErr[156] = {0};
- Double_t MSDEzErr[156] = {0};
- Double_t MSDEpErr[156] = {0};
+ Double_t deId[156] = {0};
+ Double_t msdEx[156] = {0};
+ Double_t msdEy[156] = {0};
+ Double_t msdEz[156] = {0};
+ Double_t msdEp[156] = {0};
+ Double_t deIdErr[156] = {0};
+ Double_t msdExErr[156] = {0};
+ Double_t msdEyErr[156] = {0};
+ Double_t msdEzErr[156] = {0};
+ Double_t msdEpErr[156] = {0};
Int_t lNDetElem = 4*2+4*2+18*2+26*2+26*2;
Int_t lNDetElemCh[10] = {4,4,4,4,18,18,26,26,26,26};
// Int_t lSNDetElemCh[10] = {4,8,12,16,34,52,78,104,130,156};
Int_t idOffset = 0; // 400
Int_t lSDetElemCh = 0;
for(Int_t iDE=0; iDE<lNDetElem; iDE++){
- DEidErr[iDE] = 0.;
- DEid[iDE] = idOffset+100;
- DEid[iDE] += iDE;
+ deIdErr[iDE] = 0.;
+ deId[iDE] = idOffset+100;
+ deId[iDE] += iDE;
lSDetElemCh = 0;
for(Int_t iCh=0; iCh<9; iCh++){
lSDetElemCh += lNDetElemCh[iCh];
if (iDE>=lSDetElemCh) {
- DEid[iDE] += 100;
- DEid[iDE] -= lNDetElemCh[iCh];
+ deId[iDE] += 100;
+ deId[iDE] -= lNDetElemCh[iCh];
}
}
- MSDEx[iDE]=fParameters[3*iDE+0];
- MSDEy[iDE]=fParameters[3*iDE+1];
- MSDEz[iDE]=fParameters[3*iDE+3];
- MSDEp[iDE]=fParameters[3*iDE+2];
- MSDExErr[iDE]=(Double_t)fAlign->GetParError(3*iDE+0);
- MSDEyErr[iDE]=(Double_t)fAlign->GetParError(3*iDE+1);
- MSDEzErr[iDE]=(Double_t)fAlign->GetParError(3*iDE+3);
- MSDEpErr[iDE]=(Double_t)fAlign->GetParError(3*iDE+2);
- fMSDEx->SetPoint(iDE,DEid[iDE],fParameters[3*iDE+0]);
- fMSDEx->SetPoint(iDE,DEidErr[iDE],(Double_t)fAlign->GetParError(3*iDE+0));
- fMSDEy->SetPoint(iDE,DEid[iDE],fParameters[3*iDE+1]);
- fMSDEy->SetPoint(iDE,DEidErr[iDE],(Double_t)fAlign->GetParError(3*iDE+1));
- fMSDEp->SetPoint(iDE,DEid[iDE],fParameters[3*iDE+2]);
- fMSDEp->SetPoint(iDE,DEidErr[iDE],(Double_t)fAlign->GetParError(3*iDE+2));
- fMSDEz->SetPoint(iDE,DEid[iDE],fParameters[3*iDE+3]);
- fMSDEz->SetPoint(iDE,DEidErr[iDE],(Double_t)fAlign->GetParError(3*iDE+3));
+ msdEx[iDE]=fParameters[3*iDE+0];
+ msdEy[iDE]=fParameters[3*iDE+1];
+ msdEz[iDE]=fParameters[3*iDE+3];
+ msdEp[iDE]=fParameters[3*iDE+2];
+ msdExErr[iDE]=(Double_t)fAlign->GetParError(3*iDE+0);
+ msdEyErr[iDE]=(Double_t)fAlign->GetParError(3*iDE+1);
+ msdEzErr[iDE]=(Double_t)fAlign->GetParError(3*iDE+3);
+ msdEpErr[iDE]=(Double_t)fAlign->GetParError(3*iDE+2);
+ fMSDEx->SetPoint(iDE,deId[iDE],fParameters[3*iDE+0]);
+ fMSDEx->SetPoint(iDE,deIdErr[iDE],(Double_t)fAlign->GetParError(3*iDE+0));
+ fMSDEy->SetPoint(iDE,deId[iDE],fParameters[3*iDE+1]);
+ fMSDEy->SetPoint(iDE,deIdErr[iDE],(Double_t)fAlign->GetParError(3*iDE+1));
+ fMSDEp->SetPoint(iDE,deId[iDE],fParameters[3*iDE+2]);
+ fMSDEp->SetPoint(iDE,deIdErr[iDE],(Double_t)fAlign->GetParError(3*iDE+2));
+ fMSDEz->SetPoint(iDE,deId[iDE],fParameters[3*iDE+3]);
+ fMSDEz->SetPoint(iDE,deIdErr[iDE],(Double_t)fAlign->GetParError(3*iDE+3));
}
// 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();
+
+}