X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONClusterReconstructor.cxx;h=4a21ae34f41de01dc119b2ff4c12b3fb1655eb23;hb=ff549f4f8e24822c2c374234f50590e51f1fc63b;hp=9395478341cf92c10776717bb1093253ba4e6a63;hpb=e516b01dc9b050949d85a6e082e9213ee783c82c;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONClusterReconstructor.cxx b/MUON/AliMUONClusterReconstructor.cxx index 9395478341c..4a21ae34f41 100644 --- a/MUON/AliMUONClusterReconstructor.cxx +++ b/MUON/AliMUONClusterReconstructor.cxx @@ -15,12 +15,11 @@ /* $Id$ */ -//////////////////////////////////// -// +// ----------------------------------- +// Class AliMUONClusterReconstructor +// ---------------------------------- // MUON cluster reconstructor for MUON -// -// Should implement a virtual class ClusterFinder to chose between VS and AZ method -//////////////////////////////////// +// Should implement a virtual class ClusterFinder to choose between VS and AZ method #include "AliMUONClusterReconstructor.h" #include "AliRun.h" // for gAlice @@ -34,88 +33,42 @@ #include "AliMUONClusterFinderVS.h" #include "AliMUONClusterInput.h" #include "AliMUONRawCluster.h" -#include "AliRawReader.h" // for raw data - - -const Int_t AliMUONClusterReconstructor::fgkDefaultPrintLevel = 0; +#include "AliLog.h" ClassImp(AliMUONClusterReconstructor) // Class implementation in ROOT context - -//__________________________________________________________________________ -AliMUONClusterReconstructor::AliMUONClusterReconstructor(AliLoader* loader) - : TObject() -{ - // Standard Constructor - fDebug = 0; - fNCh = 0; - fNTrackingCh = 0; - fChambers = 0; - fMUONData = 0; - fChambers = new TObjArray(AliMUONConstants::NCh()); - - fPrintLevel = fgkDefaultPrintLevel; - - // initialize loader's - fLoader = loader; - - // initialize container - fMUONData = new AliMUONData(fLoader,"MUON","MUON"); - - // Loading AliRun master - AliRunLoader* runloader = fLoader->GetRunLoader(); - if (runloader->GetAliRun() == 0x0) runloader->LoadgAlice(); - gAlice = runloader->GetAliRun(); - - // getting MUON - fMUON = (AliMUON*) gAlice->GetDetector("MUON"); -} - //__________________________________________________________________________ -AliMUONClusterReconstructor::AliMUONClusterReconstructor() - : TObject(), - fNCh(0), - fNTrackingCh(0), - fMUONData(0), - fMUON(0), - fChambers(0), - fPrintLevel(fgkDefaultPrintLevel), - fDebug(0), - fLoader(0) -{ - // Default Constructor -} - -//____________________________________________________________________ -void AliMUONClusterReconstructor::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst) +AliMUONClusterReconstructor::AliMUONClusterReconstructor(AliMUONData* data) +: TObject(), + fMUONData(data), + fRecModel(new AliMUONClusterFinderVS()), + fDigitsCath0(new TClonesArray("AliMUONDigit",1000)), + fDigitsCath1(new TClonesArray("AliMUONDigit",1000)) { - // take infos chambers from AliMUON - AliMUONChamber* pCh = 0; - pCh = &(fMUON->Chamber(id)); - - fChambers->AddAt(pCh, id); +/// Standard Constructor - // Set ClusterFinder for chamber id - ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst); + fDigitsCath0->SetOwner(kTRUE); + fDigitsCath1->SetOwner(kTRUE); } + //_______________________________________________________________________ AliMUONClusterReconstructor::AliMUONClusterReconstructor (const AliMUONClusterReconstructor& rhs) : TObject(rhs) { -// Protected copy constructor +/// Protected copy constructor - Fatal("AliMUONClusterReconstructor", "Not implemented."); + AliFatal("Not implemented."); } //_______________________________________________________________________ AliMUONClusterReconstructor & AliMUONClusterReconstructor::operator=(const AliMUONClusterReconstructor& rhs) { -// Protected assignement operator +/// Protected assignement operator if (this == &rhs) return *this; - Fatal("operator=", "Not implemented."); + AliFatal("Not implemented."); return *this; } @@ -123,87 +76,128 @@ AliMUONClusterReconstructor::operator=(const AliMUONClusterReconstructor& rhs) //__________________________________________________________________________ AliMUONClusterReconstructor::~AliMUONClusterReconstructor(void) { - if (fChambers){ - fChambers->Clear(); // Sets pointers to 0 sinche it is not the owner - delete fChambers; - } - if (fMUONData) - delete fMUONData; - - return; +/// Destructor + + delete fRecModel; + delete fDigitsCath0; + delete fDigitsCath1; } -//____________________________________________________________________ -void AliMUONClusterReconstructor::Digits2Clusters() + +//______________________________________________________________________________ +void +AliMUONClusterReconstructor::ClusterizeOneDE(Int_t detElemId) { -// -// Perform cluster finding -// - TClonesArray *dig1, *dig2; - Int_t ndig, k; - dig1 = new TClonesArray("AliMUONDigit",1000); - dig2 = new TClonesArray("AliMUONDigit",1000); - AliMUONDigit *digit; -// Loop on chambers and on cathode planes -// -// fMUONData->ResetRawClusters(); - TClonesArray * muonDigits; - - for (Int_t ich = 0; ich < 10; ich++) { - AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich); - AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel(); - //AliMUONClusterFinderAZ* rec = (AliMUONClusterFinderAZ*)iChamber->ReconstructionModel(); - - fMUONData->ResetDigits(); - fMUONData->GetCathode(0); - //TClonesArray * - muonDigits = fMUONData->Digits(ich); - ndig=muonDigits->GetEntriesFast(); - if(fDebug) - printf("1 Found %d digits in %p chamber %d\n", ndig, (void*)muonDigits,ich); - TClonesArray &lhits1 = *dig1; - Int_t n = 0; - for (k = 0; k < ndig; k++) { - digit = (AliMUONDigit*) muonDigits->UncheckedAt(k); - if (rec->TestTrack(digit->Track(0))) - new(lhits1[n++]) AliMUONDigit(*digit); - } - fMUONData->ResetDigits(); - fMUONData->GetCathode(1); - muonDigits = fMUONData->Digits(ich); - ndig=muonDigits->GetEntriesFast(); - if(fDebug) - printf("\n 2 Found %d digits in %p %d", ndig, (void*)muonDigits, ich); - TClonesArray &lhits2 = *dig2; - n=0; - - for (k=0; kUncheckedAt(k); - if (rec->TestTrack(digit->Track(0))) - new(lhits2[n++]) AliMUONDigit(*digit); - } - - if (rec) { - AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2); - rec->FindRawClusters(); - } - // copy into the container - TClonesArray* tmp = rec->GetRawClusters(); - for (Int_t id = 0; id < tmp->GetEntriesFast(); id++) { - AliMUONRawCluster* pClus = (AliMUONRawCluster*) tmp->At(id); - fMUONData->AddRawCluster(ich, *pClus); - } - dig1->Delete(); - dig2->Delete(); - } // for ich - delete dig1; - delete dig2; +/// Clusterize one detection element, and let fMUONData know about +/// the results. + + if ( fDigitsCath0->GetEntriesFast() || fDigitsCath1->GetEntriesFast() ) + { + Int_t iChamber = detElemId/100 - 1; + AliMUONClusterInput::Instance()->SetDigits(iChamber, detElemId, + fDigitsCath0,fDigitsCath1); + AliDebug(3,Form("ClusterizeOneDE iChamber=%d DE=%d",iChamber,detElemId)); + StdoutToAliDebug(3,cout << "DigitsCath0=" << endl; + fDigitsCath0->Print(); + cout << "DigitsCath1=" << endl; + fDigitsCath1->Print();); + fRecModel->FindRawClusters(); + + // copy results into the output container + TClonesArray* tmp = fRecModel->GetRawClusters(); + for (Int_t id = 0; id < tmp->GetEntriesFast(); ++id) + { + AliMUONRawCluster* pClus = (AliMUONRawCluster*) tmp->At(id); + fMUONData->AddRawCluster(iChamber, *pClus); + } + + // Reset the arrays + fDigitsCath0->Clear("C"); + fDigitsCath1->Clear("C"); + } } //____________________________________________________________________ -void AliMUONClusterReconstructor::Digits2Clusters(AliRawReader* /*rawReader*/) +void AliMUONClusterReconstructor::Digits2Clusters(Int_t chBeg) { +/// Clusterize all the tracking chamber digits. +/// +/// For each chamber, we loop *once* on that chamber digits, and store them +/// in 2 temporary arrays (one pair of arrays per detection element, +/// one array per cathode). Once a pair of arrays is full (i.e. all the digits +/// of that detection element have been stored), we clusterize this DE, and +/// move to the next one. + + if (!fRecModel) + { + AliWarning("No reco model defined. Nothing to do..."); + return; + } + + Int_t iChamber(-1); + Int_t currentDE(-1); + + // Loop on chambers + for ( iChamber = chBeg; iChamber < AliMUONConstants::NTrackingCh(); ++iChamber ) + { + TClonesArray* muonDigits = fMUONData->Digits(iChamber); + + Int_t ndig = muonDigits->GetEntriesFast(); + if (!ndig) continue; + + muonDigits->Sort(); // the sort *must* be per DE (at least), otherwise + // the following logic with currentDE will fail. + + currentDE = -1; // initialize the DE counter (that is used to track + // when we change of DE in the following loop over + // all digits) to an invalid value. + + for ( Int_t k = 0; k < ndig; ++k ) + { + AliMUONDigit* digit = (AliMUONDigit*) muonDigits->UncheckedAt(k); + if ( ! digit->Signal() > 0 ) continue; // skip void digits. + + if ( digit->DetElemId() != currentDE ) + { + AliDebug(3,Form("Switching DE from %d to %d",currentDE,digit->DetElemId())); + // we get to a new DE, so clusterize the previous one before + // moving on. + ClusterizeOneDE(currentDE); + currentDE = digit->DetElemId(); + } + + // Add the digit to the array with the right cathode number. + if (digit->Cathode() == 0) + { + new((*fDigitsCath0)[fDigitsCath0->GetLast()+1]) AliMUONDigit(*digit); + } + else + { + new((*fDigitsCath1)[fDigitsCath1->GetLast()+1]) AliMUONDigit(*digit); + } + } // end of loop on chamber digits + + // As the above logic is based on detecting a change in DE number, + // the last DE of each chamber has not been clusterized, so we do + // it here. + ClusterizeOneDE(currentDE); + } // end of loop over chambers +} + +//_______________________________________________________________________ +void +AliMUONClusterReconstructor::SetRecoModel(AliMUONClusterFinderVS* rec) +{ +/// Set reconstruction model + + delete fRecModel; + fRecModel = rec; +} -// Perform cluster finding form raw data +//_______________________________________________________________________ +void AliMUONClusterReconstructor::Trigger2Trigger() +{ +/// Copy trigger from TreeD to TreeR - Fatal("Digits2Clusters","clusterization not implemented for raw data input"); + fMUONData->SetTreeAddress("GLT"); + fMUONData->GetTriggerD(); }