#endif
const Int_t printLevel = 1;
+const Bool_t reconstructFromDigits = kTRUE; // kFALSE = reconstruct from clusters
TTree* GetESDTree(TFile *esdFile);
TFile* esdFile = TFile::Open(esdFileNameIn);
TTree* esdTree = GetESDTree(esdFile);
+ // connect ESD event to the ESD tree
+ AliESDEvent* esd = new AliESDEvent();
+ esd->ReadFromTree(esdTree);
+
// create the ESD output file and tree
TFile* newESDFile = TFile::Open(esdFileNameOut, "RECREATE");
newESDFile->SetCompressionLevel(2);
- TTree* newESDTree = esdTree->CloneTree(0);
- // connect ESD event to the ESD tree
- AliESDEvent* esd = new AliESDEvent();
- esd->ReadFromTree(esdTree);
+ // connect ESD event to the ESD tree (recreate track branch for backward compatibility)
+ esdTree->SetBranchStatus("*MuonTracks*",0);
+ TTree* newESDTree = esdTree->CloneTree(0);
+ esdTree->SetBranchStatus("*MuonTracks*",1);
+ esd->WriteToTree(newESDTree);
// get run number
if (esdTree->GetEvent(0) <= 0) {
// load the current event
esdInterface.LoadEvent(*esd, kFALSE);
- // loop over digit to modify their charge
- AliMUONVDigit *digit;
- TIter next(esdInterface.CreateDigitIterator());
- while ((digit = static_cast<AliMUONVDigit*>(next()))) {
- digit->SetCharge(digit->ADC());
- digit->Calibrated(kFALSE);
- }
+ // remove digits and clusters from ESD
+ esd->FindListObject("MuonClusters")->Clear("C");
+ esd->FindListObject("MuonPads")->Clear("C");
- // refit the tracks from digits
- AliMUONVTrackStore* newTrackStore = refitter.ReconstructFromDigits();
+ AliMUONVTrackStore* newTrackStore = 0x0;
+ if (reconstructFromDigits) {
+
+ // loop over digits to modify their charge
+ AliMUONVDigit *digit;
+ TIter next(esdInterface.CreateDigitIterator());
+ while ((digit = static_cast<AliMUONVDigit*>(next()))) {
+ digit->SetCharge(digit->ADC());
+ digit->Calibrated(kFALSE);
+ }
+
+ // refit the tracks from digits
+ refitter.SetFirstClusterIndex(0);
+ newTrackStore = refitter.ReconstructFromDigits();
+
+ } else {
+
+ // refit the tracks from clusters
+ newTrackStore = refitter.ReconstructFromClusters();
+
+ }
//----------------------------------------------//
// ------ fill new ESD and print results ------ //
AliMUONTrack* newTrack = (AliMUONTrack*) newTrackStore->FindObject(esdTrack->GetUniqueID());
// replace the content of the current ESD track or remove it if the refitting has failed
- if (newTrack) {
+ if (newTrack && (!recoParam->ImproveTracks() || newTrack->IsImproved())) {
+
+ // fill the track info
Double_t vertex[3] = {esdTrack->GetNonBendingCoor(), esdTrack->GetBendingCoor(), esdTrack->GetZ()};
- AliMUONESDInterface::MUONToESD(*newTrack, *esdTrack, vertex, esdInterface.GetDigits());
- } else {
- esdTracks->Remove(esdTrack);
- }
+ AliMUONESDInterface::MUONToESD(*newTrack, *esdTrack, vertex);
+
+ // add the clusters (and the digits if previously there)
+ for (Int_t i = 0; i < newTrack->GetNClusters(); i++) {
+ AliMUONTrackParam *param = static_cast<AliMUONTrackParam*>(newTrack->GetTrackParamAtCluster()->UncheckedAt(i));
+ AliMUONESDInterface::MUONToESD(*(param->GetClusterPtr()), *esd, esdInterface.GetDigits());
+ }
+
+ } else esdTracks->Remove(esdTrack);
// print initial and re-fitted track parameters at first cluster if any
if (printLevel>0) {