@@ -651,75 +651,39 @@ void FairMCApplication::FinishRunOnWorker()
651651// _____________________________________________________________________________
652652void FairMCApplication::Stepping ()
653653{
654- // User actions at each step
655- // ---
656-
657- // Work around for Fluka VMC, which does not call
658- // MCApplication::PreTrack()
659- static Int_t TrackId = 0 ;
660- if (fMcVersion == 2 || fMC ->GetStack ()->GetCurrentTrackNumber () != TrackId) {
661- PreTrack ();
662- TrackId = fMC ->GetStack ()->GetCurrentTrackNumber ();
663- }
664-
665- // Check if the volume with id is in the volume multimap.
666- // If it is not in the map the volume is not a sensitive volume
667- // and we do not call nay of our ProcessHits functions.
668-
669- // If the volume is in the multimap, check in second step if the current
670- // copy is alredy inside the multimap.
671- // If the volume is not in the multimap add the copy of the volume to the
672- // multimap.
673- // In any case call the ProcessHits function for this specific detector.
674- Int_t copyNo;
675- Int_t id = fMC ->CurrentVolID (copyNo);
676- Bool_t InMap = kFALSE ;
677- fDisVol = 0 ;
678- fDisDet = 0 ;
679- Int_t fCopyNo = 0 ;
680- fVolIter = fVolMap .find (id);
681-
682- if (fVolIter != fVolMap .end ()) {
683-
684- // Call Process hits for FairVolume with this id, copyNo
685- do {
686- fDisVol = fVolIter ->second ;
687- fCopyNo = fDisVol ->getCopyNo ();
688- if (copyNo == fCopyNo ) {
689- fDisDet = fDisVol ->GetDetector ();
690- if (fDisDet ) {
691- fDisDet ->ProcessHits (fDisVol );
692- }
693- InMap = kTRUE ;
694- break ;
695- }
696- ++fVolIter ;
697- } while (fVolIter != fVolMap .upper_bound (id));
698-
699- // if (fDisVol && !InMap) { // fDisVolume is set previously, no check needed
700-
701- // Create new FairVolume with this id, copyNo.
702- // Use the FairVolume with the same id found in the map to get
703- // the link to the detector.
704- // Seems that this never happens (?)
705- if (!InMap) {
706- // cout << "Volume not in map; fDisVol ? " << fDisVol << endl
707- FairVolume* fNewV = new FairVolume (fMC ->CurrentVolName (), id);
708- fNewV ->setMCid (id);
709- fNewV ->setModId (fDisVol ->getModId ());
710- fNewV ->SetModule (fDisVol ->GetModule ());
711- fNewV ->setCopyNo (copyNo);
712- fVolMap .insert (pair<Int_t, FairVolume*>(id, fNewV ));
713- fDisDet = fDisVol ->GetDetector ();
714-
715- // LOG(info) << "FairMCApplication::Stepping: new fair volume"
716- // << id << " " << copyNo << " " << fDisDet;
717- if (fDisDet ) {
718- fDisDet ->ProcessHits (fNewV );
719- }
654+ Int_t copyNo = 0 ;
655+ Int_t id = 0 ;
656+
657+ // If information about the tracks should be stored the information as to be
658+ // stored for any step.
659+ // Information about each single step has also to be stored for the other
660+ // special run modes of the simulation which are used to store information
661+ // about
662+ // 1.) Radiation length in each volume
663+ // 2.) Energy deposition in each volume
664+ // 3.) Fluence of particles through a defined plane which can be anywhere
665+ // in the geometry. This plane has not to be correlated with any real
666+ // volume
667+ if (fTrajAccepted ) {
668+ if (fMC ->TrackStep () > fTrajFilter ->GetStepSizeCut ()) {
669+ fMC ->TrackPosition (fTrkPos );
670+ fTrajFilter ->GetCurrentTrk ()->AddPoint (fTrkPos .X (), fTrkPos .Y (), fTrkPos .Z (), fTrkPos .T ());
720671 }
721672 }
722-
673+ if (fRadLenMan ) {
674+ id = fMC ->CurrentVolID (copyNo);
675+ fModVolIter = fgMasterInstance->fModVolMap .find (id);
676+ fRadLenMan ->AddPoint (fModVolIter ->second );
677+ }
678+ if (fRadMapMan ) {
679+ id = fMC ->CurrentVolID (copyNo);
680+ fModVolIter = fgMasterInstance->fModVolMap .find (id);
681+ fRadMapMan ->AddPoint (fModVolIter ->second );
682+ }
683+ if (fRadGridMan ) {
684+ fRadGridMan ->FillMeshList ();
685+ }
686+
723687 // If information about the tracks should be stored the information as to be
724688 // stored for any step.
725689 // Information about each single step has also to be stored for the other
@@ -827,11 +791,6 @@ void FairMCApplication::FinishEvent()
827791 } else {
828792 fSaveCurrentEvent = kTRUE ;
829793 }
830-
831- for (auto detectorPtr : listActiveDetectors) {
832- detectorPtr->EndOfEvent ();
833- }
834-
835794 fStack ->Reset ();
836795 if (nullptr != fTrajFilter ) {
837796 fTrajFilter ->Reset ();
@@ -1480,4 +1439,19 @@ void FairMCApplication::UndoGeometryModifications()
14801439 gGeoManager ->ClearPhysicalNodes (kFALSE );
14811440}
14821441
1483- ClassImp (FairMCApplication);
1442+ void FairMCApplication::ConstructSensitiveDetectors ()
1443+ {
1444+ for (auto const & x : fMapSensitiveDetectors )
1445+ {
1446+ LOG (debug) << " FairMCApplication::ConstructSensitiveDetectors "
1447+ << x.first << " " << x.second ;
1448+ TVirtualMC::GetMC ()->SetSensitiveDetector (x.first , x.second );
1449+ }
1450+ }
1451+
1452+ void FairMCApplication::AddSensitiveModule (std::string volName, FairModule* module )
1453+ {
1454+ fMapSensitiveDetectors [volName] = module ;
1455+ }
1456+
1457+ ClassImp (FairMCApplication)
0 commit comments