StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ttmexample.C
1 // example macro to use EEmcTTMMaker
2 // Author: Piotr A. Zolnierczuk, IUCF
3 // Date: 05/04/2004
4 //
5 
6 // ROOT/ROOT4STAR
7 class StChain;
8 class StMuTrack;
9 class StMuDstMaker;
10 class StEventInfo;
11 // TTM STUFF
12 class EEmcTower;
13 class EEmcTTMatch;
14 class EEmcTTMMaker;
15 
16 StChain *chain=0;
17 EEmcTTMMaker *ttm =0;
18 StMuDstMaker *muDstMaker= 0;
19 
20 void
21 ttmexample
22 (
23  char* inpDir = "", // MuDST directory
24  char* inpFile = "ttm.lis", // MuDST file(s);
25  char* outFile = "ttm.ndst.root",// output nano dst root file
26  Int_t nFiles = 150, // # of MuDST file(s)
27  Int_t nEvents = -1 // # of events
28  )
29  // NOTES:
30  // 1. EEmcTTMMaker main "product" is a list of EEmcTTMatch'es which in turn are
31  // EEmcTower plus a list of StMuTrack's that fullfill certain criteria.
32  // 2. Optionally the Maker created a nanoDst file [ or a 'Not-a-Dst' file :) ]
33  //
34 {
35  // load root/root4star libraries
36  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
37  loadSharedLibraries();
38  // load more libraries :)
39  gSystem->Load("libmysqlclient");
40  gSystem->Load("StDbLib");
41  gSystem->Load("StDbBroker");
42  gSystem->Load("St_db_Maker");
43  // load even more libraries (EEMC stuff)
44  gSystem->Load("StEEmcUtil");
45  gSystem->Load("StEEmcDbMaker");
46  gSystem->Load("StEEmcPoolTTM");
47 
48  // create the chain
49  chain = new StChain("StChain");
50 
51  // now we add Makers to the chain... some of that is black magic to me :)
52  muDstMaker = new StMuDstMaker(0,0,inpDir,inpFile,"",nFiles); // muDST main chain
53  StMuDbReader *db = StMuDbReader::instance(); // need the database
54  St_db_Maker *dbMk = new St_db_Maker("StarDb", "MySQL:StarDb"); // need more db?
55  StEEmcDbMaker *eemcDbMaker = new StEEmcDbMaker("eemcDb"); // need EEMC database
56 
57  // now comment in/out/change the below if you want it your way
58  eemcDbMaker->setSectors(1,12); // request sectors you need (default:1-12)
59  eemcDbMaker->setPreferedFlavor("onlped","eemcPMTped"); // request alternative db flavor
60 
61  // finally after so many lines we arrive at the good stuff
62  ttm = new EEmcTTMMaker ("TTM",muDstMaker,eemcDbMaker);
63  ttm->SetFileName(outFile); // output nanoDst file
64  // have cuts your way (optional)
65  ttm->SetMaxCTBSum(1000);
66  ttm->SetMinTrackLength(20.0);
67  ttm->SetMinTrackHits(5);
68  ttm->SetMinTrackPt(0.5);
69  ttm->SetMinTrackEta(0.7);
70  ttm->SetMaxTrackEta(2.2);
71  ttm->SetDeltaEtaCut(0.7); // ! note this is a fraction of tower width in eta
72  ttm->SetDeltaPhiCut(0.7); // ! note this is a fraction of tower width in phi
73  // this is even more optional :)
74  // the lines here repeat the default
75  // ttm->ResetZPositionsArray();
76  // ttm->AddZPosition("pres",kEEmcZPRE1+0.1);
77  // ttm->AddZPosition("post",kEEmcZPOST-0.1);
78  // ttm->AddZPosition("smd" ,kEEmcZSMD);
79  ttm->Summary(cout); // prints cut summary
80 
82  chain->Init();
83  chain->ls(3);
84 
85  //---------------------------------------------------
86  int stat=0;
87  int event=0;
88  while(++event<nEvents) {
89  stat=chain->Make();
90  // STAR intelligence: stat=2 EOF,stat=4 FATAL; if so break the loop
91  // if not OK (and not EOF nor FATAL) !!! try another event
92  if( stat==2 || stat==4) break;
93  if( stat!=0 ) continue;
94 
95  // if no track to tower matches try another event
96  if(ttm->GetMatchList()->IsEmpty()) continue;
97 
98  // set up iterator and pointers
99  TIter nextMatch(ttm->GetMatchList());
100  EEmcTTMatch *tmatch;
101  EEmcTower *tower;
102  StMuTrack *track;
103  //event info (for fun), it shows we like xml
104  StEventInfo &evInfo = muDstMaker->muDst()->event()->eventInfo();
105  cerr << "<Event";
106  cerr << "Run=\"" << evInfo.runId() << "\"\t";
107  cerr << "Event=\""<< evInfo.id() << "\">\n";
108  // loop over all towers with track hits
109  while ((tmatch = (EEmcTTMatch*) nextMatch())) {
110  tmatch->Out(cerr); // prints all match info
111  tower = tmatch->Tower();
112  // here's how to acces tower information
113  const char *tLabel = tower->TowerLabel();
114  int sector = tower->Sec(); // 0..11
115  int subsec = tower->SubSec(); // 0..4
116  int etabin = tower->Eta(); // 0..11
117  float adc = tower->ADC(); // adc - pedestal
118  float de = tower->dE(); // (adc - pedestal)/gain
119  //
120  int seclab = tower->SecLabel(); // 1..12
121  int sublab = tower->SubSecLabel(); // A..E
122  int etalab = tower->EtaLabel(); // 1..12
123  // now more than one track may hit a tower
124  TIter nextTrack(tmatch->Tracks());
125  while((track=(StMuTrack *)nextTrack())) {
126  // how to access StMuTrack consult muDST manual (does not exist)
127  TVector3 r;
128  // for example one could extrapolate track to a given z-depth
129  EEmcTTMatch::ExtrapolateToZ(track,290.0,r);
130  double pt = track->pt();
131  double x = r.x();
132  }
133  }
134  cerr << "</Event>" << endl;
135  }
136  ttm->Summary(cerr);
137 }
138 
139 
float ADC() const
gets adc value associated with the tower (pedestal adjusted)
Definition: EEmcTower.h:47
void SetDeltaEtaCut(Double_t v=1.0)
sets delta eta cut see matchparams
Definition: EEmcTTMMaker.h:127
StMuDst * muDst()
Definition: StMuDstMaker.h:425
void SetMinTrackPt(Double_t v)
sets minimum track pT required
Definition: EEmcTTMMaker.h:106
Double_t pt() const
Returns pT at point of dca to primary vertex.
Definition: StMuTrack.h:256
const char * TowerLabel() const
returns tower label, e.g. &quot;05TB09&quot;
Definition: EEmcTower.cxx:77
class EEmcTTMMaker
Definition: EEmcTTMMaker.h:40
int SubSecLabel() const
gets tower subsector label, human offset [A..E]
Definition: EEmcTower.h:78
void SetMinTrackEta(Double_t v)
sets minimum pseudorapidity at the origin required
Definition: EEmcTTMMaker.h:111
static void setLevel(unsigned int level)
sets the debug level
Definition: StMuDebug.h:74
EEmcTTMMaker(const char *self="ttmmk", class StMuDstMaker *mumaker=NULL)
float dE() const
gets calibrated energy loss value associated with the tower
Definition: EEmcTower.h:52
ostream & Summary(ostream &out) const
prints matching cuts and statistics summary
TList * GetMatchList()
returns a list of matches (EEmcTTMatch objects)
Definition: EEmcTTMMaker.h:143
void SetMaxTrackEta(Double_t v)
sets minimum pseudorapidity at the origin required
Definition: EEmcTTMMaker.h:116
void SetMinTrackLength(Double_t v)
sets minimum track length required
Definition: EEmcTTMMaker.h:101
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
void SetDeltaPhiCut(Double_t v=1.0)
sets delta phi cut see matchparams
Definition: EEmcTTMMaker.h:122
int SubSec() const
gets tower subsector index, computer offset [0,....)
Definition: EEmcTower.h:62
void SetMaxCTBSum(Int_t v)
sets maximum CTB sum allowed
Definition: EEmcTTMMaker.h:89
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
int Sec() const
gets tower sector index, computer offset [0,....)
Definition: EEmcTower.h:57
int SecLabel() const
gets tower sector label, human offset [1..12]
Definition: EEmcTower.h:73
EEmcTTMatch class contains results of TPC track to EEMC tower matching.
Definition: EEmcTTMatch.h:22
int EtaLabel() const
gets tower eta label, human offset [1..12]
Definition: EEmcTower.h:83
void SetMinTrackHits(Int_t v)
sets minimum number of hits/track required
Definition: EEmcTTMMaker.h:95
void SetFileName(const char *string)
set output file name
Definition: EEmcTTMMaker.h:130
int Eta() const
gets tower eta index, computer offset [0,....)
Definition: EEmcTower.h:67
EEmcTower holds information about an EEMC tower &#39;hit&#39;.
Definition: EEmcTower.h:17
static Bool_t ExtrapolateToZ(const StMuTrack *track, const double z, TVector3 &r)
given track and position z return TVector3 with a