* provided "as is" without express or implied warranty. *
**************************************************************************/
-/*
-$Log$
-Revision 1.18 2001/12/19 14:46:26 morsch
-Add possibility to disable StepManager() for each module separately.
-
-Revision 1.17 2001/08/29 14:28:33 morsch
-Use visibility flags -1 and 3 instead of 0 and 1.
-
-Revision 1.16 2001/05/16 14:57:22 alibrary
-New files for folders and Stack
-
-Revision 1.15 2001/03/20 06:36:28 alibrary
-100 parameters now allowed for geant shapes
-
-Revision 1.14 2001/01/26 19:58:48 hristov
-Major upgrade of AliRoot code
-
-Revision 1.13 2000/11/30 07:12:49 alibrary
-Introducing new Rndm and QA classes
-
-Revision 1.12 2000/10/02 21:28:14 fca
-Removal of useless dependecies via forward declarations
-
-Revision 1.11 2000/07/12 08:56:25 fca
-Coding convention correction and warning removal
-
-Revision 1.10 2000/07/11 18:24:59 fca
-Coding convention corrections + few minor bug fixes
-
-Revision 1.9 2000/05/16 08:45:08 fca
-Correct dtor, thanks to J.Belikov
-
-Revision 1.8 2000/02/23 16:25:22 fca
-AliVMC and AliGeant3 classes introduced
-ReadEuclid moved from AliRun to AliModule
-
-Revision 1.7 1999/09/29 09:24:29 fca
-Introduction of the Copyright and cvs Log
-
-*/
+/* $Id$ */
///////////////////////////////////////////////////////////////////////////////
// //
// //
///////////////////////////////////////////////////////////////////////////////
#include <TNode.h>
-#include "TSystem.h"
+#include <TObjArray.h>
+#include <TClonesArray.h>
+#include <TTree.h>
+#include <TSystem.h>
+#include <TDirectory.h>
#include "AliModule.h"
#include "AliRun.h"
#include "AliMagF.h"
-#include "AliMC.h"
#include "AliConfig.h"
+#include "AliTrackReference.h"
ClassImp(AliModule)
fHistograms(0),
fNodes(0),
fDebug(0),
- fEnable(1)
+ fEnable(1),
+ fTrackReferences(0),
+ fMaxIterTrackRef(0),
+ fCurrentIterTrackRef(0)
{
//
// Default constructor for the AliModule class
fHistograms(new TList()),
fNodes(new TList()),
fDebug(0),
- fEnable(1)
+ fEnable(1),
+ fTrackReferences(new TClonesArray("AliTrackReference", 100)),
+ fMaxIterTrackRef(0),
+ fCurrentIterTrackRef(0)
{
//
// Normal constructor invoked by all Modules.
fHistograms(0),
fNodes(0),
fDebug(0),
- fEnable(0)
+ fEnable(0),
+ fTrackReferences(0),
+ fMaxIterTrackRef(0),
+ fCurrentIterTrackRef(0)
{
//
// Copy constructor
// Destructor
//
+ // Remove this Module from the list of Modules
+ if (gAlice) {
+ TObjArray * modules = gAlice->Modules();
+ if (modules) modules->Remove(this);
+ }
// Delete ROOT geometry
if(fNodes) {
fNodes->Clear();
delete fNodes;
+ fNodes = 0;
+ }
+ // Delete histograms
+ if(fHistograms) {
+ fHistograms->Clear();
+ delete fHistograms;
+ fHistograms = 0;
+ }
+ // Delete track references
+ if (fTrackReferences) {
+ fTrackReferences->Delete();
+ delete fTrackReferences;
+ fTrackReferences = 0;
}
- //
// Delete TArray objects
delete fIdtmed;
delete fIdmate;
}
//_______________________________________________________________________
-Int_t AliModule::DistancetoPrimitive(Int_t, Int_t)
+Int_t AliModule::DistancetoPrimitive(Int_t, Int_t) const
{
//
// Return distance from mouse pointer to object
//_______________________________________________________________________
void AliModule::AliGetMaterial(Int_t imat, char* name, Float_t &a,
Float_t &z, Float_t &dens, Float_t &radl,
- Float_t &absl)
+ Float_t &absl) const
{
//
// Store the parameters for a material
L20:
Warning("ReadEuclidMedia","reading error or premature end of file\n");
}
+
+//_______________________________________________________________________
+void AliModule::RemapTrackReferencesIDs(Int_t *map)
+{
+ //
+ // Remapping track reference
+ // Called at finish primary
+ //
+ if (!fTrackReferences) return;
+ for (Int_t i=0;i<fTrackReferences->GetEntries();i++){
+ AliTrackReference * ref = dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(i));
+ if (ref) {
+ Int_t newID = map[ref->GetTrack()];
+ if (newID>=0) ref->SetTrack(newID);
+ else ref->SetTrack(-1);
+
+ }
+ }
+}
+
+
+//_______________________________________________________________________
+AliTrackReference* AliModule::FirstTrackReference(Int_t track)
+{
+ //
+ // Initialise the hit iterator
+ // Return the address of the first hit for track
+ // If track>=0 the track is read from disk
+ // while if track<0 the first hit of the current
+ // track is returned
+ //
+ if(track>=0) {
+ gAlice->ResetTrackReferences();
+ gAlice->TreeTR()->GetEvent(track);
+ }
+ //
+ fMaxIterTrackRef = fTrackReferences->GetEntriesFast();
+ fCurrentIterTrackRef = 0;
+ if(fMaxIterTrackRef) return dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(0));
+ else return 0;
+}
+
+//_______________________________________________________________________
+AliTrackReference* AliModule::NextTrackReference()
+{
+ //
+ // Return the next hit for the current track
+ //
+ if(fMaxIterTrackRef) {
+ if(++fCurrentIterTrackRef<fMaxIterTrackRef)
+ return dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(fCurrentIterTrackRef));
+ else
+ return 0;
+ } else {
+ printf("* AliDetector::NextTrackReference * TrackReference Iterator called without calling FistTrackReference before\n");
+ return 0;
+ }
+}
+
+
+//_______________________________________________________________________
+void AliModule::ResetTrackReferences()
+{
+ //
+ // Reset number of hits and the hits array
+ //
+ fMaxIterTrackRef = 0;
+ if (fTrackReferences) fTrackReferences->Clear();
+}
+
+void AliModule::SetTreeAddress()
+{
+ //
+ // Set branch address for the Hits and Digits Trees
+ //
+ TBranch *branch;
+ char branchname[20];
+ sprintf(branchname,"%s",GetName());
+ // Branch address for track reference tree
+ TTree *treeTR = gAlice->TreeTR();
+ if (treeTR && fTrackReferences) {
+ branch = treeTR->GetBranch(branchname);
+ if (branch) branch->SetAddress(&fTrackReferences);
+ }
+}
+
+void AliModule::AddTrackReference(Int_t label){
+ //
+ // add a trackrefernce to the list
+ if (!fTrackReferences) {
+ cerr<<"Container trackrefernce not active\n";
+ return;
+ }
+ Int_t nref = fTrackReferences->GetEntriesFast();
+ TClonesArray &lref = *fTrackReferences;
+ new(lref[nref]) AliTrackReference(label);
+}
+
+
+void AliModule::MakeBranchTR(Option_t *option, const char *file)
+{
+ //
+ // Makes branch in treeTR
+ //
+ char name[10];
+ sprintf(name,"%s",GetName());
+
+ if (GetDebug()>1)
+ printf("* MakeBranch * Making Branch %s \n",name);
+
+ TDirectory *cwd = gDirectory;
+ TBranch *branch = 0;
+ TTree* tree = gAlice->TreeTR();
+ if (tree) {
+ branch = tree->Branch(name, &fTrackReferences, 1600);
+ if (file) {
+ char * outFile = new char[strlen(gAlice->GetBaseFile())+strlen(file)+2];
+ sprintf(outFile,"%s/%s",gAlice->GetBaseFile(),file);
+ branch->SetFile(outFile);
+ TIter next( branch->GetListOfBranches());
+ while ((branch=dynamic_cast<TBranch*>(next()))) {
+ branch->SetFile(outFile);
+ }
+ delete outFile;
+
+ cwd->cd();
+
+ if (GetDebug()>1)
+ printf("* MakeBranch * Diverting Branch %s to file %s\n",name,file);
+ }
+ }
+}