1
2
3
4
5
6 package org.lcsim.util.heprep;
7
8 import hep.graphics.heprep.HepRepFactory;
9 import hep.graphics.heprep.HepRepInstance;
10 import hep.graphics.heprep.HepRepInstanceTree;
11 import hep.graphics.heprep.HepRepType;
12 import hep.graphics.heprep.HepRepTypeTree;
13 import java.awt.Color;
14 import java.util.List;
15 import org.lcsim.event.EventHeader;
16 import org.lcsim.event.EventHeader.LCMetaData;
17 import org.lcsim.fit.helicaltrack.HelicalTrack2DHit;
18 import org.lcsim.fit.helicaltrack.HelicalTrack3DHit;
19 import org.lcsim.fit.helicaltrack.HelicalTrackCross;
20 import org.lcsim.fit.helicaltrack.HelicalTrackHit;
21
22
23
24
25
26 public class HelicalTrackHitConverter implements HepRepCollectionConverter{
27
28 public boolean canHandle(Class k){
29 return HelicalTrackHit.class.isAssignableFrom(k);
30 }
31
32 public void convert (EventHeader event, List collection, HepRepFactory factory, HepRepTypeTree typeTree, HepRepInstanceTree instanceTree){
33
34 LCMetaData meta = event.getMetaData(collection);
35 String name = meta.getName();
36
37 HepRepType type3d = factory.createHepRepType(typeTree,name+"3d");
38 type3d.addAttValue("layer",LCSimHepRepConverter.HITS_LAYER);
39 type3d.addAttValue("drawAs","Point");
40 type3d.addAttValue("color",Color.ORANGE);
41 type3d.addAttValue("fill",true);
42 type3d.addAttValue("fillColor",Color.ORANGE);
43 type3d.addAttValue("MarkName","Box");
44 type3d.addAttDef("dEdx", "Hit dEdx", "physics", "");
45 type3d.addAttDef("time", "Hit time", "physics", "");
46 type3d.addAttDef("flagValue", "BarrelEndcapFlag value","physics","");
47 type3d.addAttDef("drphi", "Hit drphi", "physics","");
48 type3d.addAttDef("dr", "Hit dr", "physics","");
49 type3d.addAttDef("hit identifier", "Hit identifier", "physics", "");
50
51 HepRepType type2d = factory.createHepRepType(typeTree,name+"2d");
52 type2d.addAttValue("layer",LCSimHepRepConverter.HITS_LAYER);
53 type2d.addAttValue("drawAs","Line");
54 type2d.addAttValue("color",Color.ORANGE);
55 type2d.addAttDef("dEdx", "Hit dEdx", "physics", "");
56 type2d.addAttDef("time", "Hit time", "physics", "");
57 type2d.addAttDef("zmin", "Z min", "physics", "");
58 type2d.addAttDef("zmax", "Z max", "physics", "");
59 type2d.addAttDef("drphi", "Hit drphi", "physics","");
60 type2d.addAttDef("hit identifier", "Hit identifier", "physics", "");
61
62 HepRepType typeCenter = factory.createHepRepType(typeTree,name+"2dSegmentCenters");
63 typeCenter.addAttValue("layer",LCSimHepRepConverter.HITS_LAYER);
64 typeCenter.addAttValue("drawAs","Point");
65 typeCenter.addAttValue("color",Color.ORANGE);
66 typeCenter.addAttValue("fill",true);
67 typeCenter.addAttValue("fillColor",Color.ORANGE);
68 typeCenter.addAttValue("MarkName","Box");
69 typeCenter.addAttDef("dEdx", "Hit dEdx", "physics", "");
70 typeCenter.addAttDef("time", "Hit time", "physics", "");
71 typeCenter.addAttDef("drphi", "Hit drphi", "physics","");
72
73
74 for (HelicalTrackHit hit : (List<HelicalTrackHit>)collection){
75
76 double[] pos = hit.getPosition();
77
78 if (hit instanceof HelicalTrack3DHit || hit instanceof HelicalTrackCross) {
79 HepRepInstance instance = factory.createHepRepInstance(instanceTree,type3d);
80 instance.addAttValue("dEdx",hit.getdEdx());
81 instance.addAttValue("time",hit.getTime());
82 String flagValue;
83 if (hit instanceof HelicalTrack3DHit)
84 flagValue=((HelicalTrack3DHit)hit).BarrelEndcapFlag().toString();
85 else
86 flagValue=((HelicalTrackCross)hit).BarrelEndcapFlag().toString();
87 instance.addAttValue("flagValue",flagValue);
88 instance.addAttValue("drphi",hit.drphi());
89 instance.addAttValue("dr",hit.dr());
90 instance.addAttValue("hit identifier",hit.getLayerIdentifier());
91 factory.createHepRepPoint(instance, pos[0], pos[1], pos[2]);
92 }
93
94 else if (hit instanceof HelicalTrack2DHit){
95
96 HepRepInstance instance2d = factory.createHepRepInstance(instanceTree,type2d);
97 instance2d.addAttValue("dEdx",hit.getdEdx());
98 instance2d.addAttValue("time",hit.getTime());
99 HelicalTrack2DHit hit2d = (HelicalTrack2DHit) hit;
100 instance2d.addAttValue("zmin", hit2d.zmin());
101 instance2d.addAttValue("zmax", hit2d.zmax());
102 instance2d.addAttValue("drphi",hit.drphi());
103 instance2d.addAttValue("hit identifier",hit.getLayerIdentifier());
104 HelicalTrack2DHit h = (HelicalTrack2DHit) hit;
105 factory.createHepRepPoint(instance2d, pos[0], pos[1], h.zmin());
106 factory.createHepRepPoint(instance2d, pos[0], pos[1], h.zmax());
107
108 HepRepInstance instanceCenter = factory.createHepRepInstance(instanceTree,typeCenter);
109 instanceCenter.addAttValue("dEdx",hit.getdEdx());
110 instanceCenter.addAttValue("time",hit.getTime());
111 instanceCenter.addAttValue("drphi",hit.drphi());
112 factory.createHepRepPoint(instanceCenter,pos[0],pos[1],pos[2]);
113 }
114 }
115
116 }
117
118 }