#include "AliMUONHitMapA1.h"
#include "AliMUON.h"
#include "AliMUONLoader.h"
-#include "AliMUONChamber.h"
#include "AliMUONConstants.h"
-#include "AliMUONDigitizer.h"
#include "AliMUONTransientDigit.h"
-#include "AliMUONHitMapA1.h"
#include "AliMUONTriggerDecision.h"
#include "AliLog.h"
fMUON = NULL;
fMUONData = NULL;
fTrigDec = NULL;
-};
+}
//___________________________________________
AliMUONDigitizer::AliMUONDigitizer(AliRunDigitizer* manager) :
fMUON = NULL;
fMUONData = NULL;
fTrigDec = NULL;
-};
+}
//___________________________________________
AliMUONDigitizer::AliMUONDigitizer(const AliMUONDigitizer& rhs)
return *this;
}
-
+
+//------------------------------------------------------------------------
+Int_t AliMUONDigitizer::GetSegmentation()
+{
+ if (!fMUON->WhichSegmentation()) {
+ AliFatal("No Segmentation Type defined.");
+ return kFALSE;
+ } else
+ return fMUON->WhichSegmentation();
+
+}
+
//------------------------------------------------------------------------
Bool_t AliMUONDigitizer::Init()
{
{
AliWarning("No inputs set, nothing to do.");
return;
- };
+ }
if (!FetchLoaders(fManager->GetInputFolderName(0), fRunLoader, fGime) ) return;
if (! FetchGlobalPointers(fRunLoader) ) return;
if (! InitInputData(fGime) ) continue;
GenerateTransientDigits();
CleanupInputData(fGime);
- };
+ }
Bool_t ok = FetchLoaders(fManager->GetOutputFolderName(), fRunLoader, fGime);
if (ok) ok = InitOutputData(fGime);
CleanupArrays();
CleanupTriggerArrays();
-};
+}
//--------------------------------------------------------------------------
void AliMUONDigitizer::AddOrUpdateTransientDigit(AliMUONTransientDigit* mTD)
}
else
AddTransientDigit(mTD);
-};
+}
//------------------------------------------------------------------------
void AliMUONDigitizer::UpdateTransientDigit(AliMUONTransientDigit* mTD)
ntracks));
AliDebug(1,Form( "Reseting the number of tracks to be %d.", kMAXTRACKS));
ntracks = kMAXTRACKS;
- };
+ }
for (Int_t i = 0; i < ntracks; i++)
{
pdigit->UpdateTrackList( mTD->GetTrack(i), mTD->GetCharge(i) );
- };
-};
+ }
+}
//------------------------------------------------------------------------
void AliMUONDigitizer::AddTransientDigit(AliMUONTransientDigit* mTD)
fTDList->AddAtAndExpand(mTD, fTDCounter);
fHitMap[iNchCpl]->SetHit( mTD->PadX(), mTD->PadY(), fTDCounter);
fTDCounter++;
-};
+}
//------------------------------------------------------------------------
Bool_t AliMUONDigitizer::ExistTransientDigit(AliMUONTransientDigit* mTD)
// Choosing the maping of the cathode plane of the chamber:
Int_t iNchCpl= mTD->Chamber() + (mTD->Cathode()-1) * AliMUONConstants::NCh();
return( fHitMap[iNchCpl]->TestHit(mTD->PadX(), mTD->PadY()) );
-};
+}
//-----------------------------------------------------------------------
void AliMUONDigitizer::CreateDigits()
// Loops over the fTDList for each cathode, gets the correct signal for the
// digit and adds the new digit to the output stream.
- AliDebug(2, "Creating digits...");
- for (Int_t icat = 0; icat < 2; icat++)
- {
- //
- // Filling Digit List
- Int_t nentries = fTDList->GetEntriesFast();
- for (Int_t nent = 0; nent < nentries; nent++)
- {
- AliMUONTransientDigit* td = (AliMUONTransientDigit*)fTDList->At(nent);
- if (td == NULL) continue;
+ fTDList->Sort(); // sort by idDE
+ AliDebug(2, "Creating digits...");
+ for (Int_t icat = 0; icat < 2; icat++) {
+
+ //
+ // Filling Digit List
+ Int_t nentries = fTDList->GetEntriesFast();
+ for (Int_t nent = 0; nent < nentries; nent++) {
+
+ AliMUONTransientDigit* td = (AliMUONTransientDigit*)fTDList->At(nent);
+ if (td == NULL) continue;
- // Must be the same cathode, otherwise we will fill a mixture
- // of digits from both cathodes.
- if (icat != td->Cathode() - 1) continue;
+ // Must be the same cathode, otherwise we will fill a mixture
+ // of digits from both cathodes.
+ if (icat != td->Cathode() - 1) continue;
- AliDebug(3,Form( "Creating digit from transient digit 0x%X", (void*)td));
+ AliDebug(3,Form( "Creating digit from transient digit 0x%X", (void*)td));
- Int_t q = GetSignalFrom(td);
- if (q > 0) AddDigit(td, q);
- };
- FillOutputData();
- };
-};
+ Int_t q = GetSignalFrom(td);
+ if (q > 0) AddDigit(td, q);
+ }
+ FillOutputData();
+ }
+}
//------------------------------------------------------------------------
void AliMUONDigitizer::AddDigit(AliMUONTransientDigit* td, Int_t responseCharge)
Int_t tracks[kMAXTRACKS];
Int_t charges[kMAXTRACKS];
- Int_t digits[6];
+ Int_t digits[7];
digits[0] = td->PadX();
digits[1] = td->PadY();
digits[3] = responseCharge;
digits[4] = td->Physics();
digits[5] = td->Hit();
-
+ if (GetSegmentation() == 1)
+ digits[6] = 0;
+ else
+ digits[6] = td->DetElemId();
+
Int_t nptracks = td->GetNTracks();
- if (nptracks > kMAXTRACKS)
- {
- AliDebug(1, Form(
- "TransientDigit returned the number of tracks to be %d, which is bigger than kMAXTRACKS.",
- nptracks));
- AliDebug(1, Form("Reseting the number of tracks to be %d.", kMAXTRACKS));
- nptracks = kMAXTRACKS;
- };
+ if (nptracks > kMAXTRACKS) {
+
+ AliDebug(1, Form(
+ "TransientDigit returned the number of tracks to be %d, which is bigger than kMAXTRACKS.",
+ nptracks));
+ AliDebug(1, Form("Reseting the number of tracks to be %d.", kMAXTRACKS));
+ nptracks = kMAXTRACKS;
+ }
- for (Int_t i = 0; i < nptracks; i++)
- {
- tracks[i] = td->GetTrack(i);
- charges[i] = td->GetCharge(i);
- };
+ for (Int_t i = 0; i < nptracks; i++) {
+
+ tracks[i] = td->GetTrack(i);
+ charges[i] = td->GetCharge(i);
+ }
// Sort list of tracks according to charge
SortTracks(tracks,charges,nptracks);
- if (nptracks < kMAXTRACKS )
- {
- for (Int_t i = nptracks; i < kMAXTRACKS; i++)
- {
- tracks[i] = -1;
- charges[i] = 0;
- };
- };
+ if (nptracks < kMAXTRACKS ) {
+
+ for (Int_t i = nptracks; i < kMAXTRACKS; i++) {
+ tracks[i] = -1;
+ charges[i] = 0;
+ }
+ }
AliDebug(4,Form( "Adding digit with charge %d.", responseCharge));
OnWriteTransientDigit(td);
AddDigit(td->Chamber(), tracks, charges, digits);
AddDigitTrigger(td->Chamber(), tracks, charges, digits);
-};
+}
//------------------------------------------------------------------------
void AliMUONDigitizer::OnCreateTransientDigit(AliMUONTransientDigit* /*digit*/, TObject* /*source_object*/)
//
// This is derived by Digitisers that want to trace which digits were made from
// which hits.
-};
+}
//------------------------------------------------------------------------
void AliMUONDigitizer::OnWriteTransientDigit(AliMUONTransientDigit* /*digit*/)
//
// This is derived by Digitisers that want to trace which digits were made from
// which hits.
-};
+}
//------------------------------------------------------------------------
Bool_t AliMUONDigitizer::FetchLoaders(const char* foldername, AliRunLoader*& runloader, AliMUONLoader*& muonloader)
}
return kTRUE;
-};
+}
//------------------------------------------------------------------------
Bool_t AliMUONDigitizer::FetchGlobalPointers(AliRunLoader* runloader)
{
AliError(Form("Could not find the AliRun object in runloader 0x%X.", (void*)runloader));
return kFALSE;
- };
+ }
fMUON = (AliMUON*) gAlice->GetDetector("MUON");
if (fMUON == NULL)
{
AliError(Form("Could not find the MUON module in runloader 0x%X.", (void*)runloader));
return kFALSE;
- };
+ }
AliMUONLoader *muonloader = (AliMUONLoader*) runloader->GetLoader("MUONLoader");
if (muonloader == NULL)
{
AliError(Form("Could not find AliMUONData object in runloader 0x%X.", (void*)runloader));
return kFALSE;
- };
+ }
return kTRUE;
}
{
AliInfo("Called with option \"debug\".");
SetDebug(99);
- };
-};
+ }
+}
//------------------------------------------------------------------------
void AliMUONDigitizer::InitArrays()
//
// Note: the fTDList and fHitMap arrays must be NULL before calling this method.
- AliDebug(2, "Initialising internal arrays.");
- AliDebug(4, "Creating transient digits list.");
- fTDList = new TObjArray;
+ AliDebug(2, "Initialising internal arrays.");
+ AliDebug(4, "Creating transient digits list.");
+ fTDList = new TObjArray;
- // Array of pointer of the AliMUONHitMapA1:
- // two HitMaps per chamber, or one HitMap per cahtode plane
- fHitMap = new AliMUONHitMapA1* [2*AliMUONConstants::NCh()];
-
- // Loop over chambers for the definition AliMUONHitMap
- for (Int_t i = 0; i < AliMUONConstants::NCh(); i++)
- {
- AliDebug(4,Form( "Creating hit map for chamber %d, cathode 1.", i+1));
- AliMUONChamber* chamber = &(fMUON->Chamber(i));
- AliSegmentation* c1Segmentation = chamber->SegmentationModel(1); // Cathode plane 1
- fHitMap[i] = new AliMUONHitMapA1(c1Segmentation, fTDList);
- AliDebug(4,Form( "Creating hit map for chamber %d, cathode 2.", i+1));
- AliSegmentation* c2Segmentation = chamber->SegmentationModel(2); // Cathode plane 2
- fHitMap[i+AliMUONConstants::NCh()] = new AliMUONHitMapA1(c2Segmentation, fTDList);
- };
-};
-
+ // Array of pointer of the AliMUONHitMapA1:
+ // two HitMaps per chamber, or one HitMap per cahtode plane
+ fHitMap = new AliMUONHitMapA1* [2*AliMUONConstants::NCh()];
+
+ if (fMUON->WhichSegmentation() == 1) {
+ // Loop over chambers for the definition AliMUONHitMap
+ for (Int_t i = 0; i < AliMUONConstants::NCh(); i++) {
+
+ AliDebug(4,Form( "Creating hit map for chamber %d, cathode 1.", i+1));
+ AliMUONChamber* chamber = &(fMUON->Chamber(i));
+ AliSegmentation* c1Segmentation = chamber->SegmentationModel(1); // Cathode plane 1
+ fHitMap[i] = new AliMUONHitMapA1(c1Segmentation, fTDList);
+ AliDebug(4,Form( "Creating hit map for chamber %d, cathode 2.", i+1));
+ AliSegmentation* c2Segmentation = chamber->SegmentationModel(2); // Cathode plane 2
+ fHitMap[i+AliMUONConstants::NCh()] = new AliMUONHitMapA1(c2Segmentation, fTDList);
+ }
+
+ } else {
+ for (Int_t i = 0; i < AliMUONConstants::NCh(); i++) {
+
+ Int_t idDE = 100*(i+1);// central DE = max # of pads ?
+ if (i == 4 || i == 5) //St3
+ idDE += 4;
+
+ if (i > 5)
+ idDE += 5;// DE for max # of pads in St45 and Trigger Station
+
+ AliDebug(4,Form( "Creating hit map for chamber %d, cathode 1.", i+1));
+ AliMUONChamber* chamber = &(fMUON->Chamber(i));
+ AliMUONGeometrySegmentation* c1Segmentation = chamber->SegmentationModel2(1); // Cathode plane 1
+ fHitMap[i] = new AliMUONHitMapA1(idDE,c1Segmentation, fTDList);
+ AliDebug(4,Form( "Creating hit map for chamber %d, cathode 2.", i+1));
+ AliMUONGeometrySegmentation* c2Segmentation = chamber->SegmentationModel2(2); // Cathode plane 2
+ fHitMap[i+AliMUONConstants::NCh()] = new AliMUONHitMapA1(idDE,c2Segmentation, fTDList);
+ }
+ }
+}
//------------------------------------------------------------------------
void AliMUONDigitizer::CleanupArrays()
{
AliDebug(4,Form( "Deleting hit map for chamber %d, cathode %d.",
i%AliMUONConstants::NCh()+1, i/AliMUONConstants::NCh()+1));
delete fHitMap[i];
- };
+ }
delete [] fHitMap;
fHitMap = NULL;
delete fTDList;
fTDList = NULL;
-};
+}
//------------------------------------------------------------------------
void AliMUONDigitizer::SortTracks(Int_t *tracks, Int_t *charges, Int_t ntr) const
// Only the 3 most significant tracks are actually sorted
//
- if (ntr <= 1) return;
+ if (ntr <= 1) return;
- //
- // Loop over signals, only 3 times
- //
+ //
+ // Loop over signals, only 3 times
+ //
- Int_t qmax;
- Int_t jmax;
- Int_t idx[3] = {-2,-2,-2};
- Int_t jch[3] = {-2,-2,-2};
- Int_t jtr[3] = {-2,-2,-2};
- Int_t i, j, imax;
+ Int_t qmax;
+ Int_t jmax;
+ Int_t idx[3] = {-2,-2,-2};
+ Int_t jch[3] = {-2,-2,-2};
+ Int_t jtr[3] = {-2,-2,-2};
+ Int_t i, j, imax;
- if (ntr < 3) imax = ntr;
- else imax=3;
+ if (ntr < 3) imax = ntr;
+ else imax=3;
- for(i = 0; i < imax; i++)
- {
- qmax=0;
- jmax=0;
-
- for(j = 0; j < ntr; j++)
- {
- if ( (i == 1 && j == idx[i-1]) ||
- (i == 2 && (j == idx[i-1] || j == idx[i-2]))
- )
- continue;
-
- if(charges[j] > qmax)
- {
- qmax = charges[j];
- jmax = j;
- }
- }
-
- if(qmax > 0)
- {
- idx[i] = jmax;
- jch[i] = charges[jmax];
- jtr[i] = tracks[jmax];
- }
-
- }
-
- for(i = 0; i < 3; i++)
- {
- if (jtr[i] == -2)
- {
- charges[i] = 0;
- tracks[i] = 0;
- }
- else
- {
- charges[i] = jch[i];
- tracks[i] = jtr[i];
- }
- }
-};
+ for(i = 0; i < imax; i++)
+ {
+ qmax=0;
+ jmax=0;
+
+ for(j = 0; j < ntr; j++)
+ {
+ if ( (i == 1 && j == idx[i-1]) ||
+ (i == 2 && (j == idx[i-1] || j == idx[i-2]))
+ )
+ continue;
+
+ if(charges[j] > qmax)
+ {
+ qmax = charges[j];
+ jmax = j;
+ }
+ }
+
+ if(qmax > 0)
+ {
+ idx[i] = jmax;
+ jch[i] = charges[jmax];
+ jtr[i] = tracks[jmax];
+ }
+
+ }
+
+ for(i = 0; i < 3; i++)
+ {
+ if (jtr[i] == -2)
+ {
+ charges[i] = 0;
+ tracks[i] = 0;
+ }
+ else
+ {
+ charges[i] = jch[i];
+ tracks[i] = jtr[i];
+ }
+ }
+}