Esempio n. 1
0
 long dump(TGeoNode* ideal, TGeoNode* aligned,int level, VIDs volids) const {
   char fmt[128];
   string opt_info;
   PlacedVolume pv(ideal);
   bool sensitive = false;
   if ( m_printPositions || m_printVolIDs )  {
     stringstream log;
     if ( m_printPositions )  {
       const double* trans = ideal->GetMatrix()->GetTranslation();
       ::snprintf(fmt, sizeof(fmt), "Pos: (%f,%f,%f) ",trans[0],trans[1],trans[2]);
       log << fmt;
     }
     // Top level volume! have no volume ids
     if ( m_printVolIDs && ideal && ideal->GetMotherVolume() )  {
       VIDs vid = pv.volIDs();
       if ( !vid.empty() )  {
         sensitive = true;
         log << " VolID: ";
         volids.std::vector<VID>::insert(volids.end(),vid.begin(),vid.end());
         for(VIDs::const_iterator i=volids.begin(); i!=volids.end(); ++i)  {
           ::snprintf(fmt, sizeof(fmt), "%s:%2d ",(*i).first.c_str(), (*i).second);
           log << fmt;
         }
       }
     }
     opt_info = log.str();
   }
   TGeoVolume* volume = ideal->GetVolume();
   if ( !m_printSensitivesOnly || (m_printSensitivesOnly && sensitive) )  {
     char sens = pv.volume().isSensitive() ? 'S' : ' ';
     if ( ideal == aligned )  {
       ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s (%%s: %%s) \t[%p] %c %%s",
                  level+1,2*level+1,(void*)ideal, sens);
     }
     else  {
       ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s (%%s: %%s) Ideal:%p Aligned:%p %c %%s",
                  level+1,2*level+1,(void*)ideal,(void*)aligned, sens);
     }
     printout(INFO,"+++",fmt,"",
              aligned->GetName(),
              volume->GetTitle(),
              volume->GetShape()->IsA()->GetName(),
              opt_info.c_str());
   }
   for (Int_t idau = 0, ndau = aligned->GetNdaughters(); idau < ndau; ++idau)  {
     TGeoNode*   ideal_daughter   = ideal->GetDaughter(idau);
     const char* daughter_name    = ideal_daughter->GetName();
     TGeoNode*   aligned_daughter = volume->GetNode(daughter_name);
     dump(ideal_daughter, aligned_daughter, level+1, volids);
   }
   return 1;
 }
Esempio n. 2
0
//________________________________________________________________________________
Int_t StarMCHits::Init() {
  cout << "StarMCHits::Init() -I- Get Detectors" <<endl;
  if (! fDetectors ) delete fDetectors;
  fDetectors = 0;
  assert(StMaker::GetChain());
  fDetectors = StMaker::GetChain()->GetDataBase("VmcGeometry/Index");
  assert(fDetectors);
  // Make list of detector elements
  TDataSetIter next( fDetectors , 99);
  TDataSet *set = 0;
  if (fDetList) delete fDetList;
  fDetList = new THashList(100,0);
  Int_t N = 0;
  while ((set = next())) {
    StarVMCDetector *det = dynamic_cast<StarVMCDetector *>(set);
    if (! det ) continue;
    if (TString(det->GetName()) == "FPCT") continue; // ignore fpd
    if (TString(det->GetName()) == "BRSG") continue; // ignore tfr
    fDetList->Add(det);
    N++;
  }
  fDetList->Rehash(N);
  cout << "StarMCHits::Init() -I- Get Volume Info" << endl;
  //  TObjArray *UniqueVolumes = gGeoManager->GetListOfUVolumes();
  TObjArray *Volumes = gGeoManager->GetListOfUVolumes();
  Int_t Nids = Volumes->GetEntriesFast();
  if (! fVolUserInfo ) fVolUserInfo = new TObjArray(256);
  for (Int_t i = 0; i < Nids; i++) {
    TGeoVolume *vol  = (TGeoVolume *) Volumes->At(i);
    if (! vol) continue;
    Int_t uid = vol->GetNumber();
#if 0
    cout << "Volume:\t" << i << "\t" << vol->GetName() << "\t" << vol->GetTitle() << "\t" << uid;
#endif
    TString title(vol->GetName(),4);
    TObject *det = fDetList->FindObject(title.Data());
#if 0
    if (det) cout << "\tDetector: " << det->GetName();// << "\t" << det->GetTitle();
#endif
    fVolUserInfo->AddAtAndExpand(det,uid);
#if 0
    cout << endl;
#endif
  }
  return 0;
}
Esempio n. 3
0
//_____________________________________________________________________________
void StarMCHits::MakeDetectorDescriptors() {
  if (! gGeoManager) {
    cout << "No gGeoManager" << endl;
    return;
  }
  TDataSet *Detectors = StMaker::GetChain()->GetDataBase("VmcGeometry/Index");
  if (! Detectors) {
    cout << "No Detectors found in VmcGeometry/Index" << endl;
  }
  // Make List of sensitive volumes
  TObjArray *vols = gGeoManager->GetListOfVolumes();
  Int_t nvol = vols->GetEntriesFast();
  Int_t nSensVol = 0;
  Int_t nsize = 100;
  TArrayI Indx(nsize); Int_t *indx = Indx.GetArray();
  for (Int_t i = 0; i < nvol; i++) {
    TGeoVolume *vol = (TGeoVolume *) vols->At(i);
    if (! vol) continue;
    TGeoMedium *med = vol->GetMedium();
    if (! med) continue;
    Int_t       isvol = (Int_t) med->GetParam(0);
    if (! isvol) continue;
    indx[nSensVol] = i;
    nSensVol++;
    if (nSensVol >= nsize) {
      nsize *= 2;
      Indx.Set(nsize); 
      indx = Indx.GetArray();
    }
    TString Path(MakeDetectorDescriptor(vol->GetName()));
    if (Detectors) {
      // Check consistency 
      StarVMCDetector *det = (StarVMCDetector *) Detectors->Find(vol->GetName());
      if (! det) {
	cout << "Detector description for " << vol->GetName() << "\t" << vol->GetTitle() << " is missing" << endl;
      } else {
	TString FMT = det->GetFMT();
	cout << "Found path:\t" << Path.Data() << endl;
	cout << "Set   path:\t" << FMT.Data();
	if (Path == FMT) cout << " are the same" << endl;
	else             cout << " are the different" << endl;
      }
    }
    
  }
}