FairPipe.cxx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Generated by Together */
  2. #include "FairPipe.h"
  3. #include "FairGeoLoader.h"
  4. #include "FairGeoInterface.h"
  5. #include "FairGeoPipe.h"
  6. #include "FairGeoRootBuilder.h"
  7. #include "FairGeoNode.h"
  8. #include "FairRuntimeDb.h"
  9. #include "FairGeoPassivePar.h"
  10. #include "TObjArray.h"
  11. #include "FairRun.h"
  12. #include "FairGeoVolume.h" // for FairGeoVolume
  13. #include <stddef.h> // for NULL
  14. #include <iostream> // for operator<<, basic_ostream, etc
  15. FairPipe::~FairPipe()
  16. {
  17. }
  18. FairPipe::FairPipe()
  19. {
  20. }
  21. FairPipe::FairPipe(const char * name, const char * title)
  22. : FairModule(name ,title)
  23. {
  24. }
  25. void FairPipe::ConstructGeometry()
  26. {
  27. TString fileName=GetGeometryFileName();
  28. if (fileName.EndsWith(".geo")) {
  29. ConstructASCIIGeometry();
  30. } else if(fileName.EndsWith(".root")) {
  31. ConstructRootGeometry();
  32. } else {
  33. std::cout<< "Geometry format not supported " <<std::endl;
  34. }
  35. }
  36. void FairPipe::ConstructASCIIGeometry(){
  37. FairGeoLoader *loader=FairGeoLoader::Instance();
  38. FairGeoInterface *GeoInterface =loader->getGeoInterface();
  39. FairGeoPipe *MGeo=new FairGeoPipe();
  40. MGeo->setGeomFile(GetGeometryFileName());
  41. GeoInterface->addGeoModule(MGeo);
  42. Bool_t rc = GeoInterface->readSet(MGeo);
  43. if ( rc ) MGeo->create(loader->getGeoBuilder());
  44. TList* volList = MGeo->getListOfVolumes();
  45. // store geo parameter
  46. FairRun *fRun = FairRun::Instance();
  47. FairRuntimeDb *rtdb= FairRun::Instance()->GetRuntimeDb();
  48. FairGeoPassivePar* par=(FairGeoPassivePar*)(rtdb->getContainer("FairGeoPassivePar"));
  49. TObjArray *fSensNodes = par->GetGeoSensitiveNodes();
  50. TObjArray *fPassNodes = par->GetGeoPassiveNodes();
  51. TListIter iter(volList);
  52. FairGeoNode* node = NULL;
  53. FairGeoVolume *aVol=NULL;
  54. while( (node = (FairGeoNode*)iter.Next()) ) {
  55. aVol = dynamic_cast<FairGeoVolume*> ( node );
  56. if ( node->isSensitive() ) {
  57. fSensNodes->AddLast( aVol );
  58. }else{
  59. fPassNodes->AddLast( aVol );
  60. }
  61. }
  62. ProcessNodes( volList );
  63. par->setChanged();
  64. par->setInputVersion(fRun->GetRunId(),1);
  65. }
  66. ClassImp(FairPipe)