StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rdMuDst2spec.C
1 #include <StEEmcUtil/database/EEmcDbItem.h>
2 class StChain;
4 class EEmcDbItem;
5 class StEEmcDb;
6 StEEmcDb *myDb;
7 StChain *chain=0;
8 TH1F * hx[8];
9 TH1F * hr[8];
10 TH1F * hd[8];
11 TH1F * hs[24];
12 
13 int rdMuDst2spec(
14  char* file = "R50530.MuDst.root",
15  Int_t nFiles = 1,
16  char* inDir = "./",
17  int nEve=5 ){
18 
19  inDir = "/star/data39/reco/production62GeV/ReversedFullField/P04id/2004/089//";
20  file="st_physics_5089006_raw_4040002.MuDst.root";
21 
22  initHisto();
23 
24  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
25  loadSharedLibraries();
26  cout << " loading done " << endl;
27  gSystem->Load("StDbLib");
28  gSystem->Load("StDbBroker");
29  gSystem->Load("St_db_Maker");
30  gSystem->Load("StEEmcUtil");
31  gSystem->Load("StEEmcDbMaker");
32 
33 
34 
35  // create chain
36  chain = new StChain("StChain");
37 
38  // Now we add Makers to the chain...
39  muMk = new StMuDstMaker(0,0,inDir,file,"MuDst.root",nFiles);
40 
41  St_db_Maker *dbMk = new St_db_Maker("StarDb", "MySQL:StarDb");
42  new StEEmcDbMaker("eemcDb");
43 
44  // myMk1->setSectors(1,8);
45  // myDb->setTimeStampDay(20040320); // format: yyyymmdd
46  //myMk1->setPreferedFlavor("set-b","eemcPMTcal");
47 
48 
49  chain->Init();
50  chain->ls(3);
51  myDb = (StEEmcDb*)chain->GetDataSet("StEEmcDb");
52 
53  exit;
54  int eventCounter=0;
55  int stat=0;
56 
57  //---------------------------------------------------
58  while ( stat==0 ) {// loop over events
59  if(eventCounter>=nEve) break;
60  eventCounter++;
61  chain->Clear();
62  stat = chain->Make();
63 
64  // Access to muDst .......................
65  StMuEvent* muEve = muMk->muDst()->event();
66  int nPrim = muMk->muDst()->primaryTracks()->GetEntries(); // get number of primary tracks
67  StEventInfo &info=muEve->eventInfo();
68  // if(eventCounter%100!=0)continue;
69 
70  printf("\n\n ====================%d processing eventID %d nPrim=%d ==============\n", eventCounter,info.id(),nPrim);
71 
72  hx[0]->Fill(nPrim);
73  StMuEmcCollection* emc = muMk->muDst()->emcCollection();
74  if (!emc) {
75  printf(" No EMC data for this event\n");
76  return kStOK;
77  }
78  printEEtower(emc);
79  printEEpre(emc);
80  printEEsmd(emc);
81 
82  }
83 
84 }
85 
86 //===========================================
87 //===========================================
88 printEEtower( StMuEmcCollection* emc ) {
89  int sec,eta,sub,adc;
90  // StMuEmcHit *hit;
91 
92  int i, nh;
93 
94  printf("\Total %d hits in Tower (only ADC>0)\n",emc->getNEndcapTowerADC());
95  nh=0;
96  for (i=0; i< emc->getNEndcapTowerADC(); i++) {
97  emc->getEndcapTowerADC(i,adc,sec,sub,eta);
98  // if (adc<=0) continue; // print only non-zero values
99  // printf("i=%d Tower %2.2dT%c%2.2d adc=%4d\n",i,sec,sub+'A'-1,eta,adc );
100  // printf(" Tower isec=%d ieta=%d isub=%d adc=%4d\n",sec,eta, sub,adc );
101  //int adcX=1000+ (eta-1) + (sub-1)*12 +(sec-1)*60; assert(adc==adcX );
102 
103 
104  // fill some histo
105  int irad=sub -1 + 5*(sec-1) +60 *(eta-1);
106  EEmcDbItem *x=myDb->getTile(sec,'A'+sub-1,eta,'T');
107  if(x==0) continue;
108  if(x->fail) continue;
109  //printf("x=%p ped=%f gain=%f\n",x,x->ped, x->gain);
110  if(adc<x->thr) continue;
111  nh++;
112  adc-=x->ped;
113  if(adc>20) hr[0]->Fill(irad);
114  ((TH2F*) hd[0])->Fill(irad,adc);
115  }
116  printf(" Total %d towers with ADC>Thr & !fail \n",nh);
117 }
118 
119 
120 //===========================================
121 //===========================================
122 printEEpre( StMuEmcCollection* emc ) {
123  int sec,eta,sub,pre,adc;
124  StMuEmcHit *hit;
125 
126  int i, nh;
127  nh= emc->getNEndcapPrsHits();
128  printf("\nTotal %d hits in pre1+2+post\n",nh);
129  for (i=0; i<nh; i++) {
130  hit=emc->getEndcapPrsHit(i,sec,sub,eta,pre);
131  int ss=sub + 5*(pre-1);
132  adc=hit->getAdc();
133  //printf("i=%d pre/post(%d) %2.2d%c%c%2.2d : energy=%f adc=%d\n",i,pre,sec,pre+'P'-1,sub+'A'-1,eta,hit->getEnergy(),adc);
134 
135  // fill some histo
136  EEmcDbItem *x=myDb->getTile(sec,'A'+sub-1,eta,'P'+pre-1);
137  if(x==0) continue;
138  if(x->fail) continue;
139  if(adc<x->thr) continue;
140  adc-=x->ped;
141  int irad=sub -1 + 5*(sec-1) +60 *(eta-1);
142  if(adc>20) hr[pre]->Fill(irad);
143  }
144 }
145 
146 
147 //===========================================
148 //===========================================
149 printEEsmd( StMuEmcCollection* emc ) {
150  int sec,strip,adc;
151  char uv='U';
152 
153  for(uv='U'; uv<='V'; uv++) {
154  int nh= emc->getNEndcapSmdHits(uv);
155  printf("\nTotal %d hits in SMD-%c\n",nh,uv);
156  for (int i=0; i<nh; i++) {
157  hit=emc->getEndcapSmdHit(uv,i,sec,strip);
158  adc=hit->getAdc();
159  // printf(" SMD-%c %2.2d%c%3.3d : energy=%f adc=%d\n",uv,sec,uv,strip,hit->getEnergy(),adc);
160 
161  // fill some histo
162  EEmcDbItem *x=myDb->getByStrip(sec,uv,strip);
163  if(x==0) continue;
164  if(x->fail) continue;
165  if(adc<x->thr) continue;
166  adc-=x->ped;
167 
168  int ip=2*(sec-1) +uv -'U';
169  if(adc>20) hs[ip]->Fill(strip);
170 
171  }
172  }
173 }
174 
175 //===========================================
176 //===========================================
177 initHisto() {
178  hx[0]=new TH1F("nPrim","no of prim tracks per event",200,0.,2000);
179 
180  hr[0]=new TH1F("adcT","ADC-ped>20 vs Tower ID, spiral mode; X=iphi+60*ieta",720,-0.5,719.5);
181  hr[1]=new TH1F("adcP","ADC-ped>20 vs pres-1 ID, spiral mode; X=iphi+60*ieta",720,-0.5,719.5);
182  hr[2]=new TH1F("adcQ","ADC-ped>20 vs pres-2 ID, spiral mode; X=iphi+60*ieta",720,-0.5,719.5);
183  hr[3]=new TH1F("adcR","ADC-ped>20 vs post ID, spiral mode; X=iphi+60*ieta",720,-0.5,719.5);
184 
185  int ip;
186  for(ip=0;ip<24;ip++) {
187  char uv='U'+ip%2;
188  int sec=1+ip/2;
189  char tt1[100], tt2[100];
190  sprintf(tt1,"adc%c%02d",uv,sec);
191  sprintf(tt2,"ADC-ped>20 smd-%c%02d ; strip ID",uv,sec);
192  hs[ip]=new TH1F(tt1,tt2,288,0.5,288.5);
193  }
194 
195 
196  TH2F *h2=new TH2F("adc2T","ADC-ped vs Tower ID, spiral mode; X=iphi+60*ieta",720,-0.5,719.5,50,0,300);
197  hd[0]=(TH1F*) h2;
198 
199 }
200 
StMuDst * muDst()
Definition: StMuDstMaker.h:425
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
int getAdc() const
Return ADC value.
Definition: StMuEmcHit.h:19
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
Definition: StMuDst.h:301
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
Definition: Stypes.h:40
static StEmcCollection * emcCollection()
returns pointer to current StEmcCollection
Definition: StMuDst.h:405