PTGuiRollGMinos Class Reference

#include <PTGuiRollGMinos.h>

List of all members.

Public Member Functions

 PTGuiRollGMinos (TFile *file)
virtual ~PTGuiRollGMinos ()
TClonesArray * GetMaterials () const
TClonesArray * GetMedia () const
PTGuiMediumGetMedium (std::string ptname) const
TGraph * GetGraph (Int_t imat, Int_t ipart, Int_t imech) const

Private Member Functions

 PTGuiRollGMinos (const PTGuiRollGMinos &that)
PTGuiRollGMinosoperator= (const PTGuiRollGMinos &that)
bool ImportGeometry ()
void RollMaterials ()
void RollMedia ()

Private Attributes

TFile * fFile
TClonesArray * fMaterials
TClonesArray * fMedia
std::map< std::string,
std::string > 
fPTtoGMinosMap

Detailed Description

Definition at line 32 of file PTGuiRollGMinos.h.


Constructor & Destructor Documentation

PTGuiRollGMinos::PTGuiRollGMinos ( TFile *  file  ) 

Definition at line 42 of file PTGuiRollGMinos.cxx.

References Msg::kError, and MSG.

00042                                             : fFile(file),
00043                                    fMaterials(0), fMedia(0) {
00044   // Normal Constructor
00045   
00046   if ( !fFile ) {
00047     MSG("PTGui",Msg::kError) << "PTGuiRollGMinos ctor received null ptr." 
00048                              << endl;
00049     abort();
00050   }
00051   
00052   // Convert GMinos objects to PTGui objects
00053   RollMaterials();
00054   RollMedia();
00055     
00056 }

PTGuiRollGMinos::~PTGuiRollGMinos (  )  [virtual]

Definition at line 59 of file PTGuiRollGMinos.cxx.

References fFile.

00059                                   {
00060   // Destructor
00061 
00062   // Delete TFile and contained objects
00063   if ( fFile ) { 
00064     fFile -> Close();
00065     delete fFile; fFile = 0;
00066   }
00067   
00068   // Delete TClonesArrays and contained objects
00069   //if ( fMaterials ) { fMaterials->Delete(); delete fMaterials; }
00070   //if ( fMedia ) { fMedia -> Delete(); delete fMedia; }
00071   
00072 }

PTGuiRollGMinos::PTGuiRollGMinos ( const PTGuiRollGMinos that  )  [private]

Member Function Documentation

TGraph * PTGuiRollGMinos::GetGraph ( Int_t  imat,
Int_t  ipart,
Int_t  imech 
) const

Definition at line 93 of file PTGuiRollGMinos.cxx.

References fFile.

Referenced by PTGuiMainFrame::Plot().

00093                                                                            {
00094   // Method to pull corresponding gminos histogram from file
00095 
00096   TGraph* graph = 0;
00097   Int_t id = 10000*imat + 100*ipart + imec;
00098 
00099   std::string histname;
00100   
00101   if ( imat < 10 ) {
00102     // This is kind of stupid but I'm tired
00103     char buf[6];
00104     sprintf(buf,"%5i",id);
00105     buf[5] = '\0';
00106     histname = "h"+std::string(buf);
00107   }
00108   else {
00109     char buf[7];
00110     sprintf(buf,"%6i",id);
00111     buf[6] = '\0';
00112     histname = "h"+std::string(buf);
00113   }
00114   
00115   TH1* hist = dynamic_cast<TH1*>(fFile->Get(histname.c_str()));
00116   if ( hist ) {
00117     graph = new TGraph(hist);
00118   }
00119   else {
00120     cout << "Unable to find histogram." << endl;
00121   }
00122    
00123   return graph; // graph is owned by caller
00124   
00125 }

TClonesArray* PTGuiRollGMinos::GetMaterials (  )  const [inline]

Definition at line 40 of file PTGuiRollGMinos.h.

References fMaterials.

Referenced by PTGuiMainFrame::UpdateMaterialList().

00040 {return fMaterials;}    

TClonesArray* PTGuiRollGMinos::GetMedia (  )  const [inline]

Definition at line 41 of file PTGuiRollGMinos.h.

References fMedia.

00041 {return fMedia;}    

PTGuiMedium * PTGuiRollGMinos::GetMedium ( std::string  ptname  )  const

Definition at line 75 of file PTGuiRollGMinos.cxx.

References fMedia, fPTtoGMinosMap, and medium.

Referenced by PTGuiMainFrame::Update().

00075                                                               {
00076   // Method to find corresponding gminos medium
00077   // during construction of medium list.
00078 
00079   PTGuiMedium* medium = 0;
00080   std::map<std::string,std::string>::const_iterator itr 
00081                                            = fPTtoGMinosMap.find(ptname);
00082   if ( itr != fPTtoGMinosMap.end() ) {
00083     std::string gminosname = itr->second;
00084     medium 
00085         = dynamic_cast<PTGuiMedium*>(fMedia->FindObject(gminosname.c_str()));
00086   }
00087 
00088   return medium;
00089   
00090 }

bool PTGuiRollGMinos::ImportGeometry (  )  [private]
PTGuiRollGMinos& PTGuiRollGMinos::operator= ( const PTGuiRollGMinos that  )  [private]
void PTGuiRollGMinos::RollMaterials (  )  [private]

Definition at line 129 of file PTGuiRollGMinos.cxx.

References fFile, fMaterials, nentries, and Lit::Print().

00129                                     {
00130   // Read materials from TGeoManager arrays and puts in a TClonesArray
00131   // of PTGuiMaterial objects
00132 
00133   Int_t nentries = 0;
00134   
00135   fMaterials = dynamic_cast<TClonesArray*>(fFile->Get("GMinosMaterial"));
00136   TIter iter(fMaterials);
00137   while ( TObject* obj = iter.Next() ) {
00138     PTGuiMaterial* mat = dynamic_cast<PTGuiMaterial*>(obj);
00139     std::string matName = mat->GetName();
00140     // Fuss with material name to remove trailing spaces
00141     
00142     int pos(matName.size());
00143     for ( ; pos && matName[pos-1]==' '; --pos );
00144     matName.erase(pos,matName.size()-pos);
00145     mat->SetName(matName.c_str());
00146       
00147     mat -> Print();
00148     nentries++;
00149     
00150   }
00151 
00152 }

void PTGuiRollGMinos::RollMedia (  )  [private]

Definition at line 155 of file PTGuiRollGMinos.cxx.

References fFile, fMedia, fPTtoGMinosMap, medium, nentries, and Lit::Print().

00155                                 {
00156   // Read materials from TGeoManager arrays and puts in a TClonesArray
00157   // of PTGuiMedia objects
00158 
00159   // Set up media map names to navigate from PT to GMINOS names
00160   fPTtoGMinosMap.insert(make_pair("ALUM","ALUMINIUM"));
00161   fPTtoGMinosMap.insert(make_pair("ALUM_B","ALUB MAGNETIC AL"));
00162   fPTtoGMinosMap.insert(make_pair("IRON","STEEL"));
00163   fPTtoGMinosMap.insert(make_pair("IRON_B","IRON"));
00164   fPTtoGMinosMap.insert(make_pair("AIR","AIR"));
00165   fPTtoGMinosMap.insert(make_pair("AIR_B","AIRB MAGNETIC AIR"));
00166   fPTtoGMinosMap.insert(make_pair("CONCRETE","CONCRETE"));
00167   fPTtoGMinosMap.insert(make_pair("ROCK","ROCK"));
00168   fPTtoGMinosMap.insert(make_pair("PSTYRENE SCINT","PSTYRENE SCINT"));
00169   fPTtoGMinosMap.insert(make_pair("COEX TIO2 PSTYRENE",
00170                                   "COEX TIO2 PSTYRENE"));
00171   fPTtoGMinosMap.insert(make_pair("FARCOIL","<no match>"));
00172   fPTtoGMinosMap.insert(make_pair("FARCOIL_B","FARCOIL"));
00173   fPTtoGMinosMap.insert(make_pair("DOLOMITE","DOLOMITE"));
00174   fPTtoGMinosMap.insert(make_pair("FEPL","STPL"));
00175   fPTtoGMinosMap.insert(make_pair("FEPL_B","FEPL"));
00176   fPTtoGMinosMap.insert(make_pair("WATER","WATER"));
00177   fPTtoGMinosMap.insert(make_pair("WATER_B","WATB MATGNETIC WATER"));
00178 
00179   Int_t nentries = 0;
00180   
00181   fMedia = dynamic_cast<TClonesArray*>(fFile->Get("GMinosMedium"));
00182   TIter iter(fMedia);
00183   while ( TObject* obj = iter.Next() ) {
00184 
00185     PTGuiMedium* med = dynamic_cast<PTGuiMedium*>(obj);
00186     std::string medName = med->GetName();
00187 
00188     // Fuss with the medium name to remove trailing spaces
00189     int pos(medName.size());
00190     for ( ; pos && medName[pos-1]==' '; --pos );
00191     medName.erase(pos,medName.size()-pos);
00192     med -> SetName(medName.c_str());
00193     
00194     med -> Print();
00195     nentries++;
00196   }
00197 
00198   PTGuiMedium* medium = new PTGuiMedium("<no match>",-1,-1,-1,-1,
00199                                         -1,-1,-1,-1,-1,-1);
00200   (*fMedia)[nentries] = medium;
00201   
00202 }


Member Data Documentation

TFile* PTGuiRollGMinos::fFile [private]

Definition at line 58 of file PTGuiRollGMinos.h.

Referenced by GetGraph(), RollMaterials(), RollMedia(), and ~PTGuiRollGMinos().

TClonesArray* PTGuiRollGMinos::fMaterials [private]

Definition at line 59 of file PTGuiRollGMinos.h.

Referenced by GetMaterials(), and RollMaterials().

TClonesArray* PTGuiRollGMinos::fMedia [private]

Definition at line 60 of file PTGuiRollGMinos.h.

Referenced by GetMedia(), GetMedium(), and RollMedia().

std::map<std::string,std::string> PTGuiRollGMinos::fPTtoGMinosMap [private]

Definition at line 61 of file PTGuiRollGMinos.h.

Referenced by GetMedium(), and RollMedia().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1