#include "AliMUONVDigit.h"
#include "AliMUONVDigitStore.h"
#include "AliMUONLocalTrigger.h"
+#include "AliMUONTriggerTrack.h"
#include "AliMUONVTriggerStore.h"
+#include "AliMUONVTriggerTrackStore.h"
#include "AliMUON2DMapIterator.h"
#include "AliMUONTrackParam.h"
#include "AliMUONTrackExtrap.h"
#include "AliMUONTracker.h"
#include "AliMUONRecoParam.h"
#include "AliMUONVTrackReconstructor.h"
+#include "AliMUONCDB.h"
#include "AliMpExMapIterator.h"
#include "AliMpVSegmentation.h"
#include "AliMpSegmentation.h"
-#include "AliMpIntPair.h"
#include "AliMpPad.h"
#include "AliESDEvent.h"
#include "AliESDMuonPad.h"
#include "AliLog.h"
+#include <TROOT.h>
#include <TClass.h>
#include <TIterator.h>
#include <TMath.h>
#include <TMatrixD.h>
#include <Riostream.h>
+#include <TGeoGlobalMagField.h>
+#include <TVirtualMagField.h>
//-----------------------------------------------------------------------------
/// \class AliMUONESDInterface
/// 2) loading a whole ESDEvent and using the finders and/or the iterators
/// to access the corresponding MUON objects
///
+/// note: You can set the recoParam used to refit the MUON track with ResetTracker(...);
+/// By default we use Kalman filter + Smoother
+///
/// \author Philippe Pillot
//-----------------------------------------------------------------------------
+using std::endl;
+using std::cout;
/// \cond CLASSIMP
ClassImp(AliMUONESDInterface)
/// \endcond
+AliMUONRecoParam* AliMUONESDInterface::fgRecoParam = 0x0;
AliMUONVTrackReconstructor* AliMUONESDInterface::fgTracker = 0x0;
TString AliMUONESDInterface::fgTrackStoreName = "AliMUONTrackStoreV1";
TString AliMUONESDInterface::fgClusterStoreName = "AliMUONClusterStoreV2";
TString AliMUONESDInterface::fgDigitStoreName = "AliMUONDigitStoreV2R";
TString AliMUONESDInterface::fgTriggerStoreName = "AliMUONTriggerStoreV1";
+TString AliMUONESDInterface::fgTriggerTrackStoreName = "AliMUONTriggerTrackStoreV1";
//_____________________________________________________________________________
AliMUONESDInterface::AliMUONESDInterface()
: TObject(),
- fTracks(0x0),
- fDigits(0x0),
- fTriggers(0x0),
- fClusterMap(0x0),
- fDigitMap(0x0)
+fTracks(0x0),
+fDigits(0x0),
+fTriggers(0x0),
+fClusterMap(0x0),
+fDigitMap(0x0)
{
/// Default constructor
}
}
//_____________________________________________________________________________
-void AliMUONESDInterface::LoadEvent(AliESDEvent& esdEvent)
+void AliMUONESDInterface::LoadEvent(AliESDEvent& esdEvent, Bool_t refit)
{
/// Extract MUON data from the given ESD event
// reset data members
Reset();
+ // loop over ESD pads and fill the digit store
+ for (Int_t iPad = 0; iPad < esdEvent.GetNumberOfMuonPads(); iPad++)
+ Add(*(esdEvent.GetMuonPad(iPad)), *fDigits);
+
// loop over ESD tracks and fill the stores
- Int_t nTracks = (Int_t) esdEvent.GetNumberOfMuonTracks();
- for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
+ for (Int_t iTrack = 0; iTrack < esdEvent.GetNumberOfMuonTracks(); iTrack++) {
// get ESD track
AliESDMuonTrack* esdTrack = esdEvent.GetMuonTrack(iTrack);
if (!esdTrack->ContainTrackerData()) continue;
// add it to track store
- AliMUONTrack* track = Add(*esdTrack, *fTracks);
+ AliMUONTrack* track = Add(*esdTrack, *fTracks, refit);
// prepare cluster map
AliMpExMap* cMap = new AliMpExMap;
dMaps->SetOwner(kTRUE);
fDigitMap->Add(esdTrack->GetUniqueID(), dMaps);
- // loop over ESD clusters
- Int_t nClusters = esdTrack->GetNClusters();
- for (Int_t iCluster = 0; iCluster < nClusters; iCluster++) {
+ // loop over clusters
+ for (Int_t iCluster = 0; iCluster < track->GetNClusters(); iCluster++) {
- // get ESD cluster
- AliESDMuonCluster *esdCluster = (AliESDMuonCluster*) esdTrack->GetClusters().UncheckedAt(iCluster);
-
- // get the corresponding MUON cluster
- AliMUONVCluster* cluster = FindClusterInTrack(*track, esdCluster->GetUniqueID());
+ // get cluster
+ AliMUONVCluster* cluster = ((AliMUONTrackParam*)track->GetTrackParamAtCluster()->UncheckedAt(iCluster))->GetClusterPtr();
// fill cluster map
cMap->Add(cluster->GetUniqueID(), cluster);
// prepare digit map
AliMpExMap* dMap =new AliMpExMap;
dMap->SetOwner(kFALSE);
- dMaps->Add(esdCluster->GetUniqueID(), dMap);
+ dMaps->Add(cluster->GetUniqueID(), dMap);
- // loop over ESD pads
- Int_t nPads = esdCluster->GetNPads();
- for (Int_t iPad = 0; iPad < nPads; iPad++) {
-
- // get ESD pad
- AliESDMuonPad *esdPad = (AliESDMuonPad*) esdCluster->GetPads().UncheckedAt(iPad);
+ // loop over digits
+ for (Int_t iDigit = 0; iDigit < cluster->GetNDigits(); iDigit++) {
- // add it to digit store
- AliMUONVDigit* digit = Add(*esdPad, *fDigits);
+ // find the digit
+ AliMUONVDigit* digit = fDigits->FindObject(cluster->GetDigitId(iDigit));
// fill digit map
- if (digit) dMap->Add(esdPad->GetUniqueID(), digit);
- else dMap->Add(esdPad->GetUniqueID(), fDigits->FindObject(esdPad->GetUniqueID()));
+ if (digit) dMap->Add(digit->GetUniqueID(), digit);
+ else AliError("a digit is missing");
} // end of loop over pads
return fTriggers ? fTriggers->GetSize() : 0;
}
+//___________________________________________________________________________
+Bool_t AliMUONESDInterface::DigitsStored(UInt_t trackId) const
+{
+ /// return kTRUE if digits have been stored for all clusters of track "trackId"
+ AliMUONVCluster *cluster;
+ TIter next(CreateClusterIterator(trackId));
+ while ((cluster = static_cast<AliMUONVCluster*>(next())))
+ if (cluster->GetNDigits() == 0) return kFALSE;
+ return kTRUE;
+}
+
//___________________________________________________________________________
AliMUONTrack* AliMUONESDInterface::FindTrack(UInt_t trackId) const
{
return fTriggers ? fTriggers->CreateLocalIterator() : 0x0;
}
-//___________________________________________________________________________
-AliMUONVCluster* AliMUONESDInterface::FindClusterInTrack(const AliMUONTrack& track, UInt_t clusterId) const
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
+// static methods //
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
+
+//_____________________________________________________________________________
+void AliMUONESDInterface::ResetTracker(const AliMUONRecoParam* recoParam, Bool_t info)
{
- /// find the cluster with the given Id into the track
+ /// Reset the MUON tracker using "recoParam" if provided.
+ /// If not provided, will get them from OCDB.
+ /// Load the magnetic field from OCDB if not already set.
- Int_t nClusters = track.GetNClusters();
- for (Int_t iCluster = 0; iCluster < nClusters; iCluster++) {
+ delete fgTracker;
+ delete fgRecoParam;
+
+ if (recoParam) {
+
+ // use provided recoParam
+ fgRecoParam = new AliMUONRecoParam(*recoParam);
+
+ if (info) AliInfoClass("will refit tracks with provided RecoParam:");
+
+ } else {
+
+ // or get them from OCDB
+ fgRecoParam = AliMUONCDB::LoadRecoParam();
- AliMUONVCluster* cluster = ((AliMUONTrackParam*) track.GetTrackParamAtCluster()->UncheckedAt(iCluster))->GetClusterPtr();
- if (cluster->GetUniqueID() == clusterId) return cluster;
+ if (!fgRecoParam) AliFatalClass("RecoParam have not been set!");
}
- return 0x0;
+ // print useful parameters for refitting
+ if (info) {
+ cout<<" --> Tracking mode = "<<fgRecoParam->GetTrackingMode()<<endl;
+ if (fgRecoParam->UseSmoother()) cout<<" --> Use Smoother"<<endl;
+ else cout<<" --> Do not use smoother"<<endl;
+ cout<<" --> Vertex dispersion in bending direction = "
+ <<fgRecoParam->GetBendingVertexDispersion()<<" cm"<<endl;
+ }
+
+ // load magnetic field for track extrapolation if not already set
+ if (!TGeoGlobalMagField::Instance()->GetField() && !AliMUONCDB::LoadField())
+ AliFatalClass("Magnetic field has not been set!");
+
+ fgTracker = AliMUONTracker::CreateTrackReconstructor(fgRecoParam,0x0,0x0);
+
}
-//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
-// static methods //
-//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
-
//_____________________________________________________________________________
AliMUONVTrackStore* AliMUONESDInterface::NewTrackStore()
{
/// Create an empty track store of type fgTrackStoreName
TClass* classPtr = TClass::GetClass(fgTrackStoreName);
if (!classPtr || !classPtr->InheritsFrom("AliMUONVTrackStore")) {
- cout<<"E-AliMUONESDInterface::NewTrackStore: Unable to create store of type "<<fgTrackStoreName.Data()<<endl;
+ AliErrorClass(Form("Unable to create store of type %s", fgTrackStoreName.Data()));
return 0x0;
}
- return reinterpret_cast<AliMUONVTrackStore*>(classPtr->New());
+ return reinterpret_cast<AliMUONVTrackStore*>(gROOT->ProcessLineFast(Form("new %s()",fgTrackStoreName.Data())));
}
//_____________________________________________________________________________
/// Create an empty cluster store of type fgClusterStoreName
TClass* classPtr = TClass::GetClass(fgClusterStoreName);
if (!classPtr || !classPtr->InheritsFrom("AliMUONVClusterStore")) {
- cout<<"E-AliMUONESDInterface::NewClusterStore: Unable to create store of type "<<fgClusterStoreName.Data()<<endl;
+ AliErrorClass(Form("Unable to create store of type %s", fgClusterStoreName.Data()));
+ return 0x0;
+ }
+ return reinterpret_cast<AliMUONVClusterStore*>(gROOT->ProcessLineFast(Form("new %s()",fgClusterStoreName.Data())));
+}
+
+//_____________________________________________________________________________
+AliMUONVCluster* AliMUONESDInterface::NewCluster()
+{
+ /// Create an empty cluster of type associated to the cluster store of type fgClusterStoreName
+ TClass* classPtr = TClass::GetClass(fgClusterStoreName);
+ if (!classPtr || !classPtr->InheritsFrom("AliMUONVClusterStore")) {
+ AliErrorClass(Form("Unable to create store of type %s", fgClusterStoreName.Data()));
return 0x0;
}
- return reinterpret_cast<AliMUONVClusterStore*>(classPtr->New());
+ AliMUONVClusterStore* cStore = reinterpret_cast<AliMUONVClusterStore*>(classPtr->New());
+ AliMUONVCluster* cluster = cStore->CreateCluster(0,0,0);
+ delete cStore;
+ return cluster;
}
//_____________________________________________________________________________
/// Create an empty digit store of type fgDigitStoreName
TClass* classPtr = TClass::GetClass(fgDigitStoreName);
if (!classPtr || !classPtr->InheritsFrom("AliMUONVDigitStore")) {
- cout<<"E-AliMUONESDInterface::NewDigitStore: Unable to create store of type "<<fgDigitStoreName.Data()<<endl;
+ AliErrorClass(Form("Unable to create store of type %s", fgDigitStoreName.Data()));
+ return 0x0;
+ }
+ return reinterpret_cast<AliMUONVDigitStore*>(gROOT->ProcessLineFast(Form("new %s()",fgDigitStoreName.Data())));
+}
+
+//_____________________________________________________________________________
+AliMUONVDigit* AliMUONESDInterface::NewDigit()
+{
+ /// Create an empty digit of type associated to the digit store of type fgDigitStoreName
+ TClass* classPtr = TClass::GetClass(fgDigitStoreName);
+ if (!classPtr || !classPtr->InheritsFrom("AliMUONVDigitStore")) {
+ AliErrorClass(Form("Unable to create store of type %s", fgDigitStoreName.Data()));
return 0x0;
}
- return reinterpret_cast<AliMUONVDigitStore*>(classPtr->New());
+ AliMUONVDigitStore* dStore = reinterpret_cast<AliMUONVDigitStore*>(classPtr->New());
+ AliMUONVDigit* digit = dStore->CreateDigit(0,0,0,0);
+ delete dStore;
+ return digit;
}
//_____________________________________________________________________________
/// Create an empty trigger store of type fgTriggerStoreName
TClass* classPtr = TClass::GetClass(fgTriggerStoreName);
if (!classPtr || !classPtr->InheritsFrom("AliMUONVTriggerStore")) {
- cout<<"E-AliMUONESDInterface::NewTriggerStore: Unable to create store of type "<<fgTriggerStoreName.Data()<<endl;
+ AliErrorClass(Form("Unable to create store of type %s", fgTriggerStoreName.Data()));
+ return 0x0;
+ }
+ return reinterpret_cast<AliMUONVTriggerStore*>(gROOT->ProcessLineFast(Form("new %s()",fgTriggerStoreName.Data())));
+}
+
+//_____________________________________________________________________________
+AliMUONVTriggerTrackStore* AliMUONESDInterface::NewTriggerTrackStore()
+{
+ /// Create an empty trigger track store of type fgTriggerTrackStoreName
+ TClass* classPtr = TClass::GetClass(fgTriggerTrackStoreName);
+ if (!classPtr || !classPtr->InheritsFrom("AliMUONVTriggerTrackStore")) {
+ AliErrorClass(Form("Unable to create store of type %s", fgTriggerTrackStoreName.Data()));
return 0x0;
}
- return reinterpret_cast<AliMUONVTriggerStore*>(classPtr->New());
+ return reinterpret_cast<AliMUONVTriggerTrackStore*>(gROOT->ProcessLineFast(Form("new %s()",fgTriggerTrackStoreName.Data())));
}
//_________________________________________________________________________
}
//_____________________________________________________________________________
-void AliMUONESDInterface::ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONTrack& track)
+void AliMUONESDInterface::ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONTrack& track, Bool_t refit)
{
- /// Transfert data from ESDMuon track to MUON track
+ /// Transfert data from ESDMuon track to MUON track.
+ /// ESDMuon track must hold the pointer to the ESD event otherwise we cannot recover the clusters.
+ /// If refit = kTRUE, the track parameters at each cluster are obtained by refitting the track
+ /// or by extrapolating the parameters at the first one if the refit failed.
+ /// If refit = kFALSE, only the track parameters at first cluster are valid.
+ /// note: You can set the recoParam used to refit the MUON track with ResetTracker(...);
+ /// By default we use Kalman filter + Smoother
// if the ESDMuon track is a ghost then return an empty MUON track
if (!esdTrack.ContainTrackerData()) {
track.SetVertexErrXY2(0.,0.);
track.SetGlobalChi2(esdTrack.GetChi2());
track.SetMatchTrigger(esdTrack.GetMatchTrigger());
- track.SetLoTrgNum(-1);
track.SetChi2MatchTrigger(esdTrack.GetChi2MatchTrigger());
- track.SetTrackID(0);
track.SetHitsPatternInTrigCh(esdTrack.GetHitsPatternInTrigCh());
+ track.SetHitsPatternInTrigChTrk(esdTrack.GetHitsPatternInTrigChTrk());
track.SetLocalTrigger(esdTrack.LoCircuit(), esdTrack.LoStripX(), esdTrack.LoStripY(),
- esdTrack.LoDev(), esdTrack.LoLpt(), esdTrack.LoHpt());
+ esdTrack.LoDev(), esdTrack.LoLpt(), esdTrack.LoHpt(),
+ esdTrack.GetTriggerWithoutChamber());
+ track.Connected(esdTrack.IsConnected());
// track parameters at vertex
AliMUONTrackParam paramAtVertex;
GetParamCov(esdTrack, param);
// create empty cluster
- AliMUONVClusterStore* cStore = NewClusterStore();
- if (!cStore) return;
- AliMUONVCluster* cluster = cStore->CreateCluster(0,0,0);
+ AliMUONVCluster* cluster = NewCluster();
// fill TrackParamAtCluster with track parameters at each cluster if available
- // or with only track parameters at first (fake) cluster if not
- if(esdTrack.ClustersStored()) {
+ Bool_t clusterFound = kFALSE;
+ if(esdTrack.GetESDEvent()) {
- // loop over ESD clusters
- AliESDMuonCluster *esdCluster = (AliESDMuonCluster*) esdTrack.GetClusters().First();
- while (esdCluster) {
+ // loop over cluster Id
+ for (Int_t i = 0; i < esdTrack.GetNClusters(); i++) {
+
+ // recover the ESDMuon cluster
+ AliESDMuonCluster *esdCluster = esdTrack.GetESDEvent()->FindMuonCluster(esdTrack.GetClusterId(i));
+ if (esdCluster) clusterFound = kTRUE;
+ else {
+ AliErrorClass("a cluster is missing in ESD");
+ continue;
+ }
// copy cluster information
ESDToMUON(*esdCluster, *cluster);
// add common track parameters at current cluster
track.AddTrackParamAtCluster(param, *cluster, kTRUE);
- esdCluster = (AliESDMuonCluster*) esdTrack.GetClusters().After(esdCluster);
}
- // recompute parameters at first cluster in case of those stored
- // in ESD are not related to the most upstream cluster
- AliMUONTrackParam *firstTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->First();
- firstTrackParam->SetZ(esdTrack.GetZUncorrected()); // reset the z to the one stored in ESD
- AliMUONTrackExtrap::ExtrapToZCov(firstTrackParam,firstTrackParam->GetClusterPtr()->GetZ());
-
// refit the track to get better parameters and covariances at each cluster (temporary disable track improvement)
- if (!fgTracker) fgTracker = AliMUONTracker::CreateTrackReconstructor(AliMUONReconstructor::GetRecoParam()->GetTrackingMode(),0x0);
- if (!fgTracker->RefitTrack(track, kFALSE)) track.UpdateCovTrackParamAtCluster();
+ if (clusterFound && refit) {
+
+ AliMUONTrackParam *firstTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->First();
+ AliMUONTrackParam paramSave(*firstTrackParam);
+
+ if (!fgTracker) ResetTracker();
+
+ if (!fgTracker->RefitTrack(track, kFALSE) && track.GetGlobalChi2() < AliMUONTrack::MaxChi2()) {
+ *firstTrackParam = paramSave;
+ track.UpdateCovTrackParamAtCluster();
+ }
+
+ }
- } else {
+ }
+
+ // fill TrackParamAtCluster with only track parameters at first (fake) cluster if no cluster found in ESD
+ if (!clusterFound) {
- // get number of the first hit chamber (according to the MUONClusterMap if not empty)
+ // get number of the first hit chamber according to the MUONClusterMap
Int_t firstCh = 0;
- if (esdTrack.GetMuonClusterMap() != 0) while (!esdTrack.IsInMuonClusterMap(firstCh)) firstCh++;
- else firstCh = AliMUONConstants::ChamberNumber(param.GetZ());
+ while (firstCh < 10 && !esdTrack.IsInMuonClusterMap(firstCh)) firstCh++;
// produce fake cluster at this chamber
cluster->SetUniqueID(AliMUONVCluster::BuildUniqueID(firstCh, 0, 0));
}
+ // set the MC label from ESD track
+ track.SetMCLabel(esdTrack.GetLabel());
+
delete cluster;
- delete cStore;
}
{
/// Transfert trigger data from ESDMuon track to the MUONLocalTtrigger object
- // if the ESDMuon track is a ghost then return an empty MUON track
- if (!esdTrack.ContainTriggerData()) {
- AliMUONLocalTrigger emptyLocTrg;
- locTrg = emptyLocTrg;
- return;
- }
+ // reset the local trigger content
+ AliMUONLocalTrigger emptyLocTrg;
+ locTrg = emptyLocTrg;
+ // if the ESDMuon track is a ghost then return an empty local trigger
+ if (!esdTrack.ContainTriggerData()) return;
+
+ locTrg.SetUniqueID(esdTrack.GetUniqueID());
locTrg.SetLoCircuit(esdTrack.LoCircuit());
locTrg.SetLoStripX(esdTrack.LoStripX());
locTrg.SetLoStripY(esdTrack.LoStripY());
- locTrg.SetLoDev(esdTrack.LoDev());
+ locTrg.SetDeviation(esdTrack.LoDev());
locTrg.SetLoLpt(esdTrack.LoLpt());
locTrg.SetLoHpt(esdTrack.LoHpt());
- locTrg.SetLoSdev(1);
- locTrg.SetLoTrigY(1);
+ for (Int_t ich = 0; ich < 4; ich++)
+ if (esdTrack.TriggerFiredWithoutChamber(ich))
+ locTrg.SetTriggerWithoutChamber(ich);
+ locTrg.SetLoTrigY(0);
locTrg.SetX1Pattern(esdTrack.GetTriggerX1Pattern());
locTrg.SetX2Pattern(esdTrack.GetTriggerX2Pattern());
locTrg.SetX3Pattern(esdTrack.GetTriggerX3Pattern());
cluster.SetErrXY(esdCluster.GetErrX(),esdCluster.GetErrY());
cluster.SetCharge(esdCluster.GetCharge());
cluster.SetChi2(esdCluster.GetChi2());
+ cluster.SetMCLabel(esdCluster.GetLabel());
- if (esdCluster.PadsStored()) {
- Int_t nPads = esdCluster.GetNPads();
- for (Int_t iPad = 0; iPad < nPads; iPad++)
- cluster.AddDigitId(((AliESDMuonPad*)esdCluster.GetPads().UncheckedAt(iPad))->GetUniqueID());
- }
+ cluster.SetDigitsId(esdCluster.GetNPads(), esdCluster.GetPadsId());
}
void AliMUONESDInterface::ESDToMUON(const AliESDMuonPad& esdPad, AliMUONVDigit& digit)
{
/// Transfert data from ESDMuon pad to MUON digit
+ /// Load mapping from OCDB if not already set
+
+ if (!AliMpSegmentation::Instance(kFALSE) && !AliMUONCDB::LoadMapping(kTRUE))
+ AliFatalClass("mapping segmentation has not been set!");
const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(esdPad.GetDetElemId(), esdPad.GetManuId());
- AliMpPad pad = seg->PadByLocation(AliMpIntPair(esdPad.GetManuId(), esdPad.GetManuChannel()), kFALSE);
+ AliMpPad pad = seg->PadByLocation(esdPad.GetManuId(), esdPad.GetManuChannel(), kFALSE);
digit.Saturated(esdPad.IsSaturated());
digit.Used(kFALSE);
digit.SetUniqueID(esdPad.GetUniqueID());
digit.SetCharge(esdPad.GetCharge());
digit.SetADC(esdPad.GetADC());
- digit.SetPadXY(pad.GetIndices().GetFirst(), pad.GetIndices().GetSecond());
+ digit.SetPadXY(pad.GetIx(), pad.GetIy());
}
//_____________________________________________________________________________
-void AliMUONESDInterface::MUONToESD(const AliMUONTrack& track, AliESDMuonTrack& esdTrack, const Double_t vertex[3],
+void AliMUONESDInterface::MUONToESD(const AliMUONTrack& track, AliESDEvent& esd, const Double_t vertex[3],
const AliMUONVDigitStore* digits, const AliMUONLocalTrigger* locTrg)
{
- /// Transfert data from MUON track to ESDMuon track
+ /// Transfert data from MUON track to ESD event (ESDTrack + ESDClusters)
/// Incorporate the ESDPads if the digits are provided
/// Add trigger info if the MUON track is matched with a trigger track
+ // transfert track info
+ AliESDMuonTrack *esdTrack = esd.NewMuonTrack();
+ MUONToESD(track, *esdTrack, vertex, locTrg);
+
+ // transfert cluster info if any
+ for (Int_t i = 0; i < track.GetNClusters(); i++) {
+ AliMUONTrackParam *param = static_cast<AliMUONTrackParam*>(track.GetTrackParamAtCluster()->UncheckedAt(i));
+ MUONToESD(*(param->GetClusterPtr()), esd, digits);
+ }
+
+}
+
+//_____________________________________________________________________________
+void AliMUONESDInterface::MUONToESD(const AliMUONTrack& track, AliESDMuonTrack& esdTrack,
+ const Double_t vertex[3], const AliMUONLocalTrigger* locTrg)
+{
+ /// Transfert data from MUON track to ESDMuon track (ESDMuon track only contains clusters'Id, not cluster themselves)
+ /// Add trigger info if the MUON track is matched with a trigger track
+
// empty MUON track -> produce a ghost ESDMuon track if trigger info are available otherwise produce an empty track
if (track.GetNClusters() == 0) {
if (locTrg) MUONToESD(*locTrg, esdTrack, track.GetUniqueID());
// set global info
esdTrack.SetUniqueID(track.GetUniqueID());
esdTrack.SetChi2(track.GetGlobalChi2());
- esdTrack.SetNHit(track.GetNClusters());
+ esdTrack.SetLabel(track.GetMCLabel());
// set param at first cluster
AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track.GetTrackParamAtCluster())->First());
SetParamAtFirstCluster(*trackParam, esdTrack);
SetParamCov(*trackParam, esdTrack);
+ // set transverse position at the end of the absorber
+ AliMUONTrackParam trackParamAtAbsEnd(*trackParam);
+ AliMUONTrackExtrap::ExtrapToZ(&trackParamAtAbsEnd, AliMUONConstants::AbsZEnd());
+ Double_t xAbs = trackParamAtAbsEnd.GetNonBendingCoor();
+ Double_t yAbs = trackParamAtAbsEnd.GetBendingCoor();
+ esdTrack.SetRAtAbsorberEnd(TMath::Sqrt(xAbs*xAbs + yAbs*yAbs));
+
// set param at vertex
AliMUONTrackParam trackParamAtVtx(*trackParam);
AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0], vertex[1], vertex[2], 0., 0.);
SetParamAtDCA(trackParamAtDCA, esdTrack);
// set muon cluster info
- AliESDMuonCluster esdCluster;
esdTrack.SetMuonClusterMap(0);
while (trackParam) {
- MUONToESD(*(trackParam->GetClusterPtr()), esdCluster, digits);
- esdTrack.AddCluster(esdCluster);
- esdTrack.AddInMuonClusterMap(esdCluster.GetChamberId());
+ AliMUONVCluster *cluster = trackParam->GetClusterPtr();
+ esdTrack.AddClusterId(cluster->GetUniqueID());
+ esdTrack.AddInMuonClusterMap(cluster->GetChamberId());
trackParam = static_cast<AliMUONTrackParam*>(track.GetTrackParamAtCluster()->After(trackParam));
}
+ // set connected flag
+ esdTrack.Connected(track.IsConnected());
+
// set trigger info
esdTrack.SetLocalTrigger(track.GetLocalTrigger());
esdTrack.SetChi2MatchTrigger(track.GetChi2MatchTrigger());
esdTrack.SetHitsPatternInTrigCh(track.GetHitsPatternInTrigCh());
+ esdTrack.SetHitsPatternInTrigChTrk(track.GetHitsPatternInTrigChTrk());
if (locTrg) {
esdTrack.SetTriggerX1Pattern(locTrg->GetX1Pattern());
esdTrack.SetTriggerY1Pattern(locTrg->GetY1Pattern());
}
//_____________________________________________________________________________
-void AliMUONESDInterface::MUONToESD(const AliMUONLocalTrigger& locTrg, AliESDMuonTrack& esdTrack, UInt_t trackId)
+void AliMUONESDInterface::MUONToESD(const AliMUONLocalTrigger& locTrg, AliESDEvent& esd,
+ UInt_t trackId, const AliMUONTriggerTrack* triggerTrack)
+{
+ /// Add in ESD event a ghost ESDMuon track containing only informations about trigger track
+ AliESDMuonTrack *esdTrack = esd.NewMuonTrack();
+ MUONToESD(locTrg, *esdTrack, trackId, triggerTrack);
+}
+
+//_____________________________________________________________________________
+void AliMUONESDInterface::MUONToESD(const AliMUONLocalTrigger& locTrg, AliESDMuonTrack& esdTrack,
+ UInt_t trackId, const AliMUONTriggerTrack* triggerTrack)
{
/// Build ghost ESDMuon track containing only informations about trigger track
muonTrack.SetLocalTrigger(locTrg.LoCircuit(),
locTrg.LoStripX(),
locTrg.LoStripY(),
- locTrg.LoDev(),
+ locTrg.GetDeviation(),
locTrg.LoLpt(),
- locTrg.LoHpt());
+ locTrg.LoHpt(),
+ locTrg.GetTriggerWithoutChamber());
esdTrack.SetLocalTrigger(muonTrack.GetLocalTrigger());
esdTrack.SetChi2MatchTrigger(0.);
- esdTrack.SetHitsPatternInTrigCh(0);
esdTrack.SetTriggerX1Pattern(locTrg.GetX1Pattern());
esdTrack.SetTriggerY1Pattern(locTrg.GetY1Pattern());
esdTrack.SetTriggerX2Pattern(locTrg.GetX2Pattern());
esdTrack.SetTriggerY3Pattern(locTrg.GetY3Pattern());
esdTrack.SetTriggerX4Pattern(locTrg.GetX4Pattern());
esdTrack.SetTriggerY4Pattern(locTrg.GetY4Pattern());
-
+ UShort_t hitPattern = 0;
+ esdTrack.SetHitsPatternInTrigChTrk(hitPattern);
+ if(triggerTrack){
+ hitPattern = triggerTrack->GetHitsPatternInTrigCh();
+ esdTrack.SetHitsPatternInTrigCh(hitPattern);
+ esdTrack.SetThetaXUncorrected(triggerTrack->GetThetax());
+ esdTrack.SetThetaYUncorrected(triggerTrack->GetThetay());
+ esdTrack.SetNonBendingCoorUncorrected(triggerTrack->GetX11());
+ esdTrack.SetBendingCoorUncorrected(triggerTrack->GetY11());
+ esdTrack.SetZUncorrected(triggerTrack->GetZ11());
+ }
}
//_____________________________________________________________________________
-void AliMUONESDInterface::MUONToESD(const AliMUONVCluster& cluster, AliESDMuonCluster& esdCluster, const AliMUONVDigitStore* digits)
+void AliMUONESDInterface::MUONToESD(const AliMUONVCluster& cluster, AliESDEvent& esd, const AliMUONVDigitStore* digits)
{
- /// Transfert data from MUON cluster to ESDMuon cluster
- /// Incorporate the ESDPads if the digits are provided
-
- esdCluster.Clear("C");
+ /// Transfert data from MUON cluster to ESD event if it does not already exist
+ /// Also transfert digits'Id to cluster and digits to ESD if they are provided
- esdCluster.SetUniqueID(cluster.GetUniqueID());
- esdCluster.SetXYZ(cluster.GetX(), cluster.GetY(), cluster.GetZ());
- esdCluster.SetErrXY(cluster.GetErrX(), cluster.GetErrY());
- esdCluster.SetCharge(cluster.GetCharge());
- esdCluster.SetChi2(cluster.GetChi2());
+ AliESDMuonCluster *esdCluster = esd.FindMuonCluster(cluster.GetUniqueID());
+ if (!esdCluster) esdCluster = esd.NewMuonCluster();
+ else if (!digits || esdCluster->GetNPads() > 0) return;
- if (digits) { // transfert all data if required
+ if (digits) {
+
+ MUONToESD(cluster, *esdCluster, kTRUE);
- AliESDMuonPad esdPad;
for (Int_t i=0; i<cluster.GetNDigits(); i++) {
AliMUONVDigit* digit = digits->FindObject(cluster.GetDigitId(i));
if (!digit) {
- cout<<"E-AliMUONESDInterface::MUONToESD: digit "<<cluster.GetDigitId(i)<<" not found"<<endl;
+ AliErrorClass(Form("digit %u not found", cluster.GetDigitId(i)));
continue;
}
- MUONToESD(*digit, esdPad);
- esdCluster.AddPad(esdPad);
+ MUONToESD(*digit, esd);
}
+ } else {
+
+ MUONToESD(cluster, *esdCluster, kFALSE);
+
}
}
+//_____________________________________________________________________________
+void AliMUONESDInterface::MUONToESD(const AliMUONVCluster& cluster, AliESDMuonCluster& esdCluster, Bool_t copyPadsId)
+{
+ /// Transfert data from MUON cluster to ESDMuon cluster
+ /// Also transfert digits'Is if required
+
+ esdCluster.Clear("C");
+
+ esdCluster.SetUniqueID(cluster.GetUniqueID());
+ esdCluster.SetXYZ(cluster.GetX(), cluster.GetY(), cluster.GetZ());
+ esdCluster.SetErrXY(cluster.GetErrX(), cluster.GetErrY());
+ esdCluster.SetCharge(cluster.GetCharge());
+ esdCluster.SetChi2(cluster.GetChi2());
+ esdCluster.SetLabel(cluster.GetMCLabel());
+
+ if (copyPadsId) esdCluster.SetPadsId(cluster.GetNDigits(), cluster.GetDigitsId());
+
+}
+
+//_____________________________________________________________________________
+void AliMUONESDInterface::MUONToESD(const AliMUONVDigit& digit, AliESDEvent& esd)
+{
+ /// Transfert data from MUON digit to ESD event if it does not already exist
+ if (esd.FindMuonPad(digit.GetUniqueID())) return;
+ AliESDMuonPad *esdPad = esd.NewMuonPad();
+ MUONToESD(digit, *esdPad);
+}
+
//_____________________________________________________________________________
void AliMUONESDInterface::MUONToESD(const AliMUONVDigit& digit, AliESDMuonPad& esdPad)
{
}
//___________________________________________________________________________
-AliMUONTrack* AliMUONESDInterface::Add(const AliESDMuonTrack& esdTrack, AliMUONVTrackStore& trackStore)
+AliMUONTrack* AliMUONESDInterface::Add(const AliESDMuonTrack& esdTrack, AliMUONVTrackStore& trackStore, Bool_t refit)
{
/// Create MUON track from ESDMuon track and add it to the store
+ /// Track parameters at each clusters are recomputed or not depending on the flag "refit"
/// return a pointer to the track into the store (0x0 if the track already exist)
if(trackStore.FindObject(esdTrack.GetUniqueID())) return 0x0;
AliMUONTrack* track = trackStore.Add(AliMUONTrack());
- ESDToMUON(esdTrack, *track);
+ ESDToMUON(esdTrack, *track, refit);
return track;
}
void AliMUONESDInterface::Add(const AliESDMuonTrack& esdTrack, AliMUONVTriggerStore& triggerStore)
{
/// Create MUON local trigger from ESDMuon track and add it to the store if not already there
- if (triggerStore.FindLocal(esdTrack.LoCircuit())) return;
+ if (!triggerStore.FindLocal(esdTrack.LoCircuit())->IsNull()) return;
AliMUONLocalTrigger locTrg;
ESDToMUON(esdTrack, locTrg);
triggerStore.Add(locTrg);