StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
show.C
1 // example macro to use EEmcTTMMaker
2 // Author: Piotr A. Zolnierczuk
3 class TGeoNode;
4 class TGeoVolume;
5 
6 class StPhysicalHelixD;
7 class StThreeVectorD;
8 
9 class StChain;
10 class StMuTrack;
11 class StMuDstMaker;
12 class StEventInfo;
13 class StEventSummary;
14 
15 
16 class EEmcTower;
17 class EEmcTTDisplay;
18 class EEmcTTMMaker;
19 
20 
21 StChain *chain=0;
22 EEmcTTMMaker *ttm =0;
23 StMuDstMaker *muDstMk = 0;
24 EEmcTTDisplay *eemc = 0;
25 TPaveText *eventInfo = 0;
26 TPaveLabel *dateInfo = 0;
27 TDatime *now = 0;
28 
29 void printNodeTree(TObjArray *nodeList, Int_t level=0);
30 TGeoNode *findNode (TObjArray *nodeList,const char *name);
31 
32 
33 void
34 show
35 (
36  char* inpDir = "", // MuDST directory
37  char* inpFile = "show.lis", // MuDST file(s);
38  char* outFile = "show.root",// output tree file
39  Int_t nFiles = 50, // # of MuDST file(s)
40  Int_t nEvents = 100 // # of events
41  )
42  // remeber to adjust dbase timestamp below !!!!
43  // what a ... design
44 {
45  //gErrorIgnoreLevel=1999;
46 
47  // load root/root4star libraries
48  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
49  loadSharedLibraries();
50 
51  // load more libraries :)
52  gSystem->Load("libmysqlclient");
53  gSystem->Load("libGeom");
54  gSystem->Load("StDbLib");
55  gSystem->Load("StDbBroker");
56  gSystem->Load("St_db_Maker");
57 
58  // load even more libraries (EEMC stuff)
59  gSystem->Load("StEEmcUtil");
60  gSystem->Load("StEEmcDbMaker");
61  gSystem->Load("StEEmcPoolTTM");
62 
63  // create the chain
64  chain = new StChain("StChain");
65  //
66 
67  now = new TDatime;
68  // for display
69  TCanvas *c1 = new TCanvas("eemc","eemc",10,10,1000,1000);
70  TPaveLabel *tlab = new TPaveLabel(-0.99,+0.99,+0.99,+0.90,
71  "EEMC TOWERS & TPC TRACKS Piotr A Zolnierczuk (IU)");
72 
73  eventInfo = new TPaveText (-0.99,-0.99,+0.0 ,-0.75);
74  dateInfo = new TPaveLabel(+0.60,-0.99,+0.99,-0.95,now->AsString());
75 
76  TGeoManager *gm = new TGeoManager("eemc", "eemc tower display");
77  TGeoVolume *top = gm->MakeBox("star",0, 200., 200., 350.);
78  TGeoVolume *smbox = gm->MakeBox("smbox1",0, 2., 2., 2.);
79  smbox->SetLineColor(kRed);
80  // eemc
81  eemc = new EEmcTTDisplay();
82  eemc->SetMagneticField(0.5); // in Tesla
83  eemc->SetShowExtrapolatedTracks(true);
84 
85  TGeoTranslation *etra = new TGeoTranslation(0.0,0.0,0.5*(eemc->getZ1()+eemc->getZ2()));
86  top->AddNode(smbox, 1,NULL);
87  top->AddNode(eemc(),1,etra);
88  gm->SetTopVolume(top);
89  gm->CloseGeometry();
90  gm->SetVisLevel(4);
91  gm->SetVisOption(0);
92 
93  c1->SetTheta(90);
94  c1->SetPhi(0);
95 
96  top->Draw();
97  tlab->Draw();
98 
99  gPad->Update();
100 
101  // now we add Makers to the chain... some of that is black magic :)
102  muDstMk = new StMuDstMaker(0,0,inpDir,inpFile,"",nFiles); // muDST main chain
103  StMuDbReader *db = StMuDbReader::instance(); // need the database
104  St_db_Maker *dbMk = new St_db_Maker("StarDb", "MySQL:StarDb"); // need another db(?)
105  new StEEmcDbMaker("eemcDb"); // need EEMC database
106 
107  // now comment in/out/change the below if you want it your way
108  dbMk->setTimeStampDay(20040331); // format: yyyymmdd
109 
110  // finally after so many lines we arrive at the good stuff
111 
112  ttm = new EEmcTTMMaker ("TTM",muDstMk,eemcDbMk);
113  ttm->Summary(cout); //
114 
116 
117  chain->Init();
118 
119  StEEmcDb *eemcDb = (StEEmcDb*)chain->GetDataSet("StEEmcDb");
120  eemcDb->setSectors(1,12); // request EEMC DB for sectors you need (dafault:1-12)
121  eemcDb->setPreferedFlavor("onlped","eemcPMTped"); // request alternative flavor
122 
123  chain->ls(3);
124 
125  //---------------------------------------------------
126  next();
127 }
128 
129 
130 
131 void
132 next(int nMatch=1)
133 {
134  char buffer[1024];
135  int stat=0;
136  int match=0;
137  while(match<nMatch) {
138  stat=chain->Make();
139  if( stat==2 || stat==4) break;
140  if( stat!=0 ) continue;
141 
142  TList *matchList = ttm->GetMatchList();
143  if(matchList->IsEmpty()) continue;
144  TIter nextMatch(matchList);
145 
146  match++;
147 
148  StEventInfo &evinfo = muDstMk->muDst()->event()->eventInfo(); // event info
149  StEventSummary &evsumm = muDstMk->muDst()->event()->eventSummary();// event summary
150  sprintf(buffer,"Run #%d Event #%d\n",evinfo.runId(),evinfo.id());
151  eventInfo->Clear();
152  eventInfo->SetTextAlign(12);
153  eventInfo->AddText(buffer);
154 
155  eemc->Clear();
156  cerr << "<Event";
157  cerr << "Run=\"" << evinfo.runId() << "\"\t";
158  cerr << "Event=\""<< evinfo.id() << "\">\n";
159 
160  EEmcTTMatch *tmatch;
161  while ((tmatch = (EEmcTTMatch *) nextMatch())) {
162  TString outs;
163  eemc->AddMatch(*tmatch);
164  eemc->Out(cerr,*tmatch);
165  eemc->Out(outs,*tmatch);
166  eventInfo->AddText(outs);
167  }
168  cerr << "</Event>" << endl;
169 
170  now->Set();
171  dateInfo->SetLabel(now->AsString());
172 
173  eemc->Draw();
174  eventInfo->Draw();
175  dateInfo->Draw();
176  gPad->Update();
177 
178  }
179  ttm->Summary(cerr);
180 }
181 
182 
183 
184 
185 
186 
187 
188 void printNodeTree(TObjArray *nodeList, Int_t level)
189 {
190  TIter nextNode(nodeList);
191  TGeoNode *node;
192  while( (node=(TGeoNode *)nextNode())!=NULL ) {
193  for(int k=0;k<level;k++) cerr << "\t";
194  cerr << node->GetVolume()->GetName() << endl;
195  printNodeTree(node->GetNodes(),level+1);
196  }
197 }
198 
199 
200 
201 TGeoNode *
202 findNode(TObjArray *nodeList,const char *name)
203 {
204  TIter nextNode(nodeList);
205  TGeoNode *node;
206  while( (node=(TGeoNode *)nextNode())!=NULL ) {
207  if(strcmp(node->GetVolume()->GetName(),name)==0) return node;
208  if( (node=findNode(node->GetNodes(),name))!= NULL ) return node;
209  }
210  return NULL;
211 }
Bool_t AddMatch(EEmcTTMatch &tmatch)
Float_t getZ1() const
gets lower Z edge of EEMC (preshower)
Float_t getZ2() const
gets upper Z edge of EEMC (postshower)
StMuDst * muDst()
Definition: StMuDstMaker.h:425
class EEmcTTMMaker
Definition: EEmcTTMMaker.h:40
static void setLevel(unsigned int level)
sets the debug level
Definition: StMuDebug.h:74
void Out(ostream &out, EEmcTTMatch &tmatch)
EEmcTTMMaker(const char *self="ttmmk", class StMuDstMaker *mumaker=NULL)
ostream & Summary(ostream &out) const
prints matching cuts and statistics summary
void SetMagneticField(double B)
TList * GetMatchList()
returns a list of matches (EEmcTTMatch objects)
Definition: EEmcTTMMaker.h:143
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
void Draw(const Option_t *option="")
void Clear(const Option_t *option="")
virtual Int_t Make()
Definition: StChain.cxx:110
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
void SetShowExtrapolatedTracks(bool f)
EEmc Tower and Track Display class.
Definition: EEmcTTDisplay.h:16
EEmcTTMatch class contains results of TPC track to EEMC tower matching.
Definition: EEmcTTMatch.h:22
void setSectors(int, int)
limit the range of sectors for speed
Definition: StEEmcDb.cxx:114
EEmcTower holds information about an EEMC tower &#39;hit&#39;.
Definition: EEmcTower.h:17