#include <DetectorView.h>
Inheritance diagram for evd::DetectorView:

Public Member Functions | |
| DetectorView (TGMainFrame *mf) | |
| ~DetectorView () | |
| const char * | Description () const |
| const char * | PrintTag () const |
| void | Draw (const char *opt="") |
Private Member Functions | |
| void | DrawMCTruth (edm::EventHandle &) |
Private Attributes | |
| TPad * | f3DviewPad |
| TH3F * | f3DviewHisto |
| evdb::View3D * | f3Dview |
| geo::Geometry * | fGeo |
| const DetectorViewOption * | fOption |
|
|
Definition at line 35 of file DetectorView.cxx. References edm::EventHandle::DAQ(), geo::Geometry::DetHalfHeight(), geo::Geometry::DetHalfWidth(), geo::Geometry::DetLength(), f3Dview, f3DviewHisto, f3DviewPad, fOption, edm::EventHandle::Header(), DetectorViewOption::Instance(), geo::Geometry::Instance(), and evdb::IoModule::Instance(). 00035 : evdb::Canvas(mf) 00036 { 00037 edm::EventHandle& evt = evdb::IoModule::Instance()->GetEvent(); 00038 std::vector<const rawdata::DAQHeader*> header; 00039 short int det = rawdata::kFar; 00040 try{ evt.DAQ().Get("./",header); } 00041 catch(edm::Exception e){ 00042 std::cerr << "Error retrieving daq header, while looking "<< 00043 "in DetectorView::DetectorView(), using default fardet geometry" << std::endl; 00044 } 00045 if(header.size() > 0) det = header[0]->DetId(); 00046 geo::Geometry *geom = &geo::Geometry::Instance(evt.Header().Run(),det); 00047 00048 evdb::Canvas::fCanvas->cd(); 00049 00050 f3DviewPad = new TPad("fYviewPad","Yview",0.0,0.0,0.75,0.9); 00051 f3DviewPad->Draw(); 00052 00053 f3DviewPad->cd(); 00054 f3DviewHisto = new TH3F("f3DviewHisto",";z (cm);x (cm); y(cm)", 00055 200,0.,geom->DetLength(), 00056 32,-geom->DetHalfWidth(), geom->DetHalfWidth(), 00057 32,-geom->DetHalfHeight(),geom->DetHalfHeight()); 00058 f3DviewHisto->Draw(); 00059 00060 f3Dview = new evdb::View3D(); 00061 00062 fOption = &DetectorViewOption::Instance(); 00063 }
|
|
|
Definition at line 67 of file DetectorView.cxx. 00067 { }
|
|
|
Give a medium length description of what the view holds to be printed. Examples: "Full view of experiment", "3D View", ... Reimplemented from evdb::Canvas. Definition at line 19 of file DetectorView.h. 00019 { return "Detector View"; }
|
|
|
Implements evdb::Canvas. Definition at line 180 of file DetectorView.cxx. References evdb::View3D::Clear(), edm::EventHandle::DAQ(), evdb::View3D::Draw(), DrawMCTruth(), f3Dview, f3DviewHisto, f3DviewPad, DetectorViewOption::fDrawMCTruthVectors, fGeo, fOption, edm::EventHandle::Header(), geo::Geometry::Instance(), and evdb::IoModule::Instance(). 00181 {
00182 edm::EventHandle& evt = evdb::IoModule::Instance()->GetEvent();
00183
00184 std::vector<const rawdata::DAQHeader*> header;
00185 short int det = rawdata::kFar;
00186 try{ evt.DAQ().Get("./",header); }
00187 catch(edm::Exception e){
00188 std::cerr << "Error retrieving daq header, while looking "<<
00189 "in DetectorView::Draw(), using default fardet geometry" << std::endl;
00190 }
00191 if(header.size() > 0) det = header[0]->DetId();
00192 fGeo = &geo::Geometry::Instance(evt.Header().Run(),det);
00193
00194 f3Dview->Clear();
00195
00196 if (fOption->fDrawMCTruthVectors)
00197 DrawMCTruth(evt);
00198
00199 f3DviewPad->cd();
00200 f3DviewHisto->Draw();
00201 f3Dview->Draw();
00202
00203 evdb::Canvas::fCanvas->Update();
00204 }
|
|
|
Definition at line 71 of file DetectorView.cxx. References evdb::View3D::AddPolyLine3D(), edm::EventHandle::DetSim(), f3Dview, f3DviewHisto, and edm::EventHandle::MC(). Referenced by Draw(). 00072 {
00073 double zmin = 1e20, zmax = -1e20;
00074 double xmin = 1e20, xmax = -1e20;
00075 double ymin = 1e20, ymax = -1e20;
00076
00077 std::vector<const sim::MCTruth*> mctruth;
00078
00079 try { evt.MC().Get(".",mctruth); }
00080 catch (edm::Exception e) { }
00081
00082 for (int i=0; i<mctruth[0]->NParticles(); ++i) {
00083 const TParticle& p = mctruth[0]->GetParticle(i);
00084
00085 double xyz0[3];
00086 xyz0[0] = p.Vx();
00087 xyz0[1] = p.Vy();
00088 xyz0[2] = p.Vz();
00089
00090 double xyz1[3];
00091 // Incident particles
00092 if (p.GetStatusCode()==0) {
00093 xyz1[0] = xyz0[0] - p.Px()/2E-3;
00094 xyz1[1] = xyz0[1] - p.Py()/2E-3;
00095 xyz1[2] = xyz0[2] - p.Pz()/2E-3;
00096 }
00097 // Particles to be tracked
00098 else if (p.GetStatusCode()==1) {
00099 xyz1[0] = xyz0[0] + p.Px()/2E-3;
00100 xyz1[1] = xyz0[1] + p.Py()/2E-3;
00101 xyz1[2] = xyz0[2] + p.Pz()/2E-3;
00102 }
00103 // Intermediate states
00104 else continue;
00105
00106 // Find limits of display
00107 if (xyz0[0]<xmin) xmin = xyz0[0];
00108 if (xyz1[0]<xmin) xmin = xyz1[0];
00109 if (xyz0[0]>xmax) xmax = xyz0[0];
00110 if (xyz1[0]>xmax) xmax = xyz1[0];
00111 if (xyz0[1]<ymin) ymin = xyz0[1];
00112 if (xyz1[1]<ymin) ymin = xyz1[1];
00113 if (xyz0[1]>ymax) ymax = xyz0[1];
00114 if (xyz1[1]>ymax) ymax = xyz1[1];
00115 if (xyz0[2]<zmin) zmin = xyz0[2];
00116 if (xyz1[2]<zmin) zmin = xyz1[2];
00117 if (xyz0[2]>zmax) zmax = xyz0[2];
00118 if (xyz1[2]>zmax) zmax = xyz1[2];
00119
00120 int ic = Style::ColorFromPDG(p.GetPdgCode());
00121 int iw = Style::LineWidthFromPDG(p.GetPdgCode());
00122 int is = Style::LineStyleFromPDG(p.GetPdgCode());
00123
00124 TPolyLine3D& line = f3Dview->AddPolyLine3D(100,ic,iw,is);
00125 double dz = 2.;
00126 int npnt = (int)((xyz1[2]-xyz0[2])/dz); // 2 cm step sizes
00127 double dxdz = p.Px()/p.Pz();
00128 double dydz = p.Py()/p.Pz();
00129 double x, y, z;
00130 for (int i=0; i<npnt; ++i) {
00131 x = xyz0[0] + i*dz*dxdz;
00132 y = xyz0[1] + i*dz*dydz;
00133 z = xyz0[2] + i*dz;
00134 line.SetPoint(i,z,x,y);
00135 }
00136 }
00137
00138 std::vector<const sim::ParticleList*> particleList;
00139 try {
00140 evt.DetSim().Get(".",particleList);
00141 }
00142 catch (edm::Exception e) { }
00143
00144 std::cerr << "Interactions in this record="
00145 << particleList.size()<<std::endl;
00146
00147 for (unsigned int iev=0; iev<particleList.size(); iev++) {
00148 std::vector<sim::Particle> particles=particleList[iev]->fParticles;
00149 std::cerr <<"Event "<<iev<<" has "<<particles.size()
00150 <<" particles."<<std::endl;
00151 for (unsigned int i=0; i<particles.size(); ++i) {
00152 std::cerr << particles[i].PdgCode()<<" ";
00153 if ( (i>0 && i%10==0) || i==particles.size()-1) std::cerr << std::endl;
00154 }
00155 }
00156
00157 // Force the x and y views to have the same vertical scale
00158 if (xmax-xmin > ymax-ymin) {
00159 double tmp = 0.5*((xmax-xmin)-(ymax-ymin));
00160 ymax += tmp;
00161 ymin -= tmp;
00162 }
00163 else {
00164 double tmp = 0.5*((ymax-ymin)-(xmax-xmin));
00165 xmax += tmp;
00166 xmin -= tmp;
00167 }
00168 xmin -= 100; xmax += 100;
00169 ymin -= 100; ymax += 100;
00170 zmin -= 100; zmax += 100;
00171
00172 f3DviewHisto->GetXaxis()->SetRangeUser(zmin,zmax);
00173 f3DviewHisto->GetYaxis()->SetRangeUser(xmin,xmax);
00174 f3DviewHisto->GetZaxis()->SetRangeUser(ymin,ymax);
00175
00176 }
|
|
|
Give a short tag which can be included in filename to ID object printed Keep to ~4 characters Reimplemented from evdb::Canvas. Definition at line 20 of file DetectorView.h. 00020 { return "detectorview"; }
|
|
|
Definition at line 27 of file DetectorView.h. Referenced by DetectorView(), Draw(), and DrawMCTruth(). |
|
|
Definition at line 26 of file DetectorView.h. Referenced by DetectorView(), Draw(), and DrawMCTruth(). |
|
|
Definition at line 25 of file DetectorView.h. Referenced by DetectorView(), and Draw(). |
|
|
Definition at line 28 of file DetectorView.h. Referenced by Draw(). |
|
|
Definition at line 30 of file DetectorView.h. Referenced by DetectorView(), and Draw(). |
1.3.9.1