Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

MCRecon.cxx

Go to the documentation of this file.
00001 //  $Header: /nfs/slac/g/glast/ground/cvs/reconstruction/src/MCRecon.cxx,v 1.10 2001/08/31 07:50:19 lsrea Exp $ 
00002 
00003 //THB #include "data/MCData.h"
00004 #include "reconstruction/MCRecon.h"
00005 #include "reconstruction/ReconVisitor.h"
00006 
00007 #include "instrument/MCTruth.h"
00008 #include "instrument/FluxGenerator.h"
00009 
00010 MCRecon::MCRecon ()
00011 : Recon()
00012 {
00013     setTitle("MCRecon: ver 2.0");
00014     
00015     i_MCId         = data.addElement("MC_Id");
00016 
00017     i_MCEnergy     = data.addElement("MC_Energy");
00018     i_MC_logE      = data.addElement("MC_logE");
00019     
00020     i_MCxDirection = data.addElement("MC_xDir");
00021     i_MCyDirection = data.addElement("MC_yDir");
00022     i_MCzDirection = data.addElement("MC_zDir");
00023 
00024     i_MCxPoint     = data.addElement("MC_X0");
00025     i_MCyPoint     = data.addElement("MC_Y0");
00026     i_MCzPoint     = data.addElement("MC_Z0");
00027 #if 0 //THB  not set yet 
00028     i_MCxVertex = data.addElement("MC_xVertex");
00029     i_MCyVertex = data.addElement("MC_yVertex");
00030     i_MCzVertex = data.addElement("MC_zVertex");
00031     
00032     i_MCEnergy1    = data.addElement("MC_Energy1");
00033     i_MCEnergy2    = data.addElement("MC_Energy2");
00034     i_MCAngle1     = data.addElement("MC_Angle1");
00035     i_MCAngle2     = data.addElement("MC_Angle2");
00036     i_MCAngle12    = data.addElement("MC_Angle12");
00037     
00038     i_MCEvType     = data.addElement("MC_Evt_Type");
00039     i_MCMaterial   = data.addElement("MC_Mat_Code");
00040 
00041     i_MCSrcCode    = data.addElement("MC_Src_Code");
00042 
00043     i_lat =          data.addElement("MC_lattitude");
00044     i_lon =          data.addElement("MC_longitude");
00045     i_time =         data.addElement("MC_time") ;
00046 
00047 #endif
00048 }
00049 
00050 
00051 void MCRecon::accept (ReconVisitor& rv)
00052 {
00053     rv.visit(this);
00054 }
00055 void MCRecon::reconstruct (const MCTruth* truth)
00056 {
00057 
00058     //old style const MCTruth* truth = MCTruth::instance();
00059     if( truth==0 ) truth = MCTruth::instance();
00060     if( truth==0 ) return; // baad
00061 
00062     //const MCTruth::_Particle& particle = *truth->particle();
00063     const FluxGenerator& particle = dynamic_cast<const FluxGenerator&>(*truth->particle());
00064 
00065     double energy = particle.energy();
00066     Vector dir=particle.launchDir().unit();
00067     
00068     data[i_MCEnergy] = energy;
00069     data[i_MC_logE] = log10(energy); // silly, but useful for binning
00070     data[i_MCxDirection] = dir.x();
00071     data[i_MCyDirection] = dir.y();
00072     data[i_MCzDirection] = dir.z();
00073 
00074     FluxGenerator::ParticleData* primary = particle.m_particles;
00075     data[i_MCId] = primary->m_idcode;
00076 
00077     Point vertex = primary->m_kids[0]->m_pos;
00078 
00079     // particle end point or interaction vertex
00080     data[i_MCxPoint] = vertex.x();
00081     data[i_MCyPoint] = vertex.y();
00082     data[i_MCzPoint] = vertex.z();
00083 
00084 
00085 #if 0 //Ti_MCzPoint ODO: finish this 
00086     Point pos = particle.launchPt ();
00087     data[i_MCxPoint ] = pos.x();
00088     data[i_MCyPoint ] = pos.y();
00089     data[i_MCzPoint ] = pos.z();
00090      
00091     if(state() == DONE) return;
00092     
00093     float energy = mcData->energy();
00094     
00095     data[i_MCId] = mcData->id();
00096 
00097     data[i_MCEnergy] = energy;
00098     data[i_MC_logE] = log10(energy); // silly, but useful for binning
00099 
00100     data.addData(i_MCEnergy1, mcData->energy1());
00101     data.addData(i_MCEnergy2, mcData->energy2());
00102     
00103     Vector v0 = mcData->direction();
00104     data.addData(i_MCxDirection, v0.x());
00105     data.addData(i_MCyDirection, v0.y());
00106     data.addData(i_MCzDirection, v0.z());
00107     
00108     data[i_MCxPoint] = mcData->entry().x();
00109     data[i_MCyPoint] = mcData->entry().y();
00110     data[i_MCzPoint] = mcData->entry().z();
00111     
00112     // these Vectors are used more than once, thus more optimal to declare them
00113     Vector v1(mcData->direction1());
00114     Vector v2(mcData->direction2());
00115     
00116     double dot1  = v0 * v1;
00117     double dot2  = v0 * v2;
00118     double dot12 = v1 * v2;
00119     
00120     data.addData(i_MCAngle1,  acos(dot1));
00121     data.addData(i_MCAngle2,  acos(dot2));
00122     data.addData(i_MCAngle12, acos(dot12));
00123     
00124     data.addData(i_MCEvType, mcData->eventType());
00125     data.addData(i_MCMaterial, mcData->materialType());
00126 
00127 
00128     data[i_lat]  = mcData->orbit_info().lat();
00129     data[i_lon]  = mcData->orbit_info().lon();
00130     data[i_time] = mcData->orbit_info().time();
00131 
00132     data[i_MCxVertex] = mcData->conversionPoint().x();
00133     data[i_MCyVertex] = mcData->conversionPoint().y();
00134     data[i_MCzVertex] = mcData->conversionPoint().z();
00135 
00136     data.addData(i_MCSrcCode, mcData->code());
00137     
00138     setState(DONE);
00139 #endif
00140     return ;
00141 }
00142 
00143 void MCRecon::clear ()
00144 {
00145     Recon::clear();
00146     data.clear();
00147 }
00148 
00149 
00150 
00151 

Generated at Wed Nov 21 12:20:44 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000