StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiMasterDetectorBuilder.cxx
1 #include <cassert>
2 #include "StiMasterDetectorBuilder.h"
3 #include "TGeoManager.h"
4 #include "StiDetector.h"
5 #include "StMaker.h"
6 StiMasterDetectorBuilder::StiMasterDetectorBuilder(bool active)
7  : StiDetectorBuilder("MasterDetectorBuilder",active)
8 {}
9 
10 StiMasterDetectorBuilder::~StiMasterDetectorBuilder()
11 {}
12 
18 {
19  clear();
20 }
21 
25 {
26  if (! gGeoManager) StiVMCToolKit::GetVMC();
27 
28  StMaker *chain=StMaker::GetChain();
29 
30  LOG_INFO << "We are StiMasterDetectorBuilder::build() and will clone the geometry if exists" << endm;
31  if ( chain ){
32  TDatime t = chain->StMaker::GetDBTime();
33  LOG_INFO << "Timestamp check - Date/Time from chain is " << t.GetDate() << "/" << t.GetTime() << endm;
34  }
35 
36 #if 1
37 #else
38  if ( chain ) {
39  LOG_INFO << "StiMasterDetectorBuilder::build() : Create clone of VmcGeometry by reinitialization for reconstruction" <<endm;
40  TDataSet *set = chain->GetDataBase("VmcGeometry/Geometry", &chain->StMaker::GetDBTime());
41  delete set;
42  }
43 #endif
44  LOG_INFO << "StiMasterDetectorBuilder::build() : Started"<<endm;
45  vector<StiDetectorBuilder*>::iterator iter;
46  unsigned int nRows=0;
47  for (iter=begin();
48  iter!=end();
49  iter++)
50  {
51  LOG_INFO << "StiMasterDetectorBuilder::build() : Calling Group Builder named: " << (*iter)->getName() << endm;
52  if (!*iter) { LOG_INFO << " pointer is corrupted!!!!!!!!!!!!!!!!!!!" << endm; }
53  (*iter)->build(source);
54  nRows+=(*iter)->getNRows();
55  }
56  LOG_INFO << "StiMasterDetectorBuilder::build() : Will build local array" << endm;
57  setNRows(nRows);
58  unsigned int row=0;
59  for (iter=begin();
60  iter!=end();
61  iter++)
62  {
63  LOG_INFO << "StiMasterDetectorBuilder::build() : Builder: " << (*iter)->getName() << endm;
64  for (unsigned int i=0;i<(*iter)->getNRows();i++)
65  {
66  LOG_INFO << "StiMasterDetectorBuilder::build() : row: " << row;
67  unsigned int nSectors = (*iter)->getNSectors(i);
68  setNSectors(row,nSectors);
69  Int_t ifrow = 0;
70  for (unsigned int sector=0;sector<nSectors;sector++)
71  {
72  StiDetector *detector = (*iter)->getDetector(i,sector);
73  if (!ifrow && detector) { LOG_INFO << "\t" << detector->getName(); ifrow++; }
74  setDetector(row,sector,detector);
75  }
76  LOG_INFO << endm;
77  row++;
78  }
79  }
80  cout << "StiMasterDetectorBuilder::build() -I- Done"<<endl;
81 }
82 
86 {
87  vector<StiDetectorBuilder*>::const_iterator iter;
88  for (iter=begin();
89  iter!=end();
90  iter++)
91  {
92  if((*iter)->hasMore()) return true;
93  }
94  return false;
95 }
96 
101 {
102  vector<StiDetectorBuilder*>::const_iterator iter;
103  for (iter=begin();
104  iter!=end();
105  iter++)
106  {
107  if((*iter)->hasMore()) return (*iter)->next();
108  }
109  return 0;
110 }
111 
112 void StiMasterDetectorBuilder::add(StiDetectorBuilder *builder)
113 {
114  push_back(builder);
115 }
116 
117 StiDetectorBuilder * StiMasterDetectorBuilder::get(const string & name)
118 {
119  // iterate through the list to find the requested object.
120  vector<StiDetectorBuilder*>::const_iterator iter;
121  for (iter=begin();
122  iter!=end();
123  iter++)
124  {
125  if((*iter)->isName(name)) return *iter;
126  }
127  cout << "StiMasterDetectorBuilder::get(const string & name) -E- Requested object not found" << endl;
128  assert(0);
129 }
virtual void setNRows(UInt_t nRows)
virtual void build(StMaker &source)
const string & getName() const
Get the name of the object.
Definition: Named.cxx:22