X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDdigitsManager.cxx;h=5d1e88fc69833c74a654c0b6015cc2962e2f2709;hb=31d94b145092dc24f6c2c4fed82a5a324be08e03;hp=b7ea603f08e48cd71399921f987ab1b37a87d97d;hpb=4d6586ef2f2bd88b51cf7bc0626270ca477fc527;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDdigitsManager.cxx b/TRD/AliTRDdigitsManager.cxx index b7ea603f08e..5d1e88fc698 100644 --- a/TRD/AliTRDdigitsManager.cxx +++ b/TRD/AliTRDdigitsManager.cxx @@ -13,42 +13,7 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ -/* -$Log$ -Revision 1.8 2000/11/01 15:20:13 cblume -Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch() - -Revision 1.7 2000/11/01 14:53:20 cblume -Merge with TRD-develop - -Revision 1.1.2.5 2000/10/17 02:27:34 cblume -Get rid of global constants - -Revision 1.1.2.4 2000/10/15 23:40:01 cblume -Remove AliTRDconst - -Revision 1.1.2.3 2000/10/06 16:49:46 cblume -Made Getters const - -Revision 1.1.2.2 2000/10/04 16:34:58 cblume -Replace include files by forward declarations - -Revision 1.5 2000/06/09 11:10:07 cblume -Compiler warnings and coding conventions, next round - -Revision 1.4 2000/06/08 18:32:58 cblume -Make code compliant to coding conventions - -Revision 1.3 2000/06/07 16:27:01 cblume -Try to remove compiler warnings on Sun and HP - -Revision 1.2 2000/05/08 16:17:27 cblume -Merge TRD-develop - -Revision 1.1.2.1 2000/05/08 14:44:01 cblume -Add new class AliTRDdigitsManager - -*/ +/* $Id$ */ /////////////////////////////////////////////////////////////////////////////// // // @@ -56,8 +21,12 @@ Add new class AliTRDdigitsManager // AliTRDdataArray objects. // // // /////////////////////////////////////////////////////////////////////////////// + +#include +#include #include +#include #include "AliRun.h" @@ -81,19 +50,22 @@ AliTRDdigitsManager::AliTRDdigitsManager():TObject() // Default constructor // - fIsRaw = kFALSE; - - fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet()); + fIsRaw = kFALSE; + fEvent = 0; + fDebug = 0; + fSDigits = 0; + fTree = NULL; + fDigits = NULL; for (Int_t iDict = 0; iDict < kNDict; iDict++) { - fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI" - ,AliTRDgeometry::Ndet()); + fDictionary[iDict] = NULL; } } //_____________________________________________________________________________ AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m) +:TObject(m) { // // AliTRDdigitsManager copy constructor @@ -113,11 +85,13 @@ AliTRDdigitsManager::~AliTRDdigitsManager() 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; } } @@ -129,15 +103,58 @@ void AliTRDdigitsManager::Copy(TObject &m) // Copy function // - ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw; + ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw; + ((AliTRDdigitsManager &) m).fEvent = fEvent; + ((AliTRDdigitsManager &) m).fDebug = fDebug; + ((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::ResetArrays() +{ + // + // Reset the data arrays + // + + if (fDigits) { + delete fDigits; + } + fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet()); + + for (Int_t iDict = 0; iDict < kNDict; iDict++) { + if (fDictionary[iDict]) { + delete fDictionary[iDict]; + } + fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI" + ,AliTRDgeometry::Ndet()); + } + +} + //_____________________________________________________________________________ void AliTRDdigitsManager::SetRaw() { + // + // Switch on the raw digits flag + // fIsRaw = kTRUE; @@ -146,65 +163,77 @@ void AliTRDdigitsManager::SetRaw() } //_____________________________________________________________________________ -Bool_t AliTRDdigitsManager::MakeBranch() +Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time + , Int_t det) const +{ + // + // Returns the amplitude of a digit + // + + return ((Short_t) GetDigits(det)->GetData(row,col,time)); + +} + +//_____________________________________________________________________________ +Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree) { // - // Creates the branches for the digits and the dictionary in the digits tree + // Creates the tree and branches for the digits and the dictionary // Int_t buffersize = 64000; Bool_t status = kTRUE; - if (gAlice->TreeD()) { - - // Make the branch for the digits - if (fDigits) { - //const AliTRDdataArrayI *kDigits = - // (AliTRDdataArrayI *) fDigits->At(0); - const AliTRDdataArray *kDigits = - (AliTRDdataArray *) fDigits->At(0); - if (kDigits) { - gAlice->TreeD()->Branch("TRDdigits",kDigits->IsA()->GetName() - ,&kDigits,buffersize,1); - printf("AliTRDdigitsManager::MakeBranch -- "); + if (tree) { + fTree = tree; + } + + // Make the branch for the digits + if (fDigits) { + const AliTRDdataArray *kDigits = (AliTRDdataArray *) fDigits->At(0); + if (kDigits) { + if (!fTree) return kFALSE; + TBranch* branch = fTree->GetBranch("TRDdigits"); + if (!branch) fTree->Branch("TRDdigits",kDigits->IsA()->GetName(), + &kDigits,buffersize,99); + if (fDebug > 0) { + printf(" "); 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 AliTRDdataArrayI *kDictionary = - // (AliTRDdataArrayI *) fDictionary[iDict]->At(0); - const AliTRDdataArray *kDictionary = - (AliTRDdataArray *) fDictionary[iDict]->At(0); - if (kDictionary) { - gAlice->TreeD()->Branch(branchname,kDictionary->IsA()->GetName() - ,&kDictionary,buffersize,1); - printf("AliTRDdigitsManager::MakeBranch -- "); + // 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) { + if (!fTree) return kFALSE; + TBranch* branch = fTree->GetBranch(branchname); + if (!branch) fTree->Branch(branchname,kDictionary->IsA()->GetName(), + &kDictionary,buffersize,99); + if (fDebug > 0) { + printf(" "); printf("Making branch %s\n",branchname); } - else { - status = kFALSE; - } } else { status = kFALSE; } } - - } - else { - status = kFALSE; + else { + status = kFALSE; + } } return status; @@ -212,7 +241,7 @@ Bool_t AliTRDdigitsManager::MakeBranch() } //_____________________________________________________________________________ -Bool_t AliTRDdigitsManager::ReadDigits() +Bool_t AliTRDdigitsManager::ReadDigits(TTree *tree) { // // Reads the digit information from the input file @@ -220,12 +249,26 @@ Bool_t AliTRDdigitsManager::ReadDigits() Bool_t status = kTRUE; - status = fDigits->LoadArray("TRDdigits"); + if (tree) { + + fTree = tree; + + } + + if (!fDigits) { + if (fDebug > 0) { + printf(" "); + 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())) { @@ -246,27 +289,26 @@ Bool_t AliTRDdigitsManager::WriteDigits() // Writes out the TRD-digits and the dictionaries // - // Create the branches - if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) { - if (!MakeBranch()) return kFALSE; - } - // Store the contents of the segment array in the tree - if (!fDigits->StoreArray("TRDdigits")) { - printf("AliTRDdigitsManager::WriteDigits -- "); + if (!fDigits->StoreArray("TRDdigits",fTree)) { + printf(" "); printf("Error while storing digits in branch TRDdigits\n"); return kFALSE; } for (Int_t iDict = 0; iDict < kNDict; iDict++) { Char_t branchname[15]; sprintf(branchname,"TRDdictionary%d",iDict); - if (!fDictionary[iDict]->StoreArray(branchname)) { - printf("AliTRDdigitsManager::WriteDigits -- "); + if (!fDictionary[iDict]->StoreArray(branchname,fTree)) { + printf(" "); printf("Error while storing dictionary in branch %s\n",branchname); return kFALSE; } } + // Write the new tree to the output file + //fTree->Write(); + fTree->AutoSave(); // Modification by Jiri + return kTRUE; }