StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StAdcPedHistoMaker.cxx
1 // code 'as is' from Murad, used to generate AuAu200 pedestals from regualr muDst
2 
3 #if 0
4 //std
5 #include <map>
6 #include <string>
7 #include <algorithm>
8 #include <iostream>
9 
10 //some libraries
11 #include "StarClassLibrary/StPhysicalHelixD.hh"
12 #include "StarClassLibrary/StThreeVectorD.hh"
13 #include "StarClassLibrary/StThreeVectorF.hh"
14 
15 
16 //StEvent
17 #include "StEvent/StEmcDetector.h"
18 #include "StEvent/StEmcCollection.h"
19 #include "StEvent/StEmcRawHit.h"
20 #include "StEvent/StEmcModule.h"
21 
22 //StEmc
23 #include "StEmcClusterCollection.h"
24 #include "StEmcPoint.h"
25 #include "StEmcUtil/geometry/StEmcGeom.h"
26 #include "StEmcUtil/others/emcDetectorName.h"
27 #include "StEmcADCtoEMaker/StBemcData.h"
28 #include "StEmcADCtoEMaker/StEmcADCtoEMaker.h"
29 #include "StEmcRawMaker/defines.h"
30 #include "StEmcRawMaker/StBemcRaw.h"
31 
32 //root
33 #include "TTree.h"
34 #include "TFriendElement.h"
35 #include "TFile.h"
36 
37 //StMuDst
38 
39 
40 #include "StMuDSTMaker/COMMON/StMuTrack.h"
41 
42 //StTrackMaker
43 
44 //Endcap
45 
46 #include "StEEmcUtil/database/cstructs/eemcConstDB.hh"
47 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
48 #endif
49 
50 //new
51 #include "StAdcPedHistoMaker.h"
52 #include "StEEmcUtil/database/StEEmcDb.h"
53 #include "StEEmcUtil/database/EEmcDbItem.h"
54 
55 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
56 #include "StMuDSTMaker/COMMON/StMuDst.h"
57 #include "StMuDSTMaker/COMMON/StMuTriggerIdCollection.h"
58 #include "StMuDSTMaker/COMMON/StMuEvent.h"
59 
60 ClassImp(StAdcPedHistoMaker)
61 
62 //---------------------------
63 //---------------------------
64 //---------------------------
65 StAdcPedHistoMaker::StAdcPedHistoMaker(const char* name, StMuDstMaker* uDstMaker)
66  : StMaker(name), mDstMaker(uDstMaker) {
67  HList=0;
68  pedSub=false;
69  killMask=0;
70  SetTrigId(0);
71  cout <<"StAdcPedHistoMaker::StAdcPedHistoMaker()"<<endl;
72 }
73 
74 
75 //---------------------------
76 //---------------------------
77 //---------------------------
78 
79 StAdcPedHistoMaker::~StAdcPedHistoMaker()
80 {
81  cout <<"StAdcPedHistoMaker::~StAdcPedHistoMaker()"<<endl;
82 }
83 
84 
85 //---------------------------
86 //---------------------------
87 //---------------------------
88 
89 Int_t
90 StAdcPedHistoMaker::Init() {
91  mEeDb = (StEEmcDb*)this->GetDataSet("StEEmcDb");
92  assert(mEeDb); // eemcDB must be in the chain, fix it
93  return kStOk;
94 }
95 
96 //------------------------------------
97 //------------------------------------
98 
99 Int_t StAdcPedHistoMaker::InitRun(int runNo){
100 
101  assert(mEeDb);
102  // ................... histo for individual pixels ...
103  int i,k=0;
104  for(i=0;i<EEindexMax;i++) {
105  const EEmcDbItem *x=mEeDb->getByIndex(i);
106  if(x==0) continue;
107  // initialize histos only for pixels acquired from DB
108  k++;
109  char tt1[100],tt2[200];
110  sprintf(tt1,"a%s",x->name);
111  sprintf(tt2,"ADC for %s, cr/chan=%3.3d/%3.3d, tube=%s; ADC",x->name,
112  x->crate,x->chan,x->tube);
113  TH1F* h=new TH1F(tt1,tt2,500,-20.5,479.5);
114  hPix[i]=h;
115  HList->Add(h);
116  }
117 
118  printf("StAdcPedHistoMaker::InitRun() setup: pedSub=%d killMask=0x%0x trigId=%d\n", pedSub, killMask, trigID);
119  return kStOk;
120 }
121 
122 //------------------------------------
123 //------------------------------------
124 Int_t
126 {
127  return kStOk;
128 }
129 
130 //------------------------------------
131 //------------------------------------
132 Int_t
134 
135  StMuEvent *event = mDstMaker -> muDst() -> event();
136 
137  StMuTriggerIdCollection tic = event -> triggerIdCollection();
138  StTriggerId l1trig = tic.l1();
139  if( trigID && !l1trig.isTrigger(trigID)) return kStOk;
140 
141 
142  //--------------------
143 
144  StMuEmcCollection* emc = mDstMaker->muDst()->muEmcCollection();
145  assert(emc);
146 
147  //.......................... T O W E R S .....................
148  const int nEndcapTowers=720;
149  for(int i=0;i<nEndcapTowers;i++){
150  int sec,eta,sub,val; //muDst ranges:sec:1-12, sub:1-5, eta:1-12
151  emc->getEndcapTowerADC(i,val,sec,sub,eta);
152  const EEmcDbItem *x=mEeDb -> getTile(sec,'A'+sub-1,eta,'T');
153  if(x==0) continue;
154  float adc=val;
155  if(pedSub) adc-=x->ped;
156  if(killMask) {
157  if(x->fail ) continue; // drop broken channels
158  if(x->stat & killMask) continue; // drop not working channels
159  }
160  hPix[x->key]->Fill(adc);
161  }
162 
163  //......................... P R E - P O S T .....................
164  int pNh= emc->getNEndcapPrsHits();
165  for (int i=0; i < pNh; i++) {
166  int pre, sec, eta, sub;
167  //muDst ranges: sec:1-12, sub:1-5, eta:1-12 ,pre:1-3==>pre1/pre2/post
168  StMuEmcHit *hit=emc->getEndcapPrsHit(i,sec,sub,eta,pre);
169  float adc=hit->getAdc();
170  //Db ranges: sec=1-12,sub=A-E,eta=1-12,type=T,P-R ; slow method
171  const EEmcDbItem *x=mEeDb -> getTile(sec,sub-1+'A', eta, pre-1+'P');
172  if(x==0) continue;
173  if(pedSub) adc-=x->ped;
174  if(killMask) {
175  if(x->fail ) continue; // drop broken channels
176  if(x->stat & killMask) continue; // drop not working channels
177  }
178  hPix[x->key]->Fill(adc);
179  }
180 
181  //........................... S M D ................................
182  char uv='U';
183  for(uv='U'; uv <= 'V'; uv++) {
184  int sec, strip;
185  int nh= emc->getNEndcapSmdHits(uv);
186  for (int i=0; i < nh; i++) {
187  StMuEmcHit *hit=emc->getEndcapSmdHit(uv,i,sec,strip);
188  float adc=hit->getAdc();
189  const EEmcDbItem *x=mEeDb -> getByStrip(sec,uv,strip);
190  if(x==0) continue;
191  if(pedSub) adc-=x->ped;
192  if(killMask) {
193  if(x->fail ) continue; // drop broken channels
194  if(x->stat & killMask) continue; // drop not working channels
195  }
196  hPix[x->key]->Fill(adc);
197  }
198  }
199  return kStOk;
200 }
201 
202 
StMuDst * muDst()
Definition: StMuDstMaker.h:425
const EEmcDbItem * getByIndex(int ikey) const
returns full DB info for one pixel
Definition: StEEmcDb.cxx:584
char name[StEEmcNameLen]
ASCII name of the channel, see Readme.
Definition: EEmcDbItem.h:20
int getAdc() const
Return ADC value.
Definition: StMuEmcHit.h:19
char tube[StEEmcNameLen]
name of PMT or MAPMT pixel
Definition: EEmcDbItem.h:21
static StMuEmcCollection * muEmcCollection()
returns pointer to current StMuEmcCollection
Definition: StMuDst.h:389
Collection of trigger ids as stored in MuDst.
int chan
hardware channel
Definition: EEmcDbItem.h:28
Definition: Stypes.h:41