From abaf1f1d023048f20d886d279cb03df9646f7add Mon Sep 17 00:00:00 2001 From: cblume Date: Wed, 14 Nov 2001 10:50:46 +0000 Subject: [PATCH] Changes in digits IO. Add merging of summable digits --- TRD/AliTRD.cxx | 476 ++++++++++++++++++++++++---- TRD/AliTRD.h | 7 +- TRD/AliTRDanalyzeCluster.C | 64 ++-- TRD/AliTRDanalyzeDigits.C | 67 ++-- TRD/AliTRDanalyzeHits.C | 38 +-- TRD/AliTRDcluster.h | 3 +- TRD/AliTRDclusterizer.cxx | 9 +- TRD/AliTRDclusterizerV1.cxx | 8 + TRD/AliTRDcreateCluster.C | 18 +- TRD/AliTRDcreateDigits.C | 30 +- TRD/AliTRDdigitizer.cxx | 609 ++++++++++++++++++++++++++---------- TRD/AliTRDdigitizer.h | 106 ++++--- TRD/AliTRDdigitsManager.cxx | 201 +++++++++--- TRD/AliTRDdigitsManager.h | 19 +- TRD/AliTRDpid.cxx | 16 +- TRD/AliTRDpid.h | 3 + TRD/AliTRDsegmentArray.cxx | 35 ++- TRD/AliTRDsegmentArray.h | 6 +- TRD/AliTRDsim.cxx | 4 + TRD/AliTRDtracker.cxx | 11 +- 20 files changed, 1257 insertions(+), 473 deletions(-) diff --git a/TRD/AliTRD.cxx b/TRD/AliTRD.cxx index f9608cef36f..c6e3e267051 100644 --- a/TRD/AliTRD.cxx +++ b/TRD/AliTRD.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.33 2001/11/06 17:19:41 cblume +Add detailed geometry and simple simulator + Revision 1.32 2001/10/08 06:57:33 hristov Branches for TRD digits are created only during the digitisation @@ -135,6 +138,8 @@ Introduction of the Copyright and cvs Log #include #include #include +#include +#include #include "AliRun.h" #include "AliConst.h" @@ -153,8 +158,7 @@ Introduction of the Copyright and cvs Log #include "AliTRDrecPoint.h" #include "AliTRDcluster.h" #include "AliTRDdigitsManager.h" -#include "AliTRDdataArrayI.h" -#include "AliTRDsegmentArray.h" +#include "AliTRDdigitsMerger.h" ClassImp(AliTRD) @@ -181,11 +185,6 @@ AliTRD::AliTRD() fDrawTR = 0; fDisplayType = 0; - fDigitsArray = 0; - for (Int_t iDict = 0; iDict < AliTRDdigitsManager::NDict(); iDict++) { - fDictionaryArray[iDict] = 0; - } - } //_____________________________________________________________________________ @@ -238,11 +237,6 @@ AliTRD::AliTRD(const char *name, const char *title) fDrawTR = 0; fDisplayType = 0; - fDigitsArray = 0; - for (Int_t iDict = 0; iDict < AliTRDdigitsManager::NDict(); iDict++) { - fDictionaryArray[iDict] = 0; - } - SetMarkerColor(kWhite); } @@ -267,12 +261,14 @@ AliTRD::~AliTRD() fIshunt = 0; - delete fGeometry; - delete fHits; - delete fRecPoints; - if (fDigitsArray) delete fDigitsArray; - for (Int_t iDict = 0; iDict < AliTRDdigitsManager::NDict(); iDict++) { - if (fDictionaryArray[iDict]) delete fDictionaryArray[iDict]; + if (fGeometry) { + delete fGeometry; + } + if (fHits) { + delete fHits; + } + if (fRecPoints) { + delete fRecPoints; } } @@ -341,11 +337,13 @@ void AliTRD::Hits2Digits() AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer" ,"TRD digitizer class"); + digitizer->SetVerbose(GetDebug()); // Set the parameter digitizer->SetDiffusion(); digitizer->SetExB(); digitizer->SetEvent(gAlice->GetEvNumber()); + // Initialization digitizer->InitDetector(); @@ -353,7 +351,7 @@ void AliTRD::Hits2Digits() digitizer->MakeDigits(); // Write the digits into the input file - if (digitizer->Digits()->MakeBranch(fDigitsFile)) { + if (digitizer->MakeBranch(fDigitsFile)) { digitizer->WriteDigits(); @@ -373,6 +371,7 @@ void AliTRD::Hits2SDigits() AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer" ,"TRD digitizer class"); + digitizer->SetVerbose(GetDebug()); // For the summable digits digitizer->SetSDigits(kTRUE); @@ -385,11 +384,11 @@ void AliTRD::Hits2SDigits() // Initialization digitizer->InitDetector(); - // Create the digits + // Create the TRD s-digits branch digitizer->MakeDigits(); // Write the digits into the input file - if (digitizer->Digits()->MakeBranch(fDigitsFile)) { + if (digitizer->MakeBranch(fDigitsFile)) { digitizer->WriteDigits(); @@ -407,17 +406,39 @@ void AliTRD::SDigits2Digits() // Create final digits from summable digits // -} + // Create the TRD digitizer + AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer" + ,"TRD digitizer class"); + digitizer->SetVerbose(GetDebug()); -//_____________________________________________________________________________ -void AliTRD::AddDigit(Int_t *digits, Int_t *amp) -{ - // - // Add a digit for the TRD - // + // Set the parameter + digitizer->SetEvent(gAlice->GetEvNumber()); + + // Initialization + digitizer->InitDetector(); + + // Read the s-digits via digits manager + AliTRDdigitsManager *sdigitsManager = new AliTRDdigitsManager(); + sdigitsManager->SetVerbose(GetDebug()); + sdigitsManager->SetSDigits(kTRUE); + if (fDigitsFile) { + sdigitsManager->Open(fDigitsFile); + } + sdigitsManager->CreateArrays(); + sdigitsManager->ReadDigits(); + + // Add the s-digits to the input list + digitizer->AddSDigitsManager(sdigitsManager); - TClonesArray &ldigits = *fDigits; - new(ldigits[fNdigits++]) AliTRDdigit(kFALSE,digits,amp); + // Convert the s-digits to normal digits + digitizer->SDigits2Digits(); + + // Store the digits + if (digitizer->MakeBranch(fDigitsFile)) { + + digitizer->WriteDigits(); + + } } @@ -857,7 +878,7 @@ void AliTRD::Init() Int_t i; - if(fDebug) { + if (fDebug) { printf("\n%s: ",ClassName()); for (i = 0; i < 35; i++) printf("*"); printf(" TRD_INIT "); @@ -876,10 +897,12 @@ void AliTRD::Init() printf("%s: Leave space in front of RICH free\n",ClassName()); } - if (fGasMix == 1) + if (fGasMix == 1) { printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName()); - else + } + else { printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName()); + } } @@ -1023,55 +1046,32 @@ void AliTRD::LoadPoints(Int_t track) void AliTRD::MakeBranch(Option_t* option, const char *file) { // - // Create Tree branches for the TRD digits and cluster. + // Create Tree branches for the TRD digits. // - //Int_t buffersize = 4000; - //Char_t branchname[15]; + Int_t buffersize = 4000; + Char_t branchname[15]; + sprintf(branchname,"%s",GetName()); const char *cD = strstr(option,"D"); AliDetector::MakeBranch(option,file); - Int_t buffersize = 64000; - - if (cD) { - fDigitsArray = new AliTRDdataArrayI(); - MakeBranchInTree(gAlice->TreeD() - ,"TRDdigits", fDigitsArray->IsA()->GetName() - ,&fDigitsArray,buffersize,99,file); - - for (Int_t iDict = 0; iDict < AliTRDdigitsManager::NDict(); iDict++) { - Char_t branchname[15]; - sprintf(branchname,"TRDdictionary%d",iDict); - fDictionaryArray[iDict] = new AliTRDdataArrayI(); - MakeBranchInTree(gAlice->TreeD() - ,branchname,fDictionaryArray[iDict]->IsA()->GetName() - ,&fDictionaryArray[iDict],buffersize,99,file); - } - } + if (fDigits && gAlice->TreeD() && cD) { + MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,file); + } + } //_____________________________________________________________________________ void AliTRD::ResetDigits() { // - // Resets the digits + // Reset number of digits and the digits array for this detector // - if (gAlice->TreeD()) { - TBranch *branch; - branch = gAlice->TreeD()->GetBranch("TRDdigits"); - if (branch) { - branch->Reset(); - for (Int_t iDict = 0; iDict < AliTRDdigitsManager::NDict(); iDict++) { - Char_t branchname[15]; - sprintf(branchname,"TRDdictionary%d",iDict); - branch = gAlice->TreeD()->GetBranch(branchname); - branch->Reset(); - } - } - } + fNdigits = 0; + if (fDigits) fDigits->Clear(); } @@ -1167,3 +1167,345 @@ AliTRD &AliTRD::operator=(const AliTRD &trd) return *this; } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TRD/AliTRD.h b/TRD/AliTRD.h index 36c1f6f7d8c..c3a03e2c875 100644 --- a/TRD/AliTRD.h +++ b/TRD/AliTRD.h @@ -19,7 +19,6 @@ class AliDigit; class AliTRDhit; class AliTRDsim; class AliTRDgeometry; -class AliTRDdataArrayI; //_____________________________________________________________________________ class AliTRD : public AliDetector { @@ -34,7 +33,6 @@ class AliTRD : public AliDetector { AliTRD &operator=(const AliTRD &trd); virtual void AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q); - virtual void AddDigit(Int_t *digits, Int_t *amp); virtual void AddCluster(Float_t *pos, Int_t *digits , Int_t det, Float_t amp, Int_t *tracks , Float_t sigmaY2, Int_t iType); @@ -95,10 +93,7 @@ class AliTRD : public AliDetector { Int_t fDrawTR; // Switches marking the TR photons in the display Int_t fDisplayType; // Display type (0: normal, 1: detailed) - AliTRDdataArrayI *fDigitsArray; //! Digits array - AliTRDdataArrayI *fDictionaryArray[3]; //! Dictionary array - - ClassDef(AliTRD,3) // Transition Radiation Detector base class + ClassDef(AliTRD,4) // Transition Radiation Detector base class }; diff --git a/TRD/AliTRDanalyzeCluster.C b/TRD/AliTRDanalyzeCluster.C index 93c97864e3a..3a8ea212ab4 100644 --- a/TRD/AliTRDanalyzeCluster.C +++ b/TRD/AliTRDanalyzeCluster.C @@ -14,8 +14,8 @@ Int_t AliTRDanalyzeCluster() gAlice->GetEvent(0); // Get the pointer to the TRD detector - AliTRD *TRD = (AliTRD *) gAlice->GetDetector("TRD"); - if (!TRD) { + AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD"); + if (!trd) { cout << " No TRD detector found" << endl; rc = 2; return rc; @@ -32,9 +32,9 @@ Int_t AliTRDanalyzeCluster() ,501,-0.5,500.5); // Get the pointer to the geometry object - AliTRDgeometry *TRDgeometry; - if (TRD) { - TRDgeometry = TRD->GetGeometry(); + AliTRDgeometry *geo; + if (trd) { + geo = trd->GetGeometry(); } else { cout << " No TRD geometry found" << endl; @@ -44,66 +44,66 @@ Int_t AliTRDanalyzeCluster() // Get the pointer to the hit-tree TFile *file = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root"); - TTree *ClusterTree = file->Get("ClusterTree"); - if (!(ClusterTree)) { + TTree *clusterTree = (TTree *) file->Get("TreeR0_TRD"); + if (!(clusterTree)) { cout << " No tree with clusters found" << endl; rc = 4; return rc; } // Get the pointer to the hit container - TObjArray *ClusterArray = TRD->RecPoints(); - if (!(ClusterArray)) { - cout << " No ClusterArray found" << endl; + TObjArray *clusterArray = trd->RecPoints(); + if (!(clusterArray)) { + cout << " No clusterArray found" << endl; rc = 5; return rc; } // Set the branch address - ClusterTree->GetBranch("TRDcluster")->SetAddress(&ClusterArray); - Int_t nEntries = ClusterTree->GetEntries(); + clusterTree->GetBranch("TRDcluster")->SetAddress(&clusterArray); + Int_t nEntries = clusterTree->GetEntries(); cout << " Number of entries in the cluster tree = " << nEntries << endl; Int_t countCluster = 0; - Int_t countUnfold = 0; + Int_t countOverlap = 0; // Loop through all entries in the tree Int_t nbytes; for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) { // Import the tree - nbytes += ClusterTree->GetEvent(iEntry); + nbytes += clusterTree->GetEvent(iEntry); // Get the number of points in the detector - Int_t nCluster = ClusterArray->GetEntriesFast(); + Int_t nCluster = clusterArray->GetEntriesFast(); // Loop through all TRD digits for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) { // Get the information for this digit - AliTRDcluster *Cluster = (AliTRDcluster *) ClusterArray->UncheckedAt(iCluster); - Int_t detector = Cluster->GetDetector(); - Int_t sector = TRDgeometry->GetSector(detector); - Int_t plane = TRDgeometry->GetPlane(detector); - Int_t chamber = TRDgeometry->GetChamber(detector); - Float_t energy = Cluster->GetQ(); - Int_t track0 = Cluster->GetTrackIndex(0); - Int_t track1 = Cluster->GetTrackIndex(1); - Int_t track2 = Cluster->GetTrackIndex(2); - TParticle *Part = 0; + AliTRDcluster *cluster = (AliTRDcluster *) clusterArray->UncheckedAt(iCluster); + Int_t detector = cluster->GetDetector(); + Int_t sector = geo->GetSector(detector); + Int_t plane = geo->GetPlane(detector); + Int_t chamber = geo->GetChamber(detector); + Float_t energy = cluster->GetQ(); + Int_t track0 = cluster->GetTrackIndex(0); + Int_t track1 = cluster->GetTrackIndex(1); + Int_t track2 = cluster->GetTrackIndex(2); + TParticle *particle = 0; if (track0 > -1) { - Part = gAlice->Particle(track0); + particle = gAlice->Particle(track0); } countCluster++; - if (Cluster->FromUnfolding()) countUnfold++; + if (!cluster->Isolated()) countOverlap++; // Total spectrum hClusAll->Fill(energy); - if (!Cluster->FromUnfolding()) { + if (cluster->Isolated()) { // Noise spectrum if (track0 < 0) { @@ -111,12 +111,12 @@ Int_t AliTRDanalyzeCluster() } // Electron cluster - if ((Part) && (Part->GetPdgCode() == 11) && (track1 < 0)) { + if ((particle) && (particle->GetPdgCode() == 11) && (track1 < 0)) { hClusEl->Fill(energy); } // Pion cluster - if ((Part) && (Part->GetPdgCode() == -211) && (track1 < 0)) { + if ((particle) && (particle->GetPdgCode() == -211) && (track1 < 0)) { hClusPi->Fill(energy); } @@ -126,8 +126,8 @@ Int_t AliTRDanalyzeCluster() } - cout << " Found " << countCluster << " cluster in total" << endl; - cout << " Found " << countUnfold << " cluster from unfolding" << endl; + cout << " Found " << countCluster << " cluster in total" << endl; + cout << " Found " << countOverlap << " overlapping cluster" << endl; cout << endl; TCanvas *cCluster = new TCanvas("cCluster","AliTRDanalyzeCluster",50,50,600,600); diff --git a/TRD/AliTRDanalyzeDigits.C b/TRD/AliTRDanalyzeDigits.C index 750def8ca09..95fe7638e04 100644 --- a/TRD/AliTRDanalyzeDigits.C +++ b/TRD/AliTRDanalyzeDigits.C @@ -16,8 +16,8 @@ Int_t AliTRDanalyzeDigits() Int_t nPart = gAlice->GetEvent(0); // Get the pointer to the TRD detector - AliTRD *TRD = (AliTRD *) gAlice->GetDetector("TRD"); - if (!TRD) { + AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD"); + if (!trd) { cout << " No TRD detector found" << endl; rc = 2; return rc; @@ -25,15 +25,15 @@ Int_t AliTRDanalyzeDigits() // Get the digitizer object TFile *file = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root"); - AliTRDdigitizer *Digitizer = (AliTRDdigitizer *) file->Get("digitizer"); - if (!Digitizer) { + AliTRDdigitizer *digitizer = (AliTRDdigitizer *) file->Get("digitizer"); + if (!digitizer) { cout << " No digitizer object found" << endl; rc = 3; return rc; } // Define the histograms - Int_t adcRange = ((Int_t) Digitizer->GetADCoutRange()); + Int_t adcRange = ((Int_t) digitizer->GetADCoutRange()); TH1F *hAmpAll = new TH1F("hAmpAll" ,"Amplitude of the digits (all)" ,adcRange+1,-0.5,((Float_t) adcRange)+0.5); TH1F *hAmpEl = new TH1F("hAmpEl" ,"Amplitude of the digits (electrons)" @@ -44,9 +44,9 @@ Int_t AliTRDanalyzeDigits() ,5,-0.5,4.5); // Get the pointer to the geometry object - AliTRDgeometry *TRDgeometry; - if (TRD) { - TRDgeometry = TRD->GetGeometry(); + AliTRDgeometry *geo; + if (trd) { + geo = trd->GetGeometry(); } else { cout << " No TRD geometry found" << endl; @@ -55,21 +55,23 @@ Int_t AliTRDanalyzeDigits() } // Create the digits manager - AliTRDdigitsManager *DigitsManager = new AliTRDdigitsManager(); + AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(); + + digitsManager->Open("TRD_test.root"); // Read the digits from the file - if (!(DigitsManager->ReadDigits())) { + if (!(digitsManager->ReadDigits())) { cout << " Cannot read the digits" << endl; rc = 5; return rc; } - AliTRDmatrix *TRDmatrix; + AliTRDmatrix *matrix; Int_t countDigits = 0; - Int_t iSec = TRD->GetSensSector(); - Int_t iCha = TRD->GetSensChamber(); - Int_t timeMax = TRDgeometry->GetTimeTotal(); + Int_t iSec = trd->GetSensSector(); + Int_t iCha = trd->GetSensChamber(); + Int_t timeMax = geo->GetTimeTotal(); TProfile *hAmpTimeEl = new TProfile("hAmpTimeEl","Amplitude of the digits (electrons)" ,timeMax,-0.5,((Double_t) timeMax)-0.5); @@ -79,12 +81,12 @@ Int_t AliTRDanalyzeDigits() // Loop over all planes for (Int_t iPla = 0; iPla < kNpla; iPla++) { - Int_t iDet = TRDgeometry->GetDetector(iPla,iCha,iSec); - Int_t rowMax = TRDgeometry->GetRowMax(iPla,iCha,iSec); - Int_t colMax = TRDgeometry->GetColMax(iPla); + Int_t iDet = geo->GetDetector(iPla,iCha,iSec); + Int_t rowMax = geo->GetRowMax(iPla,iCha,iSec); + Int_t colMax = geo->GetColMax(iPla); if (iPla == 0) { - TRDmatrix = new AliTRDmatrix(rowMax,colMax,timeMax,iSec,iCha,iPla); + matrix = new AliTRDmatrix(rowMax,colMax,timeMax,iSec,iCha,iPla); } // Loop through the detector pixel @@ -92,20 +94,19 @@ Int_t AliTRDanalyzeDigits() for (Int_t col = 0; col < colMax; col++) { for (Int_t row = 0; row < rowMax; row++) { - AliTRDdigit *Digit = DigitsManager->GetDigit(row,col,time,iDet); - Int_t amp = Digit->GetAmp(); - - Int_t track0 = DigitsManager->GetTrack(0,row,col,time,iDet); - Int_t track1 = DigitsManager->GetTrack(1,row,col,time,iDet); - TParticle *Part = 0; + AliTRDdigit *digit = digitsManager->GetDigit(row,col,time,iDet); + Int_t amp = digit->GetAmp(); + Int_t track0 = digitsManager->GetTrack(0,row,col,time,iDet); + Int_t track1 = digitsManager->GetTrack(1,row,col,time,iDet); + TParticle *particle = 0; if (track0 > -1) { - Part = gAlice->Particle(track0); + particle = gAlice->Particle(track0); } if (amp > 0) { countDigits++; if (iPla == 0) { - TRDmatrix->SetSignal(row,col,time,amp); + matrix->SetSignal(row,col,time,amp); } } @@ -118,18 +119,18 @@ Int_t AliTRDanalyzeDigits() } // Electron digit - if ((Part) && (Part->GetPdgCode() == 11) && (track1 < 0)) { + if ((particle) && (particle->GetPdgCode() == 11) && (track1 < 0)) { hAmpEl->Fill(amp); hAmpTimeEl->Fill(time,amp); } // Pion digit - if ((Part) && (Part->GetPdgCode() == -211) && (track1 < 0)) { + if ((particle) && (particle->GetPdgCode() == -211) && (track1 < 0)) { hAmpPi->Fill(amp); hAmpTimePi->Fill(time,amp); } - delete Digit; + delete digit; } } @@ -140,10 +141,10 @@ Int_t AliTRDanalyzeDigits() cout << " Found " << countDigits << " digits in total" << endl; // Display the detector matrix - TRDmatrix->Draw(); - TRDmatrix->ProjRow(); - TRDmatrix->ProjCol(); - TRDmatrix->ProjTime(); + matrix->Draw(); + matrix->ProjRow(); + matrix->ProjCol(); + matrix->ProjTime(); TCanvas *cDigits = new TCanvas("cDigits","AliTRDanalyzeDigits",50,50,600,800); cDigits->Divide(2,3); diff --git a/TRD/AliTRDanalyzeHits.C b/TRD/AliTRDanalyzeHits.C index 911ab3402b1..1124d3631d6 100644 --- a/TRD/AliTRDanalyzeHits.C +++ b/TRD/AliTRDanalyzeHits.C @@ -14,17 +14,17 @@ Int_t AliTRDanalyzeHits() gAlice->GetEvent(0); // Get the pointer to the TRD detector - AliTRD *TRD = (AliTRD *) gAlice->GetDetector("TRD"); - if (!TRD) { + AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD"); + if (!trd) { cout << " No TRD detector found" << endl; rc = 2; return rc; } // Get the pointer to the geometry object - AliTRDgeometryFull *TRDgeometry; - if (TRD) { - TRDgeometry = (AliTRDgeometryFull *) TRD->GetGeometry(); + AliTRDgeometryFull *geo; + if (trd) { + geo = (AliTRDgeometryFull *) trd->GetGeometry(); } else { cout << " No TRD geometry found" << endl; @@ -36,13 +36,13 @@ Int_t AliTRDanalyzeHits() TH1F *hQdedx = new TH1F("hQdedx","Charge dedx-hits",100,0.0,1000.0); TH1F *hQtr = new TH1F("hQtr" ,"Charge TR-hits" ,100,0.0,1000.0); - Float_t rmin = TRDgeometry->Rmin(); - Float_t rmax = TRDgeometry->Rmax(); - Float_t length = TRDgeometry->GetChamberLengthI(0); - Float_t width = TRDgeometry->GetChamberWidth(0); - Int_t ncol = TRDgeometry->GetColMax(0); - Int_t nrow = TRDgeometry->GetRowMax(0,2,13); - Int_t ntime = ((Int_t) (rmax - rmin) / TRDgeometry->GetTimeBinSize()); + Float_t rmin = geo->Rmin(); + Float_t rmax = geo->Rmax(); + Float_t length = geo->GetChamberLengthI(0); + Float_t width = geo->GetChamberWidth(0); + Int_t ncol = geo->GetColMax(0); + Int_t nrow = geo->GetRowMax(0,2,13); + Int_t ntime = ((Int_t) (rmax - rmin) / geo->GetTimeBinSize()); TH2F *hZY = new TH2F("hZY" ,"Y vs Z (chamber 0)", nrow,-length/2.,length/2. ,ntime, rmin, rmax); @@ -59,8 +59,8 @@ Int_t AliTRDanalyzeHits() ,50,0.0,1000.0); // Get the pointer hit tree - TTree *HitTree = gAlice->TreeH(); - if (!HitTree) { + TTree *hitTree = gAlice->TreeH(); + if (!hitTree) { cout << " No hit tree found" << endl; rc = 4; return rc; @@ -71,7 +71,7 @@ Int_t AliTRDanalyzeHits() // Get the number of entries in the hit tree // (Number of primary particles creating a hit somewhere) - Int_t nTrack = (Int_t) HitTree->GetEntries(); + Int_t nTrack = (Int_t) hitTree->GetEntries(); cout << " Found " << nTrack << " primary particles with hits" << endl; @@ -79,7 +79,7 @@ Int_t AliTRDanalyzeHits() for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) { gAlice->ResetHits(); - nBytes += HitTree->GetEvent(iTrack); + nBytes += hitTree->GetEvent(iTrack); Int_t nPrimE = 0; Int_t nPrimP = 0; @@ -87,14 +87,14 @@ Int_t AliTRDanalyzeHits() Int_t nTotP = 0; // Get the number of hits in the TRD created by this particle - Int_t nHit = TRD->Hits()->GetEntriesFast(); + Int_t nHit = trd->Hits()->GetEntriesFast(); // Loop through the TRD hits for (Int_t iHit = 0; iHit < nHit; iHit++) { countHits++; - AliTRDhit *hit = (AliTRDhit *) TRD->Hits()->UncheckedAt(iHit); + AliTRDhit *hit = (AliTRDhit *) trd->Hits()->UncheckedAt(iHit); Float_t x = hit->X(); Float_t y = hit->Y(); @@ -102,7 +102,7 @@ Int_t AliTRDanalyzeHits() Float_t q = hit->GetCharge(); Int_t track = hit->Track(); Int_t det = hit->GetDetector(); - Int_t plane = TRDgeometry->GetPlane(det); + Int_t plane = geo->GetPlane(det); if (hit->FromDrift()) { hQdedx->Fill(q); diff --git a/TRD/AliTRDcluster.h b/TRD/AliTRDcluster.h index afe3defa962..ea563f20c46 100644 --- a/TRD/AliTRDcluster.h +++ b/TRD/AliTRDcluster.h @@ -40,7 +40,8 @@ class AliTRDcluster : public TObject { Bool_t From4pad() const { return TestBit(k4pad); } Bool_t From5pad() const { return TestBit(k5pad); } Bool_t FromLarge() const { return TestBit(kLarge); } - + Bool_t Isolated() const { return (TestBit(k2pad) || TestBit(k3pad)); } + void SetDetector(Int_t d) { fDetector = d; } void SetLocalTimeBin(Int_t t) { fTimeBin = t; } void SetQ(Float_t q) { fQ = q; } diff --git a/TRD/AliTRDclusterizer.cxx b/TRD/AliTRDclusterizer.cxx index 4b312253346..ef42b25ec79 100644 --- a/TRD/AliTRDclusterizer.cxx +++ b/TRD/AliTRDclusterizer.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.9 2001/10/21 18:30:02 hristov +Several pointers were set to zero in the default constructors to avoid memory management problems + Revision 1.8 2001/05/07 08:06:44 cblume Speedup of the code. Create only AliTRDcluster @@ -229,9 +232,11 @@ Bool_t AliTRDclusterizer::OpenOutput(const Char_t *name) } // Create a tree for the cluster - fClusterTree = new TTree("ClusterTree","Tree with TRDcluster"); + Char_t treeName[12]; + sprintf(treeName,"TreeR%d_TRD",fEvent); + fClusterTree = new TTree(treeName,"TRD cluster"); TObjArray *ioArray = 0; - fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0); + fClusterTree->BranchOld("TRDcluster","TObjArray",&ioArray,32000,0); if (savedir) { savedir->cd(); diff --git a/TRD/AliTRDclusterizerV1.cxx b/TRD/AliTRDclusterizerV1.cxx index 6c793795353..057b85427eb 100644 --- a/TRD/AliTRDclusterizerV1.cxx +++ b/TRD/AliTRDclusterizerV1.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.13 2001/05/28 17:07:58 hristov +Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of material in G10 TEC frames and material between TEC planes (C.Blume,S.Sedykh) + Revision 1.12 2001/05/21 17:42:58 hristov Constant casted to avoid the ambiguity @@ -139,6 +142,7 @@ AliTRDclusterizerV1::~AliTRDclusterizerV1() if (fDigitsManager) { delete fDigitsManager; + fDigitsManager = NULL; } } @@ -211,6 +215,8 @@ void AliTRDclusterizerV1::Init() fLUT[ilut] = lut[ilut]; } + fDigitsManager->CreateArrays(); + } //_____________________________________________________________________________ @@ -226,6 +232,8 @@ Bool_t AliTRDclusterizerV1::ReadDigits() return kFALSE; } + fDigitsManager->Open(fInputFile->GetName()); + // Read in the digit arrays return (fDigitsManager->ReadDigits()); diff --git a/TRD/AliTRDcreateCluster.C b/TRD/AliTRDcreateCluster.C index 3f90e48076d..93ddc3ca384 100644 --- a/TRD/AliTRDcreateCluster.C +++ b/TRD/AliTRDcreateCluster.C @@ -7,40 +7,40 @@ Int_t AliTRDcreateCluster() Int_t rc = 0; // Create the clusterizer - AliTRDclusterizerV1 *Clusterizer = + AliTRDclusterizerV1 *clusterizer = new AliTRDclusterizerV1("clusterizer","Clusterizer class"); // Set the parameter - Clusterizer->SetClusMaxThresh(0); - Clusterizer->SetClusSigThresh(0); - Clusterizer->Dump(); + clusterizer->SetClusMaxThresh(0); + clusterizer->SetClusSigThresh(0); + clusterizer->Dump(); // Open the file - if (!(Clusterizer->Open("TRD_test.root",0))) { + if (!(clusterizer->Open("TRD_test.root",0))) { rc = 1; return rc; } // Load the digits - if (!(Clusterizer->ReadDigits())) { + if (!(clusterizer->ReadDigits())) { rc = 2; return rc; } // Find the cluster - if (!(Clusterizer->MakeClusters())) { + if (!(clusterizer->MakeClusters())) { rc = 3; return rc; } // Write the cluster tree into the file - if (!(Clusterizer->WriteClusters(-1))) { + if (!(clusterizer->WriteClusters(-1))) { rc = 4; return rc; } // Save the clusterizer class in the file - if (!(Clusterizer->Write())) { + if (!(clusterizer->Write())) { rc = 5; return rc; } diff --git a/TRD/AliTRDcreateDigits.C b/TRD/AliTRDcreateDigits.C index 023587c698e..311b91744ea 100644 --- a/TRD/AliTRDcreateDigits.C +++ b/TRD/AliTRDcreateDigits.C @@ -14,32 +14,38 @@ Int_t AliTRDcreateDigits() gAlice->GetEvent(0); // Create the TRD digitzer - AliTRDdigitizer *Digitizer = new AliTRDdigitizer("digitizer","Digitizer class"); - Digitizer->InitDetector(); + AliTRDdigitizer *digitizer = new AliTRDdigitizer("digitizer","Digitizer class"); + digitizer->InitDetector(); // Set the parameter (for TRF ~200ns) - Digitizer->SetGasGain(1600.); - Digitizer->SetChipGain(8.0); - Digitizer->SetNoise(1000.); - Digitizer->SetADCinRange(1000.); - Digitizer->SetADCoutRange(1023.); - Digitizer->SetADCthreshold(0); - Digitizer->SetVerbose(1); + digitizer->SetGasGain(1600.); + digitizer->SetChipGain(8.0); + digitizer->SetNoise(1000.); + digitizer->SetADCinRange(1000.); + digitizer->SetADCoutRange(1023.); + digitizer->SetADCthreshold(0); + digitizer->SetVerbose(1); // Create the digits - if (!(Digitizer->MakeDigits())) { + if (!(digitizer->MakeDigits())) { rc = 2; return rc; } // Write the digits into the input file - if (!(Digitizer->WriteDigits())) { + if (!(digitizer->MakeBranch())) { rc = 3; return rc; } + // Write the digits into the input file + if (!(digitizer->WriteDigits())) { + rc = 4; + return rc; + } + // Save the digitizer class in the AliROOT file - if (!(Digitizer->Write())) { + if (!(digitizer->Write())) { rc = 4; return rc; } diff --git a/TRD/AliTRDdigitizer.cxx b/TRD/AliTRDdigitizer.cxx index 4a371b7a772..db649083ed5 100644 --- a/TRD/AliTRDdigitizer.cxx +++ b/TRD/AliTRDdigitizer.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.26 2001/11/06 17:19:41 cblume +Add detailed geometry and simple simulator + Revision 1.25 2001/06/27 09:54:44 cblume Moved fField initialization to InitDetector() @@ -116,12 +119,14 @@ Add new TRD classes /////////////////////////////////////////////////////////////////////////////// // // // Creates and handles digits from TRD hits // +// Author: C. Blume (C.Blume@gsi.de) // // // // The following effects are included: // // - Diffusion // // - ExB effects // // - Gas gain including fluctuations // // - Pad-response (simple Gaussian approximation) // +// - Time-response // // - Electronics noise // // - Electronics gain // // - Digitization // @@ -129,8 +134,11 @@ Add new TRD classes // The corresponding parameter can be adjusted via the various // // Set-functions. If these parameters are not explicitly set, default // // values are used (see Init-function). // -// To produce digits from a root-file with TRD-hits use the // -// slowDigitsCreate.C macro. // +// As an example on how to use this class to produce digits from hits // +// have a look at the macro hits2digits.C // +// The production of summable digits is demonstrated in hits2sdigits.C // +// and the subsequent conversion of the s-digits into normal digits is // +// explained in sdigits2digits.C. // // // /////////////////////////////////////////////////////////////////////////////// @@ -143,6 +151,7 @@ Add new TRD classes #include #include #include +#include #include "AliRun.h" #include "AliMagF.h" @@ -165,50 +174,51 @@ AliTRDdigitizer::AliTRDdigitizer():TNamed() // AliTRDdigitizer default constructor // - fInputFile = NULL; - fDigits = NULL; - fTRD = NULL; - fGeo = NULL; - fPRFsmp = NULL; - fTRFsmp = NULL; - - fEvent = 0; - fGasGain = 0.0; - fNoise = 0.0; - fChipGain = 0.0; - fSinRange = 0.0; - fSoutRange = 0.0; - fADCoutRange = 0.0; - fADCinRange = 0.0; - fADCthreshold = 0; - fDiffusionOn = 0; - fDiffusionT = 0.0; - fDiffusionL = 0.0; - fElAttachOn = 0; - fElAttachProp = 0.0; - fExBOn = 0; - fOmegaTau = 0.0; - fPRFOn = 0; - fTRFOn = 0; - fDriftVelocity = 0.0; - fPadCoupling = 0.0; - fTimeCoupling = 0.0; - fTimeBinWidth = 0.0; - fField = 0.0; - - fPRFbin = 0; - fPRFlo = 0.0; - fPRFhi = 0.0; - fPRFwid = 0.0; - fPRFpad = 0; - fTRFbin = 0; - fTRFlo = 0.0; - fTRFhi = 0.0; - fTRFwid = 0.0; - - fCompress = kTRUE; - fVerbose = 1; - fSDigits = kFALSE; + fInputFile = NULL; + fDigitsManager = NULL; + fSDigitsManagerList = NULL; + fSDigitsManager = NULL; + fTRD = NULL; + fGeo = NULL; + fPRFsmp = NULL; + fTRFsmp = NULL; + + fEvent = 0; + fGasGain = 0.0; + fNoise = 0.0; + fChipGain = 0.0; + fADCoutRange = 0.0; + fADCinRange = 0.0; + fADCthreshold = 0; + fDiffusionOn = 0; + fDiffusionT = 0.0; + fDiffusionL = 0.0; + fElAttachOn = 0; + fElAttachProp = 0.0; + fExBOn = 0; + fOmegaTau = 0.0; + fPRFOn = 0; + fTRFOn = 0; + fDriftVelocity = 0.0; + fPadCoupling = 0.0; + fTimeCoupling = 0.0; + fTimeBinWidth = 0.0; + fField = 0.0; + + fPRFbin = 0; + fPRFlo = 0.0; + fPRFhi = 0.0; + fPRFwid = 0.0; + fPRFpad = 0; + fTRFbin = 0; + fTRFlo = 0.0; + fTRFhi = 0.0; + fTRFwid = 0.0; + + fCompress = kTRUE; + fVerbose = 0; + fSDigits = kFALSE; + fSDigitsScale = 0.0; } @@ -220,18 +230,22 @@ AliTRDdigitizer::AliTRDdigitizer(const Text_t *name, const Text_t *title) // AliTRDdigitizer default constructor // - fInputFile = NULL; - fDigits = NULL; - fTRD = NULL; - fGeo = NULL; - fPRFsmp = NULL; - fTRFsmp = NULL; + fInputFile = NULL; + + fDigitsManager = NULL; + fSDigitsManager = NULL; + fSDigitsManagerList = NULL; - fEvent = 0; + fTRD = NULL; + fGeo = NULL; + fPRFsmp = NULL; + fTRFsmp = NULL; - fCompress = kTRUE; - fVerbose = 1; - fSDigits = kFALSE; + fEvent = 0; + + fCompress = kTRUE; + fVerbose = 0; + fSDigits = kFALSE; Init(); @@ -258,12 +272,24 @@ AliTRDdigitizer::~AliTRDdigitizer() if (fInputFile) { fInputFile->Close(); delete fInputFile; + fInputFile = NULL; + } + + if (fDigitsManager) { + delete fDigitsManager; + fDigitsManager = NULL; } - if (fDigits) { - delete fDigits; + if (fSDigitsManager) { + delete fSDigitsManager; + fSDigitsManager = NULL; } + if (fSDigitsManagerList) { + fSDigitsManagerList->Delete(); + delete fSDigitsManagerList; + fSDigitsManagerList = NULL; + } } //_____________________________________________________________________________ @@ -287,55 +313,56 @@ void AliTRDdigitizer::Copy(TObject &d) Int_t iBin; - ((AliTRDdigitizer &) d).fInputFile = NULL; - ((AliTRDdigitizer &) d).fDigits = NULL; - ((AliTRDdigitizer &) d).fTRD = NULL; - ((AliTRDdigitizer &) d).fGeo = NULL; - - ((AliTRDdigitizer &) d).fEvent = 0; - - ((AliTRDdigitizer &) d).fGasGain = fGasGain; - ((AliTRDdigitizer &) d).fNoise = fNoise; - ((AliTRDdigitizer &) d).fChipGain = fChipGain; - ((AliTRDdigitizer &) d).fSoutRange = fSoutRange; - ((AliTRDdigitizer &) d).fSinRange = fSinRange; - ((AliTRDdigitizer &) d).fADCoutRange = fADCoutRange; - ((AliTRDdigitizer &) d).fADCinRange = fADCinRange; - ((AliTRDdigitizer &) d).fADCthreshold = fADCthreshold; - ((AliTRDdigitizer &) d).fDiffusionOn = fDiffusionOn; - ((AliTRDdigitizer &) d).fDiffusionT = fDiffusionT; - ((AliTRDdigitizer &) d).fDiffusionL = fDiffusionL; - ((AliTRDdigitizer &) d).fElAttachOn = fElAttachOn; - ((AliTRDdigitizer &) d).fElAttachProp = fElAttachProp; - ((AliTRDdigitizer &) d).fExBOn = fExBOn; - ((AliTRDdigitizer &) d).fOmegaTau = fOmegaTau; - ((AliTRDdigitizer &) d).fLorentzFactor = fLorentzFactor; - ((AliTRDdigitizer &) d).fDriftVelocity = fDriftVelocity; - ((AliTRDdigitizer &) d).fPadCoupling = fPadCoupling; - ((AliTRDdigitizer &) d).fTimeCoupling = fTimeCoupling; - ((AliTRDdigitizer &) d).fTimeBinWidth = fTimeBinWidth; - ((AliTRDdigitizer &) d).fField = fField; - ((AliTRDdigitizer &) d).fPRFOn = fPRFOn; - ((AliTRDdigitizer &) d).fTRFOn = fTRFOn; - - ((AliTRDdigitizer &) d).fCompress = fCompress; - ((AliTRDdigitizer &) d).fVerbose = fVerbose; - ((AliTRDdigitizer &) d).fSDigits = fSDigits; - - ((AliTRDdigitizer &) d).fPRFbin = fPRFbin; - ((AliTRDdigitizer &) d).fPRFlo = fPRFlo; - ((AliTRDdigitizer &) d).fPRFhi = fPRFhi; - ((AliTRDdigitizer &) d).fPRFwid = fPRFwid; - ((AliTRDdigitizer &) d).fPRFpad = fPRFpad; + ((AliTRDdigitizer &) d).fInputFile = NULL; + ((AliTRDdigitizer &) d).fSDigitsManagerList = NULL; + ((AliTRDdigitizer &) d).fSDigitsManager = NULL; + ((AliTRDdigitizer &) d).fDigitsManager = NULL; + ((AliTRDdigitizer &) d).fTRD = NULL; + ((AliTRDdigitizer &) d).fGeo = NULL; + + ((AliTRDdigitizer &) d).fEvent = 0; + + ((AliTRDdigitizer &) d).fGasGain = fGasGain; + ((AliTRDdigitizer &) d).fNoise = fNoise; + ((AliTRDdigitizer &) d).fChipGain = fChipGain; + ((AliTRDdigitizer &) d).fADCoutRange = fADCoutRange; + ((AliTRDdigitizer &) d).fADCinRange = fADCinRange; + ((AliTRDdigitizer &) d).fADCthreshold = fADCthreshold; + ((AliTRDdigitizer &) d).fDiffusionOn = fDiffusionOn; + ((AliTRDdigitizer &) d).fDiffusionT = fDiffusionT; + ((AliTRDdigitizer &) d).fDiffusionL = fDiffusionL; + ((AliTRDdigitizer &) d).fElAttachOn = fElAttachOn; + ((AliTRDdigitizer &) d).fElAttachProp = fElAttachProp; + ((AliTRDdigitizer &) d).fExBOn = fExBOn; + ((AliTRDdigitizer &) d).fOmegaTau = fOmegaTau; + ((AliTRDdigitizer &) d).fLorentzFactor = fLorentzFactor; + ((AliTRDdigitizer &) d).fDriftVelocity = fDriftVelocity; + ((AliTRDdigitizer &) d).fPadCoupling = fPadCoupling; + ((AliTRDdigitizer &) d).fTimeCoupling = fTimeCoupling; + ((AliTRDdigitizer &) d).fTimeBinWidth = fTimeBinWidth; + ((AliTRDdigitizer &) d).fField = fField; + ((AliTRDdigitizer &) d).fPRFOn = fPRFOn; + ((AliTRDdigitizer &) d).fTRFOn = fTRFOn; + + ((AliTRDdigitizer &) d).fCompress = fCompress; + ((AliTRDdigitizer &) d).fVerbose = fVerbose; + ((AliTRDdigitizer &) d).fSDigits = fSDigits; + ((AliTRDdigitizer &) d).fSDigitsScale = fSDigitsScale; + + ((AliTRDdigitizer &) d).fPRFbin = fPRFbin; + ((AliTRDdigitizer &) d).fPRFlo = fPRFlo; + ((AliTRDdigitizer &) d).fPRFhi = fPRFhi; + ((AliTRDdigitizer &) d).fPRFwid = fPRFwid; + ((AliTRDdigitizer &) d).fPRFpad = fPRFpad; if (((AliTRDdigitizer &) d).fPRFsmp) delete ((AliTRDdigitizer &) d).fPRFsmp; ((AliTRDdigitizer &) d).fPRFsmp = new Float_t[fPRFbin]; for (iBin = 0; iBin < fPRFbin; iBin++) { ((AliTRDdigitizer &) d).fPRFsmp[iBin] = fPRFsmp[iBin]; } - ((AliTRDdigitizer &) d).fTRFbin = fTRFbin; - ((AliTRDdigitizer &) d).fTRFlo = fTRFlo; - ((AliTRDdigitizer &) d).fTRFhi = fTRFhi; - ((AliTRDdigitizer &) d).fTRFwid = fTRFwid; + ((AliTRDdigitizer &) d).fTRFbin = fTRFbin; + ((AliTRDdigitizer &) d).fTRFlo = fTRFlo; + ((AliTRDdigitizer &) d).fTRFhi = fTRFhi; + ((AliTRDdigitizer &) d).fTRFwid = fTRFwid; if (((AliTRDdigitizer &) d).fTRFsmp) delete ((AliTRDdigitizer &) d).fTRFsmp; ((AliTRDdigitizer &) d).fTRFsmp = new Float_t[fTRFbin]; for (iBin = 0; iBin < fTRFbin; iBin++) { @@ -440,8 +467,7 @@ void AliTRDdigitizer::Init() fADCthreshold = 1; // For the summable digits - fSinRange = 1000000.; - fSoutRange = 1000000.; + fSDigitsScale = 100.; // The drift velocity (cm / mus) fDriftVelocity = 1.5; @@ -629,11 +655,6 @@ void AliTRDdigitizer::SampleTRF() , 0.018451, 0.018282, 0.018113, 0.017947 , 0.017782, 0.017617, 0.017455, 0.017297 }; - //for (Int_t ipasa = 0; ipasa < kNpasa; ipasa++) { - // time[ipasa] += 0.13; - // time[ipasa] *= 0.5; - //} - if (fTRFsmp) delete fTRFsmp; fTRFsmp = new Float_t[fTRFbin]; @@ -708,19 +729,25 @@ Bool_t AliTRDdigitizer::Open(const Char_t *name, Int_t nEvent) // Connect the AliRoot file containing Geometry, Kine, and Hits fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name); if (!fInputFile) { - printf("AliTRDdigitizer::Open -- "); - printf("Open the ALIROOT-file %s.\n",name); + if (fVerbose > 0) { + printf("AliTRDdigitizer::Open -- "); + printf("Open the AliROOT-file %s.\n",name); + } fInputFile = new TFile(name,"UPDATE"); } else { - printf("AliTRDdigitizer::Open -- "); - printf("%s is already open.\n",name); + if (fVerbose > 0) { + printf("AliTRDdigitizer::Open -- "); + printf("%s is already open.\n",name); + } } gAlice = (AliRun*) fInputFile->Get("gAlice"); if (gAlice) { - printf("AliTRDdigitizer::Open -- "); - printf("AliRun object found on file.\n"); + if (fVerbose > 0) { + printf("AliTRDdigitizer::Open -- "); + printf("AliRun object found on file.\n"); + } } else { printf("AliTRDdigitizer::Open -- "); @@ -738,7 +765,12 @@ Bool_t AliTRDdigitizer::Open(const Char_t *name, Int_t nEvent) return kFALSE; } - return InitDetector(); + if (InitDetector()) { + return MakeBranch(); + } + else { + return kFALSE; + } } @@ -759,12 +791,24 @@ Bool_t AliTRDdigitizer::InitDetector() // Get the geometry fGeo = fTRD->GetGeometry(); - printf("AliTRDdigitizer::InitDetector -- "); - printf("Geometry version %d\n",fGeo->IsVersion()); + if (fVerbose > 0) { + printf("AliTRDdigitizer::InitDetector -- "); + printf("Geometry version %d\n",fGeo->IsVersion()); + } // The magnetic field strength in Tesla fField = 0.2 * gAlice->Field()->Factor(); + // Create a digits manager + fDigitsManager = new AliTRDdigitsManager(); + fDigitsManager->SetSDigits(fSDigits); + fDigitsManager->CreateArrays(); + fDigitsManager->SetEvent(fEvent); + fDigitsManager->SetVerbose(fVerbose); + + // The list for the input s-digits manager to be merged + fSDigitsManagerList = new TList(); + ReInit(); return kTRUE; @@ -772,14 +816,13 @@ Bool_t AliTRDdigitizer::InitDetector() } //_____________________________________________________________________________ -Bool_t AliTRDdigitizer::SumSDigits() +Bool_t AliTRDdigitizer::MakeBranch(const Char_t *file) { - // - // Sums up the summable digits and creates final digits - // Not yet implemented + // + // Create the branches for the digits array // - return kFALSE; + return fDigitsManager->MakeBranch(file); } @@ -830,9 +873,6 @@ Bool_t AliTRDdigitizer::MakeDigits() AliTRDdataArrayI *digits = 0; AliTRDdataArrayI *dictionary[kNDict]; - // Create a digits manager - fDigits = new AliTRDdigitsManager(); - // Create a container for the amplitudes AliTRDsegmentArray *signalsArray = new AliTRDsegmentArray("AliTRDdataArrayF",AliTRDgeometry::Ndet()); @@ -840,8 +880,10 @@ Bool_t AliTRDdigitizer::MakeDigits() if (fTRFOn) { timeTRDbeg = ((Int_t) (-fTRFlo / fGeo->GetTimeBinSize())) - 1; timeTRDend = ((Int_t) ( fTRFhi / fGeo->GetTimeBinSize())) - 1; - printf("AliTRDdigitizer::MakeDigits -- "); - printf("Sample the TRF between -%d and %d\n",timeTRDbeg,timeTRDend); + if (fVerbose > 0) { + printf("AliTRDdigitizer::MakeDigits -- "); + printf("Sample the TRF between -%d and %d\n",timeTRDbeg,timeTRDend); + } } Float_t elAttachProp = fElAttachProp / 100.; @@ -858,9 +900,10 @@ Bool_t AliTRDdigitizer::MakeDigits() return kFALSE; } - printf("AliTRDdigitizer::MakeDigits -- "); - printf("Start creating digits.\n"); - if (fVerbose > 0) this->Dump(); + if (fVerbose > 0) { + printf("AliTRDdigitizer::MakeDigits -- "); + printf("Start creating digits.\n"); + } // Get the pointer to the hit tree TTree *HitTree = gAlice->TreeH(); @@ -983,7 +1026,7 @@ Bool_t AliTRDdigitizer::MakeDigits() } // The same for the dictionary for (iDict = 0; iDict < kNDict; iDict++) { - dictionary[iDict] = fDigits->GetDictionary(detector,iDict); + dictionary[iDict] = fDigitsManager->GetDictionary(detector,iDict); if (dictionary[iDict]->GetNtime() == 0) { dictionary[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); } @@ -1143,8 +1186,10 @@ Bool_t AliTRDdigitizer::MakeDigits() } // All hits finished - printf("AliTRDdigitizer::MakeDigits -- "); - printf("Finished analyzing %d hits\n",countHits); + if (fVerbose > 0) { + printf("AliTRDdigitizer::MakeDigits -- "); + printf("Finished analyzing %d hits\n",countHits); + } // The total conversion factor Float_t convert = kEl2fC * fPadCoupling * fTimeCoupling * fChipGain; @@ -1166,7 +1211,7 @@ Bool_t AliTRDdigitizer::MakeDigits() } // Add a container for the digits of this detector - digits = fDigits->GetDigits(iDet); + digits = fDigitsManager->GetDigits(iDet); // Allocate memory space for the digits buffer digits->Allocate(nRowMax,nColMax,nTimeTotal); @@ -1182,7 +1227,7 @@ Bool_t AliTRDdigitizer::MakeDigits() } // Create the missing dictionary containers for (iDict = 0; iDict < kNDict; iDict++) { - dictionary[iDict] = fDigits->GetDictionary(iDet,iDict); + dictionary[iDict] = fDigitsManager->GetDictionary(iDet,iDict); if (dictionary[iDict]->GetNtime() == 0) { dictionary[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); } @@ -1202,13 +1247,9 @@ Bool_t AliTRDdigitizer::MakeDigits() if (fSDigits) { Float_t signalAmp = signals->GetDataUnchecked(iRow,iCol,iTime); - Int_t adc = 0; - if (signalAmp >= fSinRange) { - adc = ((Int_t) fSoutRange); - } - else { - adc = ((Int_t) (signalAmp * (fSoutRange / fSinRange))); - } + signalAmp *= fSDigitsScale; + signalAmp = TMath::Min(signalAmp,1.0e9); + Int_t adc = (Int_t) signalAmp; nDigits++; digits->SetDataUnchecked(iRow,iCol,iTime,adc); @@ -1263,39 +1304,276 @@ Bool_t AliTRDdigitizer::MakeDigits() totalSizeDict2 += dictionary[2]->GetSize(); Float_t nPixel = nRowMax * nColMax * nTimeMax; - printf("AliTRDdigitizer::MakeDigits -- "); - printf("Found %d digits in detector %d (%3.0f).\n" - ,nDigits,iDet - ,100.0 * ((Float_t) nDigits) / nPixel); - + if (fVerbose > 0) { + printf("AliTRDdigitizer::MakeDigits -- "); + printf("Found %d digits in detector %d (%3.0f).\n" + ,nDigits,iDet + ,100.0 * ((Float_t) nDigits) / nPixel); + } + if (fCompress) signals->Compress(1,0); } - printf("AliTRDdigitizer::MakeDigits -- "); - printf("Total number of analyzed hits = %d\n",countHits); + if (fVerbose > 0) { + printf("AliTRDdigitizer::MakeDigits -- "); + printf("Total number of analyzed hits = %d\n",countHits); + printf("AliTRDdigitizer::MakeDigits -- "); + printf("Total digits data size = %d, %d, %d, %d\n",totalSizeDigits + ,totalSizeDict0 + ,totalSizeDict1 + ,totalSizeDict2); + } + + return kTRUE; + +} + +//_____________________________________________________________________________ +void AliTRDdigitizer::AddSDigitsManager(AliTRDdigitsManager *man) +{ + // + // Add a digits manager for s-digits to the input list. + // + + fSDigitsManagerList->Add(man); + +} + +//_____________________________________________________________________________ +Bool_t AliTRDdigitizer::ConvertSDigits() +{ + // + // Converts s-digits to normal digits + // + + // Number of track dictionary arrays + const Int_t kNDict = AliTRDdigitsManager::kNDict; + + // Converts number of electrons to fC + const Double_t kEl2fC = 1.602E-19 * 1.0E15; + + Int_t iDict = 0; + + if (fVerbose > 0) { + this->Dump(); + } + + Double_t sDigitsScale = 1.0 / GetSDigitsScale(); + Double_t noise = GetNoise(); + Double_t padCoupling = GetPadCoupling(); + Double_t timeCoupling = GetTimeCoupling(); + Double_t chipGain = GetChipGain(); + Double_t convert = kEl2fC * padCoupling * timeCoupling * chipGain;; + Double_t adcInRange = GetADCinRange(); + Double_t adcOutRange = GetADCoutRange(); + Int_t adcThreshold = GetADCthreshold(); + + AliTRDdataArrayI *digitsIn; + AliTRDdataArrayI *digitsOut; + AliTRDdataArrayI *dictionaryIn[kNDict]; + AliTRDdataArrayI *dictionaryOut[kNDict]; + + // Loop through the detectors + for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) { - printf("AliTRDdigitizer::MakeDigits -- "); - printf("Total digits data size = %d, %d, %d, %d\n",totalSizeDigits - ,totalSizeDict0 - ,totalSizeDict1 - ,totalSizeDict2); + if (fVerbose > 0) { + printf("AliTRDdigitizer::ConvertSDigits -- "); + printf("Convert detector %d to digits.\n",iDet); + } + + Int_t plane = fGeo->GetPlane(iDet); + Int_t sector = fGeo->GetSector(iDet); + Int_t chamber = fGeo->GetChamber(iDet); + Int_t nRowMax = fGeo->GetRowMax(plane,chamber,sector); + Int_t nColMax = fGeo->GetColMax(plane); + Int_t nTimeTotal = fGeo->GetTimeTotal(); + + digitsIn = fSDigitsManager->GetDigits(iDet); + digitsIn->Expand(); + digitsOut = fDigitsManager->GetDigits(iDet); + digitsOut->Allocate(nRowMax,nColMax,nTimeTotal); + for (iDict = 0; iDict < kNDict; iDict++) { + dictionaryIn[iDict] = fSDigitsManager->GetDictionary(iDet,iDict); + dictionaryIn[iDict]->Expand(); + dictionaryOut[iDict] = fDigitsManager->GetDictionary(iDet,iDict); + dictionaryOut[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); + } + + for (Int_t iRow = 0; iRow < nRowMax; iRow++ ) { + for (Int_t iCol = 0; iCol < nColMax; iCol++ ) { + for (Int_t iTime = 0; iTime < nTimeTotal; iTime++) { + + Double_t signal = (Double_t) digitsIn->GetDataUnchecked(iRow,iCol,iTime); + signal *= sDigitsScale; + // Add the noise + signal = TMath::Max((Double_t) gRandom->Gaus(signal,noise),0.0); + // Convert to mV + signal *= convert; + // Convert to ADC counts. Set the overflow-bit adcOutRange if the + // signal is larger than adcInRange + Int_t adc = 0; + if (signal >= adcInRange) { + adc = ((Int_t) adcOutRange); + } + else { + adc = ((Int_t) (signal * (adcOutRange / adcInRange))); + } + // Store the amplitude of the digit if above threshold + if (adc > adcThreshold) { + digitsOut->SetDataUnchecked(iRow,iCol,iTime,adc); + } + // Copy the dictionary + for (iDict = 0; iDict < kNDict; iDict++) { + Int_t track = dictionaryIn[iDict]->GetDataUnchecked(iRow,iCol,iTime); + dictionaryOut[iDict]->SetDataUnchecked(iRow,iCol,iTime,track); + } + + } + } + } + + if (fCompress) { + digitsIn->Compress(1,0); + digitsOut->Compress(1,0); + for (iDict = 0; iDict < kNDict; iDict++) { + dictionaryIn[iDict]->Compress(1,0); + dictionaryOut[iDict]->Compress(1,0); + } + } + + } return kTRUE; } //_____________________________________________________________________________ -Bool_t AliTRDdigitizer::Merge(TTree *trees, Int_t *mask, Int_t nin, Int_t event) +Bool_t AliTRDdigitizer::MergeSDigits() { // - // Merges the summable digits of different events + // Merges the input s-digits: + // - The amplitude of the different inputs are summed up. + // - Of the track IDs from the input dictionaries only one is + // kept for each input. This works for maximal 3 different merged inputs. // + // Number of track dictionary arrays + const Int_t kNDict = AliTRDdigitsManager::kNDict; + + Int_t iDict = 0; + + AliTRDdataArrayI *digitsA; + AliTRDdataArrayI *digitsB; + AliTRDdataArrayI *dictionaryA[kNDict]; + AliTRDdataArrayI *dictionaryB[kNDict]; + + // Get the first s-digits + fSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->First(); + if (!fSDigitsManager) return kFALSE; + + // Loop through the other sets of s-digits + AliTRDdigitsManager *mergeSDigitsManager; + mergeSDigitsManager = (AliTRDdigitsManager *) + fSDigitsManagerList->After(fSDigitsManager); + + if (fVerbose > 0) { + if (mergeSDigitsManager) { + printf("AliTRDdigitizer::MergeSDigits -- "); + printf("Merge serveral input files.\n"); + } + else { + printf("AliTRDdigitizer::MergeSDigits -- "); + printf("Only one input file.\n"); + } + } + + Int_t iMerge = 0; + while (mergeSDigitsManager) { + + iMerge++; + + // Loop through the detectors + for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) { + + Int_t plane = fGeo->GetPlane(iDet); + Int_t sector = fGeo->GetSector(iDet); + Int_t chamber = fGeo->GetChamber(iDet); + Int_t nRowMax = fGeo->GetRowMax(plane,chamber,sector); + Int_t nColMax = fGeo->GetColMax(plane); + Int_t nTimeTotal = fGeo->GetTimeTotal(); + + // Loop through the pixels of one detector and add the signals + digitsA = fSDigitsManager->GetDigits(iDet); + digitsB = mergeSDigitsManager->GetDigits(iDet); + digitsA->Expand(); + digitsB->Expand(); + for (iDict = 0; iDict < kNDict; iDict++) { + dictionaryA[iDict] = fSDigitsManager->GetDictionary(iDet,iDict); + dictionaryB[iDict] = mergeSDigitsManager->GetDictionary(iDet,iDict); + dictionaryA[iDict]->Expand(); + dictionaryB[iDict]->Expand(); + } + + if (fVerbose > 0) { + printf("AliTRDdigitizer::MergeSDigits -- "); + printf("Merge detector %d of input no.%d.\n",iDet,iMerge); + } + + for (Int_t iRow = 0; iRow < nRowMax; iRow++ ) { + for (Int_t iCol = 0; iCol < nColMax; iCol++ ) { + for (Int_t iTime = 0; iTime < nTimeTotal; iTime++) { + + // Add the amplitudes of the summable digits + Int_t ampA = digitsA->GetDataUnchecked(iRow,iCol,iTime); + Int_t ampB = digitsB->GetDataUnchecked(iRow,iCol,iTime); + ampA += ampB; + digitsA->SetDataUnchecked(iRow,iCol,iTime,ampA); + + // Take only one track from each input + Int_t track = dictionaryB[0]->GetDataUnchecked(iRow,iCol,iTime); + if (iMerge < kNDict) { + dictionaryA[iMerge]->SetDataUnchecked(iRow,iCol,iTime,track); + } + + } + } + } + + if (fCompress) { + digitsA->Compress(1,0); + digitsB->Compress(1,0); + for (iDict = 0; iDict < kNDict; iDict++) { + dictionaryA[iDict]->Compress(1,0); + dictionaryB[iDict]->Compress(1,0); + } + } + + } + + // The next set of s-digits + mergeSDigitsManager = (AliTRDdigitsManager *) + fSDigitsManagerList->After(mergeSDigitsManager); + + } + return kTRUE; } +//_____________________________________________________________________________ +Bool_t AliTRDdigitizer::SDigits2Digits() +{ + // + // Merges the input s-digits and converts them to normal digits + // + + if (!MergeSDigits()) return kFALSE; + + return ConvertSDigits(); + +} + //_____________________________________________________________________________ Bool_t AliTRDdigitizer::CheckDetector(Int_t plane, Int_t chamber, Int_t sector) { @@ -1331,23 +1609,8 @@ Bool_t AliTRDdigitizer::WriteDigits() // Writes out the TRD-digits and the dictionaries // - // Create the branches - if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) { - return kFALSE; - } - // Store the digits and the dictionary in the tree - fDigits->WriteDigits(); - - // Write the new tree into the input file (use overwrite option) - Char_t treeName[15]; - sprintf(treeName,"TreeD%d",fEvent); - printf("AliTRDdigitizer::WriteDigits -- "); - printf("Write the digits tree %s for event %d.\n" - ,treeName,fEvent); - gAlice->TreeD()->Write(treeName,TObject::kOverwrite); - - return kTRUE; + return fDigitsManager->WriteDigits(); } diff --git a/TRD/AliTRDdigitizer.h b/TRD/AliTRDdigitizer.h index 9d773b9aad9..6889a629681 100644 --- a/TRD/AliTRDdigitizer.h +++ b/TRD/AliTRDdigitizer.h @@ -30,13 +30,16 @@ class AliTRDdigitizer : public TNamed { virtual void Copy(TObject &d); virtual void Init(); + virtual Bool_t InitDetector(); + virtual void ReInit(); virtual Bool_t Open(const Char_t *name, Int_t nEvent = 0); + virtual Bool_t MakeBranch(const Char_t *file = 0); virtual Bool_t MakeDigits(); - virtual Bool_t Merge(TTree *trees, Int_t *mask, Int_t nin, Int_t event); - virtual void ReInit(); - virtual Bool_t SumSDigits(); + virtual void AddSDigitsManager(AliTRDdigitsManager *man); + virtual Bool_t ConvertSDigits(); + virtual Bool_t MergeSDigits(); + virtual Bool_t SDigits2Digits(); virtual Bool_t WriteDigits(); - virtual Bool_t InitDetector(); virtual void SetGasGain(Float_t gasgain) { fGasGain = gasgain; }; virtual void SetNoise(Float_t noise) { fNoise = noise; }; @@ -58,10 +61,11 @@ class AliTRDdigitizer : public TNamed { virtual void SetCompress(Int_t c = 1) { fCompress = c; }; virtual void SetVerbose(Int_t v = 1) { fVerbose = v; }; virtual void SetSDigits(Int_t v = 1) { fSDigits = v; }; + virtual void SetSDigitsScale(Float_t s) { fSDigitsScale = s; }; virtual void SetEvent(Int_t v = 0) { fEvent = v; }; - virtual void SetManager(AliTRDdigitsManager *man) { fDigits = man; }; + virtual void SetManager(AliTRDdigitsManager *man) { fDigitsManager = man; }; - AliTRDdigitsManager *Digits() const { return fDigits; }; + AliTRDdigitsManager *Digits() const { return fDigitsManager; }; Float_t GetGasGain() const { return fGasGain; }; Float_t GetNoise() const { return fNoise; }; @@ -79,6 +83,7 @@ class AliTRDdigitizer : public TNamed { Float_t GetTimeCoupling() const { return fTimeCoupling; }; Bool_t GetCompress() const { return fCompress; }; Bool_t GetSDigits() const { return fSDigits; }; + Float_t GetSDigitsScale() const { return fSDigitsScale; }; Float_t GetTimeBinWidth() const { return fTimeBinWidth; }; virtual Float_t GetDiffusionL(Float_t vd, Float_t b); virtual Float_t GetDiffusionT(Float_t vd, Float_t b); @@ -86,50 +91,51 @@ class AliTRDdigitizer : public TNamed { protected: - TFile *fInputFile; //! ALIROOT-filename - AliTRDdigitsManager *fDigits; //! TRD digits manager - AliTRD *fTRD; //! TRD detector class - AliTRDgeometry *fGeo; //! TRD geometry + TFile *fInputFile; //! ALIROOT-file + AliTRDdigitsManager *fDigitsManager; //! Manager for the output digits + AliTRDdigitsManager *fSDigitsManager; //! Manager for the summed input s-digits + TList *fSDigitsManagerList; //! List of managers of input s-digits + AliTRD *fTRD; //! TRD detector class + AliTRDgeometry *fGeo; //! TRD geometry - Int_t fEvent; //! Event number - - Float_t fField; // Magnetic field - Float_t fGasGain; // Gas gain - Float_t fNoise; // Electronics noise - Float_t fChipGain; // Electronics gain - Float_t fADCoutRange; // ADC output range (number of channels) - Float_t fADCinRange; // ADC input range (input charge) - Float_t fSinRange; // Input range for summable digits - Float_t fSoutRange; // Output range for summable digits - Int_t fADCthreshold; // ADC threshold in ADC channel - Int_t fDiffusionOn; // Switch for the diffusion - Float_t fDiffusionT; // Diffusion in transverse direction - Float_t fDiffusionL; // Diffusion in longitudinal direction - Int_t fElAttachOn; // Switch for the electron attachment - Float_t fElAttachProp; // Propability for electron attachment (for 1m) - Int_t fExBOn; // Switch for the ExB effects - Float_t fOmegaTau; // Tangens of the Lorentz angle - Float_t fLorentzFactor; // Factor due to Lorentz force - Int_t fPRFOn; // Switch for the pad response - Float_t *fPRFsmp; //!Sampled pad response - Int_t fPRFbin; // Number of bins for the PRF - Float_t fPRFlo; // Lower boundary of the PRF - Float_t fPRFhi; // Higher boundary of the PRF - Float_t fPRFwid; // Bin width of the sampled PRF - Int_t fPRFpad; // Distance to next pad in PRF - Int_t fTRFOn; // Switch for the time response - Float_t *fTRFsmp; //!Integrated time response - Int_t fTRFbin; // Number of bins for the TRF - Float_t fTRFlo; // Lower boundary of the TRF - Float_t fTRFhi; // Higher boundary of the TRF - Float_t fTRFwid; // Bin width of the integrated TRF - Float_t fDriftVelocity; // Drift velocity (cm / mus) - Float_t fTimeBinWidth; // Time bin width in ns - Float_t fPadCoupling; // Pad coupling factor - Float_t fTimeCoupling; // Time coupling factor (image charge of moving ions) - Bool_t fCompress; // Switch to keep only compressed data in memory - Int_t fVerbose; // Sets the verbose level - Bool_t fSDigits; // Switch for the summable digits + Int_t fEvent; //! Event number + + Float_t fField; // Magnetic field + Float_t fGasGain; // Gas gain + Float_t fNoise; // Electronics noise + Float_t fChipGain; // Electronics gain + Float_t fADCoutRange; // ADC output range (number of channels) + Float_t fADCinRange; // ADC input range (input charge) + Int_t fADCthreshold; // ADC threshold in ADC channel + Int_t fDiffusionOn; // Switch for the diffusion + Float_t fDiffusionT; // Diffusion in transverse direction + Float_t fDiffusionL; // Diffusion in longitudinal direction + Int_t fElAttachOn; // Switch for the electron attachment + Float_t fElAttachProp; // Propability for electron attachment (for 1m) + Int_t fExBOn; // Switch for the ExB effects + Float_t fOmegaTau; // Tangens of the Lorentz angle + Float_t fLorentzFactor; // Factor due to Lorentz force + Int_t fPRFOn; // Switch for the pad response + Float_t *fPRFsmp; //! Sampled pad response + Int_t fPRFbin; // Number of bins for the PRF + Float_t fPRFlo; // Lower boundary of the PRF + Float_t fPRFhi; // Higher boundary of the PRF + Float_t fPRFwid; // Bin width of the sampled PRF + Int_t fPRFpad; // Distance to next pad in PRF + Int_t fTRFOn; // Switch for the time response + Float_t *fTRFsmp; //! Integrated time response + Int_t fTRFbin; // Number of bins for the TRF + Float_t fTRFlo; // Lower boundary of the TRF + Float_t fTRFhi; // Higher boundary of the TRF + Float_t fTRFwid; // Bin width of the integrated TRF + Float_t fDriftVelocity; // Drift velocity (cm / mus) + Float_t fTimeBinWidth; // Time bin width in ns + Float_t fPadCoupling; // Pad coupling factor + Float_t fTimeCoupling; // Time coupling factor (image charge of moving ions) + Bool_t fCompress; // Switch to keep only compressed data in memory + Int_t fVerbose; // Sets the verbose level + Bool_t fSDigits; // Switch for the summable digits + Float_t fSDigitsScale; // Scale factor for the summable digits private: @@ -141,7 +147,7 @@ class AliTRDdigitizer : public TNamed { virtual void SamplePRF(); virtual void SampleTRF(); - ClassDef(AliTRDdigitizer,4) // Produces TRD-Digits + ClassDef(AliTRDdigitizer,5) // Produces TRD-Digits }; diff --git a/TRD/AliTRDdigitsManager.cxx b/TRD/AliTRDdigitsManager.cxx index 4f86fc0a6ac..d0c39248f0f 100644 --- a/TRD/AliTRDdigitsManager.cxx +++ b/TRD/AliTRDdigitsManager.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.13 2001/11/06 17:19:41 cblume +Add detailed geometry and simple simulator + Revision 1.12 2001/05/16 14:57:28 alibrary New files for folders and Stack @@ -98,13 +101,16 @@ AliTRDdigitsManager::AliTRDdigitsManager():TObject() // Default constructor // - fIsRaw = kFALSE; - - fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet()); + fIsRaw = kFALSE; + fEvent = 0; + fVerbose = 0; + fSDigits = 0; + fFile = NULL; + fTree = NULL; + fDigits = NULL; for (Int_t iDict = 0; iDict < kNDict; iDict++) { - fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI" - ,AliTRDgeometry::Ndet()); + fDictionary[iDict] = NULL; } } @@ -127,14 +133,27 @@ AliTRDdigitsManager::~AliTRDdigitsManager() // AliTRDdigitsManager destructor // + if (fFile) { + fFile->Close(); + delete fFile; + fFile = NULL; + } + + if (fTree) { + delete fTree; + fTree = NULL; + } + if (fDigits) { fDigits->Delete(); delete fDigits; + fDigits = NULL; } for (Int_t iDict = 0; iDict < kNDict; iDict++) { fDictionary[iDict]->Delete(); delete fDictionary[iDict]; + fDictionary[iDict] = NULL; } } @@ -146,12 +165,31 @@ void AliTRDdigitsManager::Copy(TObject &m) // Copy function // - ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw; + ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw; + ((AliTRDdigitsManager &) m).fEvent = fEvent; + ((AliTRDdigitsManager &) m).fVerbose = fVerbose; + ((AliTRDdigitsManager &) m).fSDigits = fSDigits; TObject::Copy(m); } +//_____________________________________________________________________________ +void AliTRDdigitsManager::CreateArrays() +{ + // + // Create the data arrays + // + + fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet()); + + for (Int_t iDict = 0; iDict < kNDict; iDict++) { + fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI" + ,AliTRDgeometry::Ndet()); + } + +} + //_____________________________________________________________________________ void AliTRDdigitsManager::SetRaw() { @@ -175,67 +213,102 @@ Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time } //_____________________________________________________________________________ -Bool_t AliTRDdigitsManager::MakeBranch(char *file) +Bool_t AliTRDdigitsManager::Open(const Char_t *name) { // - // Creates the branches for the digits and the dictionary in the digits tree + // Opens the file for the TRD digits + // + + fFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name); + if (!fFile) { + if (fVerbose > 0) { + printf("AliTRDdigitsManager::Open -- "); + printf("Open the AliROOT-file %s.\n",name); + } + fFile = new TFile(name,"UPDATE"); + if (!fFile) return kFALSE; + } + else { + if (fVerbose > 0) { + printf("AliTRDdigitsManager::Open -- "); + printf("%s is already open.\n",name); + } + } + + return kTRUE; + +} + +//_____________________________________________________________________________ +Bool_t AliTRDdigitsManager::MakeBranch(const Char_t *file) +{ + // + // Creates the tree and branches for the digits and the dictionary // Int_t buffersize = 64000; Bool_t status = kTRUE; - //TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("TRD.Digits.root"); + AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD") ; - AliTRD * TRD = (AliTRD *) gAlice->GetDetector("TRD") ; + // Create the TRD digits tree + Char_t treeName[12]; + if (fSDigits) { + sprintf(treeName,"TreeS%d_TRD",fEvent); + fTree = new TTree(treeName,"TRD SDigits"); + } + else { + sprintf(treeName,"TreeD%d_TRD",fEvent); + fTree = new TTree(treeName,"TRD Digits"); + } - if (gAlice->TreeD()) { + if (fVerbose > 0) { + printf("AliTRDdigitsManager::MakeBranch -- "); + printf("Creating tree %s\n",treeName); + } - // Make the branch for the digits - if (fDigits) { - const AliTRDdataArray *kDigits = - (AliTRDdataArray *) fDigits->At(0); - if (kDigits) { - TRD->MakeBranchInTree(gAlice->TreeD(), - "TRDdigits", kDigits->IsA()->GetName(), - &kDigits,buffersize, 1,file); + // Make the branch for the digits + if (fDigits) { + const AliTRDdataArray *kDigits = (AliTRDdataArray *) fDigits->At(0); + if (kDigits) { + trd->MakeBranchInTree(fTree,"TRDdigits",kDigits->IsA()->GetName() + ,&kDigits,buffersize,99,file); + if (fVerbose > 0) { printf("AliTRDdigitsManager::MakeBranch -- "); printf("Making branch TRDdigits\n"); } - else { - status = kFALSE; - } } else { status = kFALSE; } + } + else { + status = kFALSE; + } - // Make the branches for the dictionaries - for (Int_t iDict = 0; iDict < kNDict; iDict++) { - Char_t branchname[15]; - sprintf(branchname,"TRDdictionary%d",iDict); - if (fDictionary[iDict]) { - const AliTRDdataArray *kDictionary = - (AliTRDdataArray *) fDictionary[iDict]->At(0); - if (kDictionary) { - TRD->MakeBranchInTree(gAlice->TreeD(), - branchname,kDictionary->IsA()->GetName(), - &kDictionary,buffersize, 1,file); + // Make the branches for the dictionaries + for (Int_t iDict = 0; iDict < kNDict; iDict++) { + Char_t branchname[15]; + sprintf(branchname,"TRDdictionary%d",iDict); + if (fDictionary[iDict]) { + const AliTRDdataArray *kDictionary = + (AliTRDdataArray *) fDictionary[iDict]->At(0); + if (kDictionary) { + trd->MakeBranchInTree(fTree,branchname,kDictionary->IsA()->GetName() + ,&kDictionary,buffersize,99,file); + if (fVerbose > 0) { printf("AliTRDdigitsManager::MakeBranch -- "); printf("Making branch %s\n",branchname); } - else { - status = kFALSE; - } } else { status = kFALSE; } } - - } - else { - status = kFALSE; + else { + status = kFALSE; + } } return status; @@ -251,12 +324,42 @@ Bool_t AliTRDdigitsManager::ReadDigits() Bool_t status = kTRUE; - status = fDigits->LoadArray("TRDdigits"); + // Get the digits tree + Char_t treeName[12]; + if (fSDigits) { + sprintf(treeName,"TreeS%d_TRD",fEvent); + } + else { + sprintf(treeName,"TreeD%d_TRD",fEvent); + } + if (fFile) { + fTree = (TTree *) fFile->Get(treeName); + } + else { + fTree = (TTree *) gDirectory->Get(treeName); + } + if (!fTree) { + if (fVerbose > 0) { + printf("AliTRDdigitsManager::ReadDigits -- "); + printf("Could not find tree %s.\n",treeName); + } + return kFALSE; + } + + if (!fDigits) { + if (fVerbose > 0) { + printf("AliTRDdigitsManager::ReadDigits -- "); + printf("Create the data arrays.\n"); + } + CreateArrays(); + } + + status = fDigits->LoadArray("TRDdigits",fTree); for (Int_t iDict = 0; iDict < kNDict; iDict++) { Char_t branchname[15]; sprintf(branchname,"TRDdictionary%d",iDict); - status = fDictionary[iDict]->LoadArray(branchname); + status = fDictionary[iDict]->LoadArray(branchname,fTree); } if (fDigits->TestBit(AliTRDdigit::RawDigit())) { @@ -277,15 +380,8 @@ Bool_t AliTRDdigitsManager::WriteDigits() // Writes out the TRD-digits and the dictionaries // - // Create the branches - if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) { - printf("AliTRDdigitsManager::WriteDigits -- "); - printf("Call MakeBranch\n"); - if (!MakeBranch()) return kFALSE; - } - // Store the contents of the segment array in the tree - if (!fDigits->StoreArray("TRDdigits")) { + if (!fDigits->StoreArray("TRDdigits",fTree)) { printf("AliTRDdigitsManager::WriteDigits -- "); printf("Error while storing digits in branch TRDdigits\n"); return kFALSE; @@ -293,13 +389,16 @@ Bool_t AliTRDdigitsManager::WriteDigits() for (Int_t iDict = 0; iDict < kNDict; iDict++) { Char_t branchname[15]; sprintf(branchname,"TRDdictionary%d",iDict); - if (!fDictionary[iDict]->StoreArray(branchname)) { + if (!fDictionary[iDict]->StoreArray(branchname,fTree)) { printf("AliTRDdigitsManager::WriteDigits -- "); printf("Error while storing dictionary in branch %s\n",branchname); return kFALSE; } } + // Write the new tree to the output file + fTree->Write(); + return kTRUE; } diff --git a/TRD/AliTRDdigitsManager.h b/TRD/AliTRDdigitsManager.h index ce298b7314c..14cad80f6f1 100644 --- a/TRD/AliTRDdigitsManager.h +++ b/TRD/AliTRDdigitsManager.h @@ -13,6 +13,7 @@ #include class TFile; +class TTree; class AliTRDsegmentArray; class AliTRDdataArrayI; @@ -29,12 +30,17 @@ class AliTRDdigitsManager : public TObject { virtual ~AliTRDdigitsManager(); AliTRDdigitsManager &operator=(const AliTRDdigitsManager &m); + virtual void CreateArrays(); virtual void Copy(TObject &m); - virtual Bool_t MakeBranch(char *file=0); + virtual Bool_t Open(const Char_t *name); + virtual Bool_t MakeBranch(const Char_t *file = 0); virtual Bool_t ReadDigits(); virtual Bool_t WriteDigits(); virtual void SetRaw(); + virtual void SetEvent(Int_t evt) { fEvent = evt; }; + virtual void SetVerbose(Int_t v = 1) { fVerbose = v; }; + virtual void SetSDigits(Int_t v = 1) { fSDigits = v; }; virtual Bool_t IsRaw() const { return fIsRaw; }; static Int_t NDict() { return fgkNDict; }; @@ -55,12 +61,19 @@ class AliTRDdigitsManager : public TObject { static const Int_t fgkNDict; // Number of track dictionary arrays - AliTRDsegmentArray *fDigits; //! Digits data Array + Int_t fEvent; // Event number + + TFile *fFile; //! File containing the TRD digits tree + TTree *fTree; //! Tree for the digits arrays + + AliTRDsegmentArray *fDigits; //! Digits data array AliTRDsegmentArray *fDictionary[kNDict]; //! Track dictionary data array Bool_t fIsRaw; // Flag indicating raw digits + Bool_t fSDigits; // Switch for the summable digits + Int_t fVerbose; // Verbose flag - ClassDef(AliTRDdigitsManager,1) // Manages the TRD digits + ClassDef(AliTRDdigitsManager,3) // Manages the TRD digits }; diff --git a/TRD/AliTRDpid.cxx b/TRD/AliTRDpid.cxx index c6a2105164b..52218732943 100644 --- a/TRD/AliTRDpid.cxx +++ b/TRD/AliTRDpid.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.2 2001/11/06 17:19:41 cblume +Add detailed geometry and simple simulator + Revision 1.1 2001/05/07 08:08:05 cblume Update of TRD code @@ -67,6 +70,8 @@ AliTRDpid::AliTRDpid():TNamed() fPIDindexMin = 0; fPIDindexMax = 0; + fEvent = 0; + fThreePadOnly = kFALSE; } @@ -83,6 +88,8 @@ AliTRDpid::AliTRDpid(const char* name, const char* title):TNamed(name,title) fGeometry = NULL; fFileKine = NULL; + fEvent = 0; + Init(); } @@ -108,11 +115,13 @@ AliTRDpid::~AliTRDpid() if (fClusterArray) { fClusterArray->Delete(); delete fClusterArray; + fClusterArray = NULL; } if (fTrackArray) { fTrackArray->Delete(); delete fTrackArray; + fTrackArray = NULL; } fFileKine->Close(); @@ -147,6 +156,7 @@ void AliTRDpid::Copy(TObject &p) ((AliTRDpid &) p).fPIDindexMin = fPIDindexMin; ((AliTRDpid &) p).fPIDindexMax = fPIDindexMax; ((AliTRDpid &) p).fThreePadOnly = fThreePadOnly; + ((AliTRDpid &) p).fEvent = fEvent; } @@ -320,6 +330,8 @@ Bool_t AliTRDpid::ReadKine(const Char_t *name, Int_t event) return kFALSE; } + fEvent = event; + return kTRUE; } @@ -388,7 +400,9 @@ Bool_t AliTRDpid::ReadTracks(const Char_t *name) } } - TTree *trackTree = (TTree *) file->Get("TreeT"); + Char_t treeName[12]; + sprintf(treeName,"TreeT%d_TRD",fEvent); + TTree *trackTree = (TTree *) file->Get(treeName); TBranch *trackBranch = trackTree->GetBranch("tracks"); Int_t nEntry = ((Int_t) trackTree->GetEntries()); diff --git a/TRD/AliTRDpid.h b/TRD/AliTRDpid.h index 99da2182ad3..0b15f44dc38 100644 --- a/TRD/AliTRDpid.h +++ b/TRD/AliTRDpid.h @@ -54,6 +54,7 @@ class AliTRDpid : public TNamed { void SetPIDindexMax(Int_t max) { fPIDindexMax = max; }; void SetThreePadOnly(Bool_t only) { fThreePadOnly = only; }; + void SetEvent(Int_t event) { fEvent = event; }; TObjArray *GetTrackArray() { return fTrackArray; }; TObjArray *GetClusterArray() { return fClusterArray; }; @@ -80,6 +81,8 @@ class AliTRDpid : public TNamed { Bool_t fThreePadOnly; // Use only three pad cluster in the charge sum + Int_t fEvent; // Event number + TObjArray *fTrackArray; //! Array containing the tracks TObjArray *fClusterArray; //! Array containing the cluster AliTRDgeometry *fGeometry; //! The TRD geometry diff --git a/TRD/AliTRDsegmentArray.cxx b/TRD/AliTRDsegmentArray.cxx index ab01aee63d6..81b3725e5ae 100644 --- a/TRD/AliTRDsegmentArray.cxx +++ b/TRD/AliTRDsegmentArray.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.7 2001/03/13 09:30:35 cblume +Update of digitization. Moved digit branch definition to AliTRD + Revision 1.6 2000/11/01 14:53:21 cblume Merge with TRD-develop @@ -130,16 +133,22 @@ void AliTRDsegmentArray::Delete() } //_____________________________________________________________________________ -Bool_t AliTRDsegmentArray::LoadArray(const Char_t *branchname) +Bool_t AliTRDsegmentArray::LoadArray(const Char_t *branchname, TTree *tree) { // // Loads all segments of the array from the branch of - // the digits tree + // the digits tree // - // Connect the digits tree - fTree = gAlice->TreeD(); - if (!fTree) return kFALSE; + fTree = tree; + + // Connect the digits tree as default + if (!fTree) { + printf("AliTRDsegmentArray::LoadArray -- "); + printf("Use default TreeD\n"); + fTree = gAlice->TreeD(); + if (!fTree) return kFALSE; + } // Get the branch fBranch = fTree->GetBranch(branchname); @@ -162,16 +171,22 @@ Bool_t AliTRDsegmentArray::LoadArray(const Char_t *branchname) } //_____________________________________________________________________________ -Bool_t AliTRDsegmentArray::StoreArray(const Char_t *branchname) +Bool_t AliTRDsegmentArray::StoreArray(const Char_t *branchname, TTree *tree) { // // Stores all segments of the array in the branch of - // the digits tree + // the digits tree // - // Connect the digits tree - fTree = gAlice->TreeD(); - if (!fTree) return kFALSE; + fTree = tree; + + // Connect the digits tree as default + if (!fTree) { + printf("AliTRDsegmentArray::StoreArray -- "); + printf("Use default TreeD\n"); + fTree = gAlice->TreeD(); + if (!fTree) return kFALSE; + } // Get the branch fBranch = fTree->GetBranch(branchname); diff --git a/TRD/AliTRDsegmentArray.h b/TRD/AliTRDsegmentArray.h index fcfa8220458..7638bec6efc 100644 --- a/TRD/AliTRDsegmentArray.h +++ b/TRD/AliTRDsegmentArray.h @@ -11,6 +11,8 @@ // Array for TRD detector segments containing digits // //////////////////////////////////////////////////////// +class TTree; + class AliTRDdataArray; //_____________________________________________________________________________ @@ -27,8 +29,8 @@ class AliTRDsegmentArray : public AliTRDsegmentArrayBase { virtual void Delete(); virtual void Delete(const char *) { Delete(); }; - virtual Bool_t LoadArray(const Char_t *branchname); - virtual Bool_t StoreArray(const Char_t *branchname); + virtual Bool_t LoadArray(const Char_t *branchname, TTree *tree = 0); + virtual Bool_t StoreArray(const Char_t *branchname, TTree *tree = 0); virtual AliTRDdataArray *GetDataArray(Int_t det) const; virtual AliTRDdataArray *GetDataArray(Int_t sec, Int_t cha, Int_t pla) const; diff --git a/TRD/AliTRDsim.cxx b/TRD/AliTRDsim.cxx index 4cc93868254..68097ab5c10 100644 --- a/TRD/AliTRDsim.cxx +++ b/TRD/AliTRDsim.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.10 2001/05/31 16:53:26 alibrary +Correction to the destructor + Revision 1.9 2001/05/21 16:45:47 hristov Last minute changes (C.Blume) @@ -218,6 +221,7 @@ void AliTRDsim::Init() if (fSpectrum) delete fSpectrum; fSpectrum = new TH1D("TRspectrum","TR spectrum",fSpNBins,fSpLower,fSpUpper); + fSpectrum->SetDirectory(0); // Set the sigma values SetSigma(); diff --git a/TRD/AliTRDtracker.cxx b/TRD/AliTRDtracker.cxx index 963de0103af..30640e7f3d1 100644 --- a/TRD/AliTRDtracker.cxx +++ b/TRD/AliTRDtracker.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.13 2001/05/30 12:17:47 hristov +Loop variables declared once + Revision 1.12 2001/05/28 17:07:58 hristov Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of material in G10 TEC frames and material between TEC planes (C.Blume,S.Sedykh) @@ -696,7 +699,9 @@ void AliTRDtracker::ReadClusters(TObjArray *array, const Char_t *filename) TFile *file = TFile::Open(filename); if (!file->IsOpen()) {printf("Can't open file %s !\n",filename); return;} - TTree *ClusterTree = (TTree*)file->Get("ClusterTree"); + Char_t treeName[12]; + sprintf(treeName,"TreeR%d_TRD",fEvent); + TTree *ClusterTree = (TTree*) file->Get(treeName); TObjArray *ClusterArray = new TObjArray(400); @@ -868,7 +873,9 @@ Int_t AliTRDtracker::WriteTracks(const Char_t *filename) { printf("%s is already open.\n",filename); } - TTree tracktree("TreeT","Tree with TRD tracks"); + Char_t treeName[12]; + sprintf(treeName,"TreeT%d_TRD",fEvent); + TTree tracktree(treeName,"Tree with TRD tracks"); AliTRDtrack *iotrack=0; tracktree.Branch("tracks","AliTRDtrack",&iotrack,32000,0); -- 2.43.0