* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
-
/* $Id$ */
///////////////////////////////////////////////////////////////////////////////
// class for MUON reconstruction //
// //
///////////////////////////////////////////////////////////////////////////////
-#include <TParticle.h>
-#include <TArrayF.h>
-#include "AliRunLoader.h"
-#include "AliHeader.h"
-#include "AliGenEventHeader.h"
-#include "AliESD.h"
+#include "AliMUONReconstructor.h"
-#include "AliMUONData.h"
-#include "AliMUONEventReconstructor.h"
-#include "AliMUONClusterReconstructor.h"
-#include "AliMUONTriggerDecision.h"
+#include "AliESD.h"
+#include "AliESDMuonTrack.h"
+#include "AliGenEventHeader.h"
+#include "AliHeader.h"
+#include "AliLog.h"
+#include "AliMUON.h"
+#include "AliMUONCalibrationData.h"
+#include "AliMUONClusterFinderAZ.h"
#include "AliMUONClusterFinderVS.h"
+#include "AliMUONClusterReconstructor.h"
+#include "AliMUONData.h"
+#include "AliMUONDigitCalibrator.h"
+#include "AliMUONEventRecoCombi.h"
+#include "AliMUONRawReader.h"
#include "AliMUONTrack.h"
#include "AliMUONTrackParam.h"
+#include "AliMUONTrackReconstructor.h"
#include "AliMUONTriggerTrack.h"
-#include "AliESDMuonTrack.h"
-#include "AliMUONReconstructor.h"
+#include "AliRawReader.h"
+#include "AliRun.h"
+#include "AliRunLoader.h"
+#include "TTask.h"
+#include <TArrayF.h>
+#include <TParticle.h>
+#include "TStopwatch.h"
ClassImp(AliMUONReconstructor)
+
//_____________________________________________________________________________
AliMUONReconstructor::AliMUONReconstructor()
- : AliReconstructor()
+ : AliReconstructor(), fCalibrationData(0x0)
{
+ AliDebug(1,"");
}
+
+//______________________________________________________________________________
+AliMUONReconstructor::AliMUONReconstructor(const AliMUONReconstructor& right)
+ : AliReconstructor(right)
+{
+/// Protected copy constructor (not implemented)
+
+ AliFatal("Copy constructor not provided.");
+}
+
//_____________________________________________________________________________
AliMUONReconstructor::~AliMUONReconstructor()
{
+ AliDebug(1,"");
+ delete fCalibrationData;
}
+
+//______________________________________________________________________________
+AliMUONReconstructor&
+AliMUONReconstructor::operator=(const AliMUONReconstructor& right)
+{
+/// Protected assignement operator (not implemented)
+
+ // check assignement to self
+ if (this == &right) return *this;
+
+ AliFatal("Assignement operator not provided.");
+
+ return *this;
+}
+
+//_____________________________________________________________________________
+TTask*
+AliMUONReconstructor::GetCalibrationTask(AliMUONData* data) const
+{
+ //
+ // Create the calibration task(s).
+ //
+
+ const AliRun* run = fRunLoader->GetAliRun();
+
+ // Not really clean, but for the moment we must check whether the
+ // simulation has decalibrated the data or not...
+ const AliMUON* muon = static_cast<AliMUON*>(run->GetModule("MUON"));
+ if ( muon->DigitizerType().Contains("NewDigitizer") )
+ {
+ AliInfo("Calibration will occur.");
+ Int_t runNumber = run->GetRunNumber();
+ fCalibrationData = new AliMUONCalibrationData(runNumber);
+ if ( !fCalibrationData->IsValid() )
+ {
+ AliError("Could not retrieve calibrations !");
+ delete fCalibrationData;
+ fCalibrationData = 0x0;
+ return 0x0;
+ }
+ TTask* calibration = new TTask("MUONCalibrator","MUON Digit calibrator");
+ calibration->Add(new AliMUONDigitCalibrator(data,fCalibrationData));
+ //FIXME: calibration->Add(something about dead channels should go here).
+ return calibration;
+ }
+ else
+ {
+ AliInfo("Detected the usage of old digitizer (w/o decalibration). "
+ "Will not calibrate then.");
+ return 0x0;
+ }
+}
+
+//_____________________________________________________________________________
+void
+AliMUONReconstructor::Init(AliRunLoader* runLoader)
+{
+ fRunLoader = runLoader;
+}
+
//_____________________________________________________________________________
void AliMUONReconstructor::Reconstruct(AliRunLoader* runLoader) const
{
AliLoader* loader = runLoader->GetLoader("MUONLoader");
Int_t nEvents = runLoader->GetNumberOfEvents();
-// used local container for each method
-// passing fLoader as argument, could be avoided ???
- AliMUONEventReconstructor* recoEvent = new AliMUONEventReconstructor(loader);
- AliMUONData* dataEvent = recoEvent->GetMUONData();
+ AliMUONData* data = new AliMUONData(loader,"MUON","MUON");
- AliMUONClusterReconstructor* recoCluster = new AliMUONClusterReconstructor(loader);
- AliMUONData* dataCluster = recoCluster->GetMUONData();
+// passing loader as argument.
+ AliMUONTrackReconstructor* recoEvent = new AliMUONTrackReconstructor(loader, data);
- AliMUONTriggerDecision* trigDec = new AliMUONTriggerDecision(loader,0,dataCluster);
- // AliMUONData* dataTrig = trigDec->GetMUONData();
+ if (strstr(GetOption(),"Original"))
+ recoEvent->SetTrackMethod(1); // Original tracking
+ else if (strstr(GetOption(),"Combi"))
+ recoEvent->SetTrackMethod(3); // Combined cluster / track
+ else
+ recoEvent->SetTrackMethod(2); // Kalman
+ AliMUONClusterReconstructor* recoCluster = new AliMUONClusterReconstructor(data);
+
+ AliMUONClusterFinderVS *recModel = recoCluster->GetRecoModel();
- for (Int_t i = 0; i < 10; i++) {
- AliMUONClusterFinderVS *recModel = new AliMUONClusterFinderVS();
- recModel->SetGhostChi2Cut(10);
- recoCluster->SetReconstructionModel(i,recModel);
- }
+ if (!strstr(GetOption(),"VS")) {
+ recModel = (AliMUONClusterFinderVS*) new AliMUONClusterFinderAZ();
+ recoCluster->SetRecoModel(recModel);
+ }
+ recModel->SetGhostChi2Cut(10);
loader->LoadDigits("READ");
loader->LoadRecPoints("RECREATE");
loader->LoadTracks("RECREATE");
+ TTask* calibration = GetCalibrationTask(data);
+
+ Int_t chBeg = recoEvent->GetTrackMethod() == 3 ? 6 : 0;
// Loop over events
for(Int_t ievent = 0; ievent < nEvents; ievent++) {
- printf("Event %d\n",ievent);
+
+ AliDebug(1,Form("Event %d",ievent));
+
runLoader->GetEvent(ievent);
- //----------------------- digit2cluster & Digits2Trigger -------------------
+ //----------------------- digit2cluster & Trigger2Trigger -------------------
if (!loader->TreeR()) loader->MakeRecPointsContainer();
// tracking branch
- dataCluster->MakeBranch("RC");
- dataCluster->SetTreeAddress("D,RC");
- recoCluster->Digits2Clusters();
- dataCluster->Fill("RC");
+ if (recoEvent->GetTrackMethod() != 3) {
+ data->MakeBranch("RC");
+ data->SetTreeAddress("D,RC");
+ } else {
+ data->SetTreeAddress("D");
+ data->SetTreeAddress("RCC");
+ }
+ // Important for avoiding a memory leak when reading digits ( to be investigated more in detail)
+ // In any case the reading of GLT is needed for the Trigger2Tigger method below
+ data->SetTreeAddress("GLT");
+
+ data->GetDigits();
+
+ if ( calibration )
+ {
+ calibration->ExecuteTask();
+ }
+
+ recoCluster->Digits2Clusters(chBeg);
+
+ if (recoEvent->GetTrackMethod() == 3) {
+ // Combined cluster / track finder
+ AliMUONEventRecoCombi::Instance()->FillEvent(data, (AliMUONClusterFinderAZ*)recModel);
+ ((AliMUONClusterFinderAZ*) recModel)->SetReco(2);
+ }
+ else data->Fill("RC");
// trigger branch
- dataCluster->MakeBranch("TC");
- dataCluster->SetTreeAddress("TC");
- trigDec->Trigger2Trigger();
- dataCluster->Fill("TC");
+ data->MakeBranch("TC");
+ data->SetTreeAddress("TC");
+ recoCluster->Trigger2Trigger();
+ data->Fill("TC");
- loader->WriteRecPoints("OVERWRITE");
+ //AZ loader->WriteRecPoints("OVERWRITE");
//---------------------------- Track & TriggerTrack ---------------------
if (!loader->TreeT()) loader->MakeTracksContainer();
// trigger branch
- dataEvent->MakeBranch("RL"); //trigger track
- dataEvent->SetTreeAddress("RL");
+ data->MakeBranch("RL"); //trigger track
+ data->SetTreeAddress("RL");
recoEvent->EventReconstructTrigger();
- dataEvent->Fill("RL");
+ data->Fill("RL");
// tracking branch
- dataEvent->MakeBranch("RT"); //track
- dataEvent->SetTreeAddress("RT");
+ data->MakeBranch("RT"); //track
+ data->SetTreeAddress("RT");
recoEvent->EventReconstruct();
- dataEvent->Fill("RT");
+ data->Fill("RT");
- loader->WriteTracks("OVERWRITE");
+ loader->WriteTracks("OVERWRITE");
+ if (recoEvent->GetTrackMethod() == 3) {
+ // Combined cluster / track
+ ((AliMUONClusterFinderAZ*) recModel)->SetReco(1);
+ data->MakeBranch("RC");
+ data->SetTreeAddress("RC");
+ AliMUONEventRecoCombi::Instance()->FillRecP(data, recoEvent);
+ data->Fill("RC");
+ }
+ loader->WriteRecPoints("OVERWRITE");
+
//--------------------------- Resetting branches -----------------------
- dataCluster->ResetDigits();
- dataCluster->ResetRawClusters();
- dataCluster->ResetTrigger();
-
- dataEvent->ResetRawClusters();
- dataEvent->ResetTrigger();
- dataEvent->ResetRecTracks();
- dataEvent->ResetRecTriggerTracks();
-
+ data->ResetDigits();
+ data->ResetRawClusters();
+ data->ResetTrigger();
+
+ data->ResetRawClusters();
+ data->ResetTrigger();
+ data->ResetRecTracks();
+ data->ResetRecTriggerTracks();
+
}
loader->UnloadDigits();
loader->UnloadRecPoints();
delete recoCluster;
delete recoEvent;
- delete trigDec;
+ delete data;
+ delete calibration;
}
+
+//_____________________________________________________________________________
+void AliMUONReconstructor::Reconstruct(AliRunLoader* runLoader, AliRawReader* rawReader) const
+{
+ // AliLoader
+ AliLoader* loader = runLoader->GetLoader("MUONLoader");
+ AliMUONData data(loader,"MUON","MUON");
+
+ // passing loader as argument.
+ AliMUONTrackReconstructor recoEvent(loader, &data);
+
+ AliMUONRawReader rawData(&data);
+
+ AliMUONClusterReconstructor recoCluster(&data);
+
+ if (strstr(GetOption(),"Original"))
+ {
+ recoEvent.SetTrackMethod(1); // Original tracking
+ }
+ else
+ {
+ recoEvent.SetTrackMethod(2); // Kalman
+ }
+
+ AliMUONClusterFinderVS *recModel = recoCluster.GetRecoModel();
+ if (!strstr(GetOption(),"VS"))
+ {
+ recModel = (AliMUONClusterFinderVS*) new AliMUONClusterFinderAZ();
+ recoCluster.SetRecoModel(recModel);
+ }
+ recModel->SetGhostChi2Cut(10);
+
+ TTask* calibration = GetCalibrationTask(&data);
+
+ loader->LoadRecPoints("RECREATE");
+ loader->LoadTracks("RECREATE");
+ loader->LoadDigits("READ");
+
+ // Loop over events
+ Int_t iEvent = 0;
+
+ TStopwatch totalTimer;
+ TStopwatch rawTimer;
+ TStopwatch calibTimer;
+ TStopwatch clusterTimer;
+ TStopwatch trackingTimer;
+
+ rawTimer.Start(kTRUE); rawTimer.Stop();
+ calibTimer.Start(kTRUE); calibTimer.Stop();
+ clusterTimer.Start(kTRUE); clusterTimer.Stop();
+ trackingTimer.Start(kTRUE); trackingTimer.Stop();
+
+ totalTimer.Start(kTRUE);
+
+ while (rawReader->NextEvent())
+ {
+ AliDebug(1,Form("Event %d",iEvent));
+
+ runLoader->GetEvent(iEvent++);
+
+ //----------------------- raw2digits & raw2trigger-------------------
+ if (!loader->TreeD())
+ {
+ AliDebug(1,Form("Making Digit Container for event %d",iEvent));
+ loader->MakeDigitsContainer();
+ }
+
+ data.SetTreeAddress("D,GLT");
+ rawTimer.Start(kFALSE);
+ rawData.Raw2Digits(rawReader);
+ rawTimer.Stop();
+
+ if ( calibration )
+ {
+ calibTimer.Start(kFALSE);
+ calibration->ExecuteTask();
+ calibTimer.Stop();
+ }
+
+ //----------------------- digit2cluster & Trigger2Trigger -------------------
+ clusterTimer.Start(kFALSE);
+
+ if (!loader->TreeR()) loader->MakeRecPointsContainer();
+
+ // tracking branch
+ data.MakeBranch("RC");
+ data.SetTreeAddress("RC");
+ recoCluster.Digits2Clusters();
+ data.Fill("RC");
+
+ // trigger branch
+ data.MakeBranch("TC");
+ data.SetTreeAddress("TC");
+// recoCluster.Trigger2Trigger();
+ data.Fill("TC");
+
+ loader->WriteRecPoints("OVERWRITE");
+
+ clusterTimer.Stop();
+
+ //---------------------------- Track & TriggerTrack ---------------------
+ trackingTimer.Start(kFALSE);
+ if (!loader->TreeT()) loader->MakeTracksContainer();
+
+ // trigger branch
+ data.MakeBranch("RL"); //trigger track
+ data.SetTreeAddress("RL");
+ recoEvent.EventReconstructTrigger();
+ data.Fill("RL");
+
+ // tracking branch
+ data.MakeBranch("RT"); //track
+ data.SetTreeAddress("RT");
+ recoEvent.EventReconstruct();
+ data.Fill("RT");
+
+ loader->WriteTracks("OVERWRITE");
+ trackingTimer.Stop();
+
+ //--------------------------- Resetting branches -----------------------
+ data.ResetDigits();
+ data.ResetRawClusters();
+ data.ResetTrigger();
+
+ data.ResetRawClusters();
+ data.ResetTrigger();
+ data.ResetRecTracks();
+ data.ResetRecTriggerTracks();
+
+ }
+
+ totalTimer.Stop();
+
+ loader->UnloadRecPoints();
+ loader->UnloadTracks();
+ loader->UnloadDigits();
+
+ AliInfo(Form("Execution time for converting RAW data to digits in MUON : R:%.2fs C:%.2fs",
+ rawTimer.RealTime(),rawTimer.CpuTime()));
+ AliInfo(Form("Execution time for calibrating MUON : R:%.2fs C:%.2fs",
+ calibTimer.RealTime(),calibTimer.CpuTime()));
+ AliInfo(Form("Execution time for clusterizing MUON : R:%.2fs C:%.2fs",
+ clusterTimer.RealTime(),clusterTimer.CpuTime()));
+ AliInfo(Form("Execution time for tracking MUON : R:%.2fs C:%.2fs",
+ trackingTimer.RealTime(),trackingTimer.CpuTime()));
+ AliInfo(Form("Total Execution time for Reconstruct(from raw) MUON : R:%.2fs C:%.2fs",
+ totalTimer.RealTime(),totalTimer.CpuTime()));
+}
+
//_____________________________________________________________________________
void AliMUONReconstructor::FillESD(AliRunLoader* runLoader, AliESD* esd) const
{
AliMUONData* muonData = new AliMUONData(loader,"MUON","MUON");
// declaration
- Int_t iEvent, nPart;
- Int_t nTrackHits, nPrimary;
+ Int_t iEvent;// nPart;
+ Int_t nTrackHits;// nPrimary;
Double_t fitFmin;
- TArrayF vertex(3);
Double_t bendingSlope, nonBendingSlope, inverseBendingMomentum;
Double_t xRec, yRec, zRec, chi2MatchTrigger;
AliMUONTrack* recTrack = 0;
AliMUONTrackParam* trackParam = 0;
AliMUONTriggerTrack* recTriggerTrack = 0;
- TParticle* particle = new TParticle();
- AliGenEventHeader* header = 0;
+// TParticle* particle = new TParticle();
+// AliGenEventHeader* header = 0;
iEvent = runLoader->GetEventNumber();
runLoader->GetEvent(iEvent);
- // vertex calculation (maybe it exists already somewhere else)
- vertex[0] = vertex[1] = vertex[2] = 0.;
- nPrimary = 0;
- if ( (header = runLoader->GetHeader()->GenEventHeader()) ) {
- header->PrimaryVertex(vertex);
- } else {
- runLoader->LoadKinematics("READ");
- runLoader->TreeK()->GetBranch("Particles")->SetAddress(&particle);
- nPart = (Int_t)runLoader->TreeK()->GetEntries();
- for(Int_t iPart = 0; iPart < nPart; iPart++) {
- runLoader->TreeK()->GetEvent(iPart);
- if (particle->GetFirstMother() == -1) {
- vertex[0] += particle->Vx();
- vertex[1] += particle->Vy();
- vertex[2] += particle->Vz();
- nPrimary++;
- }
- if (nPrimary) {
- vertex[0] /= (double)nPrimary;
- vertex[1] /= (double)nPrimary;
- vertex[2] /= (double)nPrimary;
- }
- }
- }
+ // Get vertex
+ Double_t vertex[3] = {0};
+ const AliESDVertex *esdVert = esd->GetVertex();
+ if (esdVert) esdVert->GetXYZ(vertex);
+
+ // nPrimary = 0;
+// if ( (header = runLoader->GetHeader()->GenEventHeader()) ) {
+// header->PrimaryVertex(vertex);
+// } else {
+// runLoader->LoadKinematics("READ");
+// runLoader->TreeK()->GetBranch("Particles")->SetAddress(&particle);
+// nPart = (Int_t)runLoader->TreeK()->GetEntries();
+// for(Int_t iPart = 0; iPart < nPart; iPart++) {
+// runLoader->TreeK()->GetEvent(iPart);
+// if (particle->GetFirstMother() == -1) {
+// vertex[0] += particle->Vx();
+// vertex[1] += particle->Vy();
+// vertex[2] += particle->Vz();
+// nPrimary++;
+// }
+// if (nPrimary) {
+// vertex[0] /= (double)nPrimary;
+// vertex[1] /= (double)nPrimary;
+// vertex[2] /= (double)nPrimary;
+// }
+// }
+// }
// setting ESD MUON class
AliESDMuonTrack* theESDTrack = new AliESDMuonTrack() ;
// reading info from tracks
recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks);
- trackParam = recTrack->GetTrackParamAtVertex();
+ trackParam = (AliMUONTrackParam*) (recTrack->GetTrackParamAtHit())->First();
+ trackParam->ExtrapToVertex(vertex[0],vertex[1],vertex[2]);
bendingSlope = trackParam->GetBendingSlope();
nonBendingSlope = trackParam->GetNonBendingSlope();
theESDTrack->SetInverseBendingMomentum(inverseBendingMomentum);
theESDTrack->SetThetaX(TMath::ATan(nonBendingSlope));
theESDTrack->SetThetaY(TMath::ATan(bendingSlope));
- theESDTrack->SetZ(vertex[2]);
- theESDTrack->SetBendingCoor(vertex[1]); // calculate vertex at ESD or Tracking level ?
- theESDTrack->SetNonBendingCoor(vertex[0]);
+ theESDTrack->SetZ(zRec);
+ theESDTrack->SetBendingCoor(yRec); // calculate vertex at ESD or Tracking level ?
+ theESDTrack->SetNonBendingCoor(xRec);
theESDTrack->SetChi2(fitFmin);
theESDTrack->SetNHit(nTrackHits);
theESDTrack->SetMatchTrigger(matchTrigger);
//} // end loop on event
loader->UnloadTracks();
- if (!header)
- runLoader->UnloadKinematics();
+ // if (!header)
+// runLoader->UnloadKinematics();
delete theESDTrack;
delete muonData;
// delete particle;
+}//_____________________________________________________________________________
+void AliMUONReconstructor::FillESD(AliRunLoader* runLoader, AliRawReader* /*rawReader*/, AliESD* esd) const
+{
+ // don't need rawReader ???
+ FillESD(runLoader, esd);
}