void alignment_reset_dbg(const string& path, const Alignment& a) { TGeoPhysicalNode* n = a.ptr(); cout << " +++++++++++++++++++++++++++++++ " << path << endl; cout << " +++++ Misaligned physical node: " << endl; n->Print(); string np; if ( n->IsAligned() ) { for (Int_t i=0; i<=n->GetLevel(); i++) { TGeoMatrix* mm = n->GetNode(i)->GetMatrix(); np += "/"; np += n->GetNode(i)->GetName(); if ( mm->IsIdentity() ) continue; if ( i == 0 ) continue; TGeoHMatrix* glob = n->GetMatrix(i-1); NodeMap::const_iterator j=original_matrices.find(np); if ( j != original_matrices.end() && i!=n->GetLevel() ) { cout << " +++++ Patch Level: " << i << np << endl; *mm = *((*j).second); } else { if ( i==n->GetLevel() ) { cout << " +++++ Level: " << i << np << " --- Original matrix: " << endl; n->GetOriginalMatrix()->Print(); cout << " +++++ Level: " << i << np << " --- Local matrix: " << endl; mm->Print(); TGeoHMatrix* hm = dynamic_cast<TGeoHMatrix*>(mm); hm->SetTranslation(n->GetOriginalMatrix()->GetTranslation()); hm->SetRotation(n->GetOriginalMatrix()->GetRotationMatrix()); cout << " +++++ Level: " << i << np << " --- New local matrix" << endl; mm->Print(); } else { cout << " +++++ Level: " << i << np << " --- Keep matrix " << endl; mm->Print(); } } cout << " +++++ Level: " << i << np << " --- Global matrix: " << endl; glob->Print(); *glob *= *mm; cout << " +++++ Level: " << i << np << " --- New global matrix: " << endl; glob->Print(); } } cout << "\n\n\n +++++ physical node (full): " << np << endl; n->Print(); cout << " +++++ physical node (global): " << np << endl; n->GetMatrix()->Print(); }
//__________________________________________________________________________ Bool_t BuildFieldMap(const TGeoHMatrix& matrix) { // Create a Uniform Magnetic field and write it to file string filename = "runs/polarisation/guide_tube/C8=9 A +SQUIDs Coil =26_4 mA +D1=2 A + 6WS TC guide tube -100 z +80 cm.txt"; // Define shape of field TGeoShape* magFieldShape = new Box("FieldShape",0.031, 0.031, 3.0); // Define transformation that locates field in geometry TGeoMatrix* magFieldPosition = new TGeoHMatrix(matrix); magFieldPosition->Print(); MagFieldMap* field = new MagFieldMap("Field", magFieldShape, magFieldPosition); if (field->BuildMap(filename) == kFALSE) { Error("BuildFieldMap","Cannot open file: %s", filename); return kFALSE; } // Add field to magfield manager MagFieldArray* magFieldArray = new MagFieldArray(); magFieldArray->AddField(field); /* // Elec Field // Define shape of field TGeoShape* elecFieldShape = new Tube("SolenoidFieldShape",hvCellRMin, hvCellRMax, hvCellHalfZ); // Define transformation that locates field in geometry TGeoMatrix* elecFieldPosition = new TGeoHMatrix(matrix); TVector3 elecFieldStrength(hvCellEx, hvCellEy, hvCellEz); ElecField* elecField = new UniformElecField("ElectricField", elecFieldStrength, elecFieldShape, elecFieldPosition); // Add field to electric field manager ElecFieldArray* elecFieldArray = new ElecFieldArray(); elecFieldArray->AddField(elecField); */ // -- Write magfieldmanager to geometry file const char *magFileName = "geom/fields.root"; TFile *f = TFile::Open(magFileName,"recreate"); if (!f || f->IsZombie()) { Error("BuildFieldMap","Cannot open file: %s", magFileName); return kFALSE; } magFieldArray->Write(magFieldArray->GetName()); // elecFieldArray->Write(elecFieldArray->GetName()); f->ls(); f->Close(); delete magFieldArray; // delete elecFieldArray; magFieldArray = 0; // elecFieldArray = 0; return kTRUE; }