void KVGeoImport::ImportGeometry(Double_t dTheta, Double_t dPhi, Double_t ThetaMin, Double_t PhiMin, Double_t ThetaMax, Double_t PhiMax) { // Scan the geometry in order to find all detectors and detector alignments. // This is done by sending out "particles" from (0,0,0) in all directions between // (ThetaMin,ThetaMax) - with respect to Z-axis - and (PhiMin,PhiMax) - cylindrical // angle in the (X,Y)-plane, over a grid of step dTheta in Theta and dPhi in Phi. KVEvent* evt = new KVEvent(); KVNucleus* nuc = evt->AddParticle(); nuc->SetZAandE(1,1,1); Double_t theta,phi; Int_t count=0; // note that ImportGeometry can be called for a KVMultiDetArray // which already contains detectors, groups and id telescopes fGroupNumber=fArray->GetStructureTypeList("GROUP")->GetEntries(); Int_t ndets0 = fArray->GetDetectors()->GetEntries(); Int_t idtels0 = fArray->GetListOfIDTelescopes()->GetEntries(); for(theta=ThetaMin; theta<=ThetaMax; theta+=dTheta){ for(phi=PhiMin; phi<=PhiMax; phi+=dPhi){ nuc->SetTheta(theta); nuc->SetPhi(phi); fCurrentGroup = 0; fLastDetector = 0; PropagateEvent(evt); count++; } } // make sure detector nodes are correct TIter next(fArray->GetDetectors()); KVDetector*d; while( (d=(KVDetector*)next()) ) d->GetNode()->RehashLists(); // set up all detector node trajectories //fArray->CalculateGeoNodeTrajectories(); if(fCreateArray){ fArray->SetGeometry(GetGeometry()); KVGeoNavigator* nav = fArray->GetNavigator(); nav->SetDetectorNameFormat(fDetNameFmt); for(register int i=0; i<fStrucNameFmt.GetEntries(); i++){ KVNamedParameter* fmt = fStrucNameFmt.GetParameter(i); nav->SetStructureNameFormat(fmt->GetName(), fmt->GetString()); } nav->SetNameCorrespondanceList(fDetStrucNameCorrespList); fArray->CalculateDetectorSegmentationIndex(); } Info("ImportGeometry", "Tested %d directions - Theta=[%f,%f:%f] Phi=[%f,%f:%f]",count,ThetaMin,ThetaMax,dTheta,PhiMin,PhiMax,dPhi); Info("ImportGeometry", "Imported %d detectors into array", fArray->GetDetectors()->GetEntries()-ndets0); if(fCreateArray){ fArray->CreateIDTelescopesInGroups(); Info("ImportGeometry", "Created %d identification telescopes in array", fArray->GetListOfIDTelescopes()->GetEntries()-idtels0); } }
void KVNameValueList::SetValue(const KVNamedParameter& p) { // add (or replace) a parameter with the same name, type & value as 'p' KVNamedParameter* par = FindParameter(p.GetName()); par ? par->Set(p.GetName(), p) : fList.Add(new KVNamedParameter(p)); }
void KVVAMOSDetector::SetT0(const Char_t* type, Double_t t0) { // Set the value of the constant T0 (in ns) used for calibrating // time of flight of type 'type' (SED_HF, SI_HF, SI_SED1, ...). KVNamedParameter* par = (KVNamedParameter*)fT0list->FindObject(Form("T%s", type)); if (par) par->Set(t0); else Error("SetT0", "Impossible to set T0 for unknown time ACQ parameter %s", type); }
Double_t KVVAMOSDetector::GetT0(const Char_t* type) const { // Returns the value of the constant T0 (in ns) used for calibrating // time of flight of type 'type' (SED_HF, SI_HF, SI_SED1, ...). if (!fT0list) return 0.; KVNamedParameter* par = (KVNamedParameter*)fT0list->FindObject(Form("T%s", type)); return (par ? par->GetDouble() : 0); }
void KVNameValueList::AddValue(const KVNamedParameter& p) { // if a parameter with the same name & type as 'p' exists, // add numerical value of p to value of parameter in list, // or for strings we add to a comma-separated list of strings. // otherwise, add a copy of p to list KVNamedParameter* par = FindParameter(p.GetName()); par ? par->Add(p) : fList.Add(new KVNamedParameter(p)); }
//______________________________________________ TString KVNameValueList::GetTStringValue(const Char_t* name) const { //return the value in TString format //for a parameter using its name //return string "-1" if no parameter with such name are present KVNamedParameter* par = FindParameter(name); if (!par) { Error("GetStringValue(const Char_t*)", "\"%s\" does not correspond to an existing parameter, default value \"-1\" is returned", name); return "-1"; } return par->GetTString(); }
void KVClassFactory::AddGetSetMethods(const KVNameValueList& nvl) { // For each named parameter in the list, we add protected member variables and // public Get/Set methods with the name and type of the parameter. // Example: given a list containing NAME="some string" NUMBER=3 [integer] // PI=3.141592 [double], we generate the methods // void SetNAME(const TString&); // const TString& GetNAME() const; // void SetNUMBER(Int_t); // Int_t GetNUMBER() const; // void SetPI(Double_t); // Double_t GetPI() const; int npars = nvl.GetNpar(); for(int i=0; i<npars; i++){ KVNamedParameter* par = nvl.GetParameter(i); if(par->IsString()){ KVClassMember* v = AddMember(par->GetName(),"TString","member automatically generated by KVClassFactory::AddGetSetMethods"); KVClassMethod* m = AddMethod(Form("Set%s",par->GetName()), "void"); m->AddArgument("const TString&"); m->SetMethodBody( Form(" // Method automatically generated by KVClassFactory::AddGetSetMethods\n" "\n" " %s=arg1;", v->GetName()) ); m = AddMethod(Form("Get%s",par->GetName()), "const TString&", "public", kFALSE, kTRUE); m->SetMethodBody( Form(" // Method automatically generated by KVClassFactory::AddGetSetMethods\n" "\n" " return %s;", v->GetName()) ); // make sure #include "TString.h" appears in header file if( ! fHeadInc.FindObject("TString.h") ) AddHeaderIncludeFile("TString.h"); } else if(par->IsInt()){ KVClassMember* v = AddMember(par->GetName(),"Int_t","member automatically generated by KVClassFactory::AddGetSetMethods"); KVClassMethod* m = AddMethod(Form("Set%s",par->GetName()), "void"); m->AddArgument("Int_t"); m->SetMethodBody( Form(" // Method automatically generated by KVClassFactory::AddGetSetMethods\n" "\n" " %s=arg1;", v->GetName()) ); m = AddMethod(Form("Get%s",par->GetName()), "Int_t", "public", kFALSE, kTRUE); m->SetMethodBody( Form(" // Method automatically generated by KVClassFactory::AddGetSetMethods\n" "\n" " return %s;", v->GetName()) ); } else if(par->IsDouble()){ KVClassMember* v = AddMember(par->GetName(),"Double_t","member automatically generated by KVClassFactory::AddGetSetMethods"); KVClassMethod* m = AddMethod(Form("Set%s",par->GetName()), "void"); m->AddArgument("Double_t"); m->SetMethodBody( Form(" // Method automatically generated by KVClassFactory::AddGetSetMethods\n" "\n" " %s=arg1;", v->GetName()) ); m = AddMethod(Form("Get%s",par->GetName()), "Double_t", "public", kFALSE, kTRUE); m->SetMethodBody( Form(" // Method automatically generated by KVClassFactory::AddGetSetMethods\n" "\n" " return %s;", v->GetName()) ); } } }