From 3cd6899f36e20a8192510441007363b2d0748cfd Mon Sep 17 00:00:00 2001 From: Dmytro Kresan Date: Wed, 13 Feb 2019 09:24:05 +0100 Subject: [PATCH] Add support for TVirtualMCSensitiveDetector. --- base/sim/FairDetector.h | 2 +- base/sim/FairMCApplication.cxx | 95 ++++--------------- base/sim/FairMCApplication.h | 13 +++ base/sim/FairModule.cxx | 19 ++-- base/sim/FairModule.h | 11 ++- base/sim/fastsim/FairFastSimDetector.cxx | 4 +- base/sim/fastsim/FairFastSimDetector.h | 2 +- examples/MQ/pixelDetector/src/Pixel.cxx | 9 +- examples/MQ/pixelDetector/src/Pixel.h | 2 +- .../Tutorial3/simulation/FairTestDetector.cxx | 9 +- .../Tutorial3/simulation/FairTestDetector.h | 2 +- .../Tutorial1/src/FairTutorialDet1.cxx | 23 +++-- .../Tutorial1/src/FairTutorialDet1.h | 4 +- .../Tutorial2/src/FairTutorialDet2.cxx | 9 +- .../Tutorial2/src/FairTutorialDet2.h | 2 +- .../Tutorial4/src/mc/FairTutorialDet4.cxx | 6 +- .../Tutorial4/src/mc/FairTutorialDet4.h | 3 +- .../rutherford/src/FairRutherford.cxx | 9 +- .../rutherford/src/FairRutherford.h | 2 +- .../NewDetector/NewDetector.cxx | 9 +- .../NewDetector/NewDetector.h | 2 +- .../NewDetector/NewDetector.cxx | 9 +- .../NewDetector/NewDetector.h | 2 +- 23 files changed, 102 insertions(+), 146 deletions(-) diff --git a/base/sim/FairDetector.h b/base/sim/FairDetector.h index 7f64f73a6a..f80fe81e49 100644 --- a/base/sim/FairDetector.h +++ b/base/sim/FairDetector.h @@ -49,7 +49,7 @@ class FairDetector : public FairModule /** this method is called for each step during simulation (see FairMCApplication::Stepping()) */ - virtual Bool_t ProcessHits( FairVolume* v=0)=0; + virtual void ProcessHits()=0; /** this is called at the end of an event */ diff --git a/base/sim/FairMCApplication.cxx b/base/sim/FairMCApplication.cxx index 68c85c0cbf..1e56a69765 100644 --- a/base/sim/FairMCApplication.cxx +++ b/base/sim/FairMCApplication.cxx @@ -661,76 +661,9 @@ void FairMCApplication::FinishRunOnWorker() //_____________________________________________________________________________ void FairMCApplication::Stepping() { -// User actions at each step -// --- - - // Work around for Fluka VMC, which does not call - // MCApplication::PreTrack() - static Int_t TrackId = 0; - if ( fMcVersion ==2 && fMC->GetStack()->GetCurrentTrackNumber() != TrackId ) { - PreTrack(); - TrackId = fMC->GetStack()->GetCurrentTrackNumber(); - } - - // Check if the volume with id is in the volume multimap. - // If it is not in the map the volume is not a sensitive volume - // and we do not call nay of our ProcessHits functions. - - // If the volume is in the multimap, check in second step if the current - // copy is alredy inside the multimap. - // If the volume is not in the multimap add the copy of the volume to the - // multimap. - // In any case call the ProcessHits function for this specific detector. - Int_t copyNo; - Int_t id = fMC->CurrentVolID(copyNo); - Bool_t InMap =kFALSE; - fDisVol=0; - fDisDet=0; - Int_t fCopyNo=0; - fVolIter =fVolMap.find(id); - - if (fVolIter!=fVolMap.end()) { - - // Call Process hits for FairVolume with this id, copyNo - do { - fDisVol=fVolIter->second; - fCopyNo=fDisVol->getCopyNo(); - if(copyNo==fCopyNo) { - fDisDet=fDisVol->GetDetector(); - if (fDisDet) { - fDisDet->ProcessHits(fDisVol); - } - InMap=kTRUE; - break; - } - fVolIter++; - } - while(fVolIter!=fVolMap.upper_bound(id)); - - // if(fDisVol && !InMap) { // fDisVolume is set previously, no check needed - - // Create new FairVolume with this id, copyNo. - // Use the FairVolume with the same id found in the map to get - // the link to the detector. - // Seems that this never happens (?) - if(!InMap) { - // cout << "Volume not in map; fDisVol ? " << fDisVol << endl - FairVolume* fNewV=new FairVolume( fMC->CurrentVolName(), id); - fNewV->setMCid(id); - fNewV->setModId(fDisVol->getModId()); - fNewV->SetModule(fDisVol->GetModule()); - fNewV->setCopyNo(copyNo); - fVolMap.insert(pair(id, fNewV)); - fDisDet=fDisVol->GetDetector(); - - // LOG(info) << "FairMCApplication::Stepping: new fair volume" - // << id << " " << copyNo << " " << fDisDet; - if ( fDisDet) { - fDisDet->ProcessHits(fNewV); - } - } - } - + Int_t copyNo = 0; + Int_t id = 0; + // If information about the tracks should be stored the information as to be // stored for any step. // Information about each single step has also to be stored for the other @@ -838,11 +771,6 @@ void FairMCApplication::FinishEvent() fSaveCurrentEvent = kTRUE; } - for (auto detectorPtr : listActiveDetectors) - { - detectorPtr->EndOfEvent(); - } - fStack->Reset(); if(NULL != fTrajFilter) { fTrajFilter->Reset(); @@ -1504,4 +1432,21 @@ void FairMCApplication::UndoGeometryModifications() } +void FairMCApplication::ConstructSensitiveDetectors() +{ + LOG(info) << "############ ?????????? Construct sensitive detectors"; + + for(auto const& x : fMapSensitiveDetectors) + { + LOG(debug) << "FairMCApplication::ConstructSensitiveDetectors " + << x.first << " " << x.second; + TVirtualMC::GetMC()->SetSensitiveDetector(x.first, x.second); + } +} + +void FairMCApplication::AddSensitiveModule(std::string volName, FairModule* module) +{ + fMapSensitiveDetectors[volName] = module; +} + ClassImp(FairMCApplication) diff --git a/base/sim/FairMCApplication.h b/base/sim/FairMCApplication.h index 4bd338d9f2..9ff8bef054 100644 --- a/base/sim/FairMCApplication.h +++ b/base/sim/FairMCApplication.h @@ -37,6 +37,7 @@ class FairRootManager; class FairTask; class FairTrajFilter; class FairVolume; +class FairModule; class FairRunSim; class TChain; class TIterator; @@ -93,6 +94,9 @@ class FairMCApplication : public TVirtualMCApplication virtual Bool_t MisalignGeometry(); /** Define parameters for optical processes (optional) */ virtual void ConstructOpGeometry(); // MC Application + + virtual void ConstructSensitiveDetectors(); + /** Define actions at the end of event */ virtual void FinishEvent(); // MC Application /** Define actions at the end of primary track */ @@ -203,6 +207,11 @@ class FairMCApplication : public TVirtualMCApplication * Get the current application state. */ FairMCApplicationState GetState() const { return fState; } + + /** + * Add module to the list of sensitive detectors. + */ + void AddSensitiveModule(std::string volName, FairModule* module); private: // methods @@ -296,6 +305,10 @@ class FairMCApplication : public TVirtualMCApplication /** Current state */ FairMCApplicationState fState; //! + + /** List of sensitive detectors. + * To be used with TVirtualMCSensitiveDetector. */ + std::map fMapSensitiveDetectors; ClassDef(FairMCApplication,4) //Interface to MonteCarlo application diff --git a/base/sim/FairModule.cxx b/base/sim/FairModule.cxx index c1789a8fd3..9313a6b36c 100644 --- a/base/sim/FairModule.cxx +++ b/base/sim/FairModule.cxx @@ -77,7 +77,7 @@ FairModule::~FairModule() } //__________________________________________________________________________ FairModule::FairModule(const char* Name, const char* title ,Bool_t Active) - :TNamed(Name, title), + :TVirtualMCSensitiveDetector(Name, title), fMotherVolumeName(""), fgeoVer("Not defined"), fgeoName("Not defined"), @@ -96,7 +96,7 @@ FairModule::FairModule(const char* Name, const char* title ,Bool_t Active) //__________________________________________________________________________ FairModule::FairModule(const FairModule& rhs) - :TNamed(rhs), + :TVirtualMCSensitiveDetector(rhs), fMotherVolumeName(rhs.fMotherVolumeName), fgeoVer(rhs.fgeoVer), fgeoName(rhs.fgeoName), @@ -139,8 +139,7 @@ FairModule::FairModule(const FairModule& rhs) //__________________________________________________________________________ FairModule::FairModule() - : TNamed(), - fMotherVolumeName(""), + : fMotherVolumeName(""), fgeoVer("Not defined"), fgeoName("Not defined"), fModId(-1), @@ -160,7 +159,7 @@ FairModule& FairModule::operator= (const FairModule& rhs) if (this == &rhs) return *this; // base class assignment - TNamed::operator=(rhs); + TVirtualMCSensitiveDetector::operator=(rhs); // assignment operator fMotherVolumeName = rhs.fMotherVolumeName; @@ -188,7 +187,7 @@ FairModule& FairModule::operator= (const FairModule& rhs) //__________________________________________________________________________ void FairModule::Streamer(TBuffer& b) { - TNamed::Streamer(b); + TVirtualMCSensitiveDetector::Streamer(b); if (b.IsReading()) { @@ -294,6 +293,9 @@ void FairModule::ProcessNodes(TList* aList) FairGeoVolume* aVol=NULL; if ( node->isSensitive() && fActive ) { + + FairMCApplication::Instance()->AddSensitiveModule(volume->GetName(), this); + volume->setModId(fModId); volume->SetModule(this); svList->Add(volume); @@ -306,9 +308,10 @@ void FairModule::ProcessNodes(TList* aList) //__________________________________________________________________________ void FairModule::AddSensitiveVolume(TGeoVolume* v) { - LOG(debug2)<<"AddSensitiveVolume " << v->GetName(); + FairMCApplication::Instance()->AddSensitiveModule(v->GetName(), this); + // Only register volumes which are not already registered // Otherwise the stepping will be slowed down if( ! vList->findObject(v->GetName() ) ) { @@ -321,8 +324,6 @@ void FairModule::AddSensitiveVolume(TGeoVolume* v) fNbOfSensitiveVol++; } } - - //__________________________________________________________________________ FairVolume* FairModule::getFairVolume(FairGeoNode* fN) { diff --git a/base/sim/FairModule.h b/base/sim/FairModule.h index 76c4546e3d..4176b1abbe 100644 --- a/base/sim/FairModule.h +++ b/base/sim/FairModule.h @@ -8,7 +8,7 @@ #ifndef FAIRMODULE_H #define FAIRMODULE_H -#include "TNamed.h" // for TNamed +#include "TVirtualMCSensitiveDetector.h" #include "FairGeoInterface.h" // for FairGeoInterface #include "FairGeoLoader.h" // for FairGeoLoader @@ -47,7 +47,7 @@ class TVirtualMC; * Changelog: 29.02.2012 [O.Merle] Fixed missing material assignment for top volume. * ... and please - add some documentation to your code. */ -class FairModule: public TNamed +class FairModule: public TVirtualMCSensitiveDetector { public: /**default ctor*/ @@ -136,6 +136,13 @@ class FairModule: public TNamed TString fMotherVolumeName; //! FairVolume* getFairVolume(FairGeoNode* fNode); void AddSensitiveVolume(TGeoVolume* v); + + virtual void EndOfEvent() {} + + virtual void Initialize() {} + + virtual void ProcessHits() {} + private: /** Re-implimented from ROOT: TGeoMatrix::SetDefaultName() */ void SetDefaultMatrixName(TGeoMatrix* matrix); diff --git a/base/sim/fastsim/FairFastSimDetector.cxx b/base/sim/fastsim/FairFastSimDetector.cxx index 1e20716743..4c084c88a5 100644 --- a/base/sim/fastsim/FairFastSimDetector.cxx +++ b/base/sim/fastsim/FairFastSimDetector.cxx @@ -63,11 +63,9 @@ void FairFastSimDetector::ConstructGeometry() } } -Bool_t FairFastSimDetector::ProcessHits(FairVolume*) +void FairFastSimDetector::ProcessHits() { FastSimProcessParticle(); - - return kTRUE; } ClassImp(FairFastSimDetector) diff --git a/base/sim/fastsim/FairFastSimDetector.h b/base/sim/fastsim/FairFastSimDetector.h index f4cf6adec2..060d6059a9 100644 --- a/base/sim/fastsim/FairFastSimDetector.h +++ b/base/sim/fastsim/FairFastSimDetector.h @@ -23,7 +23,7 @@ class FairFastSimDetector : public FairDetector virtual void Initialize() = 0; - virtual Bool_t ProcessHits(FairVolume* vol = 0) final; + virtual void ProcessHits() final; virtual void EndOfEvent() {} diff --git a/examples/MQ/pixelDetector/src/Pixel.cxx b/examples/MQ/pixelDetector/src/Pixel.cxx index 7eb9ae8aff..69f03dd8c6 100644 --- a/examples/MQ/pixelDetector/src/Pixel.cxx +++ b/examples/MQ/pixelDetector/src/Pixel.cxx @@ -87,7 +87,7 @@ void Pixel::Initialize() FairDetector::Initialize(); } -Bool_t Pixel::ProcessHits(FairVolume* vol) +void Pixel::ProcessHits() { /** This method is called from the MC stepping */ @@ -108,10 +108,11 @@ Bool_t Pixel::ProcessHits(FairVolume* vol) TVirtualMC::GetMC()->IsTrackStop() || TVirtualMC::GetMC()->IsTrackDisappeared() ) { fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber(); - fVolumeID = vol->getMCid(); + Int_t copyNo = 0; + fVolumeID = TVirtualMC::GetMC()->CurrentVolID(copyNo); - if (fELoss == 0. ) { return kFALSE; } + if (fELoss == 0. ) { return; } // Taking stationNr and sectorNr from string is almost effortless. // Simulation of 100k events with 5 pions without magnetic field takes: @@ -135,8 +136,6 @@ Bool_t Pixel::ProcessHits(FairVolume* vol) FairStack* stack = static_cast(TVirtualMC::GetMC()->GetStack()); stack->AddPoint(kPixel); } - - return kTRUE; } void Pixel::EndOfEvent() diff --git a/examples/MQ/pixelDetector/src/Pixel.h b/examples/MQ/pixelDetector/src/Pixel.h index 831391e44f..04efc11841 100644 --- a/examples/MQ/pixelDetector/src/Pixel.h +++ b/examples/MQ/pixelDetector/src/Pixel.h @@ -40,7 +40,7 @@ class Pixel: public FairDetector /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ - virtual Bool_t ProcessHits( FairVolume* v=0); + virtual void ProcessHits(); /** Registers the produced collections in FAIRRootManager. */ virtual void Register(); diff --git a/examples/advanced/Tutorial3/simulation/FairTestDetector.cxx b/examples/advanced/Tutorial3/simulation/FairTestDetector.cxx index f84b34f608..58f0dba072 100644 --- a/examples/advanced/Tutorial3/simulation/FairTestDetector.cxx +++ b/examples/advanced/Tutorial3/simulation/FairTestDetector.cxx @@ -78,7 +78,7 @@ void FairTestDetector::Initialize() rtdb->getContainer("FairTestDetectorGeoPar"); } -Bool_t FairTestDetector::ProcessHits(FairVolume* vol) +void FairTestDetector::ProcessHits() { /** This method is called from the MC stepping */ @@ -99,12 +99,13 @@ Bool_t FairTestDetector::ProcessHits(FairVolume* vol) if (TVirtualMC::GetMC()->IsTrackExiting() || TVirtualMC::GetMC()->IsTrackStop() || TVirtualMC::GetMC()->IsTrackDisappeared()) { fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber(); - fVolumeID = vol->getMCid(); + Int_t copyNo = 0; + fVolumeID = TVirtualMC::GetMC()->CurrentVolID(copyNo); TVirtualMC::GetMC()->TrackPosition(fPosOut); TVirtualMC::GetMC()->TrackMomentum(fMomOut); if (fELoss == 0.) { - return kFALSE; + return; } AddHit(fTrackID, fVolumeID, @@ -120,8 +121,6 @@ Bool_t FairTestDetector::ProcessHits(FairVolume* vol) FairStack* stack = static_cast(TVirtualMC::GetMC()->GetStack()); stack->AddPoint(kTutDet); } - - return kTRUE; } void FairTestDetector::EndOfEvent() diff --git a/examples/advanced/Tutorial3/simulation/FairTestDetector.h b/examples/advanced/Tutorial3/simulation/FairTestDetector.h index 94439dbe04..617883213b 100644 --- a/examples/advanced/Tutorial3/simulation/FairTestDetector.h +++ b/examples/advanced/Tutorial3/simulation/FairTestDetector.h @@ -40,7 +40,7 @@ class FairTestDetector : public FairDetector /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ - virtual Bool_t ProcessHits(FairVolume* v = 0); + virtual void ProcessHits(); /** Registers the produced collections in FAIRRootManager. */ virtual void Register(); diff --git a/examples/simulation/Tutorial1/src/FairTutorialDet1.cxx b/examples/simulation/Tutorial1/src/FairTutorialDet1.cxx index 6a78c8539b..252b4dd8b5 100644 --- a/examples/simulation/Tutorial1/src/FairTutorialDet1.cxx +++ b/examples/simulation/Tutorial1/src/FairTutorialDet1.cxx @@ -1,8 +1,8 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "FairTutorialDet1.h" @@ -21,6 +21,7 @@ #include "FairTutorialDet1Point.h" // for FairTutorialDet1Point #include "FairVolume.h" // for FairVolume #include "FairLogger.h" // for logging +#include "FairMCApplication.h" #include // for ostream #include "TClonesArray.h" // for TClonesArray @@ -90,7 +91,7 @@ void FairTutorialDet1::Initialize() */ } -Bool_t FairTutorialDet1::ProcessHits(FairVolume* vol) +void FairTutorialDet1::ProcessHits() { /** This method is called from the MC stepping */ @@ -112,8 +113,9 @@ Bool_t FairTutorialDet1::ProcessHits(FairVolume* vol) TVirtualMC::GetMC()->IsTrackStop() || TVirtualMC::GetMC()->IsTrackDisappeared() ) { fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber(); - fVolumeID = vol->getMCid(); - if (fELoss == 0. ) { return kFALSE; } + Int_t copyNo = 0; + fVolumeID = TVirtualMC::GetMC()->CurrentVolID(copyNo); + if (fELoss == 0. ) { return; } AddHit(fTrackID, fVolumeID, TVector3(fPos.X(), fPos.Y(), fPos.Z()), TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, fELoss); @@ -122,12 +124,13 @@ Bool_t FairTutorialDet1::ProcessHits(FairVolume* vol) FairStack* stack = static_cast(TVirtualMC::GetMC()->GetStack()); stack->AddPoint(kTutDet); } - - return kTRUE; } void FairTutorialDet1::EndOfEvent() { + + LOG(info) << "FairTutorialDet1 : " << fFairTutorialDet1PointCollection->GetEntriesFast() + << " points registered."; fFairTutorialDet1PointCollection->Clear(); @@ -167,9 +170,9 @@ void FairTutorialDet1::Reset() void FairTutorialDet1::ConstructGeometry() { - /** If you are using the standard ASCII input for the geometry - just copy this and use it for your detector, otherwise you can - implement here you own way of constructing the geometry. */ + /** If you are using the standard ASCII input for the geometry + just copy this and use it for your detector, otherwise you can + implement here you own way of constructing the geometry. */ ConstructASCIIGeometry(fgGeo, "FairTutorialDet1GeoPar"); } diff --git a/examples/simulation/Tutorial1/src/FairTutorialDet1.h b/examples/simulation/Tutorial1/src/FairTutorialDet1.h index 163393fe8d..28206929e7 100644 --- a/examples/simulation/Tutorial1/src/FairTutorialDet1.h +++ b/examples/simulation/Tutorial1/src/FairTutorialDet1.h @@ -42,7 +42,7 @@ class FairTutorialDet1: public FairDetector /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ - virtual Bool_t ProcessHits( FairVolume* v=0); + virtual void ProcessHits(); /** Registers the produced collections in FAIRRootManager. */ virtual void Register(); @@ -56,8 +56,6 @@ class FairTutorialDet1: public FairDetector /** Create the detector geometry */ void ConstructGeometry(); - - /** This method is an example of how to add your own point * of type FairTutorialDet1Point to the clones array */ diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2.cxx b/examples/simulation/Tutorial2/src/FairTutorialDet2.cxx index 2277450cfe..836a4fbf72 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2.cxx +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2.cxx @@ -90,7 +90,7 @@ void FairTutorialDet2::Initialize() */ } -Bool_t FairTutorialDet2::ProcessHits(FairVolume* vol) +void FairTutorialDet2::ProcessHits() { /** This method is called from the MC stepping */ @@ -111,8 +111,9 @@ Bool_t FairTutorialDet2::ProcessHits(FairVolume* vol) TVirtualMC::GetMC()->IsTrackStop() || TVirtualMC::GetMC()->IsTrackDisappeared() ) { fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber(); - fVolumeID = vol->getMCid(); - if (fELoss == 0. ) { return kFALSE; } + Int_t copyNo = 0; + fVolumeID = TVirtualMC::GetMC()->CurrentVolID(copyNo); + if (fELoss == 0. ) { return; } AddHit(fTrackID, fVolumeID, TVector3(fPos.X(), fPos.Y(), fPos.Z()), TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, fELoss); @@ -121,8 +122,6 @@ Bool_t FairTutorialDet2::ProcessHits(FairVolume* vol) FairStack* stack = static_cast(TVirtualMC::GetMC()->GetStack()); stack->AddPoint(kTutDet); } - - return kTRUE; } void FairTutorialDet2::EndOfEvent() diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2.h b/examples/simulation/Tutorial2/src/FairTutorialDet2.h index 803a5edaff..519057459a 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2.h +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2.h @@ -41,7 +41,7 @@ class FairTutorialDet2: public FairDetector /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ - virtual Bool_t ProcessHits( FairVolume* v=0); + virtual void ProcessHits(); /** Registers the produced collections in FAIRRootManager. */ virtual void Register(); diff --git a/examples/simulation/Tutorial4/src/mc/FairTutorialDet4.cxx b/examples/simulation/Tutorial4/src/mc/FairTutorialDet4.cxx index 912dd602b2..afd7006e24 100644 --- a/examples/simulation/Tutorial4/src/mc/FairTutorialDet4.cxx +++ b/examples/simulation/Tutorial4/src/mc/FairTutorialDet4.cxx @@ -171,7 +171,7 @@ void FairTutorialDet4::InitParContainers() } -Bool_t FairTutorialDet4::ProcessHits(FairVolume* /*vol*/) +void FairTutorialDet4::ProcessHits() { /** This method is called from the MC stepping */ @@ -194,7 +194,7 @@ Bool_t FairTutorialDet4::ProcessHits(FairVolume* /*vol*/) fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber(); // fVolumeID = vol->getMCid(); fVolumeID = fGeoHandler->GetUniqueDetectorId(); - if (fELoss == 0. ) { return kFALSE; } + if (fELoss == 0. ) { return; } if(!fGlobalCoordinates) { @@ -217,8 +217,6 @@ Bool_t FairTutorialDet4::ProcessHits(FairVolume* /*vol*/) FairStack* stack = static_cast(TVirtualMC::GetMC()->GetStack()); stack->AddPoint(kTutDet); } - - return kTRUE; } void FairTutorialDet4::EndOfEvent() diff --git a/examples/simulation/Tutorial4/src/mc/FairTutorialDet4.h b/examples/simulation/Tutorial4/src/mc/FairTutorialDet4.h index 21c2dfebe6..ad4710a002 100644 --- a/examples/simulation/Tutorial4/src/mc/FairTutorialDet4.h +++ b/examples/simulation/Tutorial4/src/mc/FairTutorialDet4.h @@ -51,7 +51,7 @@ class FairTutorialDet4: public FairDetector /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ - virtual Bool_t ProcessHits( FairVolume* v=0); + virtual void ProcessHits(); /** Registers the produced collections in FAIRRootManager. */ virtual void Register(); @@ -141,7 +141,6 @@ class FairTutorialDet4: public FairDetector **/ void ConstructASCIIGeometry(); - FairTutorialDet4(const FairTutorialDet4&); FairTutorialDet4& operator=(const FairTutorialDet4&); diff --git a/examples/simulation/rutherford/src/FairRutherford.cxx b/examples/simulation/rutherford/src/FairRutherford.cxx index 50ea178f7f..e267a48339 100644 --- a/examples/simulation/rutherford/src/FairRutherford.cxx +++ b/examples/simulation/rutherford/src/FairRutherford.cxx @@ -92,7 +92,7 @@ void FairRutherford::Initialize() */ } -Bool_t FairRutherford::ProcessHits(FairVolume* vol) +void FairRutherford::ProcessHits() { /** This method is called from the MC stepping */ @@ -113,8 +113,9 @@ Bool_t FairRutherford::ProcessHits(FairVolume* vol) TVirtualMC::GetMC()->IsTrackStop() || TVirtualMC::GetMC()->IsTrackDisappeared() ) { fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber(); - fVolumeID = vol->getMCid(); - if (fELoss == 0. ) { return kFALSE; } + Int_t copyNo = 0; + fVolumeID = TVirtualMC::GetMC()->CurrentVolID(copyNo); + if (fELoss == 0. ) { return; } AddHit(fTrackID, fVolumeID, TVector3(fPos.X(), fPos.Y(), fPos.Z()), TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, fELoss); @@ -123,8 +124,6 @@ Bool_t FairRutherford::ProcessHits(FairVolume* vol) FairStack* stack = static_cast(TVirtualMC::GetMC()->GetStack()); stack->AddPoint(kFairRutherford); } - - return kTRUE; } void FairRutherford::EndOfEvent() diff --git a/examples/simulation/rutherford/src/FairRutherford.h b/examples/simulation/rutherford/src/FairRutherford.h index af42058371..2c4bf3d6da 100644 --- a/examples/simulation/rutherford/src/FairRutherford.h +++ b/examples/simulation/rutherford/src/FairRutherford.h @@ -42,7 +42,7 @@ class FairRutherford: public FairDetector /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ - virtual Bool_t ProcessHits( FairVolume* v=0); + virtual void ProcessHits(); /** Registers the produced collections in FAIRRootManager. */ virtual void Register(); diff --git a/templates/project_root_containers/NewDetector/NewDetector.cxx b/templates/project_root_containers/NewDetector/NewDetector.cxx index 82ca2c6686..40f7bce2c3 100644 --- a/templates/project_root_containers/NewDetector/NewDetector.cxx +++ b/templates/project_root_containers/NewDetector/NewDetector.cxx @@ -96,7 +96,7 @@ void NewDetector::Initialize() NewDetectorGeoPar* par=(NewDetectorGeoPar*)(rtdb->getContainer("NewDetectorGeoPar")); } -Bool_t NewDetector::ProcessHits(FairVolume* vol) +void NewDetector::ProcessHits() { /** This method is called from the MC stepping */ @@ -117,8 +117,9 @@ Bool_t NewDetector::ProcessHits(FairVolume* vol) TVirtualMC::GetMC()->IsTrackStop() || TVirtualMC::GetMC()->IsTrackDisappeared() ) { fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber(); - fVolumeID = vol->getMCid(); - if (fELoss == 0. ) { return kFALSE; } + Int_t copyNo = 0; + fVolumeID = TVirtualMC::GetMC()->CurrentVolID(copyNo); + if (fELoss == 0. ) { return; } AddHit(fTrackID, fVolumeID, TVector3(fPos.X(), fPos.Y(), fPos.Z()), TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, fELoss); @@ -127,8 +128,6 @@ Bool_t NewDetector::ProcessHits(FairVolume* vol) MyProjStack* stack = (MyProjStack*) TVirtualMC::GetMC()->GetStack(); stack->AddPoint(kNewDetector); } - - return kTRUE; } void NewDetector::EndOfEvent() diff --git a/templates/project_root_containers/NewDetector/NewDetector.h b/templates/project_root_containers/NewDetector/NewDetector.h index 288dae785a..ded927e080 100644 --- a/templates/project_root_containers/NewDetector/NewDetector.h +++ b/templates/project_root_containers/NewDetector/NewDetector.h @@ -40,7 +40,7 @@ class NewDetector: public FairDetector /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ - virtual Bool_t ProcessHits( FairVolume* v=0); + virtual void ProcessHits(); /** Registers the produced collections in FAIRRootManager. */ virtual void Register(); diff --git a/templates/project_stl_containers/NewDetector/NewDetector.cxx b/templates/project_stl_containers/NewDetector/NewDetector.cxx index 2e13a7eca8..83afb3cb26 100644 --- a/templates/project_stl_containers/NewDetector/NewDetector.cxx +++ b/templates/project_stl_containers/NewDetector/NewDetector.cxx @@ -96,7 +96,7 @@ void NewDetector::Initialize() NewDetectorGeoPar* par = (NewDetectorGeoPar*)(rtdb->getContainer("NewDetectorGeoPar")); } -Bool_t NewDetector::ProcessHits(FairVolume* vol) +void NewDetector::ProcessHits() { /** This method is called from the MC stepping */ @@ -118,10 +118,11 @@ Bool_t NewDetector::ProcessHits(FairVolume* vol) TVirtualMC::GetMC()->IsTrackDisappeared()) { fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber(); - fVolumeID = vol->getMCid(); + Int_t copyNo = 0; + fVolumeID = TVirtualMC::GetMC()->CurrentVolID(copyNo); if (fELoss == 0.) { - return kFALSE; + return; } AddHit(fTrackID, fVolumeID, @@ -135,8 +136,6 @@ Bool_t NewDetector::ProcessHits(FairVolume* vol) MyProjStack* stack = (MyProjStack*)TVirtualMC::GetMC()->GetStack(); stack->AddPoint(kNewDetector); } - - return kTRUE; } void NewDetector::EndOfEvent() diff --git a/templates/project_stl_containers/NewDetector/NewDetector.h b/templates/project_stl_containers/NewDetector/NewDetector.h index aa74920937..d7a01abdd3 100644 --- a/templates/project_stl_containers/NewDetector/NewDetector.h +++ b/templates/project_stl_containers/NewDetector/NewDetector.h @@ -40,7 +40,7 @@ class NewDetector : public FairDetector /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ - virtual Bool_t ProcessHits(FairVolume* v = 0); + virtual void ProcessHits(); /** Registers the produced collections in FAIRRootManager. */ virtual void Register();