/* $Id$ */
-// ------------------
+//-----------------------------------------------------------------------------
// Class AliMUON
// ------------------
// AliDetector class for MUON subsystem
// providing simulation data management
+//-----------------------------------------------------------------------------
#include "Riostream.h"
#include "AliLoader.h"
#include "AliRunDigitizer.h"
#include "AliMC.h"
-#include "AliRun.h"
+#include "AliRun.h"
+#include "AliRawDataHeaderSim.h"
#include "AliMUON.h"
#include "AliMUONChamberTrigger.h"
#include "AliMUONConstants.h"
#include "AliMUONHit.h"
-#include "AliMUONRawCluster.h"
-#include "AliMUONTransientDigit.h"
#include "AliMUONGeometry.h"
#include "AliMUONGeometryTransformer.h"
#include "AliMUONGeometryBuilder.h"
#include "AliMUONCommonGeometryBuilder.h"
#include "AliMUONVGeometryBuilder.h"
-#include "AliMUONGeometrySegmentation.h"
-#include "AliMUONDigitizerv2.h"
-#include "AliMUONSDigitizerv1.h"
#include "AliMUONRawWriter.h"
-#include "AliMUONSegmentation.h"
#include "AliLog.h"
#include "AliMUONSDigitizerV2.h"
#include "AliMUONSlatGeometryBuilder.h"
#include "AliMUONTriggerGeometryBuilder.h"
+#include "AliMUONDigitStoreV1.h"
+#include "AliMUONVTriggerStore.h"
+#include "AliMUONHitStoreV1.h"
+
// Defaults parameters for Z positions of chambers
// taken from values for "stations" in AliMUON::AliMUON
// const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
: AliDetector(),
fNCh(0),
fNTrackingCh(0),
- fMUONData(0),
fSplitLevel(0),
fChambers(0),
fGeometryBuilder(0),
- fSegmentation(0),
fAccCut(kFALSE),
fAccMin(0.),
fAccMax(0.),
fTriggerResponseV1(kFALSE),
fTriggerCoinc44(0),
fTriggerEffCells(0),
- fSDigitizerType(""),
- fDigitizerType(""),
+ fDigitizerWithNoise(1),
+ fIsTailEffect(kTRUE),
fRawWriter(0x0),
- fDigitMaker(0x0)
-
+ fDigitMaker(0x0),
+ fHitStore(0x0),
+ fDigitStoreConcreteClassName()
{
/// Default Constructor
}
//__________________________________________________________________
-AliMUON::AliMUON(const char *name, const char *title,
- const char* sDigitizerClassName,
- const char* digitizerClassName)
- : AliDetector(name,title),
+AliMUON::AliMUON(const char *name, const char* title)
+ : AliDetector(name, title),
fNCh(AliMUONConstants::NCh()),
fNTrackingCh(AliMUONConstants::NTrackingCh()),
- fMUONData(0),
fSplitLevel(0),
fChambers(0),
fGeometryBuilder(0),
- fSegmentation(0),
fAccCut(kFALSE),
fAccMin(0.),
fAccMax(0.),
fTriggerResponseV1(kFALSE),
fTriggerCoinc44(0),
fTriggerEffCells(0),
- fSDigitizerType(sDigitizerClassName),
- fDigitizerType(digitizerClassName),
+ fDigitizerWithNoise(1),
+ fIsTailEffect(kTRUE),
fRawWriter(0x0),
- fDigitMaker(new AliMUONDigitMaker(kFALSE))
+ fDigitMaker(new AliMUONDigitMaker),
+ fHitStore(0x0),
+ fDigitStoreConcreteClassName("AliMUONDigitStoreV2S")
{
/// Standard constructor
AliDebug(1,Form("ctor this=%p",this));
fIshunt = 0;
- SetMarkerColor(kRed);//
+ //PH SetMarkerColor(kRed);//
// Geometry builder
fGeometryBuilder = new AliMUONGeometryBuilder(this);
// Creating List of Chambers
Int_t ch;
fChambers = new TObjArray(AliMUONConstants::NCh());
-
+ fChambers->SetOwner(kTRUE);
+
// Loop over stations
for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
// Loop over 2 chambers in the station
/// Destructor
AliDebug(1,Form("dtor this=%p",this));
- fIshunt = 0;
-
- if (fChambers){
- fChambers->Delete();
- delete fChambers;
- }
-
- delete fMUONData;
+ delete fChambers;
delete fGeometryBuilder;
- delete fSegmentation;
delete fRawWriter;
delete fDigitMaker;
+ delete fHitStore;
}
//_____________________________________________________________________________
}
//__________________________________________________________________
-void AliMUON::SetTreeAddress()
+void
+AliMUON::MakeBranch(Option_t* opt)
{
-/// Set Hits tree address
-
- GetMUONData()->SetLoader(fLoader);
- // GetMUONData()->MakeBranch("D,S,RC");
- // GetMUONData()->SetTreeAddress("H,D,S,RC");
- GetMUONData()->SetTreeAddress("H");
- if (fHits != GetMUONData()->Hits()) {
+ /// Create branche(s) to hold MUON hits
+ AliDebug(1,"");
+
+ TString sopt(opt);
+ if ( sopt != "H" ) return;
+
+ if (!fHitStore)
+ {
+ fHitStore = new AliMUONHitStoreV1;
if ( gAlice->GetMCApp() )
- if ( gAlice->GetMCApp()->GetHitLists() ) {
- fHits = GetMUONData()->Hits();
- gAlice->GetMCApp()->AddHitList(fHits); // For purifyKine, only necessary when Hit list is created in AliMUONData
+ {
+ if ( gAlice->GetMCApp()->GetHitLists() )
+ {
+ // AliStack::PurifyKine needs to be able to loop on our hits
+ // to remap the track numbers.
+ gAlice->GetMCApp()->AddHitList(fHitStore->Collection());
}
+ }
}
- fHits = GetMUONData()->Hits(); // Added by Ivana to use the methods FisrtHit, NextHit of AliDetector
+
+ TTree* treeH = fLoader->TreeH();
+
+ if (!treeH)
+ {
+ AliFatal("No TreeH");
+ }
+
+ fHitStore->Connect(*treeH);
+}
+
+//__________________________________________________________________
+void
+AliMUON::SetTreeAddress()
+{
+ /// Set Hits tree address
+
+// if ( gAlice->GetMCApp() && fHitStore )
+// {
+// TList* l = gAlice->GetMCApp()->GetHitLists();
+// if ( l )
+// {
+// TObject* o = l->First();
+// if (o!=fHitStore->HitCollection())
+// {
+// AliError(Form("Something is strange hitcollection=%x",fHitStore->HitCollection()));
+// l->Print();
+// }
+// }
+// }
+}
+
+//_________________________________________________________________
+void
+AliMUON::ResetHits()
+{
+ /// Reset hits
+
+ AliDebug(1,"");
+ if (fHitStore) fHitStore->Clear();
}
//_________________________________________________________________
}
//____________________________________________________________________
-void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
+void AliMUON::SetResponseModel(Int_t id, const AliMUONResponse& response)
{
/// Set the response for chamber id
((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
//____________________________________________________________________
AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
{
-/// FIXME: the selection of the class should be done through a factory
-/// mechanism. (see also Hits2SDigits()).
+/// Return digitizer
- AliDebug(1, Form("Digitizer used : %s",fDigitizerType.Data()));
-
- if ( fDigitizerType == "digitizer:default" ) // NewDigitizerNewTrigger
- {
- return new AliMUONDigitizerV3(manager,kTRUE);
- }
- else if ( fDigitizerType == "digitizer:NewDigitizerWONoiseNewTrigger" )
- {
- return new AliMUONDigitizerV3(manager,kFALSE);
- }
- else
- {
- AliFatal(Form("Unknown digitizer type : %s",fDigitizerType.Data()));
- }
- return 0x0;
-}
-
-//_____________________________________________________________________
-TString
-AliMUON::SDigitizerType() const
-{
-/// Return digitizer type
-
- return fSDigitizerType;
+ return new AliMUONDigitizerV3(manager, fDigitizerWithNoise);
}
//_____________________________________________________________________
//_____________________________________________________________________
void AliMUON::Hits2SDigits()
{
-/// FIXME: the selection of the sdigitizer should be done through a
-/// factory mechanism.
+/// Perform Hits2Digits using SDigitizerV2
- AliDebug(1, Form("SDigitizer used : %s",fSDigitizerType.Data()));
-
- if ( fSDigitizerType == "sdigitizer:default" )
- {
- // Adaption of AliMUONSDigitizerv1 to be excuted by the AliSimulation framework
- AliRunLoader* runLoader = fLoader->GetRunLoader();
- AliRunDigitizer * manager = new AliRunDigitizer(1,1);
- manager->SetInputStream(0,runLoader->GetFileName(),AliConfig::GetDefaultEventFolderName());
- AliMUONDigitizer * dMUON = new AliMUONSDigitizerv1(manager);
- fLoader->LoadHits("READ");
- for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
- runLoader->GetEvent(iEvent);
- dMUON->Exec("");
- }
- fLoader->UnloadHits();
- }
- else if ( fSDigitizerType == "sdigitizer:AliMUONSDigitizerV2" )
- {
- TTask* sdigitizer = new AliMUONSDigitizerV2;
- sdigitizer->ExecuteTask();
- }
- else
- {
- AliFatal(Form("Unknown sdigitizer classname : %s",fSDigitizerType.Data()));
- }
-}
-
-//_____________________________________________________________________
-TString
-AliMUON::DigitizerType() const
-{
-/// Return digitizer type
-
- return fDigitizerType;
+ AliMUONSDigitizerV2 sdigitizer;
+ sdigitizer.ExecuteTask();
}
//_____________________________________________________________________
{
/// Convert digits of the current event to raw data
+ AliRawDataHeaderSim header;
+
if (!fRawWriter)
{
- fRawWriter = new AliMUONRawWriter(fMUONData);
+ fRawWriter = new AliMUONRawWriter;
+ AliDebug(1,Form("Creating %s",fRawWriter->ClassName()));
if (fTriggerScalerEvent == kTRUE)
{
fRawWriter->SetScalersNumbers();
}
}
- if (!fRawWriter->Digits2Raw())
+ fLoader->LoadDigits("READ");
+
+ TTree* treeD = fLoader->TreeD();
+
+ if (!treeD)
+ {
+ AliError("Could not get TreeD");
+ return;
+ }
+
+ AliMUONVTriggerStore* triggerStore = AliMUONVTriggerStore::Create(*treeD);
+ AliMUONVDigitStore* digitStore = AliMUONVDigitStore::Create(*treeD);
+
+ triggerStore->Connect(*treeD,kFALSE);
+ digitStore->Connect(*treeD,kFALSE);
+
+ treeD->GetEvent(0);
+
+ fRawWriter->SetHeader(header);
+ if (!fRawWriter->Digits2Raw(digitStore,triggerStore))
{
AliError("pb writting raw data");
}
+
+ delete triggerStore;
+ delete digitStore;
+
+ fLoader->UnloadDigits();
}
//_____________________________________________________________________
/// Convert raw data to SDigit
/// Only for tracking for the moment (ChF)
- //fLoader->LoadDigits("READ");
+ fLoader->LoadDigits("READ");
if (!fLoader->TreeS()) fLoader->MakeSDigitsContainer();
- fMUONData->MakeBranch("S");
- fMUONData->SetTreeAddress("S");
- fDigitMaker->Raw2Digits(rawReader);
- fMUONData->Fill("S");
+ TTree* treeS = fLoader->TreeS();
+
+ AliMUONVDigitStore* sDigitStore = new AliMUONDigitStoreV1;
+ sDigitStore->Connect(*treeS);
+
+ fDigitMaker->Raw2Digits(rawReader,sDigitStore,0x0);
fLoader->WriteSDigits("OVERWRITE");
- fMUONData->ResetSDigits();
+
fLoader->UnloadSDigits();
+ delete sDigitStore;
+
return kTRUE;
-
}
//_______________________________________________________________________
AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
GetName(),topfoldername));
fLoader = new AliLoader(GetName(),topfoldername);
- fMUONData = new AliMUONData(fLoader,GetName(),GetName());
- fMUONData->SetSplitLevel(fSplitLevel);
-
- fDigitMaker->SetMUONData(fMUONData);
return fLoader;
}
-//_______________________________________________________________________
-
-AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
-{
-/// Return rawcluster (icluster) for chamber ichamber and cathode icathod
-/// Obsolete ??
-
- TClonesArray *muonRawCluster = GetMUONData()->RawClusters(ichamber);
- ResetRawClusters();
- TTree *treeR = fLoader->TreeR();
- Int_t nent=(Int_t)treeR->GetEntries();
- treeR->GetEvent(nent-2+icathod-1);
- //treeR->GetEvent(icathod);
- //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
-
- AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
- //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
-
- return mRaw;
-}
//________________________________________________________________________
void
}
+//____________________________________________________________________
+Int_t AliMUON::GetDigitizerWithNoise() const
+{
+///
+/// Returns fDigitizerWithNoise
+///
+ return fDigitizerWithNoise;
+
+}
+
+//____________________________________________________________________
+Bool_t AliMUON::UsingFastTrackerDecoder() const
+{
+/// Checks to see if we are using the fast decoder for tracker DDL streams.
+
+ if ( ! fDigitMaker ) {
+ AliError("Digit maker is not instantiated.");
+ return kFALSE;
+ }
+
+ return fDigitMaker->UsingFastTrackerDecoder();
+}
+
+//____________________________________________________________________
+Bool_t AliMUON::UsingFastTriggerDecoder() const
+{
+/// Checks to see if we are using the fast decoder for trigger DDL streams.
+
+ if ( ! fDigitMaker ) {
+ AliError("Digit maker is not instantiated.");
+ return kFALSE;
+ }
+
+ return fDigitMaker->UsingFastTriggerDecoder();
+}
+
+//____________________________________________________________________
+void AliMUON::SetFastTrackerDecoder(Bool_t useFastDecoder)
+{
+/// Set fast raw data decoder
+
+ if ( ! fDigitMaker ) {
+ AliError("Digit maker is not instantiated.");
+ return;
+ }
+
+ fDigitMaker->SetFastTrackerDecoder(useFastDecoder);
+}
+
+//____________________________________________________________________
+void AliMUON::SetFastTriggerDecoder(Bool_t useFastDecoder)
+{
+/// Set fast raw data decoder
+
+ if ( ! fDigitMaker ) {
+ AliError("Digit maker is not instantiated.");
+ return;
+ }
+
+ fDigitMaker->SetFastTriggerDecoder(useFastDecoder);
+}
+