X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STEER%2FAliModule.cxx;h=ed3c6575905daa5a44908cd2662f7e214f39b72d;hb=54d34aac48bb923502ca39356d982e5f84398da5;hp=7c5f26d87d3cebc6c68353977fd6822989fc8649;hpb=02ca27620516082f3519b935ffa21cafdaed5fc3;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliModule.cxx b/STEER/AliModule.cxx index 7c5f26d87d3..ed3c6575905 100644 --- a/STEER/AliModule.cxx +++ b/STEER/AliModule.cxx @@ -1,3 +1,20 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + /////////////////////////////////////////////////////////////////////////////// // // // Base class for ALICE modules. Both sensitive modules (Modules) and // @@ -15,130 +32,147 @@ //End_Html // // /////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "AliLog.h" +#include "AliConfig.h" +#include "AliLoader.h" +#include "AliMagF.h" #include "AliModule.h" #include "AliRun.h" -#include "AliHit.h" -#include "AliPoints.h" -#include -#include -#include +#include "AliTrackReference.h" +#include "AliMC.h" +#include "AliSimulation.h" +#include "AliRawDataHeader.h" + +#include "AliDAQ.h" ClassImp(AliModule) -//_____________________________________________________________________________ -AliModule::AliModule() +Float_t AliModule::fgDensityFactor = 1.0; + +//_______________________________________________________________________ +AliModule::AliModule(): + fIdtmed(0), + fIdmate(0), + fLoMedium(0), + fHiMedium(0), + fActive(0), + fEnable(1), + fMaxIterTrackRef(0), + fCurrentIterTrackRef(0), + fRunLoader(0) { // // Default constructor for the AliModule class // - fHistograms = 0; - fNodes = 0; } -//_____________________________________________________________________________ -AliModule::AliModule(const char* name,const char *title):TNamed(name,title) +//_______________________________________________________________________ +AliModule::AliModule(const char* name,const char *title): + TNamed(name,title), + fIdtmed(new TArrayI(100)), + fIdmate(new TArrayI(100)), + fLoMedium(65536), + fHiMedium(0), + fActive(0), + fEnable(1), + fMaxIterTrackRef(0), + fCurrentIterTrackRef(0), + fRunLoader(0) { // // Normal constructor invoked by all Modules. // Create the list for Module specific histograms // Add this Module to the global list of Modules in Run. // - // - // Initialises the histogram list - fHistograms = new TList(); - // - // Initialises the list of ROOT TNodes - fNodes = new TList(); - // // Get the Module numeric ID + Int_t id = gAlice->GetModuleID(name); if (id>=0) { // Module already added ! - Warning("Ctor","Module: %s already present at %d\n",name,id); + AliWarning(Form("Module: %s already present at %d",name,id)); return; } // // Add this Module to the list of Modules - gAlice->Modules()->Add(this); - // - // - SetMarkerColor(3); + + gAlice->AddModule(this); + + //PH SetMarkerColor(3); // - // Allocate space for tracking media and material indexes - fIdtmed = new TArrayI(100); - fIdmate = new TArrayI(100); + // Clear space for tracking media and material indexes + for(Int_t i=0;i<100;i++) (*fIdmate)[i]=(*fIdtmed)[i]=0; - // - // Prepare to find the tracking media range - fLoMedium = 65536; - fHiMedium = 0; } -//_____________________________________________________________________________ +//_______________________________________________________________________ AliModule::~AliModule() { // // Destructor // - fHistograms = 0; - // - // Delete ROOT geometry - fNodes->Clear(); - delete fNodes; - // + + // Remove this Module from the list of Modules + if (gAlice) { + TObjArray * modules = gAlice->Modules(); + if (modules) modules->Remove(this); + } + // Delete TArray objects delete fIdtmed; delete fIdmate; -} - -//_____________________________________________________________________________ -void AliModule::Disable() -{ - // - // Disable Module on viewer - // - fActive = kFALSE; - TIter next(fNodes); - TNode *node; - // - // Loop through geometry to disable all - // nodes for this Module - while((node = (TNode*)next())) { - node->SetVisibility(0); - } -} -//_____________________________________________________________________________ -Int_t AliModule::DistancetoPrimitive(Int_t, Int_t) -{ - // - // Return distance from mouse pointer to object - // Dummy routine for the moment - // - return 9999; -} +} -//_____________________________________________________________________________ -void AliModule::Enable() +//_______________________________________________________________________ +void AliModule::AliMaterial(Int_t imat, const char* name, Float_t a, + Float_t z, Float_t dens, Float_t radl, + Float_t absl, Float_t *buf, Int_t nwbuf) const { // - // Enable Module on the viewver + // Store the parameters for a material // - fActive = kTRUE; - TIter next(fNodes); - TNode *node; + // imat the material index will be stored in (*fIdmate)[imat] + // name material name + // a atomic mass + // z atomic number + // dens density + // radl radiation length + // absl absorbtion length + // buf adress of an array user words + // nwbuf number of user words // - // Loop through geometry to enable all - // nodes for this Module - while((node = (TNode*)next())) { - node->SetVisibility(1); - } + Int_t kmat; + //Build the string uniquename as "DET_materialname" + TString uniquename = GetName(); + uniquename.Append("_"); + uniquename.Append(name); + //if geometry loaded from file only fill fIdmate, else create material too + if(AliSimulation::Instance()->IsGeometryFromFile()){ + TGeoMaterial *mat = gGeoManager->GetMaterial(uniquename.Data()); + kmat = mat->GetUniqueID(); + (*fIdmate)[imat]=kmat; + }else{ + if (fgDensityFactor != 1.0) + AliWarning(Form("Material density multiplied by %.2f!", fgDensityFactor)); + gMC->Material(kmat, uniquename.Data(), a, z, dens * fgDensityFactor, radl, absl, buf, nwbuf); + (*fIdmate)[imat]=kmat; + } } - -//_____________________________________________________________________________ -void AliModule::AliMaterial(Int_t imat, const char* name, Float_t a, - Float_t z, Float_t dens, Float_t radl, - Float_t absl, Float_t *buf, Int_t nwbuf) const + +//_______________________________________________________________________ +void AliModule::AliGetMaterial(Int_t imat, char* name, Float_t &a, + Float_t &z, Float_t &dens, Float_t &radl, + Float_t &absl) const { // // Store the parameters for a material @@ -153,16 +187,18 @@ void AliModule::AliMaterial(Int_t imat, const char* name, Float_t a, // buf adress of an array user words // nwbuf number of user words // - Int_t kmat; - AliMC::GetMC()->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf); - (*fIdmate)[imat]=kmat; + + Float_t buf[10]; + Int_t nwbuf, kmat; + kmat=(*fIdmate)[imat]; + gMC->Gfmate(kmat, name, a, z, dens, radl, absl, buf, nwbuf); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliModule::AliMixture(Int_t imat, const char *name, Float_t *a, - Float_t *z, Float_t dens, Int_t nlmat, - Float_t *wmat) const + Float_t *z, Float_t dens, Int_t nlmat, + Float_t *wmat) const { // // Defines mixture or compound imat as composed by @@ -184,21 +220,34 @@ void AliModule::AliMixture(Int_t imat, const char *name, Float_t *a, // wmat array of concentrations // Int_t kmat; - AliMC::GetMC()->Mixture(kmat, name, a, z, dens, nlmat, wmat); - (*fIdmate)[imat]=kmat; + //Build the string uniquename as "DET_mixturename" + TString uniquename = GetName(); + uniquename.Append("_"); + uniquename.Append(name); + //if geometry loaded from file only fill fIdmate, else create mixture too + if(AliSimulation::Instance()->IsGeometryFromFile()){ + TGeoMaterial *mat = gGeoManager->GetMaterial(uniquename.Data()); + kmat = mat->GetUniqueID(); + (*fIdmate)[imat]=kmat; + }else{ + if (fgDensityFactor != 1.0) + AliWarning(Form("Material density multiplied by %.2f!", fgDensityFactor)); + gMC->Mixture(kmat, uniquename.Data(), a, z, dens * fgDensityFactor, nlmat, wmat); + (*fIdmate)[imat]=kmat; + } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliModule::AliMedium(Int_t numed, const char *name, Int_t nmat, - Int_t isvol, Int_t ifield, Float_t fieldm, - Float_t tmaxfd, Float_t stemax, Float_t deemax, - Float_t epsil, Float_t stmin, Float_t *ubuf, - Int_t nbuf) const + Int_t isvol, Int_t ifield, Float_t fieldm, + Float_t tmaxfd, Float_t stemax, Float_t deemax, + Float_t epsil, Float_t stmin, Float_t *ubuf, + Int_t nbuf) const { // // Store the parameters of a tracking medium // - // numed the medium number is stored into (*fIdtmed)[numed-1] + // numed the medium number is stored into (*fIdtmed)[numed] // name medium name // nmat the material number is stored into (*fIdmate)[nmat] // isvol sensitive volume if isvol!=0 @@ -217,15 +266,26 @@ void AliModule::AliMedium(Int_t numed, const char *name, Int_t nmat, // = 3 constant magnetic field along z // Int_t kmed; - AliMC::GetMC()->Medium(kmed,name, (*fIdmate)[nmat], isvol, ifield, fieldm, - tmaxfd, stemax, deemax, epsil, stmin, ubuf, nbuf); - (*fIdtmed)[numed]=kmed; + //Build the string uniquename as "DET_mediumname" + TString uniquename = GetName(); + uniquename.Append("_"); + uniquename.Append(name); + //if geometry loaded from file only fill fIdtmed, else create medium too + if(AliSimulation::Instance()->IsGeometryFromFile()){ + TGeoMedium *med = gGeoManager->GetMedium(uniquename.Data()); + kmed = med->GetId(); + (*fIdtmed)[numed]=kmed; + }else{ + gMC->Medium(kmed, uniquename.Data(), (*fIdmate)[nmat], isvol, ifield, + fieldm, tmaxfd, stemax, deemax, epsil, stmin, ubuf, nbuf); + (*fIdtmed)[numed]=kmed; + } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliModule::AliMatrix(Int_t &nmat, Float_t theta1, Float_t phi1, - Float_t theta2, Float_t phi2, Float_t theta3, - Float_t phi3) const + Float_t theta2, Float_t phi2, Float_t theta3, + Float_t phi3) const { // // Define a rotation matrix. Angles are in degrees. @@ -238,57 +298,95 @@ void AliModule::AliMatrix(Int_t &nmat, Float_t theta1, Float_t phi1, // theta3 polar angle for axis III // phi3 azimuthal angle for axis III // - AliMC::GetMC()->Matrix(nmat, theta1, phi1, theta2, phi2, theta3, phi3); + gMC->Matrix(nmat, theta1, phi1, theta2, phi2, theta3, phi3); } -//_____________________________________________________________________________ -void AliModule::SetEuclidFile(char* material, char* geometry) +//_______________________________________________________________________ +Float_t AliModule::ZMin() const { - // - // Sets the name of the Euclid file - // - fEuclidMaterial=material; - if(geometry) { - fEuclidGeometry=geometry; - } else { - char* name = new char[strlen(material)]; - strcpy(name,material); - strcpy(&name[strlen(name)-4],".euc"); - fEuclidGeometry=name; - delete [] name; - } + return -500; +} + +//_______________________________________________________________________ +Float_t AliModule::ZMax() const +{ + return 500; +} + +//_______________________________________________________________________ +void AliModule::AddAlignableVolumes() const +{ + // + if (IsActive()) + AliWarning(Form(" %s still has to implement the AddAlignableVolumes method!",GetName())); +} + +//_______________________________________________________________________ + +AliLoader* AliModule::MakeLoader(const char* /*topfoldername*/) +{ + return 0x0; } + +//_____________________________________________________________________________ +AliTrackReference* AliModule::AddTrackReference(Int_t label, Int_t id){ + // + // add a trackrefernce to the list + return (gAlice->GetMCApp()->AddTrackReference(label, id)); +} + //_____________________________________________________________________________ -void AliModule::Streamer(TBuffer &R__b) +TTree* AliModule::TreeTR() { // - // Stream an object of class Module. + // Return TR tree pointer // - if (R__b.IsReading()) { - Version_t R__v = R__b.ReadVersion(); if (R__v) { } - TNamed::Streamer(R__b); - TAttLine::Streamer(R__b); - TAttMarker::Streamer(R__b); - fEuclidMaterial.Streamer(R__b); - fEuclidGeometry.Streamer(R__b); - R__b >> fActive; - R__b >> fHistograms; - // - // Stream the pointers but not the TClonesArrays - R__b >> fNodes; // diff - } else { - R__b.WriteVersion(AliModule::IsA()); - TNamed::Streamer(R__b); - TAttLine::Streamer(R__b); - TAttMarker::Streamer(R__b); - fEuclidMaterial.Streamer(R__b); - fEuclidGeometry.Streamer(R__b); - R__b << fActive; - R__b << fHistograms; - // - // Stream the pointers but not the TClonesArrays - R__b << fNodes; // diff + if ( fRunLoader == 0x0) + { + AliError("Can not get the run loader"); + return 0x0; + } + + TTree* tree = fRunLoader->TreeTR(); + return tree; +} + + +//_____________________________________________________________________________ +void AliModule::Digits2Raw() +{ +// This is a dummy version that just copies the digits file contents +// to a raw data file. + + AliWarning(Form("Dummy version called for %s", GetName())); + + Int_t nDDLs = AliDAQ::NumberOfDdls(GetName()); + + if (!GetLoader()) return; + fstream digitsFile(GetLoader()->GetDigitsFileName(), ios::in); + if (!digitsFile) return; + + digitsFile.seekg(0, ios::end); + UInt_t size = digitsFile.tellg(); + UInt_t ddlSize = 4 * (size / (4*nDDLs)); + Char_t* buffer = new Char_t[ddlSize+1]; + + for (Int_t iDDL = 0; iDDL < nDDLs; iDDL++) { + char fileName[20]; + strcpy(fileName,AliDAQ::DdlFileName(GetName(),iDDL)); + fstream rawFile(fileName, ios::out); + if (!rawFile) return; + + AliRawDataHeader header; + header.fSize = ddlSize + sizeof(header); + rawFile.write((char*) &header, sizeof(header)); + + digitsFile.read(buffer, ddlSize); + rawFile.write(buffer, ddlSize); + rawFile.close(); } + + digitsFile.close(); + delete[] buffer; } -