/* Generated by Together */ #include "CbmMagnet.h" #include "CbmGeoMagnet.h" #include "CbmGeoPassivePar.h" #include "FairGeoLoader.h" #include "FairGeoInterface.h" #include "FairRuntimeDb.h" #include "FairRun.h" #include "FairGeoVolume.h" #include "FairGeoNode.h" #include "TList.h" #include "TObjArray.h" #include "TGeoMatrix.h" CbmMagnet::CbmMagnet() : CbmModule("CbmMagnet", "CbmMagnet"), frot(NULL), fposrot(NULL) { } CbmMagnet::CbmMagnet(const char *name, const char *title, Double_t px, Double_t py, Double_t pz, Double_t rx, Double_t ry, Double_t rz) : CbmModule(name, title), frot(new TGeoRotation("", rx, ry, rz)), fposrot(new TGeoCombiTrans(px, py, pz, frot)) { } CbmMagnet::~CbmMagnet() { } void CbmMagnet::ConstructGeometry() { TString fileName=GetGeometryFileName(); if (fileName.EndsWith(".root")) { LOG(info) << "Constructing MAGNET from ROOT file " << fileName.Data(); // Quick and dirty fix: The top magnet volume of magnet_v18a is centred // at the origin of the GCS. It has to be shifted by 40 cm downstream // (centre coordinates (0, 0, 40) cm) in order to be at the proper place. // TODO: We have to urgently find a convention, such that this is not arbitrary. if ( fileName.Contains("magnet_v18a.geo.root") ) { LOG(info) << "Magnet with shift 40 cm"; TGeoTranslation* trans = new TGeoTranslation(); trans->SetTranslation(0., 0., 40.); ConstructRootGeometry(trans); } //? v18a // Similar fix for v18b (for muon setup, without field clamps). This // geometry is internally shifted by 80 cm downstream (along z). It has // thus to be shifted by -40 cm in z to be in the proper position. else if ( fileName.Contains("magnet_v18b.geo.root") ) { LOG(info) << "Constructing magnet with shift -40 cm"; TGeoTranslation* trans = new TGeoTranslation(); trans->SetTranslation(0., 0., -40.); ConstructRootGeometry(trans); } //? v18b else ConstructRootGeometry(); //? not v18a or v18b; no explicite shift } else if (fileName.EndsWith(".geo")) { LOG(info) << "Constructing MAGNET from ASCII file " << fileName.Data(); ConstructASCIIGeometry(); } else if (fileName.EndsWith(".gdml")) { LOG(info) << "Constructing MAGNET from GDML file " << fileName.Data(); ConstructGDMLGeometry(fposrot); } else { LOG(fatal) << "Geometry format of MAGNET file " << fileName.Data() << " not supported."; } } void CbmMagnet::ConstructASCIIGeometry() { FairGeoLoader *loader=FairGeoLoader::Instance(); FairGeoInterface *GeoInterface =loader->getGeoInterface(); CbmGeoMagnet *MGeo=new CbmGeoMagnet(); MGeo->setGeomFile(GetGeometryFileName()); GeoInterface->addGeoModule(MGeo); Bool_t rc = GeoInterface->readSet(MGeo); if ( rc ) MGeo->create(loader->getGeoBuilder()); TList* volList = MGeo->getListOfVolumes(); // store geo parameter FairRun *fRun = FairRun::Instance(); FairRuntimeDb *rtdb= FairRun::Instance()->GetRuntimeDb(); CbmGeoPassivePar* par=(CbmGeoPassivePar*)(rtdb->getContainer("CbmGeoPassivePar")); TObjArray *fSensNodes = par->GetGeoSensitiveNodes(); TObjArray *fPassNodes = par->GetGeoPassiveNodes(); TListIter iter(volList); FairGeoNode* node = NULL; FairGeoVolume *aVol=NULL; while( (node = (FairGeoNode*)iter.Next()) ) { aVol = dynamic_cast ( node ); if ( node->isSensitive() ) { fSensNodes->AddLast( aVol ); }else{ fPassNodes->AddLast( aVol ); } } ProcessNodes( volList ); par->setChanged(); par->setInputVersion(fRun->GetRunId(),1); } Bool_t CbmMagnet::CheckIfSensitive(std::string) { // There are no sensitive volumes in the magnet return kFALSE; } ClassImp(CbmMagnet)