#include "IBeamlineCoordinates.hxx" #include "IBeamlineParameterExtractor.hxx" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using std::cout; using std::endl; double GetDensity(const double* point); std::ostream& operator<<(std::ostream& stream,const TVector3& vect){ stream<<"("< Set the number of points along the beam axis that should be checked.\n" " -H Set the maximum height above and below the beamline to sample.\n" " -d Set the transverse radial distance from the beam axis to scan along.\n" " -p Set the transverse azimuthal angle to the vertical to scan along (in radians).\n" " -o Set the output file name.\n" "\n" "Beamline Options: \n" " -b Set the beamline type.\n" " -B Set the beamline to match the geometry in the named file.\n" "Other Options: \n" " -I Load geometry and fieldmap from a root file. Equivalent to: -B -R \n" <>n_beamline_points; break; } case 'H': { stream>>top; break; } case 'p': { stream>>transverseAngle; break; } case 'd': { stream>>transverseDist; break; } case 'o': { stream>>outfilename; break; } case 'b': { std::string beam_type(optarg); if(beam_type=="g4bl_p2"){ COMETLog("Setting beamline to g4beamline phase-II parameters, (ie. default)"); }else if (beam_type=="111216"){ COMETLog("Setting beamline to phase-II parameters matching fields in 111216"); beamline.SetLength_prodTgtSec(4875); beamline.SetLength_Tor1_exit(800); }else if (beam_type=="150630_p1"){ COMETLog("Setting beamline to phase-I parameters matching fields in 150630"); beamline.SetPhase(1); beamline.SetLength_Tor1_exit(700); beamline.SetLength_prodTgtSec(5175); }else{ COMETError("Bad beamline specification: "<ls(); field_list->InitialiseField(); beamline.Initialise(); TFile* outfile=TFile::Open(outfilename.c_str(),"recreate"); const double length=beamline.GetTotalLength(); const double lengthPerbin=length/n_beamline_points; int binsUp=top/lengthPerbin; top=binsUp*lengthPerbin; COMETError(binsUp<<", "<GetFieldValue(global_arr,field_vectors); TVector3 field(field_vectors[0],field_vectors[1],field_vectors[2]); field*=1/unit::tesla; if(j==0){ //COMETError("Filling j==0 plots, i=="<Fill(point,field.Mag()); hLongitudinal->Fill(point,field.Dot(direction)); hVertical->Fill(point,field.Dot(vertical)); hHorizontal->Fill(point,field.Dot(horizontal)); outline->SetPoint(i,-global.X(),global.Z()); } hMagnitude2d->Fill( point, height, field.Mag() ); hVertical2d ->Fill( point, height, field.Dot(vertical) ); hLongitudinal2d->Fill( point, height, field.Dot(direction) ); hHorizontal2d->Fill( point, height, field.Dot(horizontal) ); if(gGeoManager){ const double density=GetDensity(global_arr); hGeometry->Fill(point,height,density); } } point+=beamline_step; } std::vector component_edges; beamline.GetComponentEnds(component_edges); double max=hMagnitude->GetMaximum(); for(auto i_comp=component_edges.begin(); i_comp!=component_edges.end(); ++i_comp){ TVector3 left=beamline.ToGlobalCoords(*i_comp,-100,TMath::Pi()/2); TVector3 right=beamline.ToGlobalCoords(*i_comp,100,TMath::Pi()/2); TLine* line=new TLine(-left.X(),left.Z(),-right.X(),right.Z()); outline->GetListOfFunctions()->Add(line); line=new TLine(*i_comp,0,*i_comp,max/2); hMarkers->GetListOfFunctions()->Add(line); } outline->SetLineWidth(2); outline->SetLineColor(kBlack); outline->Write("outline"); outfile->Write(); outfile->Close(); return 0; } double GetDensity(const double* point){ // Factors of 10 come from units in geometry being cm, not mm as used by // field const TGeoNode* node=gGeoManager->FindNode(point[0]/10,point[1]/10,point[2]/10); if(!node){ COMETDebug("No node, perhaps in the world volume?"); return -1; } const TGeoVolume* volume =node->GetVolume(); if(!volume){ COMETError("Node without a volume !"); return -1; } const TGeoMaterial* material =volume->GetMaterial(); return material->GetDensity(); }