X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDReconstructor.cxx;h=be74c987d9fba057a51a84b2f2e099e42d1770c2;hb=4ea997df718622ff648fa363cd4b55e26c4485cd;hp=589663b2acf432334efb4f43847f34777a2921bb;hpb=d202144c4160ff96592b1020b1457ff88079693e;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDReconstructor.cxx b/TRD/AliTRDReconstructor.cxx index 589663b2acf..be74c987d9f 100644 --- a/TRD/AliTRDReconstructor.cxx +++ b/TRD/AliTRDReconstructor.cxx @@ -1,242 +1,364 @@ /************************************************************************** - * 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. * - **************************************************************************/ +* 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 for TRD reconstruction // +// Class for TRD reconstruction // // // /////////////////////////////////////////////////////////////////////////////// -#include +#include +#include +#include +#include -#include "AliTRDReconstructor.h" -#include "AliRunLoader.h" -#include "AliTRDclusterizerV1.h" -#include "AliTRDtracker.h" -#include "AliTRDpidESD.h" #include "AliRawReader.h" -#include "AliLog.h" -#include "AliTRDtrigger.h" -#include "AliTRDtrigParam.h" -#include "AliTRDgtuTrack.h" -#include "AliRun.h" -#include "AliESDTrdTrack.h" -#include "AliESD.h" + +#include "AliTRDReconstructor.h" +#include "AliTRDclusterizer.h" +#include "AliTRDrawData.h" +#include "AliTRDdigitsManager.h" +#include "AliTRDtrackerV1.h" + +#define SETFLG(n,f) ((n) |= f) +#define CLRFLG(n,f) ((n) &= ~f) ClassImp(AliTRDReconstructor) -Bool_t AliTRDReconstructor::fgkSeedingOn = kFALSE; +TClonesArray *AliTRDReconstructor::fgClusters = 0x0; +TClonesArray *AliTRDReconstructor::fgTracklets = 0x0; +Char_t* AliTRDReconstructor::fgSteerNames[kNsteer] = { + "DigitsConversion " + ,"Tail Cancellation " + ,"Clusters LUT " + ,"Clusters GAUSS " + ,"Clusters Sharing " + ,"NN PID " + ,"8 dEdx slices in ESD " + ,"Write Clusters " + ,"Write Online Tracklets " + ,"Drift Gas Argon " + ,"Stand Alone Tracking " + ,"Vertex Constrain " + ,"Tracklet Improve " + ,"HLT Mode " + ,"Cosmic Reconstruction " + ,"Process Online Tracklets" +}; +Char_t* AliTRDReconstructor::fgSteerFlags[kNsteer] = { + "dc"// digits conversion [false] + ,"tc"// apply tail cancellation [true] + ,"lut"// look-up-table for cluster shape in the r-phi direction + ,"gs"// gauss cluster shape in the r-phi direction + ,"sh"// cluster sharing between tracks + ,"nn"// PID method in reconstruction (NN) [true] + ,"8s"// 8 dEdx slices in ESD [true] + ,"cw"// write clusters [true] + ,"tw"// write online tracklets [false] + ,"ar"// drift gas [false] - do not update the number of exponentials in the TC ! + ,"sa"// track seeding (stand alone tracking) [true] + ,"vc"// vertex constrain on stand alone track finder [false] + ,"ti"// improve tracklets in stand alone track finder [true] + ,"hlt"// HLT reconstruction [false] + ,"cos"// Cosmic Reconstruction [false] + ,"tp"// also use online tracklets for reconstruction [false] +}; +Char_t* AliTRDReconstructor::fgTaskNames[kNtasks] = { + "RawReader" + ,"Clusterizer" + ,"Tracker" + ,"PID" +}; +Char_t* AliTRDReconstructor::fgTaskFlags[kNtasks] = { + "rr" + ,"cl" + ,"tr" + ,"pd" +}; //_____________________________________________________________________________ -void AliTRDReconstructor::Reconstruct(AliRunLoader* runLoader) const +AliTRDReconstructor::AliTRDReconstructor() + :AliReconstructor() + ,fSteerParam(0) { -// reconstruct clusters + // setting default "ON" steering parameters + // owner of debug streamers + SETFLG(fSteerParam, kOwner); + // write clusters [cw] + SETFLG(fSteerParam, kWriteClusters); + // track seeding (stand alone tracking) [sa] + SETFLG(fSteerParam, kSeeding); + // PID method in reconstruction (NN) [nn] + SETFLG(fSteerParam, kSteerPID); + // number of dEdx slices in the ESD track [8s] + SETFLG(fSteerParam, kEightSlices); + // vertex constrain for stand alone track finder + SETFLG(fSteerParam, kVertexConstrained); + // improve tracklets for stand alone track finder + SETFLG(fSteerParam, kImproveTracklet); + // use look up table for cluster r-phi position + SETFLG(fSteerParam, kLUT); + // use tail cancellation + SETFLG(fSteerParam, kTC); + + memset(fStreamLevel, 0, kNtasks*sizeof(UChar_t)); + memset(fDebugStream, 0, sizeof(TTreeSRedirector *) * kNtasks); + // Xe tail cancellation parameters + fTCParams[0] = 1.156; // r1 + fTCParams[1] = 0.130; // r2 + fTCParams[2] = 0.114; // c1 + fTCParams[3] = 0.624; // c2 + // Ar tail cancellation parameters + fTCParams[4] = 6.; // r1 + fTCParams[5] = 0.62; // r2 + fTCParams[6] = 0.0087;// c1 + fTCParams[7] = 0.07; // c2 +} - AliLoader *loader=runLoader->GetLoader("TRDLoader"); - loader->LoadRecPoints("recreate"); +//_____________________________________________________________________________ +AliTRDReconstructor::AliTRDReconstructor(const AliTRDReconstructor &r) + :AliReconstructor(r) + ,fSteerParam(r.fSteerParam) +{ + // + // Copy constructor + // + + memcpy(fStreamLevel, r.fStreamLevel, kNtasks*sizeof(UChar_t)); + memcpy(fTCParams, r.fTCParams, 8*sizeof(Double_t)); + memcpy(fDebugStream, r.fDebugStream, sizeof(TTreeSRedirector *) *kNtasks); + // ownership of debug streamers is not taken + CLRFLG(fSteerParam, kOwner); +} - AliTRDclusterizerV1 clusterer("clusterer", "TRD clusterizer"); - runLoader->CdGAFile(); - Int_t nEvents = runLoader->GetNumberOfEvents(); +//_____________________________________________________________________________ +AliTRDReconstructor::~AliTRDReconstructor() +{ + // + // Destructor + // - for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) { - clusterer.Open(runLoader->GetFileName(), iEvent); - clusterer.ReadDigits(); - clusterer.MakeClusters(); - clusterer.WriteClusters(-1); + if(fgClusters) { + fgClusters->Delete(); delete fgClusters; } - - loader->UnloadRecPoints(); - - // Trigger (tracklets, LTU) - - loader->LoadTracks(); - if (loader->TreeT()) { - Info("Reconstruct","Tracklets already exist"); - return; + if(fgTracklets) { + fgTracklets->Delete(); delete fgTracklets; } - Info("Reconstruct","Trigger tracklets will be produced"); - - AliTRDtrigger trdTrigger("Trigger","Trigger class"); - - AliTRDtrigParam *trigp = new AliTRDtrigParam("TRDtrigParam","TRD Trigger parameters"); - - if (runLoader->GetAliRun() == 0x0) runLoader->LoadgAlice(); - gAlice = runLoader->GetAliRun(); - Double_t x[3] = { 0.0, 0.0, 0.0 }; - Double_t b[3]; - gAlice->Field(x,b); // b[] is in kilo Gauss - Float_t field = b[2] * 0.1; // Tesla - Info("Reconstruct","Trigger set for magnetic field = %f Tesla \n",field); - - trigp->SetField(field); - trigp->Init(); - trdTrigger.SetParameter(trigp); - - for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) { - trdTrigger.Open(runLoader->GetFileName(), iEvent); - trdTrigger.ReadDigits(); - trdTrigger.MakeTracklets(); - trdTrigger.WriteTracklets(-1); + if(fSteerParam&kOwner){ + for(Int_t itask = 0; itask < kNtasks; itask++) + if(fDebugStream[itask]) delete fDebugStream[itask]; } +} - loader->UnloadTracks(); +//_____________________________________________________________________________ +void AliTRDReconstructor::Init(){ + // + // Init Options + // + SetOption(GetOption()); + Options(fSteerParam, fStreamLevel); } //_____________________________________________________________________________ -void AliTRDReconstructor::Reconstruct(AliRunLoader* runLoader, - AliRawReader* rawReader) const +void AliTRDReconstructor::ConvertDigits(AliRawReader *rawReader + , TTree *digitsTree) const { -// reconstruct clusters + // + // Convert raw data digits into digit objects in a root tree + // - AliInfo("Reconstruct TRD clusters from RAW data"); + //AliInfo("Convert raw data digits into digit objects [RawReader -> Digit TTree]"); - AliLoader *loader=runLoader->GetLoader("TRDLoader"); - loader->LoadRecPoints("recreate"); + AliTRDrawData rawData; + rawReader->Reset(); + rawReader->Select("TRD"); + rawData.OpenOutput(); + AliTRDdigitsManager *manager = rawData.Raw2Digits(rawReader); + manager->MakeBranch(digitsTree); + manager->WriteDigits(); + delete manager; - AliTRDclusterizerV1 clusterer("clusterer", "TRD clusterizer"); - runLoader->CdGAFile(); - Int_t nEvents = runLoader->GetNumberOfEvents(); +} - for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) { - if (!rawReader->NextEvent()) break; - clusterer.Open(runLoader->GetFileName(), iEvent); - clusterer.ReadDigits(rawReader); - clusterer.MakeClusters(); - clusterer.WriteClusters(-1); - } +//_____________________________________________________________________________ +void AliTRDReconstructor::Reconstruct(AliRawReader *rawReader + , TTree *clusterTree) const +{ + // + // Reconstruct clusters + // - loader->UnloadRecPoints(); + //AliInfo("Reconstruct TRD clusters from RAW data [RawReader -> Cluster TTree]"); - // Trigger (tracklets, LTU) - loader->LoadTracks(); - if (loader->TreeT()) { - Info("Reconstruct","Tracklets already exist"); - return; - } - Info("Reconstruct","Trigger tracklets will be produced"); + rawReader->Reset(); + rawReader->Select("TRD"); + + // New (fast) cluster finder + AliTRDclusterizer clusterer(fgTaskNames[kClusterizer], fgTaskNames[kClusterizer]); + clusterer.SetReconstructor(this); + clusterer.OpenOutput(clusterTree); + clusterer.OpenTrackletOutput(); + clusterer.SetUseLabels(kFALSE); + clusterer.Raw2ClustersChamber(rawReader); + + if(IsWritingClusters()) return; - AliTRDtrigger trdTrigger("Trigger","Trigger class"); + // take over ownership of clusters + fgClusters = clusterer.RecPoints(); + clusterer.SetClustersOwner(kFALSE); - AliTRDtrigParam *trigp = new AliTRDtrigParam("TRDtrigParam","TRD Trigger parameters"); + // take over ownership of online tracklets + fgTracklets = clusterer.TrackletsArray(); + clusterer.SetTrackletsOwner(kFALSE); +} - if (runLoader->GetAliRun() == 0x0) runLoader->LoadgAlice(); - gAlice = runLoader->GetAliRun(); - Double_t x[3] = { 0.0, 0.0, 0.0 }; - Double_t b[3]; - gAlice->Field(x,b); // b[] is in kilo Gauss - Float_t field = b[2] * 0.1; // Tesla - Info("Reconstruct","Trigger set for magnetic field = %f Tesla \n",field); +//_____________________________________________________________________________ +void AliTRDReconstructor::Reconstruct(TTree *digitsTree + , TTree *clusterTree) const +{ + // + // Reconstruct clusters + // - trigp->SetField(field); - trigp->Init(); - trdTrigger.SetParameter(trigp); + //AliInfo("Reconstruct TRD clusters from Digits [Digit TTree -> Cluster TTree]"); - rawReader->RewindEvents(); + AliTRDclusterizer clusterer(fgTaskNames[kClusterizer], fgTaskNames[kClusterizer]); + clusterer.SetReconstructor(this); + clusterer.OpenOutput(clusterTree); + clusterer.ReadDigits(digitsTree); + clusterer.MakeClusters(); - for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) { - if (!rawReader->NextEvent()) break; - trdTrigger.Open(runLoader->GetFileName(), iEvent); - trdTrigger.ReadDigits(rawReader); - trdTrigger.MakeTracklets(); - trdTrigger.WriteTracklets(-1); - } + if(IsWritingClusters()) return; - loader->UnloadTracks(); + // take over ownership of clusters + fgClusters = clusterer.RecPoints(); + clusterer.SetClustersOwner(kFALSE); + // take over ownership of online tracklets + fgTracklets = clusterer.TrackletsArray(); + clusterer.SetTrackletsOwner(kFALSE); } //_____________________________________________________________________________ -AliTracker* AliTRDReconstructor::CreateTracker(AliRunLoader* runLoader) const +AliTracker *AliTRDReconstructor::CreateTracker() const { -// create a TRD tracker + // + // Create a TRD tracker + // + + //return new AliTRDtracker(NULL); + AliTRDtrackerV1 *tracker = new AliTRDtrackerV1(); + tracker->SetReconstructor(this); + return tracker; - runLoader->CdGAFile(); - return new AliTRDtracker(gFile); } //_____________________________________________________________________________ -void AliTRDReconstructor::FillESD(AliRunLoader* runLoader, - AliESD* esd) const +void AliTRDReconstructor::FillESD(TTree* /*digitsTree*/ + , TTree* /*clusterTree*/ + , AliESDEvent* /*esd*/) const { -// make PID - - Double_t parTRD[] = { - 280., // Min. Ionizing Particle signal. Check it !!! - 0.23, // relative resolution Check it !!! - 10. // PID range (in sigmas) - }; - AliTRDpidESD trdPID(parTRD); - trdPID.MakePID(esd); - - // Trigger (tracks, GTU) - - AliTRDtrigger trdTrigger("Trigger","Trigger class"); - - AliTRDtrigParam *trigp = new AliTRDtrigParam("TRDtrigParam","TRD Trigger parameters"); - - if (runLoader->GetAliRun() == 0x0) runLoader->LoadgAlice(); - gAlice = runLoader->GetAliRun(); - Double_t x[3] = { 0.0, 0.0, 0.0 }; - Double_t b[3]; - gAlice->Field(x,b); // b[] is in kilo Gauss - Float_t field = b[2] * 0.1; // Tesla - Info("FillESD","Trigger set for magnetic field = %f Tesla \n",field); - - trigp->SetField(field); - trigp->Init(); - - trdTrigger.SetParameter(trigp); - trdTrigger.SetRunLoader(runLoader); - trdTrigger.Init(); - - Int_t iEvent = runLoader->GetEventNumber(); - runLoader->GetEvent(iEvent); - trdTrigger.ReadTracklets(runLoader); + // + // Fill ESD + // - AliESDTrdTrack *TrdTrack = new AliESDTrdTrack(); - AliTRDgtuTrack *GtuTrack; - - Int_t nTracks = trdTrigger.GetNumberOfTracks(); - for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) { - - GtuTrack = trdTrigger.GetTrack(iTrack); - - TrdTrack->SetYproj(GtuTrack->GetYproj()); - TrdTrack->SetZproj(GtuTrack->GetZproj()); - TrdTrack->SetSlope(GtuTrack->GetSlope()); - TrdTrack->SetDetector(GtuTrack->GetDetector()); - TrdTrack->SetTracklets(GtuTrack->GetTracklets()); - TrdTrack->SetPlanes(GtuTrack->GetPlanes()); - TrdTrack->SetClusters(GtuTrack->GetClusters()); - TrdTrack->SetPt(GtuTrack->GetPt()); - TrdTrack->SetPhi(GtuTrack->GetPhi()); - TrdTrack->SetEta(GtuTrack->GetEta()); - TrdTrack->SetLabel(GtuTrack->GetLabel()); - TrdTrack->SetPID(GtuTrack->GetPID()); - TrdTrack->SetIsElectron(GtuTrack->IsElectron()); +} - esd->AddTrdTrack(TrdTrack); +//_____________________________________________________________________________ +void AliTRDReconstructor::SetOption(Option_t *opt) +{ + // + // Read option string into the steer param. + // + + AliReconstructor::SetOption(opt); + + TString s(opt); + TObjArray *opar = s.Tokenize(","); + for(Int_t ipar=0; iparGetEntriesFast(); ipar++){ + Bool_t processed = kFALSE; + TString sopt(((TObjString*)(*opar)[ipar])->String()); + for(Int_t iopt=0; ioptGetEntriesFast() < 3) continue; + TString taskstr(((TObjString*)(*stl)[1])->String()); + TString levelstring(((TObjString*)(*stl)[2])->String()); + Int_t level = levelstring.Atoi(); + + // Set the stream Level + processed = kFALSE; + for(Int_t it=0; it= minLevel[task] && !fDebugStream[task]){ + TDirectory *savedir = gDirectory; + fDebugStream[task] = new TTreeSRedirector(Form("TRD.Debug%s.root", fgTaskNames[task])); + savedir->cd(); + SETFLG(fSteerParam, kOwner); + } } +//_____________________________________________________________________________ +void AliTRDReconstructor::Options(UInt_t steer, UChar_t *stream) +{ + // + // Print the options + // + for(Int_t iopt=0; iopt>iopt)&1)?" : ON":" : OFF"):"")); + } + AliDebugGeneral("AliTRDReconstructor", 1, " Debug Streaming"); + for(Int_t it=0; it