FairTarget.cxx 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /********************************************************************************
  2. * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
  3. * *
  4. * This software is distributed under the terms of the *
  5. * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
  6. * copied verbatim in the file "LICENSE" *
  7. ********************************************************************************/
  8. /* Generated by Together */
  9. #include "FairTarget.h"
  10. #include "FairGeoInterface.h" // for FairGeoInterface
  11. #include "FairGeoLoader.h" // for FairGeoLoader
  12. #include "FairGeoNode.h" // for FairGeoNode
  13. #include "FairGeoPassivePar.h" // for FairGeoPassivePar
  14. #include "FairGeoTarget.h" // for FairGeoTarget
  15. #include "FairGeoVolume.h" // for FairGeoVolume
  16. #include "FairRun.h" // for FairRun
  17. #include "FairRuntimeDb.h" // for FairRuntimeDb
  18. #include "TList.h" // for TListIter, TList (ptr only)
  19. #include "TObjArray.h" // for TObjArray
  20. #include "TString.h" // for TString
  21. #include <stddef.h> // for NULL
  22. FairTarget::~FairTarget()
  23. {
  24. }
  25. FairTarget::FairTarget()
  26. : FairModule("FairTarget", "")
  27. {
  28. }
  29. FairTarget::FairTarget(const char* name, const char* title)
  30. : FairModule(name ,title)
  31. {
  32. }
  33. void FairTarget::ConstructGeometry()
  34. {
  35. FairGeoLoader* loader=FairGeoLoader::Instance();
  36. FairGeoInterface* GeoInterface =loader->getGeoInterface();
  37. FairGeoTarget* MGeo=new FairGeoTarget();
  38. MGeo->setGeomFile(GetGeometryFileName());
  39. GeoInterface->addGeoModule(MGeo);
  40. Bool_t rc = GeoInterface->readSet(MGeo);
  41. if ( rc ) { MGeo->create(loader->getGeoBuilder()); }
  42. TList* volList = MGeo->getListOfVolumes();
  43. // store geo parameter
  44. FairRun* fRun = FairRun::Instance();
  45. FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb();
  46. FairGeoPassivePar* par=static_cast<FairGeoPassivePar*>(rtdb->getContainer("FairGeoPassivePar"));
  47. TObjArray* fSensNodes = par->GetGeoSensitiveNodes();
  48. TObjArray* fPassNodes = par->GetGeoPassiveNodes();
  49. TListIter iter(volList);
  50. FairGeoNode* node = NULL;
  51. FairGeoVolume* aVol=NULL;
  52. while( (node = static_cast<FairGeoNode*>(iter.Next())) ) {
  53. aVol = dynamic_cast<FairGeoVolume*> ( node );
  54. if ( node->isSensitive() ) {
  55. fSensNodes->AddLast( aVol );
  56. } else {
  57. fPassNodes->AddLast( aVol );
  58. }
  59. }
  60. ProcessNodes( volList );
  61. par->setChanged();
  62. par->setInputVersion(fRun->GetRunId(),1);
  63. }
  64. ClassImp(FairTarget)