void KVNameValueList::Merge(const KVNameValueList& other) { // Merge other list into this one. // Any parameters in 'other' which do not exist in this one are added. // Any parameters which exist in both have their values summed. for (int i = 0; i < other.GetNpar(); ++i) { KVNamedParameter* np_other = other.GetParameter(i); AddValue(*np_other); } }
//______________________________________________ Int_t KVNameValueList::Compare(const TObject* obj) const { // Compare the contents of two KVNameValueList // Returns the number of same parameters (name and value) KVNameValueList* nvl = (KVNameValueList*)obj; Int_t neq = 0; Int_t np1 = GetNpar(); Int_t np2 = nvl->GetNpar(); for (Int_t ii = 0; ii < np1; ii += 1) { for (Int_t jj = 0; jj < np2; jj += 1) { if (*(GetParameter(ii)) == *(GetParameter(jj))) neq += 1; } } return neq; }
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()) ); } } }
void KVINDRA_VAMOS::DetectEvent(KVEvent* event, KVReconstructedEvent* rec_event, const Char_t* detection_frame) { // the ROOT geometry can not be use for filtering SetROOTGeometry(kFALSE); // iterate through list of particles // and detect in VAMOS KVNucleus* part, *_part; KVNameValueList* nvl = NULL; Bool_t isVAMOSevent = kFALSE; static KVVAMOSReconEvent tmp_rec_vamos_event; tmp_rec_vamos_event.Clear(); while ((part = event->GetNextParticle())) { // loop over particles #ifdef KV_DEBUG cout << "DetectEvent(): looking at particle in VAMOS---->" << endl; part->Print(); #endif _part = (KVNucleus*)part->GetFrame(detection_frame, kFALSE); if (_part->GetTheta() > 14) continue; _part->SetE0(); Double_t eLostInTarget = 0; if (fTarget && (fFilterType != kFilterType_Geo)) { fTarget->SetOutgoing(kTRUE); //simulate passage through target material Double_t ebef = _part->GetKE(); fTarget->DetectParticle(_part); eLostInTarget = ebef - _part->GetKE(); if (_part->GetKE() < 1.e-3) { part->GetParameters()->SetValue("UNDETECTED", "STOPPED IN TARGET"); part->AddGroup("UNDETECTED"); part->AddGroup("STOPPED IN TARGET"); } fTarget->SetOutgoing(kFALSE); } if ((_part->GetKE() > 1.e-3) && (nvl = GetVAMOS()->DetectParticle(_part)) && (nvl->GetNpar() > 0)) { _part->SetMomentum(*_part->GetPInitial()); isVAMOSevent = kTRUE; KVVAMOSReconNuc* recon_nuc = (KVVAMOSReconNuc*)tmp_rec_vamos_event.AddParticle(); // copy parameter list part->GetParameters()->Copy(*(recon_nuc->GetParameters())); recon_nuc->SetZandA(part->GetZ(), part->GetA()); recon_nuc->SetMomentum(_part->GetMomentum()); recon_nuc->SetQ(_part->GetParameters()->GetIntValue("Q")); recon_nuc->SetBrho(_part->GetParameters()->GetDoubleValue("Brho")); recon_nuc->GetParameters()->SetValue("Delta", _part->GetParameters()->GetDoubleValue("Delta")); recon_nuc->SetThetaVandPhiV(_part->GetParameters()->GetDoubleValue("ThetaV"), _part->GetParameters()->GetDoubleValue("PhiV")); recon_nuc->GetParameters()->SetValue("DETECTED", "OK"); recon_nuc->SetTargetEnergyLoss(eLostInTarget); recon_nuc->SetIsIdentified(); recon_nuc->SetIsCalibrated(); recon_nuc->SetIsOK(); recon_nuc->SetZMeasured(); recon_nuc->SetQMeasured(); recon_nuc->SetAMeasured(); //recon_nuc->SetIsBasicQandAidentified(); // Clear this nucleus detected in VAMOS in order to inhibit the // its detection in INDRA part->Clear(); } else _part->SetMomentum(*_part->GetPInitial()); SafeDelete(nvl); } //fin de loop over particles // if a nucleus is detected in VAMOS then continue filtering the event in INDRA if (isVAMOSevent) { // Info("DetectEvent","event %d is a VAMOS event",event->GetNumber()); GetINDRA()->DetectEvent(event, rec_event, detection_frame); // Set the reconstructed nucleus detected in VAMOS in the VAMOS event KVVAMOSReconEvent* rec_vamos_event = ((KVIVReconEvent*)rec_event)->GetVAMOSEvent(); tmp_rec_vamos_event.Copy(*rec_vamos_event); // rec_event->Print(); } }