Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

PTSimHit.cxx

Go to the documentation of this file.
00001 
00002 //
00003 // PTSimHit
00004 //
00005 // PTSimHit stores data from a single hit recorded during transport
00006 // of a track through an active detector element.
00007 //
00008 // S. Kasahara  05/04 
00010 
00011 #include <iostream>
00012 using namespace std;
00013 
00014 #include <TClonesArray.h>
00015 
00016 #include "Digitization/DigiScintHit.h"
00017 
00018 #include "ParticleTransportSim/PTSimHit.h"
00019 #include "Conventions/Munits.h"
00020 #include "MessageService/MsgService.h"
00021 
00022 ClassImp(PTSimHit)
00023 
00024 std::ostream& operator << (std::ostream& os, const PTSimHit& mh)
00025                                           { return mh.Print(os); }
00026 
00027 CVSID("$Id: PTSimHit.cxx,v 1.10 2009/04/24 19:10:26 schubert Exp $");
00028 
00029 
00030 //_________________________________________________________
00031 PTSimHit::PTSimHit() : fUseLinearStep(false) {
00032    //  Default constructor
00033   this -> Clear(); // initialize data members
00034 }
00035 
00036 //__________________________________________________________
00037 PTSimHit::~PTSimHit() {
00038 // Destructor
00039 
00040 }
00041 
00042 //__________________________________________________________
00043 void PTSimHit::Clear(Option_t* /* option */) {
00044 // Resets hit data so that object can be reused
00045 
00046   fStripEndId.SetDetector(Detector::kFar);
00047   fStripEndId.SetPlane(999);
00048   fStripEndId.SetStrip(999);
00049   fPdg = 0;
00050   fTrkIndex = -1;
00051   fGlobalPos0.SetXYZT(0,0,0,0);
00052   fLocalPos0.SetXYZT(0,0,0,0);
00053   fP40.SetPxPyPzE(0,0,0,0);
00054   fGlobalPos.SetXYZT(0,0,0,0);
00055   fLocalPos.SetXYZT(0,0,0,0);
00056   fP4.SetPxPyPzE(0,0,0,0);
00057   fELoss = 0;
00058   fStep = 0;
00059 
00060 }  
00061 
00062 //__________________________________________________________
00063 void PTSimHit::CreateDigiScintHit(TClonesArray& hitarray) const {
00064 // Creates DigiScintHit from stored data and adds it to users
00065 // TClonesArray at position entry
00066 
00067   MSG("PTSim",Msg::kVerbose) << "PTSimHit::CreateDigiScintHit\n" 
00068                                << *(this) << endl;
00069 
00070   if ( fStripEndId.GetPlane() == 999 ) {
00071     MSG("PTSim",Msg::kFatal) 
00072        << "CreateDigiScintHit called with invalid plane id " << endl;
00073     abort();
00074   }
00075   
00076   Int_t entry = hitarray.GetEntriesFast();
00077   Double_t step = fStep;
00078   if ( fUseLinearStep ) {
00079     // This is a bad idea but is useful for comparing to gminos
00080     double dx = fLocalPos.X() - fLocalPos0.X();
00081     double dy = fLocalPos.Y() - fLocalPos0.Y();
00082     double dz = fLocalPos.Z() - fLocalPos0.Z();
00083     step = sqrt(dx*dx+dy*dy+dz*dz);
00084   }
00085   
00086   new((hitarray)[entry]) DigiScintHit(fTrkIndex,fPdg,fP40.E(),
00087                            fStripEndId,
00088                            fLocalPos0.T(),
00089                            fLocalPos0.X()*Munits::cm,
00090                            fLocalPos0.Y()*Munits::cm,
00091                            fLocalPos0.Z()*Munits::cm,
00092                            fLocalPos.T(),
00093                            fLocalPos.X()*Munits::cm,
00094                            fLocalPos.Y()*Munits::cm,
00095                            fLocalPos.Z()*Munits::cm,
00096                            step*Munits::cm,fELoss,
00097                            fP40.Px(),fP40.Py(),fP40.Pz());
00098   return;
00099 }  
00100 
00101 
00102 //__________________________________________________________
00103 void PTSimHit::Init(const PlexStripEndId& seid, Int_t pdg, Int_t trkind,
00104                       const TLorentzVector& globalpos,
00105                       const TLorentzVector& localpos, 
00106                       const TLorentzVector& p4) {
00107 // Store entry point data for this hit
00108  
00109   fStripEndId = seid;
00110   fPdg = pdg;
00111   fTrkIndex = trkind;
00112   fGlobalPos0 = globalpos;
00113   fLocalPos0 = localpos;
00114   fP40 = p4;
00115 
00116   return;
00117 
00118 }  
00119 
00120 //__________________________________________________________
00121 std::ostream& PTSimHit::Print(std::ostream& os) const {
00122   //  Print hit data on ostream.
00123 
00124 
00125   os << "PTSimHit:" << endl;
00126  
00127   os << "StripEndId " << fStripEndId.AsString() 
00128      << " particle id(pdg) " << fPdg 
00129      << " trk index " << fTrkIndex << endl;
00130   os << "Entry x,y,z (local)(cm): " << fLocalPos0.X() << " " << fLocalPos0.Y()
00131      << " " << fLocalPos0.Z() << endl;
00132   os << "      x,y,z(global)(cm): " << fGlobalPos0.X() << " "  
00133      << fGlobalPos0.Y() << " "
00134      << fGlobalPos0.Z() << endl;
00135   os << "      time(sec) " <<  fLocalPos0.T() << " p4(GeV) "
00136      << fP40.Px() << " " << fP40.Py() << " " 
00137      << fP40.Pz() << " " << fP40.E() << endl;
00138   os << "Exit x,y,z (local)(cm): " << fLocalPos.X() << " " << fLocalPos.Y()
00139      << " " << fLocalPos.Z() << endl;
00140   os << "     x,y,z(global)(cm): " << fGlobalPos.X() << " " 
00141      << fGlobalPos.Y() << " " 
00142      << fGlobalPos.Z() << endl;
00143   os << "     time(sec) " <<  fLocalPos.T() << " p4(GeV) "
00144      << fP4.Px() << " " << fP4.Py() << " " 
00145      << fP4.Pz() << " " << fP4.E() << endl;
00146   os << "Eloss(GeV) " << fELoss << " Step(cm) " << fStep << endl;
00147 
00148   return os;
00149 
00150 }
00151 
00152 //__________________________________________________________
00153 void PTSimHit::Print(Option_t* /* option */) const {
00154   //  Print hit in form supported by TObject::Print.
00155 
00156   Print(std::cout);
00157   return;
00158 }
00159 
00160 //__________________________________________________________
00161 void PTSimHit::SetCurrentState(const TLorentzVector& globalpos,
00162                                  const TLorentzVector& localpos, 
00163                                  const TLorentzVector& p4) {
00164 // Store current data for this track
00165 
00166   fGlobalPos = globalpos;
00167   fLocalPos = localpos;
00168   fP4 = p4;
00169 
00170   return;
00171 
00172 }  
00173 
00174 
00175 

Generated on Mon Feb 15 11:07:26 2010 for loon by  doxygen 1.3.9.1