@@ -210,3 +210,80 @@ void MCInterface::AddSurfaceStepCollection(REX::REveManager *&eveMng, bool first
210210 }
211211 }
212212}
213+
214+ void MCInterface::AddSimParticleCollection (REX::REveManager *&eveMng, bool firstloop, std::tuple<std::vector<std::string>, std::vector<const SimParticleCollection *>> sim_tuple, REX::REveElement* &scene, std::vector<int > particleIds, bool extracted){
215+ std::cout<<" [ REveMCInterface::AddSimParticleCollection() ]" <<std::endl;
216+ std::vector<const SimParticleCollection*> sim_list = std::get<1 >(sim_tuple);
217+ std::vector<std::string> names = std::get<0 >(sim_tuple);
218+
219+ if (sim_list.size () !=0 ){
220+ for (unsigned int i=0 ; i < sim_list.size (); i++){
221+ std::string comptitle = " SimParticleCollection" + names[i];
222+
223+ // make compund object to store hits
224+ std::string drawfilename (" EventDisplay/config/drawutils.txt" );
225+ SimpleConfig drawconfig (drawfilename);
226+
227+ // eXtract the track and input tag:
228+ std::vector<const SimParticleCollection*> sim_list = std::get<1 >(sim_tuple);
229+ std::vector<std::string> names = std::get<0 >(sim_tuple);
230+
231+ // Loop over SimParticle
232+ // for(unsigned int j=0; j< sim_list.size(); j++){
233+ const SimParticleCollection* simcol = sim_list[i];
234+
235+ if (simcol!=0 ){
236+ auto SimCollection = new REX::REveCompound (" SimParticles" ," SimParticles" ,1 );
237+ for ( auto const & simpair : *simcol) {
238+ // Check user defined list of particles to plot
239+ const mu2e::SimParticle& simpart = simpair.second ;
240+ auto pdgid = simpart.pdgId ();
241+ auto startCode = simpart.creationCode ().name () ;
242+ auto stopCode = simpart.stoppingCode ().name () ;
243+ int x = Contains (particleIds,pdgid);
244+ GeomHandle<DetectorSystem> det;
245+
246+
247+ if (x == 1 ){
248+ // Make label
249+ // std::string momentum = 0;//std::to_string(simpart.startMomentum().R());
250+ std::string edep = std::to_string (simpart.endKineticEnergy ());
251+ CLHEP::Hep3Vector StartPos = det->toDetector (simpart.startPosition ());
252+ CLHEP::Hep3Vector EndPos = det->toDetector (simpart.endPosition ());
253+ double momentum = sqrt (simpart.startMomentum ().x ()*simpart.startMomentum ().x ()+simpart.startMomentum ().y ()*simpart.startMomentum ().y () + simpart.startMomentum ().z ()*simpart.startMomentum ().z ());
254+ std::string mctitle_start = " SimParticle PDGid " + std::to_string (simpart.pdgId ()) + ' \n '
255+ + " Creation code " + (startCode) + " Stopping code " + (stopCode) + ' \n '
256+ + " Start Position: " + ' \n '
257+ + " x " + std::to_string (StartPos.x ())
258+ + " y " + std::to_string (StartPos.y ())
259+ + " z " + std::to_string (StartPos.z ())
260+ + " time :" + std::to_string (simpart.startGlobalTime () )+ ' \n '
261+ + " Start Momentum " + std::to_string (momentum) + " Start Energy " + std::to_string (simpart.startMomentum ().e ()) + ' \n '
262+ + " End Position: " + ' \n '
263+ + " x " + std::to_string ( EndPos.x ())
264+ + " y " + std::to_string ( EndPos.y ())
265+ + " z " + std::to_string ( EndPos.z ())
266+ + " time :" + std::to_string (simpart.endGlobalTime () );
267+
268+ // add point
269+
270+ // add point
271+ // auto simpoint_start = new REX::REvePointSet(mctitle_start,mctitle_start,1);
272+ // create line with the above label
273+ auto simpart_line = new REX::REveLine (mctitle_start,mctitle_start,1 );
274+ simpart_line->SetNextPoint (pointmmTocm (StartPos.x ()), pointmmTocm (StartPos.y ()),pointmmTocm (StartPos.z ()));
275+ simpart_line->SetNextPoint (pointmmTocm (EndPos.x ()), pointmmTocm (EndPos.y ()),pointmmTocm (EndPos.z ()));
276+ // set line colour
277+ SetLineColorPID (pdgid, simpart_line );
278+ simpart_line->SetLineWidth (drawconfig.getInt (" TrackLineWidth" ));
279+ SimCollection->AddElement (simpart_line);
280+
281+
282+ }
283+ // }
284+ }
285+ scene->AddElement (SimCollection);
286+ }
287+ }
288+ }
289+ }
0 commit comments