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

ScintHitAna.cxx

Go to the documentation of this file.
00001 
00002 // $Id: ScintHitAna.cxx,v 1.3 2006/12/01 20:12:11 rhatcher Exp $
00003 //
00004 // FILL_IN: [Document your code!!]
00005 //
00006 // n.tagg1@physics.ox.ac.uk
00008 #include "ScintHitAna.h"
00009 #include "MessageService/MsgService.h"
00010 #include "MinosObjectMap/MomNavigator.h"
00011 #include "JobControl/JobCModuleRegistry.h" // For JOBMODULE macro
00012 
00013 #include "Record/SimSnarlRecord.h"
00014 #include "Record/SimSnarlHeader.h"
00015 #include "UgliGeometry/UgliGeomHandle.h"
00016 
00017 JOBMODULE(ScintHitAna, "ScintHitAna",
00018           "ScintHitAna");
00019 
00020 
00021 ClassImp(MyGeom)
00022 
00023 CVSID("$Id: ScintHitAna.cxx,v 1.3 2006/12/01 20:12:11 rhatcher Exp $");
00024 //......................................................................
00025 
00026 ScintHitAna::ScintHitAna()
00027 {
00028   //======================================================================
00029   // Make a tree.
00030   //======================================================================
00031   fTreeFile = new TFile("scinthits.root","RECREATE");
00032   fTree = new TTree("shtree","shtree");
00033   fTree->Branch("scinthit","DigiScintHit",&fHit,32000,1);
00034   fTree->Branch("geom","MyGeom",&fGeom,32000,1);
00035   fTree->Branch("event",&fEvent,"event/I");
00036   fEvent = 0;
00037   fGeom = new MyGeom;
00038 }
00039 
00040 //......................................................................
00041 
00042 ScintHitAna::~ScintHitAna()
00043 {
00044 //======================================================================
00045 // Close the file
00046 //======================================================================
00047   fTreeFile->cd();
00048   fTree->Write();
00049   fTreeFile->Close();
00050   delete fTreeFile;
00051   delete fTree;
00052 }
00053 
00054 //......................................................................
00055 
00056 JobCResult ScintHitAna::Ana(const MomNavigator* mom)
00057 {
00058 //======================================================================
00059 // Fill the tree.
00060 //======================================================================
00061   
00062   SimSnarlRecord* simsnarl = 0;
00063   TObject* tobj;
00064   TIter    fragiter = mom->FragmentIter();
00065   
00066   // Get the simsnarl.
00067   while( ( tobj = fragiter.Next() ) ) {
00068     simsnarl = dynamic_cast<SimSnarlRecord*>(tobj);
00069     if(simsnarl) break;
00070   }
00071   const SimSnarlHeader* simHeader = simsnarl->GetSimSnarlHeader();
00072   if(simHeader ==0){
00073     MSG("Photon",Msg::kError) << "Cannot find SimSnarlHeader in SimSnarl." << endl;
00074     return JobCResult::kFailed;
00075   }
00076   
00077   // We need a context to do table lookups
00078   VldContext simContext = simHeader->GetVldContext();
00079   
00080   
00081   // Get the DigiScintHits.
00082   // Get the scint hit array.
00083   const TObjArray* hitArray = 
00084     dynamic_cast<const TObjArray*>(simsnarl->FindComponent(0,"DigiScintHits"));
00085   if(hitArray==0) {
00086     cout << "Can't find scint hit array.\n"; 
00087     return JobCResult::kPassed;  
00088   };
00089   
00090   
00091   // Fill the tree.
00092   UgliGeomHandle ugli(simContext);
00093   
00094   TIter hitarrayIter(hitArray);
00095   while( (tobj = hitarrayIter.Next()) ) {
00096     const DigiScintHit* scinthit = dynamic_cast<DigiScintHit*>(tobj);
00097     if(scinthit) {
00098       fHit = const_cast<DigiScintHit*>(scinthit);
00099 
00100       UgliStripHandle strip = ugli.GetStripHandle(scinthit->StripEndId());
00101       fGeom->length = strip.GetHalfLength();
00102       fGeom->width  = strip.GetHalfWidth();
00103       fGeom->thickness = strip.GetHalfThickness();
00104 
00105       fTree->Fill();
00106 
00107     }
00108   }
00109   
00110 
00111   fEvent++;
00112 
00113   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00114 }
00115 

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