#include <Types.h>
Collaboration diagram for GenParticleType:
Public Member Functions | |
virtual std::string | name () const |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
virtual Lib::IIterator * | iterator () |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
virtual Lib::Variable | value (Lib::Identifier, const std::string &, void *) |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
virtual void | visualize (Lib::Identifier, void *) |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
GenParticleType (IParticlePropertySvc *, IDataProviderSvc *, IUserInterfaceSvc *) | |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
Static Public Member Functions | |
static void | represent (HepMC::GenParticle *, ISession *, SoRegion *, IParticlePropertySvc *) |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
static void | representDecay (HepMC::GenParticle *, ISession *, SoRegion *, IParticlePropertySvc *) |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
Private Member Functions | |
void | clear () |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// | |
Private Attributes | |
std::string | fType |
IParticlePropertySvc * | fParticlePropertySvc |
IDataProviderSvc * | fDataProviderSvc |
IUserInterfaceSvc * | fUISvc |
Definition at line 16 of file Types.h.
GenParticleType::GenParticleType | ( | IParticlePropertySvc * | , | |
IDataProviderSvc * | , | |||
IUserInterfaceSvc * | ||||
) |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Definition at line 43 of file Types.cpp.
00048 :OnX::BaseType(aUISvc->printer()) 00049 ,fType("GenParticle") 00050 ,fParticlePropertySvc(aParticlePropertySvc) 00051 ,fDataProviderSvc(aDataProviderSvc) 00052 ,fUISvc(aUISvc) 00055 { 00056 addProperty("particle",Lib::Property::STRING); 00057 addProperty("barcode",Lib::Property::INTEGER); 00058 addProperty("pdg_id",Lib::Property::INTEGER); 00059 addProperty("energy",Lib::Property::DOUBLE); 00060 addProperty("pt",Lib::Property::DOUBLE); 00061 addProperty("charge",Lib::Property::DOUBLE,6); 00062 addProperty("beg_vtx",Lib::Property::BOOLEAN); 00063 addProperty("end_vtx",Lib::Property::BOOLEAN); 00064 addProperty("beg_vtx_d",Lib::Property::DOUBLE); 00065 addProperty("end_vtx_d",Lib::Property::DOUBLE); 00066 addProperty("beg_vtx_barcode",Lib::Property::INTEGER); 00067 addProperty("end_vtx_barcode",Lib::Property::INTEGER); 00068 }
std::string GenParticleType::name | ( | ) | const [virtual] |
Lib::IIterator * GenParticleType::iterator | ( | ) | [virtual] |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Definition at line 77 of file Types.cpp.
00081 { 00082 if(!fDataProviderSvc) return 0; 00083 SmartDataPtr<DataObject> 00084 smartDataObject(fDataProviderSvc,"/Event/McEventCollection"); 00085 if(smartDataObject) {} 00086 DataObject* dataObject = 0; 00087 StatusCode sc = 00088 fDataProviderSvc->retrieveObject("/Event/Gen/HepMCEvents", dataObject); 00089 if(!sc.isSuccess()) return 0; 00090 LHCb::HepMCEvents* mcEvents = dynamic_cast<LHCb::HepMCEvents*>(dataObject); 00091 if(!mcEvents) return 0; 00092 00093 class Iterator : public Lib::IIterator { 00094 public: //Lib::IIterator 00095 virtual Lib::Identifier object() { 00096 if(fIterator==fEvent.particles_end()) return 0; 00097 return *fIterator; 00098 } 00099 virtual void next() { ++fIterator;} 00100 virtual void* tag() { return 0;} 00101 public: 00102 Iterator(HepMC::GenEvent& aEvent):fEvent(aEvent) { 00103 fIterator = fEvent.particles_begin(); 00104 } 00105 private: 00106 HepMC::GenEvent& fEvent; 00107 HepMC::GenEvent::particle_const_iterator fIterator; 00108 }; 00109 00110 LHCb::HepMCEvents::iterator it; 00111 for(it=mcEvents->begin();it!=mcEvents->end();it++) { 00112 // In principle we should have only one McEvent : 00113 HepMC::GenEvent* genEvent = (*it)->pGenEvt(); 00114 return new Iterator(*genEvent); 00115 } 00116 return 0; 00117 }
Lib::Variable GenParticleType::value | ( | Lib::Identifier | , | |
const std::string & | , | |||
void * | ||||
) | [virtual] |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Definition at line 119 of file Types.cpp.
00126 { 00127 HepMC::GenParticle* obj = (HepMC::GenParticle*)aIdentifier; 00128 if(aName=="id") { 00129 return Lib::Variable(printer(),(void*)obj); 00130 } else if(aName=="particle") { 00131 if(fParticlePropertySvc) { 00132 ParticleProperty* pp = 00133 fParticlePropertySvc->findByStdHepID((int)obj->pdg_id()); 00134 if(pp) return Lib::Variable(printer(),pp->particle()); 00135 } 00136 return Lib::Variable(printer(),std::string("nil")); 00137 } else if(aName=="barcode") { 00138 return Lib::Variable(printer(),obj->barcode()); 00139 } else if(aName=="pdg_id") { 00140 return Lib::Variable(printer(),(int)(obj->pdg_id())); 00141 } else if(aName=="energy") { 00142 return Lib::Variable(printer(),obj->momentum().e()); 00143 } else if(aName=="pt") { 00144 double px = obj->momentum().px(); 00145 double py = obj->momentum().py(); 00146 return Lib::Variable(printer(),sqrt(px*px+py*py)); 00147 } else if(aName=="charge") { 00148 if(fParticlePropertySvc) { 00149 ParticleProperty* pp = 00150 fParticlePropertySvc->findByStdHepID((int)obj->pdg_id()); 00151 if(pp) return Lib::Variable(printer(),pp->charge()); 00152 } 00153 return Lib::Variable(printer(),0.); 00154 00155 } else if(aName=="beg_vtx_barcode") { 00156 HepMC::GenVertex* v = obj->production_vertex(); 00157 return Lib::Variable(printer(),v? v->barcode() : 0); 00158 } else if(aName=="end_vtx_barcode") { 00159 HepMC::GenVertex* v = obj->end_vertex(); 00160 return Lib::Variable(printer(),v? v->barcode() : 0); 00161 } else if(aName=="beg_vtx") { 00162 HepMC::GenVertex* v = obj->production_vertex(); 00163 return Lib::Variable(printer(),v?true:false); 00164 } else if(aName=="beg_vtx_d") { 00165 HepMC::GenVertex* v = obj->production_vertex(); 00166 if(v) return Lib::Variable(printer(),v->point3d().r()); 00167 return Lib::Variable(printer(),0.); 00168 } else if(aName=="end_vtx") { 00169 HepMC::GenVertex* v = obj->end_vertex(); 00170 return Lib::Variable(printer(),v?true:false); 00171 } else if(aName=="end_vtx_d") { 00172 HepMC::GenVertex* v = obj->end_vertex(); 00173 if(v) return Lib::Variable(printer(),v->point3d().r()); 00174 return Lib::Variable(printer(),0.); 00175 00176 /* 00177 } else if(aName=="bx") { 00178 HepMC::GenVertex* v = obj->production_vertex(); 00179 if(v) return Lib::Variable(printer(),v->point3d().x()); 00180 return Lib::Variable(printer(),0.); 00181 } else if(aName=="by") { 00182 HepMC::GenVertex* v = obj->production_vertex(); 00183 if(v) return Lib::Variable(printer(),v->point3d().y()); 00184 return Lib::Variable(printer(),0.); 00185 } else if(aName=="bz") { 00186 HepMC::GenVertex* v = obj->production_vertex(); 00187 if(v) return Lib::Variable(printer(),v->point3d().z()); 00188 return Lib::Variable(printer(),0.); 00189 00190 } else if(aName=="ex") { 00191 HepMC::GenVertex* v = obj->end_vertex(); 00192 if(v) return Lib::Variable(printer(),v->point3d().x()); 00193 return Lib::Variable(printer(),0.); 00194 } else if(aName=="ey") { 00195 HepMC::GenVertex* v = obj->end_vertex(); 00196 if(v) return Lib::Variable(printer(),v->point3d().y()); 00197 return Lib::Variable(printer(),0.); 00198 } else if(aName=="ez") { 00199 HepMC::GenVertex* v = obj->end_vertex(); 00200 if(v) return Lib::Variable(printer(),v->point3d().z()); 00201 return Lib::Variable(printer(),0.); 00202 } else if(aName=="ed") { 00203 HepMC::GenVertex* v = obj->end_vertex(); 00204 if(v) return Lib::Variable(printer(),v->point3d().r()); 00205 return Lib::Variable(printer(),0.); 00206 */ 00207 00208 } else { 00209 return Lib::Variable(printer()); 00210 } 00211 }
void GenParticleType::visualize | ( | Lib::Identifier | , | |
void * | ||||
) | [virtual] |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Definition at line 213 of file Types.cpp.
00219 { 00220 if(!aIdentifier) return; 00221 if(!fUISvc) return; 00222 SoRegion* soRegion = fUISvc->currentSoRegion(); 00223 if(!soRegion) return; 00224 00225 ISession* session = fUISvc->session(); 00226 std::string value; 00227 bool showDecay = false; 00228 if(session->parameterValue("modeling.showDecay",value)) 00229 Lib::smanip::tobool(value,showDecay); 00230 00231 if(showDecay) 00232 representDecay((HepMC::GenParticle*)aIdentifier, 00233 session,soRegion,fParticlePropertySvc); 00234 else 00235 represent((HepMC::GenParticle*)aIdentifier, 00236 session,soRegion,fParticlePropertySvc); 00237 00238 }
void GenParticleType::represent | ( | HepMC::GenParticle * | , | |
ISession * | , | |||
SoRegion * | , | |||
IParticlePropertySvc * | ||||
) | [static] |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Definition at line 248 of file Types.cpp.
00256 { 00257 HepMC::GenVertex* pv = aGenParticle->production_vertex(); 00258 HepMC::GenVertex* ev = aGenParticle->end_vertex(); 00259 00260 if(!pv && !ev) return; 00261 00262 // Representation attributes : 00263 // Get color (default is grey (valid on black or white background) ): 00264 double r = 0.5, g = 0.5, b = 0.5; 00265 double hr = 1.0, hg = 1.0, hb = 0.0; 00266 std::string value; 00267 if(aSession->parameterValue("modeling.color",value)) 00268 Lib::smanip::torgb(value,r,g,b); 00269 if(aSession->parameterValue("modeling.highlightColor",value)) 00270 Lib::smanip::torgb(value,hr,hg,hb); 00271 double lineWidth = 0; 00272 if(aSession->parameterValue("modeling.lineWidth",value)) 00273 if(!Lib::smanip::todouble(value,lineWidth)) lineWidth = 0; 00274 00275 bool showText = false; 00276 aSession->parameterValue("modeling.showText",value); 00277 Lib::smanip::tobool(value,showText); 00278 //double sizeText = 0.05; 00279 //aSession->parameterValue("modeling.sizeText",value); 00280 //if(!Lib::smanip::todouble(value,sizeText)) sizeText = 0.05; 00281 aSession->parameterValue("modeling.posText",value); 00282 std::string posTextAtb = value=="" ? "medium" : value; 00283 00284 double scale = 1; 00285 aSession->parameterValue("modeling.scale",value); 00286 if(!Lib::smanip::todouble(value,scale)) scale = 1; 00287 00288 HepMC::ThreeVector* pb; 00289 HepMC::ThreeVector* pe; 00290 HepMC::ThreeVector* vect; 00291 if(!pv && ev) { 00292 pe->set(scale * ev->point3d().x(), 00293 scale * ev->point3d().y(), 00294 scale * ev->point3d().z()); 00295 vect->set(aGenParticle->momentum().px(), 00296 aGenParticle->momentum().py(), 00297 aGenParticle->momentum().pz()); 00298 double factor = 10000/vect->r(); 00299 pb->set( pe->x() - factor * vect->x(), 00300 pe->y() - factor * vect->y(), 00301 pe->z() - factor * vect->z()) ; 00302 } else if(pv && !ev) { 00303 pb->set(scale * pv->point3d().x(), 00304 scale * pv->point3d().y(), 00305 scale * pv->point3d().z()); 00306 vect->set(aGenParticle->momentum().px(), 00307 aGenParticle->momentum().py(), 00308 aGenParticle->momentum().pz()); 00309 double factor = 10000/vect->r(); 00310 pe->set( pb->x() + factor * vect->x(), 00311 pb->y() + factor * vect->y(), 00312 pb->z() + factor * vect->z()) ; 00313 } else { 00314 pb->set(scale * pv->point3d().x(), 00315 scale * pv->point3d().y(), 00316 scale * pv->point3d().z()); 00317 pe->set(scale * ev->point3d().x(), 00318 scale * ev->point3d().y(), 00319 scale * ev->point3d().z()); 00320 } 00321 00322 SoSeparator* separator = new SoSeparator; 00323 separator->setName("sceneGraph"); 00324 00325 // Material : 00326 SoHighlightMaterial* highlightMaterial = new SoHighlightMaterial; 00327 highlightMaterial->setName("highlight"); 00328 highlightMaterial->diffuseColor.setValue 00329 (SbColor((float)r,(float)g,(float)b)); 00330 highlightMaterial->highlightColor.setValue 00331 (SbColor((float)hr,(float)hg,(float)hb)); 00332 //highlightMaterial->transparency.setValue((float)transparency); 00333 separator->addChild(highlightMaterial); 00334 00335 // Build name : 00336 std::string s; 00337 Lib::smanip::printf(s,128,"GenParticle/0x%lx",(unsigned long)aGenParticle); 00338 SbName name(s.c_str()); 00339 00340 SoDrawStyle* drawStyle = new SoDrawStyle; 00341 drawStyle->style.setValue(SoDrawStyle::LINES); 00342 drawStyle->linePattern.setValue(0xFFFF); 00343 drawStyle->lineWidth.setValue((float)lineWidth); 00344 00345 SoLightModel* lightModel = new SoLightModel; 00346 lightModel->model = SoLightModel::BASE_COLOR; 00347 00348 SbVec3f points[2]; 00349 points[0].setValue((float)pb->x(),(float)pb->y(),(float)pb->z()); 00350 points[1].setValue((float)pe->x(),(float)pe->y(),(float)pe->z()); 00351 00352 // Text : 00353 if(showText) { 00354 SbVec3f textPoint; 00355 if(posTextAtb=="medium") { 00356 textPoint = (points[0] + points[1])/2; 00357 } else { 00358 double posText; 00359 if(Lib::smanip::todouble(posTextAtb,posText)) { 00360 SbVec3f direction = points[1]-points[0]; 00361 direction.normalize(); 00362 direction *= (float)posText; 00363 textPoint = points[0] + direction; 00364 } else { 00365 textPoint = (points[0] + points[1])/2; 00366 } 00367 } 00368 00369 SoSeparator* sepText = new SoSeparator; 00370 SoTransform* tsf = new SoTransform; 00371 tsf->translation.setValue(textPoint); 00372 00373 std::string partname = "nil"; 00374 ParticleProperty* pp = 00375 aParticlePropertySvc->findByStdHepID((int)aGenParticle->pdg_id()); 00376 if(pp) partname = pp->particle(); 00377 00378 SoFont* font = new SoFont(); 00379 font->name.setValue("times"); 00380 font->size.setValue(20.0F); 00381 00382 SoText2* text = new SoText2(); 00383 text->string.set1Value(0,partname.c_str()); 00384 text->setName(name); 00385 00386 sepText->addChild(tsf); 00387 sepText->addChild(font); 00388 sepText->addChild(text); 00389 00390 separator->addChild(sepText); 00391 } 00392 00393 separator->addChild(lightModel); 00394 separator->addChild(drawStyle); 00395 00396 float d = (points[1]-points[0]).length(); 00397 if(d<=0) { 00398 SoTranslation* translation = new SoTranslation; 00399 translation->translation = points[0]; 00400 separator->addChild(translation); 00401 00402 double radius = aGenParticle->momentum().e()/1000; 00403 //SbPolyhedron* sbPol = new SbPolyhedronSphere(0,radius,0,2* M_PI,0,M_PI); 00404 SbPolyhedron* sbPol = new SbPolyhedronBox(radius,radius,radius); 00405 SoPolyhedron* polyhedron = new SoPolyhedron(*sbPol); 00406 delete sbPol; 00407 polyhedron->setName(name); 00408 polyhedron->solid.setValue(FALSE); 00409 separator->addChild(polyhedron); 00410 } else { 00411 SoCoordinate3* coordinate3 = new SoCoordinate3; 00412 coordinate3->point.setValues(0,2,points); 00413 separator->addChild(coordinate3); 00414 00415 SoLineSet* lineSet = new SoLineSet; 00416 int32_t vertices = 2; 00417 lineSet->numVertices.setValues(0,1,&vertices); 00418 lineSet->setName(name); 00419 separator->addChild(lineSet); 00420 } 00421 00422 region_addToDynamicScene(*aRegion,separator); 00423 00424 }
void GenParticleType::representDecay | ( | HepMC::GenParticle * | , | |
ISession * | , | |||
SoRegion * | , | |||
IParticlePropertySvc * | ||||
) | [static] |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Definition at line 426 of file Types.cpp.
00434 { 00435 00436 // Daughters : 00437 HepMC::GenVertex* ev = aGenParticle->end_vertex(); 00438 if(!ev) return; 00439 HepMC::GenVertex::particle_iterator it; 00440 for(it=ev->particles_begin(HepMC::children); 00441 it!=ev->particles_end(HepMC::children);++it) { 00442 HepMC::GenParticle* particle = *it; 00443 if(particle) { 00444 represent(aGenParticle,aSession,aRegion,aParticlePropertySvc); 00445 00446 representDecay(particle,aSession,aRegion,aParticlePropertySvc); 00447 } 00448 } 00449 00450 }
void GenParticleType::clear | ( | ) | [private] |
std::string GenParticleType::fType [private] |
IUserInterfaceSvc* GenParticleType::fUISvc [private] |