#include <DemoShell.h>
Inheritance diagram for trk::DemoShell:

Public Member Functions | |
| DemoShell (const char *version) | |
| void | Update (const cfg::Config &c) |
| jobc::Result | Reco (edm::EventHandle &evt) |
| jobc::Result | Ana (const edm::EventHandle &evt) |
Private Attributes | |
| int | fDebug |
| Controls debug output 0=none, 99=scream. | |
|
|
Definition at line 20 of file DemoShell.cxx. References jobc::Module::SetCfgVersion(). 00020 : 00021 jobc::Module("trk::DemoShell"), 00022 fDebug(0) 00023 { 00024 this->SetCfgVersion(version); 00025 }
|
|
|
The analysis method is intended to perform checks of the performance of the reconstruction for the purposes of optimization, testing, and validation.
Reimplemented from jobc::Module. Definition at line 45 of file DemoShell.cxx. 00046 {
00047 return jobc::kPassed;
00048 }
|
|
|
Reconstruction method for this module. Provides read-write access to the event data.
Reimplemented from jobc::Module. Definition at line 58 of file DemoShell.cxx. References recobase::Prong::Add(), recobase::Cluster::Add(), edm::EventHandle::Cal(), recobase::CellHit::Cell(), fDebug, util::EDMUtils::GetGeometry(), recobase::CellHit::Plane(), geo::Geometry::Plane(), edm::EventHandle::Reco(), recobase::Prong::SetDir(), recobase::Prong::SetStart(), recobase::Prong::SetStop(), and recobase::CellHit::View(). 00059 {
00060 //
00061 // "hits" is an C++ STL vector of CellHits (ok, really pointer to
00062 // CellHits...). The vector will be populated by data from the event
00063 //
00064 std::vector<const recobase::CellHit*> hits;
00065
00066 // Try to pull the CellHits out of the event.
00067 std::string fInputCalHits = "./";
00068 try { evt.Cal().Get(fInputCalHits.c_str(), hits); }
00069 catch (...) {
00070 // Failed to find any CalHits. Fail the event and keep processing
00071 if (fDebug>0) {
00072 std::cout << __FILE__ << ":" << __LINE__
00073 << "Failed to find any CalHits" << std::endl;
00074 }
00075 return jobc::kFailed;
00076 }
00077
00078 // If debugging is turned on, report that we found some hits to work
00079 // with
00080 if (fDebug>0) {
00081 std::cout << __FILE__ << ":" << __LINE__
00082 << " Found " << hits.size() << " hits in event."
00083 << std::endl;
00084 }
00085
00086 //
00087 // To give an example of how to work with the CellHit I'll show how
00088 // to do a least squares fit. We'll need some information about the
00089 // cell locations. That comes from the Geometry object.
00090 //
00091 const geo::Geometry& geom = util::EDMUtils::GetGeometry(evt);
00092
00093 // We now have the basics of what we need. For example, I can fit a
00094 // straight line
00095 double xzViewSx = 0.0;
00096 double xzViewSx2 = 0.0;
00097 double xzViewSy = 0.0;
00098 double xzViewSxy = 0.0;
00099 double xzViewN = 0.0;
00100 double yzViewSx = 0.0;
00101 double yzViewSx2 = 0.0;
00102 double yzViewSy = 0.0;
00103 double yzViewSxy = 0.0;
00104 double yzViewN = 0.0;
00105 double xyz1[3] = { 0,0, 99.E99}; // Upstream point in hit cluster
00106 double xyz2[3] = { 0,0,-99.E99}; // Downstream point in hit cluster
00107 for (unsigned int i=0; i<hits.size(); ++i) {
00108 const recobase::CellHit* h = hits[i]; // Get the address of the ith hit once
00109
00110 // Load the xyz location of the cell center into "xyz". Since we
00111 // have no information about the transverse position leave the
00112 // optional "localz" argument off
00113 double xyz[3]; // xyz[0]=x, xyz[1]=y, xyz[2]=z
00114 geom.Plane(h->Plane()).Cell(h->Cell()).GetCenter(xyz);
00115
00116 // Store the direction fit information into a prong object
00117
00118 // Keep track of point which is most upstream in z and most downstream in z
00119 if (xyz[2]<xyz1[2]) { xyz1[0] = xyz[0]; xyz1[1] = xyz[1]; xyz1[2] = xyz[2]; }
00120 if (xyz[2]>xyz2[2]) { xyz2[0] = xyz[0]; xyz2[1] = xyz[1]; xyz2[2] = xyz[2]; }
00121
00122 // Accumulate sums for least squares fit in the X and Y views
00123 if (h->View()==geo::kX) {
00124 xzViewSx += xyz[2]; // in the x-z view z is the independent variable
00125 xzViewSx2 += xyz[2]*xyz[2];
00126 xzViewSy += xyz[0]; // in the x-z view x is the dependent variable
00127 xzViewSxy += xyz[2]*xyz[0];
00128 xzViewN += 1.0;
00129 }
00130 if (h->View()==geo::kY) {
00131 yzViewSx += xyz[2]; // in the y-z view z is the independent variable
00132 yzViewSx2 += xyz[2]*xyz[2];
00133 yzViewSy += xyz[1]; // in the y-z view y is the dependent variable
00134 yzViewSxy += xyz[2]*xyz[1];
00135 yzViewN += 1.0;
00136 }
00137 }
00138 double xzDenom = xzViewN*xzViewSx2 - xzViewSx*xzViewSx;
00139 double yzDenom = yzViewN*yzViewSx2 - yzViewSx*xzViewSx;
00140
00141 // Intercepts
00142 double xzA = (xzViewSy*xzViewSx2-xzViewSx*xzViewSxy)/xzDenom;
00143 double yzA = (yzViewSy*yzViewSx2-yzViewSx*yzViewSxy)/yzDenom;
00144
00145 // Slopes
00146 double xzB = (xzViewN*xzViewSxy - xzViewSx*xzViewSy)/xzDenom;
00147 double yzB = (yzViewN*yzViewSxy - yzViewSx*xzViewSy)/yzDenom;
00148
00149 if (fDebug>0) {
00150 std::cout << __FILE__ << ":" << __LINE__
00151 << " XZ(a,b)=(" << xzA << "," << xzB << ")" << std::endl;
00152 std::cout << __FILE__ << ":" << __LINE__
00153 << " YZ(a,b)=(" << yzA << "," << yzB << ")" << std::endl;
00154 }
00155
00156 // Now pack the data into objects other modules can use
00157
00158 // Store the collection of hits used as a cluster. In this simple
00159 // case, I just add every hits to the cluster. A real algorithm
00160 // would have to make some more intelligent decisions.
00161 recobase::Cluster clust;
00162 for (unsigned int i=0; i<hits.size(); ++i) clust.Add(hits[i]);
00163
00164 // Store information about the prong we've just formed
00165 recobase::Prong prong;
00166 prong.Add(&clust);
00167
00168 // Set the start and stop points based on the line fit
00169 xyz1[0] = xzA + xzB*xyz1[2]; xyz1[1] = yzA + yzB*xyz1[2];
00170 xyz2[0] = xzA + xzB*xyz2[2]; xyz2[1] = yzA + yzB*xyz2[2];
00171 prong.SetStart(xyz1);
00172 prong.SetStop (xyz2);
00173
00174 double dir[3];
00175 double norm = sqrt(xzB*xzB + yzB*yzB + 1.0);
00176 dir[0] = xzB/norm;
00177 dir[1] = yzB/norm;
00178 dir[2] = 1.0/norm;
00179 prong.SetDir(dir);
00180
00181 // And finally, make a track. Currently this adds little beyond what
00182 // is already in the prong, but will eventually be further
00183 // developed.
00184 recobase::Track track(&prong);
00185
00186 // Finally, store the results in the event
00187 if (evt.Reco().GetFolder("./demoshell")==0) {
00188 evt.Reco().MakeFolder("./demoshell");
00189 }
00190 evt.Reco().Put(clust,"./demoshell");
00191 evt.Reco().Put(prong,"./demoshell");
00192 evt.Reco().Put(track,"./demoshell");
00193
00194 return jobc::kPassed;
00195 }
|
|
|
Implements cfg::Observer. Definition at line 29 of file DemoShell.cxx. References fDebug. 00030 {
00031 c("Debug").Get(fDebug);
00032 // Unpack other configuration data following the above example
00033 // ...
00034 }
|
|
|
Controls debug output 0=none, 99=scream.
Definition at line 26 of file DemoShell.h. |
1.3.9.1