示例#1
0
void KVSpectroDetector::UpdateVolumeAndNodeNames(){
	// Update the names of Volumes and the names of the Nodes of this
	// detector.
	// The name of the volume representing the detector (returned
	// by GetAbsGeoVolume()) is DET_<detector name>. 
	// The name of the active volumes is ACTIVE_<detector name>_<material name>.
	// The name of the other volumes is <detector name>_<material name>.

	GetAbsGeoVolume()->SetName( Form("DET_%s", GetName() ) );
	TObjArray  *nodes = GetAbsGeoVolume()->GetNodes();
	TGeoNode   *node  = NULL;
	TGeoVolume *vol   = NULL;

	TIter next( nodes );
	while( (node = (TGeoNode *)next()) ){
		TString name, nname;
		vol = node->GetVolume();
		name.Form("%s_%s", GetName(), vol->GetMaterial()->GetName());
		if( GetActiveVolumes()->Contains( vol ) )
			name.Prepend("ACTIVE_");
		vol->SetName( name.Data() );
		nname = name;
		Int_t i=0;
		while( nodes->FindObject( nname.Data() ) )
			nname.Form("%s_%d",name.Data(), ++i);
		node->SetName( nname.Data() );
		node->SetNumber( i );
	}
}