From 85a5290fa5efd16cc6c8058b4668d9dfd646a3bc Mon Sep 17 00:00:00 2001 From: hristov Date: Thu, 27 Nov 2003 18:01:24 +0000 Subject: [PATCH 1/1] Code for simulation, sdigitization and digitization moved from macros to compiled code and AliSimulation class (T.Kuhr) --- EMCAL/AliEMCAL.cxx | 19 ++ EMCAL/AliEMCAL.h | 3 + FMD/AliFMD.cxx | 6 + FMD/AliFMD.h | 1 + FMD/AliFMDSDigitizer.cxx | 2 +- FMD/AliFMDSDigitizer.h | 2 +- ITS/AliITS.cxx | 42 +++- ITS/AliITS.h | 1 + MUON/AliMUON.cxx | 6 + MUON/AliMUON.h | 1 + MUON/AliMUONDigitizerv1.cxx | 26 ++- PHOS/AliPHOS.cxx | 22 +- PHOS/AliPHOS.h | 3 + PMD/AliPMD.cxx | 20 ++ PMD/AliPMD.h | 2 + PMD/AliPMDDigitizer.cxx | 5 +- PMD/AliPMDDigitizer.h | 2 +- RICH/AliRICH.cxx | 6 + RICH/AliRICH.h | 1 + START/AliSTART.cxx | 6 + START/AliSTART.h | 2 + STEER/AliModule.h | 5 + STEER/AliRunLoader.cxx | 20 +- STEER/AliSimulation.cxx | 416 ++++++++++++++++++++++++++++++++++++ STEER/AliSimulation.h | 65 ++++++ STEER/STEERLinkDef.h | 3 + STEER/libSTEER.pkg | 2 +- TOF/AliTOF.cxx | 11 +- TOF/AliTOF.h | 1 + TOF/AliTOFSDigitizer.cxx | 2 +- TOF/AliTOFSDigitizer.h | 2 +- TPC/AliTPC.cxx | 93 ++++---- TPC/AliTPC.h | 4 +- TRD/AliTRD.cxx | 53 ++--- TRD/AliTRD.h | 1 + TRD/AliTRDdigitizer.cxx | 47 ++-- ZDC/AliZDC.cxx | 19 +- 37 files changed, 774 insertions(+), 148 deletions(-) create mode 100644 STEER/AliSimulation.cxx create mode 100644 STEER/AliSimulation.h diff --git a/EMCAL/AliEMCAL.cxx b/EMCAL/AliEMCAL.cxx index 953f398ae27..d34a7bc66e6 100644 --- a/EMCAL/AliEMCAL.cxx +++ b/EMCAL/AliEMCAL.cxx @@ -38,6 +38,9 @@ class TFile; #include "AliEMCAL.h" #include "AliEMCALGeometry.h" #include "AliEMCALLoader.h" +#include "AliRun.h" +#include "AliEMCALSDigitizer.h" +#include "AliEMCALDigitizer.h" ClassImp(AliEMCAL) //____________________________________________________________________________ @@ -240,3 +243,19 @@ AliLoader* AliEMCAL::MakeLoader(const char* topfoldername) fLoader = new AliEMCALLoader(GetName(),topfoldername); return fLoader; } + +//____________________________________________________________________________ +void AliEMCAL::Hits2SDigits() +{ +// create summable digits + + AliEMCALSDigitizer* emcalDigitizer = + new AliEMCALSDigitizer(fLoader->GetRunLoader()->GetFileName().Data()); + emcalDigitizer->ExecuteTask(); +} + +//____________________________________________________________________________ +AliDigitizer* AliEMCAL::CreateDigitizer(AliRunDigitizer* manager) +{ + return new AliEMCALDigitizer(manager); +} diff --git a/EMCAL/AliEMCAL.h b/EMCAL/AliEMCAL.h index ea1c34eba96..a9b2438a635 100644 --- a/EMCAL/AliEMCAL.h +++ b/EMCAL/AliEMCAL.h @@ -49,6 +49,9 @@ class AliEMCAL : public AliDetector { virtual AliLoader* MakeLoader(const char* topfoldername); + virtual void Hits2SDigits(); + virtual AliDigitizer* CreateDigitizer(AliRunDigitizer* manager); + protected: //AliEMCALQAChecker * fQATask ; //! PHOS checkers container diff --git a/FMD/AliFMD.cxx b/FMD/AliFMD.cxx index feb90fe96aa..c66b68af2fd 100644 --- a/FMD/AliFMD.cxx +++ b/FMD/AliFMD.cxx @@ -64,6 +64,7 @@ #include "AliMagF.h" #include "AliRun.h" #include "AliMC.h" +#include "AliFMDDigitizer.h" ClassImp (AliFMD) //_____________________________________________________________________________ @@ -341,3 +342,8 @@ void AliFMD::MakeBranchInTreeD(TTree *treeD, const char *file) } } +//____________________________________________________________________________ +AliDigitizer* AliFMD::CreateDigitizer(AliRunDigitizer* manager) +{ + return new AliFMDDigitizer(manager); +} diff --git a/FMD/AliFMD.h b/FMD/AliFMD.h index e507ceb65a6..08a47e7d258 100644 --- a/FMD/AliFMD.h +++ b/FMD/AliFMD.h @@ -39,6 +39,7 @@ public: // Digitisation TClonesArray *ReconParticles() const {return fReconParticles;} virtual void SetHitsAddressBranch(TBranch *b){b->SetAddress(&fHits);} + virtual AliDigitizer* CreateDigitizer(AliRunDigitizer* manager); protected: //Granularity diff --git a/FMD/AliFMDSDigitizer.cxx b/FMD/AliFMDSDigitizer.cxx index 97307a45dd0..f3c649196fe 100644 --- a/FMD/AliFMDSDigitizer.cxx +++ b/FMD/AliFMDSDigitizer.cxx @@ -62,7 +62,7 @@ ClassImp(AliFMDSDigitizer) } //____________________________________________________________________________ -AliFMDSDigitizer::AliFMDSDigitizer(char* HeaderFile,char *SdigitsFile ):TTask("AliFMDSDigitizer","") +AliFMDSDigitizer::AliFMDSDigitizer(const char* HeaderFile,char *SdigitsFile ):TTask("AliFMDSDigitizer","") { fNevents = 0 ; // Number of events to digitize, 0 means all evens in current file // add Task to //root/Tasks folder diff --git a/FMD/AliFMDSDigitizer.h b/FMD/AliFMDSDigitizer.h index 5b6ed79d5f3..56c2f15079f 100644 --- a/FMD/AliFMDSDigitizer.h +++ b/FMD/AliFMDSDigitizer.h @@ -27,7 +27,7 @@ class AliFMDSDigitizer: public TTask { public: AliFMDSDigitizer() ; // ctor - AliFMDSDigitizer(char* HeaderFile,char *SdigitsFile = 0) ; + AliFMDSDigitizer(const char* HeaderFile,char *SdigitsFile = 0) ; virtual ~AliFMDSDigitizer() ; // dtor // Int_t Digitize(Float_t Energy); diff --git a/ITS/AliITS.cxx b/ITS/AliITS.cxx index 81ad690d382..7f1009c52d3 100644 --- a/ITS/AliITS.cxx +++ b/ITS/AliITS.cxx @@ -107,6 +107,7 @@ the AliITS class. #include "AliITSsimulationSPD.h" #include "AliITSsimulationSSD.h" #include "AliMC.h" +#include "AliITSDigitizer.h" ClassImp(AliITS) @@ -949,19 +950,23 @@ void AliITS::Hits2SDigits(){ // none. // return; // Using Hits in place of the larger sDigits. + fLoader->LoadHits("read"); + fLoader->LoadSDigits("recreate"); AliRunLoader* rl = fLoader->GetRunLoader(); - AliHeader *header=rl->GetHeader(); // Get event number from this file. - if (header == 0x0) - { - rl->LoadHeader(); - header=rl->GetHeader(); - if (header == 0x0) return; - } + + for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) { // Do the Hits to Digits operation. Use Standard input values. // Event number from file, no background hit merging , use size from // AliITSgeom class, option="All", input from this file only. - HitsToSDigits(header->GetEvent(),0,-1," ",fOpt," "); + rl->GetEvent(iEvent); + if (!fLoader->TreeS()) fLoader->MakeTree("S"); + MakeBranch("S"); + SetTreeAddress(); + HitsToSDigits(iEvent,0,-1," ",fOpt," "); + } + fLoader->UnloadHits(); + fLoader->UnloadSDigits(); } //______________________________________________________________________ void AliITS::Hits2PreDigits(){ @@ -978,6 +983,11 @@ void AliITS::Hits2PreDigits(){ HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," "); } //______________________________________________________________________ +AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager) +{ + return new AliITSDigitizer(manager); +} +//______________________________________________________________________ void AliITS::SDigitsToDigits(Option_t *opt){ // Standard Summable digits to Digits function. // Inputs: @@ -1049,11 +1059,23 @@ void AliITS::Hits2Digits(){ // Outputs: // none. - AliHeader *header=fLoader->GetRunLoader()->GetHeader(); // Get event number from this file. + fLoader->LoadHits("read"); + fLoader->LoadDigits("recreate"); + AliRunLoader* rl = fLoader->GetRunLoader(); + + for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) { // Do the Hits to Digits operation. Use Standard input values. // Event number from file, no background hit merging , use size from // AliITSgeom class, option="All", input from this file only. - HitsToDigits(header->GetEvent(),0,-1," ",fOpt," "); + rl->GetEvent(iEvent); + if (!fLoader->TreeD()) fLoader->MakeTree("D"); + MakeBranch("D"); + SetTreeAddress(); + HitsToDigits(iEvent,0,-1," ",fOpt," "); + } + + fLoader->UnloadHits(); + fLoader->UnloadDigits(); } //______________________________________________________________________ void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size, diff --git a/ITS/AliITS.h b/ITS/AliITS.h index 4fb231a2430..111184b6178 100644 --- a/ITS/AliITS.h +++ b/ITS/AliITS.h @@ -120,6 +120,7 @@ class AliITS : public AliDetector { void SetTreeAddressD(TTree *treeD); void Hits2SDigits(); // Turn hits into SDigits void Hits2PreDigits(); // Turn hits into SDigits + AliDigitizer* CreateDigitizer(AliRunDigitizer* manager); void SDigits2Digits(){SDigitsToDigits("All");} // Turn SDigits to Digits void SDigitsToDigits(Option_t *opt="All"); // Turn SDigits to Digits void Hits2Digits(); // Turn hits straight into Digits. diff --git a/MUON/AliMUON.cxx b/MUON/AliMUON.cxx index 7f8cd05e3bd..e63a35b613e 100644 --- a/MUON/AliMUON.cxx +++ b/MUON/AliMUON.cxx @@ -67,6 +67,7 @@ #include "AliMUONTriggerCircuit.h" #include "AliMUONTriggerDecision.h" #include "AliRun.h" +#include "AliMUONDigitizerv1.h" // Defaults parameters for Z positions of chambers @@ -337,6 +338,11 @@ void AliMUON::SetNsec(Int_t id, Int_t nsec) // Set number of segmented cathods for chamber id ((AliMUONChamber*) fChambers->At(id))->SetNsec(nsec); } +//____________________________________________________________________ +AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) +{ + return new AliMUONDigitizerv1(manager); +} //_____________________________________________________________________ void AliMUON::SDigits2Digits() { diff --git a/MUON/AliMUON.h b/MUON/AliMUON.h index 859fb2407ac..c9e45844183 100644 --- a/MUON/AliMUON.h +++ b/MUON/AliMUON.h @@ -61,6 +61,7 @@ class AliMUON : public AliDetector { virtual void Digits2Reco(); virtual void FindClusters(); // Digitisation + virtual AliDigitizer* CreateDigitizer(AliRunDigitizer* manager); virtual void SDigits2Digits(); // Configuration Methods (per station id) // diff --git a/MUON/AliMUONDigitizerv1.cxx b/MUON/AliMUONDigitizerv1.cxx index 882c55b06ac..f8d542c778b 100644 --- a/MUON/AliMUONDigitizerv1.cxx +++ b/MUON/AliMUONDigitizerv1.cxx @@ -25,25 +25,32 @@ ClassImp(AliMUONDigitizerv1) //___________________________________________ -AliMUONDigitizerv1::AliMUONDigitizerv1() :AliDigitizer() +AliMUONDigitizerv1::AliMUONDigitizerv1() : + AliDigitizer(), + fHitMap(0), + fTDList(0), + fTDCounter(0), + fDebug(0), + fMask(0), + fSignal(0) { // Default ctor - don't use it - fHitMap = 0; - fTDList = 0; if (GetDebug()>2) cerr<<"AliMUONDigitizerv1::AliMUONDigitizerv1" <<"(AliRunDigitizer* manager) was processed"<2) cerr<<"AliMUONDigitizerv1::AliMUONDigitizerv1" <<"(AliRunDigitizer* manager) was processed"<GetRunLoader()->GetFileName().Data()); + phosDigitizer->ExecuteTask("all"); +} + +//____________________________________________________________________________ +AliDigitizer* AliPHOS::CreateDigitizer(AliRunDigitizer* manager) +{ + return new AliPHOSDigitizer(manager); +} diff --git a/PHOS/AliPHOS.h b/PHOS/AliPHOS.h index f612c8d644a..d28e5e5ebe6 100644 --- a/PHOS/AliPHOS.h +++ b/PHOS/AliPHOS.h @@ -54,6 +54,9 @@ class AliPHOS : public AliDetector { virtual AliLoader* MakeLoader(const char* topfoldername); + virtual void Hits2SDigits(); + virtual AliDigitizer* CreateDigitizer(AliRunDigitizer* manager); + protected: AliPHOSQAChecker * fQATask ; //! PHOS checkers container diff --git a/PMD/AliPMD.cxx b/PMD/AliPMD.cxx index 938b197ce24..de70e52203c 100644 --- a/PMD/AliPMD.cxx +++ b/PMD/AliPMD.cxx @@ -52,6 +52,7 @@ #include "AliPMDRecPoint.h" #include "AliRun.h" #include "AliMC.h" +#include "AliPMDDigitizer.h" ClassImp(AliPMD) @@ -350,3 +351,22 @@ AliPMDhit::AliPMDhit(Int_t shunt,Int_t track, Int_t *vol, Float_t *hits): fEnergy=hits[3]; } + +//____________________________________________________________________________ +void AliPMD::Hits2SDigits() +{ +// create summable digits + + AliRunLoader* runLoader = fLoader->GetRunLoader(); + AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer; + pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(), + "HS"); + pmdDigitizer->SetZPosition(365.0); + + for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) { + pmdDigitizer->Hits2SDigits(iEvent); + } + fLoader->UnloadHits(); + fLoader->UnloadSDigits(); + delete pmdDigitizer; +} diff --git a/PMD/AliPMD.h b/PMD/AliPMD.h index a41c524f977..1936632de41 100644 --- a/PMD/AliPMD.h +++ b/PMD/AliPMD.h @@ -48,6 +48,8 @@ public: virtual void SetTreeAddress(); virtual void ResetHits(); + virtual void Hits2SDigits(); + private: TClonesArray* fRecPoints; //! List of reconstructed hits Int_t fNRecPoints; // Number of reconstructed hits diff --git a/PMD/AliPMDDigitizer.cxx b/PMD/AliPMDDigitizer.cxx index 135e73f8764..03f6454c44b 100644 --- a/PMD/AliPMDDigitizer.cxx +++ b/PMD/AliPMDDigitizer.cxx @@ -87,13 +87,12 @@ AliPMDDigitizer::~AliPMDDigitizer() // // Member functions // -void AliPMDDigitizer::OpengAliceFile(Char_t *file, Option_t *option) +void AliPMDDigitizer::OpengAliceFile(const char *file, Option_t *option) { // Loads galice.root file and corresponding header, kinematics // hits and sdigits or digits depending on the option // - fRunLoader = AliRunLoader::Open(file,AliConfig::fgkDefaultEventFolderName, - "UPDATE"); + fRunLoader = AliRunLoader::Open(file,AliConfig::fgkDefaultEventFolderName); if (!fRunLoader) { diff --git a/PMD/AliPMDDigitizer.h b/PMD/AliPMDDigitizer.h index f2532cf944c..22d7d716303 100644 --- a/PMD/AliPMDDigitizer.h +++ b/PMD/AliPMDDigitizer.h @@ -38,7 +38,7 @@ class AliPMDDigitizer AliPMDDigitizer(); virtual ~AliPMDDigitizer(); - void OpengAliceFile(char *file, Option_t *option); + void OpengAliceFile(const char *file, Option_t *option); void Hits2SDigits(Int_t ievt); void Hits2Digits(Int_t ievt); diff --git a/RICH/AliRICH.cxx b/RICH/AliRICH.cxx index 6fe76ffc0da..1d2278bcf6f 100644 --- a/RICH/AliRICH.cxx +++ b/RICH/AliRICH.cxx @@ -28,6 +28,7 @@ #include #include #include +#include "AliRICHDigitizer.h" ClassImp(AliRICHhit) //__________________________________________________________________________________________________ @@ -133,6 +134,11 @@ void AliRICH::Hits2SDigits() if(GetDebug()) Info("Hit2SDigits","Stop."); }//void AliRICH::Hits2SDigits() //__________________________________________________________________________________________________ +AliDigitizer* AliRICH::CreateDigitizer(AliRunDigitizer* manager) +{ + return new AliRICHDigitizer(manager); +} +//__________________________________________________________________________________________________ void AliRICH::SDigits2Digits() { //Generate digits from sdigits. diff --git a/RICH/AliRICH.h b/RICH/AliRICH.h index 5aa3fbc8d10..ba926296ea0 100644 --- a/RICH/AliRICH.h +++ b/RICH/AliRICH.h @@ -267,6 +267,7 @@ public: AliRICH& operator=(const AliRICH&) {return *this;} virtual Int_t IsVersion() const =0; void Hits2SDigits(); //virtual + AliDigitizer* CreateDigitizer(AliRunDigitizer* manager); //virtual void SDigits2Digits(); //virtual inline void CreateHits(); diff --git a/START/AliSTART.cxx b/START/AliSTART.cxx index bdf950af9d1..402f8c8a4ec 100755 --- a/START/AliSTART.cxx +++ b/START/AliSTART.cxx @@ -56,6 +56,7 @@ #include "AliSTARThitPhoton.h" #include "AliSTARTvertex.h" #include "AliMC.h" +#include "AliSTARTDigitizer.h" ClassImp(AliSTART) @@ -261,3 +262,8 @@ void AliSTART::Hit2digit(Int_t /*evnum*/) { } +//_____________________________________________________________________________ +AliDigitizer* AliSTART::CreateDigitizer(AliRunDigitizer* manager) +{ + return new AliSTARTDigitizer(manager); +} diff --git a/START/AliSTART.h b/START/AliSTART.h index 004f4a1a0eb..939c0cc91b6 100755 --- a/START/AliSTART.h +++ b/START/AliSTART.h @@ -44,6 +44,8 @@ public: virtual void SetTreeAddress(); TClonesArray *Photons() {return fPhotons;} + virtual AliDigitizer* CreateDigitizer(AliRunDigitizer* manager); + protected: Int_t fIdSens; // Sensetive Cherenkov radiator Int_t fNPhotons; // Number of photons plan to photokatod diff --git a/STEER/AliModule.h b/STEER/AliModule.h index 92c233cef9c..35db6d6f65e 100644 --- a/STEER/AliModule.h +++ b/STEER/AliModule.h @@ -20,6 +20,8 @@ class TFile; class TTree; class AliLoader; class AliTrackReference; +class AliDigitizer; +class AliRunDigitizer; class AliModule : public TNamed , public TAttLine, public TAttMarker, @@ -80,7 +82,10 @@ public: virtual void AddHit(Int_t, Int_t*, Float_t *) { Error("AddDigit","Hits cannot be added to module %s\n",fName.Data());} virtual void Hits2SDigits() {} + virtual AliDigitizer* CreateDigitizer(AliRunDigitizer* /*manager*/) + {return NULL;} virtual void SDigits2Digits() {} + virtual void Hits2Digits() {} virtual void Digits2Reco() {} virtual void Digits2Raw() {} virtual void Raw2Digits() {} diff --git a/STEER/AliRunLoader.cxx b/STEER/AliRunLoader.cxx index 7dacc5227ac..8821997dace 100644 --- a/STEER/AliRunLoader.cxx +++ b/STEER/AliRunLoader.cxx @@ -77,6 +77,7 @@ AliRunLoader::AliRunLoader(): fUnixDirName(".") { AliConfig::Instance();//force to build the folder structure + if (!fgRunLoader) fgRunLoader = this; } /**************************************************************************/ @@ -95,6 +96,7 @@ AliRunLoader::AliRunLoader(const char* eventfoldername): { //ctor SetEventFolderName(eventfoldername); + if (!fgRunLoader) fgRunLoader = this; } /**************************************************************************/ @@ -124,15 +126,26 @@ AliRunLoader::~AliRunLoader() } /**************************************************************************/ -AliRunLoader::AliRunLoader(TFolder* topfolder):TNamed(fgkRunLoaderName,fgkRunLoaderName) +AliRunLoader::AliRunLoader(TFolder* topfolder): + TNamed(fgkRunLoaderName,fgkRunLoaderName), + fLoaders(new TObjArray()), + fEventFolder(topfolder), + fCurrentEvent(0), + fGAFile(0x0), + fHeader(0x0), + fStack(0x0), + fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")), + fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")), + fNEventsPerFile(1), + fUnixDirName(".") { //ctor + if (!fgRunLoader) fgRunLoader = this; if(topfolder == 0x0) { Fatal("AliRunLoader(TFolder*)","Parameter is NULL"); return; } - fEventFolder = topfolder; TObject* obj = fEventFolder->FindObject(fgkRunLoaderName); if (obj) @@ -143,7 +156,6 @@ AliRunLoader::AliRunLoader(TFolder* topfolder):TNamed(fgkRunLoaderName,fgkRunLoa return;//never reached } - fLoaders = new TObjArray(); fEventFolder->Add(this);//put myself to the folder to accessible for all } @@ -421,7 +433,7 @@ AliRunLoader* AliRunLoader::Open result->SetDirName(dirname); result->SetGAliceFile(gAliceFile);//set the pointer to gAliceFile - fgRunLoader = result; //PH get access from any place + if (!fgRunLoader) fgRunLoader = result; //PH get access from any place return result; } /**************************************************************************/ diff --git a/STEER/AliSimulation.cxx b/STEER/AliSimulation.cxx new file mode 100644 index 00000000000..54440d3702b --- /dev/null +++ b/STEER/AliSimulation.cxx @@ -0,0 +1,416 @@ +/************************************************************************** + * 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 running generation, simulation and digitization // +// // +// Hits, sdigits and digits are created for all detectors by typing: // +// // +// AliSimulation sim; // +// sim.Run(); // +// // +// The Run method returns kTRUE in case of successful execution. // +// The number of events can be given as argument to the Run method or it // +// can be set by // +// // +// sim.SetNumberOfEvents(n); // +// // +// The name of the configuration file can be specified by // +// // +// sim.SetConfigFile("..."); // +// // +// The generation of particles and the simulation of detector hits can be // +// switched on or off by // +// // +// sim.SetRunGeneration(kTRUE); // generation of primary particles // +// sim.SetRunSimulation(kFALSE); // but no tracking // +// // +// For which detectors sdigits and digits will be created, can be steered // +// by // +// // +// sim.SetMakeSDigits("ALL"); // make sdigits for all detectors // +// sim.SetMakeDigits("ITS TPC"); // make digits only for ITS and TPC // +// // +// The argument is a (case sensitive) string with the names of the // +// detectors separated by a space. An empty string ("") can be used to // +// disable the creation of sdigits or digits. The special string "ALL" // +// selects all available detectors. This is the default. // +// // +// The creation of digits from hits instead of from sdigits can be selected // +// by // +// // +// sim.SetMakeDigitsFromHits("TRD"); // +// // +// The argument is again a string with the selected detectors. Be aware that // +// this feature is not available for all detectors and that merging is not // +// possible, when digits are created directly from hits. // +// // +// Backgound events can be merged by calling // +// // +// sim.MergeWith("background/galice.root", 2); // +// // +// The first argument is the file name of the background galice file. The // +// second argument is the number of signal events per background event. // +// The default value for this is 1. MergeWith can be called several times // +// to merge more than two event streams. It is assumed that the sdigits // +// were already produced for the background events. // +// // +/////////////////////////////////////////////////////////////////////////////// + + +#include "AliSimulation.h" +#include "AliRunLoader.h" +#include "AliRun.h" +#include "AliModule.h" +#include "AliGenerator.h" +#include "AliRunDigitizer.h" +#include + + +ClassImp(AliSimulation) + + +//_____________________________________________________________________________ +AliSimulation::AliSimulation(const char* name, const char* title) : + TNamed(name, title) +{ +// create simulation object with default parameters + + Init(); +} + +//_____________________________________________________________________________ +AliSimulation::AliSimulation(const AliSimulation& sim) : + TNamed(sim) +{ +// copy constructor + + fRunGeneration = sim.fRunGeneration; + fRunSimulation = sim.fRunSimulation; + fMakeSDigits = sim.fMakeSDigits; + fMakeDigits = sim.fMakeDigits; + fMakeDigitsFromHits = sim.fMakeDigitsFromHits; + fStopOnError = sim.fStopOnError; + + fNEvents = sim.fNEvents; + fConfigFileName = sim.fConfigFileName; + fGAliceFileName = sim.fGAliceFileName; + fBkgrdFileNames = new TObjArray; + for (Int_t i = 0; i < sim.fBkgrdFileNames->GetEntriesFast(); i++) { + if (!sim.fBkgrdFileNames->At(i)) continue; + fBkgrdFileNames->Add(sim.fBkgrdFileNames->At(i)->Clone()); + } + + fRunLoader = NULL; +} + +//_____________________________________________________________________________ +AliSimulation& AliSimulation::operator = (const AliSimulation& sim) +{ +// assignment operator + + this->~AliSimulation(); + new(this) AliSimulation(sim); + return *this; +} + +//_____________________________________________________________________________ +AliSimulation::~AliSimulation() +{ +// clean up + + fBkgrdFileNames->Delete(); + delete fBkgrdFileNames; +} + +//_____________________________________________________________________________ +void AliSimulation::Init() +{ +// set default parameters + + fRunGeneration = kTRUE; + fRunSimulation = kTRUE; + fMakeSDigits = "ALL"; + fMakeDigits = "ALL"; + fMakeDigitsFromHits = ""; + fStopOnError = kFALSE; + + fNEvents = 1; + fConfigFileName = "Config.C"; + fGAliceFileName = "galice.root"; + fBkgrdFileNames = new TObjArray; + + fRunLoader = NULL; +} + + +//_____________________________________________________________________________ +void AliSimulation::SetNumberOfEvents(Int_t nEvents) +{ +// set the number of events for one run + + fNEvents = nEvents; +} + +//_____________________________________________________________________________ +void AliSimulation::SetConfigFile(const char* fileName) +{ +// set the name of the config file + + fConfigFileName = fileName; +} + +//_____________________________________________________________________________ +void AliSimulation::MergeWith(const char* fileName, Int_t nSignalPerBkgrd) +{ +// add a file with background events for merging + + TObjString* fileNameStr = new TObjString(fileName); + fileNameStr->SetUniqueID(nSignalPerBkgrd); + fBkgrdFileNames->Add(fileNameStr); +} + + +//_____________________________________________________________________________ +Bool_t AliSimulation::Run(Int_t nEvents) +{ +// run the generation, simulation and digitization + + if (nEvents > 0) fNEvents = nEvents; + + // generation and simulation -> hits + if (fRunGeneration) { + if (!gAlice) { + Error("Run", "no gAlice object. Restart aliroot and try again."); + return kFALSE; + } + if (gAlice->Modules()->GetEntries() > 0) { + Error("Run", "gAlice was already run. Restart aliroot and try again."); + return kFALSE; + } + if (!RunSimulation()) if (fStopOnError) return kFALSE; + } + + // reopen the run loader + if (fRunLoader) delete fRunLoader; + fRunLoader = AliRunLoader::Open(fGAliceFileName.Data()); + if (!fRunLoader) { + Error("Run", "no run loader found in file %s", + fGAliceFileName.Data()); + return kFALSE; + } + fRunLoader->LoadgAlice(); + gAlice = fRunLoader->GetAliRun(); + if (!gAlice) { + Error("GetLoadersAndDetectors", "no gAlice object found in file %s", + fGAliceFileName.Data()); + return kFALSE; + } + + // hits -> summable digits + if (!fMakeSDigits.IsNull()) { + if (!RunSDigitization(fMakeSDigits)) if (fStopOnError) return kFALSE; + } + + // summable digits -> digits + if (!fMakeDigits.IsNull()) { + if (!RunDigitization(fMakeDigits, fMakeDigitsFromHits)) { + if (fStopOnError) return kFALSE; + } + } + + // hits -> digits + if (!fMakeDigitsFromHits.IsNull()) { + if (fBkgrdFileNames->GetEntriesFast() > 0) { + Warning("Run", "Merging and direct creation of digits from hits " + "was selected for some detectors. " + "No merging will be done for the following detectors: %s", + fMakeDigitsFromHits.Data()); + } + if (!RunHitsDigitization(fMakeDigitsFromHits)) { + if (fStopOnError) return kFALSE; + } + } + + return kTRUE; +} + +//_____________________________________________________________________________ +Bool_t AliSimulation::RunSimulation() +{ +// run the generation and simulation + + Info("RunSimulation", "initializing gAlice with config file %s", + fConfigFileName.Data()); + gAlice->Init(fConfigFileName.Data()); + fRunLoader = gAlice->GetRunLoader(); + if (!fRunLoader) { + Error("RunSimulation", "gAlice has no run loader object. " + "Check your config file: %s", fConfigFileName.Data()); + return kFALSE; + } + fGAliceFileName = fRunLoader->GetFileName(); + + if (!fRunSimulation) { + if (!gAlice->Generator()) { + Error("RunSimulation", "gAlice has no generator object. " + "Check your config file: %s", fConfigFileName.Data()); + return kFALSE; + } + gAlice->Generator()->SetTrackingFlag(0); + } + + Info("Run", "running gAlice"); + gAlice->Run(fNEvents); + + return kTRUE; +} + +//_____________________________________________________________________________ +Bool_t AliSimulation::RunSDigitization(const TString& detectors) +{ +// run the digitization and produce summable digits + + TString detStr = detectors; + TObjArray* detArray = gAlice->Detectors(); + for (Int_t iDet = 0; iDet < detArray->GetEntriesFast(); iDet++) { + AliModule* det = (AliModule*) detArray->At(iDet); + if (!det || !det->IsActive()) continue; + if (IsSelected(det->GetName(), detStr)) { + Info("RunSDigitization", "creating summable digits for %s", + det->GetName()); + det->Hits2SDigits(); + } + } + + if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { + Error("RunSDigitization", "the following detectors were not found: %s", + detStr.Data()); + if (fStopOnError) return kFALSE; + } + + return kTRUE; +} + + +//_____________________________________________________________________________ +Bool_t AliSimulation::RunDigitization(const TString& detectors, + const TString& excludeDetectors) +{ +// run the digitization and produce digits from sdigits + + Int_t nStreams = fBkgrdFileNames->GetEntriesFast() + 1; + Int_t signalPerBkgrd = 1; + if (nStreams > 1) signalPerBkgrd = fBkgrdFileNames->At(0)->GetUniqueID(); + AliRunDigitizer* manager = new AliRunDigitizer(nStreams, signalPerBkgrd); + manager->SetInputStream(0, fGAliceFileName.Data()); + for (Int_t iStream = 1; iStream < nStreams; iStream++) { + const char* fileName = ((TObjString*) + (fBkgrdFileNames->At(iStream-1)))->GetName(); + manager->SetInputStream(iStream, fileName); + } + + TString detStr = detectors; + TString detExcl = excludeDetectors; + TObjArray* detArray = gAlice->Detectors(); + for (Int_t iDet = 0; iDet < detArray->GetEntriesFast(); iDet++) { + AliModule* det = (AliModule*) detArray->At(iDet); + if (!det || !det->IsActive()) continue; + if (IsSelected(det->GetName(), detStr) && + !IsSelected(det->GetName(), detExcl)) { + if (!det->CreateDigitizer(manager)) { + Error("RunDigitization", "no digitizer for %s", det->GetName()); + if (fStopOnError) return kFALSE; + } + } + } + + if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { + Error("RunDigitization", "the following detectors were not found: %s", + detStr.Data()); + if (fStopOnError) return kFALSE; + } + + if (!manager->GetListOfTasks()->IsEmpty()) { + Info("RunDigitization", "executing digitization"); + manager->Exec(""); + } + delete manager; + + return kTRUE; +} + +//_____________________________________________________________________________ +Bool_t AliSimulation::RunHitsDigitization(const TString& detectors) +{ +// run the digitization and produce digits from hits + + TString detStr = detectors; + TObjArray* detArray = gAlice->Detectors(); + for (Int_t iDet = 0; iDet < detArray->GetEntriesFast(); iDet++) { + AliModule* det = (AliModule*) detArray->At(iDet); + if (!det || !det->IsActive()) continue; + if (IsSelected(det->GetName(), detStr)) { + Info("RunHitsDigitization", "creating digits from hits for %s", + det->GetName()); + det->Hits2Digits(); + } + } + + if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { + Error("RunHitsDigitization", "the following detectors were not found: %s", + detStr.Data()); + if (fStopOnError) return kFALSE; + } + + return kTRUE; +} + + +//_____________________________________________________________________________ +Bool_t AliSimulation::IsSelected(TString detName, TString& detectors) const +{ +// check whether detName is contained in detectors +// if yes, it is removed from detectors + + // check if all detectors are selected + if ((detectors.CompareTo("ALL") == 0) || + detectors.BeginsWith("ALL ") || + detectors.EndsWith(" ALL") || + detectors.Contains(" ALL ")) { + detectors = "ALL"; + return kTRUE; + } + + // search for the given detector + Bool_t result = kFALSE; + if ((detectors.CompareTo(detName) == 0) || + detectors.BeginsWith(detName+" ") || + detectors.EndsWith(" "+detName) || + detectors.Contains(" "+detName+" ")) { + detectors.ReplaceAll(detName, ""); + result = kTRUE; + } + + // clean up the detectors string + while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " "); + while (detectors.BeginsWith(" ")) detectors.Remove(0, 1); + while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1); + + return result; +} diff --git a/STEER/AliSimulation.h b/STEER/AliSimulation.h new file mode 100644 index 00000000000..61b12beceac --- /dev/null +++ b/STEER/AliSimulation.h @@ -0,0 +1,65 @@ +#ifndef ALISIMULATION_H +#define ALISIMULATION_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +#include +#include + +class AliRunLoader; + + +class AliSimulation: public TNamed { +public: + AliSimulation(const char* name = "AliSimulation", + const char* title = "generation, simulation and digitization"); + AliSimulation(const AliSimulation& sim); + AliSimulation& operator = (const AliSimulation& sim); + virtual ~AliSimulation(); + + void SetNumberOfEvents(Int_t nEvents); + void SetConfigFile(const char* fileName); + + void SetRunGeneration(Bool_t run) {fRunGeneration = run;}; + void SetRunSimulation(Bool_t run) {fRunSimulation = run;}; + void SetMakeSDigits(const char* detectors) + {fMakeSDigits = detectors;}; + void MergeWith(const char* fileName, Int_t nSignalPerBkgrd = 1); + void SetMakeDigits(const char* detectors) + {fMakeDigits = detectors;}; + void SetMakeDigitsFromHits(const char* detectors) + {fMakeDigitsFromHits = detectors;}; + + virtual Bool_t Run(Int_t nEvents = 0); + +private: + void Init(); + + Bool_t IsSelected(TString detName, TString& detectors) const; + + Bool_t RunSimulation(); + Bool_t RunSDigitization(const TString& detectors); + Bool_t RunDigitization(const TString& detectors, + const TString& excludeDetectors); + Bool_t RunHitsDigitization(const TString& detectors); + + Bool_t fRunGeneration; // generate prim. particles or not + Bool_t fRunSimulation; // simulate detectors (hits) or not + TString fMakeSDigits; // create sdigits for these detectors + TString fMakeDigits; // create digits for these detectors + TString fMakeDigitsFromHits; // create digits from hits for these detectors + Bool_t fStopOnError; // stop or continue on errors + + Int_t fNEvents; // number of events + TString fConfigFileName; // name of the config file + TString fGAliceFileName; // name of the galice file + TObjArray* fBkgrdFileNames; // names of background files for merging + + AliRunLoader* fRunLoader; //! current run loader object + + ClassDef(AliSimulation, 1) // class for running generation, simulation and digitization +}; + +#endif diff --git a/STEER/STEERLinkDef.h b/STEER/STEERLinkDef.h index bd6ad43bfbd..0ee5cb5f841 100644 --- a/STEER/STEERLinkDef.h +++ b/STEER/STEERLinkDef.h @@ -10,6 +10,8 @@ #pragma link C++ global gAlice; #pragma link C++ global gMC; +#pragma link C++ global kAliDetMax; +#pragma link C++ global kAliDetAll; #pragma link C++ enum VertexSmear_t; #pragma link C++ enum VertexSource_t; @@ -75,6 +77,7 @@ #pragma link C++ class AliMemoryWatcher+; #pragma link C++ class AliBarrelTrack+; #pragma link C++ class AliMC+; +#pragma link C++ class AliSimulation+; #endif diff --git a/STEER/libSTEER.pkg b/STEER/libSTEER.pkg index b5e5cc6c4ca..d5767b8e227 100644 --- a/STEER/libSTEER.pkg +++ b/STEER/libSTEER.pkg @@ -17,7 +17,7 @@ AliGausCorr.cxx AliTrackReference.cxx AliESD.cxx \ AliTrackMap.cxx AliTrackMapper.cxx AliCollisionGeometry.cxx \ AliMemoryWatcher.cxx AliBarrelTrack.cxx \ AliESDtrack.cxx AliESDv0.cxx AliESDcascade.cxx AliESDvertex.cxx AliESDpid.cxx \ -AliMC.cxx +AliMC.cxx AliSimulation.cxx HDRS:= $(SRCS:.cxx=.h) DHDR= STEERLinkDef.h diff --git a/TOF/AliTOF.cxx b/TOF/AliTOF.cxx index 666d28ee05c..497097ff338 100644 --- a/TOF/AliTOF.cxx +++ b/TOF/AliTOF.cxx @@ -70,6 +70,7 @@ #include "AliTOFhit.h" #include "AliTOFhitT0.h" #include "AliMC.h" +#include "AliTOFDigitizer.h" ClassImp(AliTOF) @@ -723,15 +724,21 @@ void AliTOF::Hits2SDigits() //#endif //char * fileSDigits = 0 ; - char * fileHeader = 0; + const char * fileHeader = fLoader->GetRunLoader()->GetFileName().Data(); AliTOFSDigitizer * sd = new AliTOFSDigitizer(fileHeader) ; sd->Exec("") ; sd->Print(""); - delete sd ; +// delete sd ; } +//___________________________________________________________________________ +AliDigitizer* AliTOF::CreateDigitizer(AliRunDigitizer* manager) +{ + return new AliTOFDigitizer(manager); +} + //___________________________________________________________________________ Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track) { diff --git a/TOF/AliTOF.h b/TOF/AliTOF.h index 3c8e739a6b2..19e80703aaf 100644 --- a/TOF/AliTOF.h +++ b/TOF/AliTOF.h @@ -76,6 +76,7 @@ public: virtual AliTOFMerger* Merger(); // virtual void Hits2Digits(); virtual void Hits2SDigits(); + virtual AliDigitizer* CreateDigitizer(AliRunDigitizer* manager); virtual void Digits2Reco() {cout << "AliTOF::Digits2Reco() dummy function called" << endl;} void Digits2Raw (Int_t evNumber=0); void Raw2Digits (Int_t evNumber=0); diff --git a/TOF/AliTOFSDigitizer.cxx b/TOF/AliTOFSDigitizer.cxx index 0be6089e08e..795ca7ccdfc 100644 --- a/TOF/AliTOFSDigitizer.cxx +++ b/TOF/AliTOFSDigitizer.cxx @@ -74,7 +74,7 @@ ClassImp(AliTOFSDigitizer) } //____________________________________________________________________________ - AliTOFSDigitizer::AliTOFSDigitizer(char* HeaderFile, Int_t evNumber1, Int_t nEvents):TTask("AliTOFSDigitizer","") + AliTOFSDigitizer::AliTOFSDigitizer(const char* HeaderFile, Int_t evNumber1, Int_t nEvents):TTask("AliTOFSDigitizer","") { fEvent1=evNumber1; fEvent2=fEvent1+nEvents; diff --git a/TOF/AliTOFSDigitizer.h b/TOF/AliTOFSDigitizer.h index 08f78ffcff1..a47cbb32329 100644 --- a/TOF/AliTOFSDigitizer.h +++ b/TOF/AliTOFSDigitizer.h @@ -20,7 +20,7 @@ class AliTOFSDigitizer: public TTask { public: AliTOFSDigitizer() ; // ctor - AliTOFSDigitizer(char* HeaderFile, Int_t evNumber1=0, Int_t nEvents=1) ; // par ctor + AliTOFSDigitizer(const char* HeaderFile, Int_t evNumber1=0, Int_t nEvents=1) ; // par ctor virtual ~AliTOFSDigitizer() ; // dtor diff --git a/TPC/AliTPC.cxx b/TPC/AliTPC.cxx index 2b9cde3fbf2..97a429703ed 100644 --- a/TPC/AliTPC.cxx +++ b/TPC/AliTPC.cxx @@ -75,6 +75,7 @@ #include "AliTPCcluster.h" #include "AliTrackReference.h" #include "AliMC.h" +#include "AliTPCDigitizer.h" ClassImp(AliTPC) @@ -1227,6 +1228,11 @@ void AliTPC::Hits2ExactClustersSector(Int_t isec) +//______________________________________________________________________ +AliDigitizer* AliTPC::CreateDigitizer(AliRunDigitizer* manager) +{ + return new AliTPCDigitizer(manager); +} //__ void AliTPC::SDigits2Digits2(Int_t /*eventnumber*/) { @@ -1409,6 +1415,22 @@ void AliTPC::SetDefaults(){ } //__________________________________________________________________ +void AliTPC::Hits2Digits() +{ + fLoader->LoadHits("read"); + fLoader->LoadDigits("recreate"); + AliRunLoader* runLoader = fLoader->GetRunLoader(); + + for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) { + runLoader->GetEvent(iEvent); + SetActiveSectors(); + Hits2Digits(iEvent); + } + + fLoader->UnloadHits(); + fLoader->UnloadDigits(); +} +//__________________________________________________________________ void AliTPC::Hits2Digits(Int_t eventnumber) { //---------------------------------------------------- @@ -1555,53 +1577,19 @@ void AliTPC::Hits2SDigits() // summable digits - 16 bit "ADC", no noise, no saturation //----------------------------------------------------------- - //---------------------------------------------------- - // Loop over all sectors for a single event - //---------------------------------------------------- - //MI change - for pp run -// Int_t eventnumber = gAlice->GetEvNumber(); -// AliRunLoader* rl = (AliRunLoader*)fLoader->GetEventFolder()->FindObject(AliRunLoader::fgkRunLoaderName); -// rl->GetEvent(eventnumber); -// 12/05/2003 This method is obsolete and not used. It should be redesingned -// M.Kowalski - - if (fLoader->TreeH() == 0x0) - { - if(fLoader->LoadHits()) - { - Error("Hits2Digits","Can not load hits."); - } - } - SetTreeAddress(); - - if(fDefaults == 0) SetDefaults(); - GenerNoise(500000); //create table with noise - - //setup TPCDigitsArray + fLoader->LoadHits("read"); + fLoader->LoadSDigits("recreate"); + AliRunLoader* runLoader = fLoader->GetRunLoader(); - if(GetDigitsArray()) delete GetDigitsArray(); - - if (fLoader->TreeS() == 0x0 ) - { - fLoader->MakeTree("S"); - } - - AliTPCDigitsArray *arr = new AliTPCDigitsArray; - arr->SetClass("AliSimDigits"); - arr->Setup(fTPCParam); - arr->MakeTree(fLoader->TreeS()); - SetDigitsArray(arr); - - cerr<<"Digitizing TPC -- summable digits...\n"; - - // fDigitsSwitch=1; // summable digits -for the moment direct - - for(Int_t isec=0;isecGetNSector();isec++) if (IsSectorActive(isec)) Hits2DigitsSector(isec); + for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) { + runLoader->GetEvent(iEvent); + SetTreeAddress(); + SetActiveSectors(); + Hits2SDigits2(iEvent); + } - // write results - // - cout<<"Why method TPC::Hits2SDigits writes digits and not sdigits? skowron\n"; - fLoader->WriteDigits("OVERWRITE"); + fLoader->UnloadHits(); + fLoader->UnloadSDigits(); } //_____________________________________________________________________________ @@ -3087,18 +3075,19 @@ AliTPCParam* AliTPC::LoadTPCParam(TFile *file) { } -//_____________________________________________________________________________ + +//____________________________________________________________________________ Double_t SigmaY2(Double_t r, Double_t tgl, Double_t pt) { // - // Parametrised error of the cluster reconstruction (pad direction) + // Parametrised error of the cluster reconstruction (pad direction) // // Sigma rphi const Float_t kArphi=0.41818e-2; const Float_t kBrphi=0.17460e-4; const Float_t kCrphi=0.30993e-2; const Float_t kDrphi=0.41061e-3; - + pt=TMath::Abs(pt)*1000.; Double_t x=r/pt; tgl=TMath::Abs(tgl); @@ -3109,8 +3098,9 @@ Double_t SigmaY2(Double_t r, Double_t tgl, Double_t pt) return s; } -//_____________________________________________________________________________ -Double_t SigmaZ2(Double_t r, Double_t tgl) + +//____________________________________________________________________________ +Double_t SigmaZ2(Double_t r, Double_t tgl) { // // Parametrised error of the cluster reconstruction (drift direction) @@ -3119,7 +3109,7 @@ Double_t SigmaZ2(Double_t r, Double_t tgl) const Float_t kAz=0.39614e-2; const Float_t kBz=0.22443e-4; const Float_t kCz=0.51504e-1; - + tgl=TMath::Abs(tgl); Double_t s=kAz - kBz*r*tgl + kCz*tgl*tgl; @@ -3128,3 +3118,4 @@ Double_t SigmaZ2(Double_t r, Double_t tgl) return s; } + diff --git a/TPC/AliTPC.h b/TPC/AliTPC.h index 03f6e10a711..b30306e6aa9 100644 --- a/TPC/AliTPC.h +++ b/TPC/AliTPC.h @@ -72,6 +72,7 @@ public: virtual void Hits2Clusters(Int_t eventn=0); virtual void Hits2ExactClustersSector(Int_t isec); // MI change calculate "exact" cluster position + virtual AliDigitizer* CreateDigitizer(AliRunDigitizer* manager); virtual void SDigits2Digits(){;} //MI change -cycling to production virtual void SDigits2Digits2(Int_t eventnumber=0); @@ -79,7 +80,8 @@ public: virtual void Hits2SDigits2(Int_t eventnumber=0); virtual void Digits2Reco(Int_t firstevent=0,Int_t lastevent=0); - virtual void Hits2Digits(Int_t eventnumber=0); //MI change + virtual void Hits2Digits(); + virtual void Hits2Digits(Int_t eventnumber); //MI change virtual void Hits2DigitsSector(Int_t isec); //MI change virtual void Init(); virtual Int_t IsVersion() const =0; diff --git a/TRD/AliTRD.cxx b/TRD/AliTRD.cxx index a8fa23b9510..0149069cd9f 100644 --- a/TRD/AliTRD.cxx +++ b/TRD/AliTRD.cxx @@ -230,32 +230,25 @@ void AliTRD::Hits2Digits() // // Create digits // - if (!fLoader->TreeH()) fLoader->LoadHits("read"); - SetTreeAddress(); - AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer" ,"TRD digitizer class"); digitizer->SetDebug(GetDebug()); - digitizer->SetEvent(gAlice->GetEvNumber()); // Initialization digitizer->InitDetector(); - // Create the digits - digitizer->MakeDigits(); - - // Write the digits into the input file - - if (!fLoader->TreeD()) fLoader->MakeTree("D"); - if (digitizer->MakeBranch(fLoader->TreeD())) { + if (!fLoader->TreeH()) fLoader->LoadHits("read"); + fLoader->LoadDigits("recreate"); + AliRunLoader* runLoader = fLoader->GetRunLoader(); + for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) { + digitizer->Open(runLoader->GetFileName().Data(), iEvent); + digitizer->MakeDigits(); digitizer->WriteDigits(); - - // Save the digitizer class in the AliROOT - digitizer->Write(); - } + fLoader->UnloadHits(); + fLoader->UnloadDigits(); } //_____________________________________________________________________________ @@ -264,35 +257,33 @@ void AliTRD::Hits2SDigits() // // Create summable digits // - if (!fLoader->TreeH()) fLoader->LoadHits("read"); - SetTreeAddress(); - AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer" ,"TRD digitizer class"); - digitizer->SetDebug(GetDebug()); - // For the summable digits digitizer->SetSDigits(kTRUE); - digitizer->SetEvent(gAlice->GetEvNumber()); + digitizer->SetDebug(GetDebug()); // Initialization digitizer->InitDetector(); - // Create the TRD s-digits branch - digitizer->MakeDigits(); - - // Write the digits into the input file - if (!fLoader->TreeS()) fLoader->MakeTree("S"); - - if (digitizer->MakeBranch(fLoader->TreeS())) { + if (!fLoader->TreeH()) fLoader->LoadHits("read"); + fLoader->LoadSDigits("recreate"); + AliRunLoader* runLoader = fLoader->GetRunLoader(); + for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) { + digitizer->Open(runLoader->GetFileName().Data(), iEvent); + digitizer->MakeDigits(); digitizer->WriteDigits(); + } - // Save the digitizer class in the AliROOT - digitizer->Write(); - + fLoader->UnloadHits(); + fLoader->UnloadSDigits(); } +//_____________________________________________________________________________ +AliDigitizer* AliTRD::CreateDigitizer(AliRunDigitizer* manager) +{ + return new AliTRDdigitizer(manager); } //_____________________________________________________________________________ diff --git a/TRD/AliTRD.h b/TRD/AliTRD.h index d2c4b94a87b..5ddbf321f5c 100644 --- a/TRD/AliTRD.h +++ b/TRD/AliTRD.h @@ -80,6 +80,7 @@ class AliTRD : public AliDetector { virtual void Hits2Digits(); virtual void Hits2SDigits(); + virtual AliDigitizer* CreateDigitizer(AliRunDigitizer* manager); virtual void SDigits2Digits(); virtual AliTRDsim *CreateTR() = 0; diff --git a/TRD/AliTRDdigitizer.cxx b/TRD/AliTRDdigitizer.cxx index 0df0e23016d..f440d9c4107 100644 --- a/TRD/AliTRDdigitizer.cxx +++ b/TRD/AliTRDdigitizer.cxx @@ -81,14 +81,15 @@ AliTRDdigitizer::AliTRDdigitizer() // AliTRDdigitizer default constructor // + fRunLoader = 0; fDigitsManager = 0; - fSDigitsManagerList = 0; fSDigitsManager = 0; + fSDigitsManagerList = 0; fTRD = 0; fGeo = 0; fPar = 0; - fMasks = 0; fEvent = 0; + fMasks = 0; fCompress = kTRUE; fDebug = 0; fSDigits = kFALSE; @@ -107,31 +108,26 @@ AliTRDdigitizer::AliTRDdigitizer(const Text_t *name, const Text_t *title) // AliTRDdigitizer constructor // - fDigitsManager = NULL; - fSDigitsManager = NULL; - fSDigitsManagerList = NULL; - fTRD = NULL; - fGeo = NULL; + fRunLoader = 0; //NewIO: These data members probably are not needed anymore fDigitsManager = 0; - fSDigitsManagerList = 0; fSDigitsManager = 0; + fSDigitsManagerList = 0; fTRD = 0; fGeo = 0; fPar = 0; //End NewIO comment - fMasks = 0; fEvent = 0; + fMasks = 0; fCompress = kTRUE; fDebug = 0; fSDigits = kFALSE; + fSDigitsScale = 100.; // For the summable digits fMergeSignalOnly = kFALSE; fSimpleSim = kFALSE; fSimpleDet = 0; - // For the summable digits - fSDigitsScale = 100.; } @@ -144,23 +140,23 @@ AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager // AliTRDdigitizer constructor // + fRunLoader = 0; fDigitsManager = 0; - fSDigitsManagerList = 0; fSDigitsManager = 0; + fSDigitsManagerList = 0; fTRD = 0; fGeo = 0; fPar = 0; - fMasks = 0; fEvent = 0; + fMasks = 0; fCompress = kTRUE; fDebug = 0; fSDigits = kFALSE; + fSDigitsScale = 100.; // For the summable digits fMergeSignalOnly = kFALSE; fSimpleSim = kFALSE; fSimpleDet = 0; - // For the summable digits - fSDigitsScale = 100.; } @@ -173,25 +169,23 @@ AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager) // - + fRunLoader = 0; fDigitsManager = 0; - fSDigitsManagerList = 0; fSDigitsManager = 0; + fSDigitsManagerList = 0; fTRD = 0; fGeo = 0; fPar = 0; - - fMasks = 0; fEvent = 0; + fMasks = 0; fCompress = kTRUE; fDebug = 0; fSDigits = kFALSE; + fSDigitsScale = 100.; // For the summable digits fMergeSignalOnly = kFALSE; fSimpleSim = kFALSE; fSimpleDet = 0; - // For the summable digits - fSDigitsScale = 100.; } @@ -255,14 +249,15 @@ void AliTRDdigitizer::Copy(TObject &d) // Copy function // - ((AliTRDdigitizer &) d).fSDigitsManagerList = 0; - ((AliTRDdigitizer &) d).fSDigitsManager = 0; + ((AliTRDdigitizer &) d).fRunLoader = 0; ((AliTRDdigitizer &) d).fDigitsManager = 0; + ((AliTRDdigitizer &) d).fSDigitsManager = 0; + ((AliTRDdigitizer &) d).fSDigitsManagerList = 0; ((AliTRDdigitizer &) d).fTRD = 0; ((AliTRDdigitizer &) d).fGeo = 0; - ((AliTRDdigitizer &) d).fMasks = 0; - ((AliTRDdigitizer &) d).fEvent = 0; ((AliTRDdigitizer &) d).fPar = 0; + ((AliTRDdigitizer &) d).fEvent = 0; + ((AliTRDdigitizer &) d).fMasks = 0; ((AliTRDdigitizer &) d).fCompress = fCompress; ((AliTRDdigitizer &) d).fDebug = fDebug ; ((AliTRDdigitizer &) d).fSDigits = fSDigits; @@ -406,7 +401,7 @@ Bool_t AliTRDdigitizer::Open(const Char_t *file, Int_t nEvent) // Connect the AliRoot file containing Geometry, Kine, and Hits - fRunLoader = AliRunLoader::Open(file,AliConfig::fgkDefaultEventFolderName,"UPDATE"); + fRunLoader = AliRunLoader::Open(file,AliConfig::fgkDefaultEventFolderName); if (!fRunLoader) { diff --git a/ZDC/AliZDC.cxx b/ZDC/AliZDC.cxx index d5915bd6a76..90c8c5c1a04 100644 --- a/ZDC/AliZDC.cxx +++ b/ZDC/AliZDC.cxx @@ -325,6 +325,15 @@ void AliZDC::Hits2SDigits() { printf("\n Entering AliZDC::SDigits2Digits() "); + fLoader->LoadHits("read"); + fLoader->LoadSDigits("recreate"); + AliRunLoader* runLoader = fLoader->GetRunLoader(); + + for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) { + runLoader->GetEvent(iEvent); + if (!fLoader->TreeS()) fLoader->MakeTree("S"); + MakeBranch("S"); + //---------------------------------------------------------------- if(!fMerger){ printf(" ZDC digitization (without merging)\n"); @@ -361,9 +370,9 @@ void AliZDC::Hits2SDigits() fNMergedhits++; delete MHit; } - gAlice->TreeS()->Fill(); - gAlice->TreeS()->AutoSave(); - gAlice->TreeS()->Reset(); + fLoader->TreeS()->Fill(); + fLoader->TreeS()->AutoSave(); + fLoader->TreeS()->Reset(); } //---------------------------------------------------------------- else if(fMerger){ @@ -415,6 +424,10 @@ void AliZDC::Hits2SDigits() treeS->AutoSave(); } + } + + fLoader->UnloadHits(); + fLoader->UnloadSDigits(); } //_____________________________________________________________________________ -- 2.39.3