/*
$Log$
+Revision 1.10 2002/03/13 07:55:04 jchudoba
+Correction of the errourness last commit.
+
+Revision 1.8 2002/02/13 09:03:24 jchudoba
+Remove some deletes from dtor, those objects are deleted earlier in Exec() method (where they are created)
+
+Revision 1.7 2001/11/22 11:15:41 jchudoba
+Proper deletion of arrays (thanks to Rene Brun)
+
+Revision 1.6 2001/11/02 12:55:45 jchudoba
+cleanup of the code, add const to Get methods
+
+Revision 1.4 2001/10/18 14:44:09 jchudoba
+Define constant MAXTRACKS for maximum number of tracks associated with 1 digit
+
+Revision 1.3 2001/10/04 20:01:54 jchudoba
+changes for TTask implementation, some other small editing
+
Revision 1.2 2001/07/28 10:46:04 hristov
AliRunDigitizer.h included; typos corrected
merging/digitization classes
*/
-
#include <TTree.h>
-#include <TVector.h>
#include <TObjArray.h>
#include <TFile.h>
#include <TDirectory.h>
-#include <iostream.h>
+#include <Riostream.h>
#include "AliMUONDigitizer.h"
#include "AliMUONConstants.h"
#include "AliMUONChamber.h"
-#include "AliHitMap.h"
#include "AliMUONHitMapA1.h"
#include "AliMUON.h"
#include "AliMUONHit.h"
AliMUONDigitizer::AliMUONDigitizer() :AliDigitizer()
{
// Default ctor - don't use it
- ;
+ fHits = 0;
+ fPadHits = 0;
+ fHitMap = 0;
+ fTDList = 0;
}
//___________________________________________
fTDList = 0;
fHits = 0;
fPadHits = 0;
- fTrList = 0;
- fAddress = 0;
fDebug = 0;
if (GetDebug()>2)
cerr<<"AliMUONDigitizer::AliMUONDigitizer"
// Destructor
if (fHits) delete fHits;
if (fPadHits) delete fPadHits;
- if (fHitMap) delete fHitMap;
- if (fTDList) delete fTDList;
- if (fTrList) delete fTrList;
- if (fAddress) delete fAddress;
}
//------------------------------------------------------------------------
-Bool_t AliMUONDigitizer::Exists(const AliMUONPadHit *mergable)
+Bool_t AliMUONDigitizer::Exists(const AliMUONPadHit *padhit) const
{
- AliMUONPadHit *padhit = (AliMUONPadHit*) mergable;
return (fHitMap[fNch]->TestHit(padhit->PadX(),padhit->PadY()));
}
//------------------------------------------------------------------------
-void AliMUONDigitizer::Update(AliMUONPadHit *mergable)
+void AliMUONDigitizer::Update(AliMUONPadHit *padhit)
{
- AliMUONPadHit *padhit = (AliMUONPadHit*) mergable;
- AliMUONTransientDigit* pdigit;
- Int_t ipx = padhit->PadX(); // pad number on X
- Int_t ipy = padhit->PadY(); // pad number on Y
- Int_t iqpad = Int_t(padhit->QPad()); // charge per pad
-
- pdigit = (AliMUONTransientDigit*) fHitMap[fNch]->GetHit(ipx, ipy);
- // update charge
- //
- (*pdigit).AddSignal(iqpad);
- (*pdigit).AddPhysicsSignal(iqpad);
- // update list of tracks
- //
- TObjArray* fTrList = (TObjArray*)pdigit->TrackList();
- Int_t lastEntry = fTrList->GetLast();
- TVector *pTrack = (TVector*)fTrList->At(lastEntry);
- TVector &ptrk = *pTrack;
- TVector &trinfo = *((TVector*) (*fAddress)[fCountadr-1]);
- Int_t lastTrack = Int_t(ptrk(0));
-
- if (trinfo(0) != kBgTag) {
- if (lastTrack == fTrack) {
- Int_t lastCharge = Int_t(ptrk(1));
- lastCharge += iqpad;
- fTrList->RemoveAt(lastEntry);
- trinfo(1) = lastCharge;
- fTrList->AddAt(&trinfo,lastEntry);
+ AliMUONTransientDigit *pdigit =
+ static_cast<AliMUONTransientDigit*>(
+ fHitMap[fNch]->GetHit(padhit->PadX(),padhit->PadY()));
+
+ // update charge
+ //
+ Int_t iqpad = padhit->QPad(); // charge per pad
+ pdigit->AddSignal(iqpad);
+ pdigit->AddPhysicsSignal(iqpad);
+
+ // update list of tracks
+ //
+ Int_t track, charge;
+ track = fTrack+fMask;
+ if (fSignal) {
+ charge = iqpad;
} else {
- fTrList->Add(&trinfo);
+ charge = kBgTag;
}
- } else {
- if (lastTrack != -1) fTrList->Add(&trinfo);
- }
+ pdigit->UpdateTrackList(track,charge);
}
//------------------------------------------------------------------------
-void AliMUONDigitizer::CreateNew(AliMUONPadHit *mergable)
+void AliMUONDigitizer::CreateNew(AliMUONPadHit *padhit)
{
// Create new AliMUONTransientDigit and add it to the fTDList
- AliMUONPadHit *padhit = (AliMUONPadHit*) mergable;
- AliMUONTransientDigit* pdigit;
-
- Int_t ipx = padhit->PadX(); // pad number on X
- Int_t ipy = padhit->PadY(); // pad number on Y
fTDList->AddAtAndExpand(
new AliMUONTransientDigit(fNch,fDigits),fCounter);
- fHitMap[fNch]->SetHit(ipx, ipy, fCounter);
- fCounter++;
- pdigit = (AliMUONTransientDigit*)fTDList->At(fTDList->GetLast());
+ fHitMap[fNch]->SetHit(padhit->PadX(),padhit->PadY(),fCounter);
+ AliMUONTransientDigit* pdigit =
+ (AliMUONTransientDigit*)fTDList->Last();
// list of tracks
- TObjArray *fTrList = (TObjArray*)pdigit->TrackList();
- TVector &trinfo = *((TVector*) (*fAddress)[fCountadr-1]);
- fTrList->Add(&trinfo);
+ Int_t track, charge;
+ track = fTrack+fMask;
+ if (fSignal) {
+ charge = padhit->QPad();
+ } else {
+ charge = kBgTag;
+ }
+ pdigit->AddToTrackList(track,charge);
+ fCounter++;
}
if (GetDebug()>2) cerr<<" AliMUONDigitizer::Digitize() starts"<<endl;
fTDList = new TObjArray;
- if(!fAddress) fAddress = new TClonesArray("TVector",10000);
AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
if (!pMUON) {
return;
}
pMUON->MakeBranchInTreeD(fManager->GetTreeD());
- fHitMap= new AliHitMap* [AliMUONConstants::NCh()];
- for (Int_t i = 0; i < AliMUONConstants::NCh(); i++) {fHitMap[i] = 0;}
+ fHitMap= new AliMUONHitMapA1* [AliMUONConstants::NCh()];
//
// loop over cathodes
//
- fCountadr = 0;
for (int icat = 0; icat < 2; icat++) {
fCounter = 0;
- Int_t * nmuon = new Int_t [AliMUONConstants::NCh()];
for (Int_t i = 0; i < AliMUONConstants::NCh(); i++) {
iChamber = &(pMUON->Chamber(i));
// if (!(iChamber->Nsec() == 1 && icat == 1)) {
segmentation = iChamber->SegmentationModel(icat+1);
fHitMap[i] = new AliMUONHitMapA1(segmentation, fTDList);
- nmuon[i] = 0;
// }
}
// Loop over files to digitize
-
+ fSignal = kTRUE;
for (Int_t inputFile=0; inputFile<fManager->GetNinputs();
inputFile++) {
// Connect MUON branches
+ if (inputFile > 0 ) fSignal = kFALSE;
TBranch *branchHits = 0;
TBranch *branchPadHits = 0;
TTree *treeH = fManager->GetInputTreeH(inputFile);
branchHits->SetAddress(&fHits);
}
else
- Error("Digitize","branch MUON was not found");
+ Error("Exec","branch MUON was not found");
}
if (GetDebug()>2) cerr<<" branchHits = "<<branchHits<<endl;
if (branchPadHits)
branchPadHits->SetAddress(&fPadHits);
else
- Error("Digitize","branch MUONCluster was not found");
+ Error("Exec","branch MUONCluster was not found");
}
if (GetDebug()>2) cerr<<" branchPadHits = "<<branchPadHits<<endl;
// Loop over hits
AliMUONHit* mHit;
- for(int i = 0; i < fHits->GetEntriesFast(); ++i)
- {
- mHit = (AliMUONHit*) (*fHits)[i];
+ for(Int_t i = 0; i < fHits->GetEntriesFast(); ++i) {
+ mHit = static_cast<AliMUONHit*>(fHits->At(i));
fNch = mHit->Chamber()-1; // chamber number
- iChamber = &(pMUON->Chamber(fNch));
if (fNch > AliMUONConstants::NCh()-1) {
cerr<<"AliMUONDigitizer: ERROR: "
<<"fNch > AliMUONConstants::NCh()-1, fNch, NCh(): "
<<fNch<<", "<< AliMUONConstants::NCh()<<endl;
return;
}
+ iChamber = &(pMUON->Chamber(fNch));
//
// Loop over pad hits
for (AliMUONPadHit* mPad =
Int_t iqpad = Int_t(mPad->QPad()); // charge per pad
if (cathode != (icat+1)) continue;
- new((*fAddress)[fCountadr++]) TVector(2);
-
- TVector &trinfo = *((TVector*) (*fAddress)[fCountadr-1]);
- Int_t mask = fManager->GetMask(inputFile);
- trinfo(0) = (Float_t)(fTrack + mask); // tag background
-// trinfo(0) = (Float_t)fTrack;
- if (inputFile == 0) {
- trinfo(1) = (Float_t)iqpad;
- } else {
- trinfo(1) = kBgTag;
- }
+ fMask = fManager->GetMask(inputFile);
fDigits[0] = ipx;
fDigits[1] = ipy;
fDigits[2] = icat;
}
if (mHit->Particle() == kMuonPlus ||
mHit->Particle() == kMuonMinus) {
- fDigits[5] = (mPad->HitNumber()) + mask;
+ fDigits[5] = (mPad->HitNumber()) + fMask;
} else fDigits[5] = -1;
// build the list of fired pads and update the info,
} // end file loop
if (GetDebug()>2) cerr<<"END OF FILE LOOP"<<endl;
- Int_t tracks[10];
- Int_t charges[10];
+ Int_t tracks[kMAXTRACKS];
+ Int_t charges[kMAXTRACKS];
Int_t nentries = fTDList->GetEntriesFast();
for (Int_t nent = 0; nent < nentries; nent++) {
fDigits[4] = address->Physics();
fDigits[5] = address->Hit();
- TObjArray* fTrList = (TObjArray*)address->TrackList();
- Int_t nptracks = fTrList->GetEntriesFast();
+ Int_t nptracks = address->GetNTracks();
- // this was changed to accomodate the real number of tracks
-
- if (nptracks > 10 && GetDebug() >0) {
- cerr<<"Attention - nptracks > 10 "<<nptracks<<endl;
- nptracks = 10;
+ if (nptracks > kMAXTRACKS) {
+ if (GetDebug() >0) {
+ cerr<<"AliMUONDigitizer: nptracks > 10 "<<nptracks;
+ cerr<<"reset to max value "<<kMAXTRACKS<<endl;
+ }
+ nptracks = kMAXTRACKS;
}
if (nptracks > 2 && GetDebug() >2) {
- cerr<<"Attention - nptracks > 2 "<<nptracks<<endl;
+ cerr<<"AliMUONDigitizer: nptracks > 2 "<<nptracks<<endl;
printf("cat,ich,ix,iy,q %d %d %d %d %d \n",icat,ich,fDigits[0],fDigits[1],q);
}
for (Int_t tr = 0; tr < nptracks; tr++) {
- TVector *ppP = (TVector*)fTrList->At(tr);
- if(!ppP ) {
- cerr<<"Error: ppP = "<<ppP<<endl;
- return;
- }
- TVector &pp = *ppP;
- tracks[tr] = Int_t(pp(0));
- charges[tr] = Int_t(pp(1));
+ tracks[tr] = address->GetTrack(tr);
+ charges[tr] = address->GetCharge(tr);
} //end loop over list of tracks for one pad
// Sort list of tracks according to charge
if (nptracks > 1) {
SortTracks(tracks,charges,nptracks);
}
- if (nptracks < 10 ) {
- for (Int_t i = nptracks; i < 10; i++) {
+ if (nptracks < kMAXTRACKS ) {
+ for (Int_t i = nptracks; i < kMAXTRACKS; i++) {
tracks[i] = 0;
charges[i] = 0;
}
// fill digits
pMUON->AddDigits(ich,tracks,charges,fDigits);
- // delete fTrList;
}
fManager->GetTreeD()->Fill();
fHitMap[ii] = 0;
}
}
- delete [] nmuon;
} //end loop over cathodes
if (GetDebug()>2)
cerr<<"AliMUONDigitizer::Exec: writing the TreeD: "
delete [] fHitMap;
delete fTDList;
- if (fAddress) fAddress->Delete();
if (fHits) fHits->Delete();
if (fPadHits) fPadHits->Delete();
}