StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MuEzPanitkinMaker.cxx
1 // *-- Author : Rene Fatemi
2 //
3 // $Id: MuEzPanitkinMaker.cxx,v 1.7 2009/12/03 22:35:03 ogrebeny Exp $
4 
5 #include <TFile.h>
6 #include <TH1.h>
7 #include <TH2.h>
8 #include <StMessMgr.h>
9 
10 #include "MuEzPanitkinMaker.h"
11 
12 #include "StMuDSTMaker/COMMON/StMuEvent.h"
13 #include "StMuDSTMaker/COMMON/StMuDst.h"
14 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
15 
16 #include "StMuDSTMaker/EZTREE/EztEventHeader.h"
17 #include "StMuDSTMaker/EZTREE/EztTrigBlob.h"
18 #include "StMuDSTMaker/EZTREE/EztEmcRawData.h"
19 #include "StMuDSTMaker/EZTREE/StTriggerDataMother.h"
20 
21 //tmp
22 #include "StTriggerData2005.h" // tmp
23 
24 #include "EEqaSorter.h"
25 #include "StEEmcUtil/database/StEEmcDb.h"
26 
27 #include "RawPixels.h"
28 ClassImp(MuEzPanitkinMaker)
29 
30 //________________________________________________
31 //________________________________________________
32 MuEzPanitkinMaker::MuEzPanitkinMaker(const Char_t *self, const Char_t *muDstMakerName) : StMaker(self){
33  mMuDstMaker = (StMuDstMaker*)GetMaker(muDstMakerName);
34  assert(mMuDstMaker);
35 
36  trgAkio=0;
37  nTrigEve=nInpEve=0;
38  HList=0;
39  qaSort=0;
40  rawPixels=0;
41  trigID=0;
42  SetHistoPixels(false);
43  SetSpy(false);
44 }
45 
46 
47 //___________________ _____________________________
48 //________________________________________________
49 MuEzPanitkinMaker::~MuEzPanitkinMaker(){
50  delete trgAkio;
51  delete qaSort;
52  delete rawPixels;
53 }
54 
55 //___________________ _____________________________
56 //________________________________________________
57 void MuEzPanitkinMaker::saveHisto(TString fname){
58  TString outName=fname+".hist.root";
59  TFile f( outName,"recreate");
60  assert(f.IsOpen());
61  printf("%d histos are written to '%s' ...\n",HList->GetEntries(),outName.Data());
62  HList->Write();
63  f.Close();
64 
65 }
66 
67 //________________________________________________
68 //________________________________________________
69 Int_t MuEzPanitkinMaker::Init(){
70 
71  assert(HList);
72  StEEmcDb *eeDb = (StEEmcDb*)this->GetDataSet("StEEmcDb");
73  assert(eeDb);
74 
75  qaSort=new EEqaSorter(eeDb);
76  qaSort->initHisto(HList, 1000, 1000); // nBins, maxAdc
77  qaSort->initSpy(HList, 5, 1); // time constant/sec & mode, //mode: 1=balewski@rcf, 2=eemc@evp,3=operator@evp
78  qaSort->setPath("StRoot/StEEmcPool/muEztPanitkin/","/star/u/balewski/0x/defaultPanitkinOut/");
79 
80  if(pixlesOn) {
81  rawPixels=new RawPixels(HList,eeDb);
82  rawPixels->setLimits(0,4095);// range for histos
83  rawPixels->doRawAdc();// converions mode
84  //rawPixels->doPedSub();// converions mode
85  // rawPixels->doPedAndGain(); //
86 
87  }
88  gMessMgr->Message("","I") <<GetName()<<"::Init() filter trigID="<<trigID<<endm;
89  return StMaker::Init();
90 }
91 
92 //________________________________________________
93 //________________________________________________
94 Int_t MuEzPanitkinMaker::InitRun(int runNo){
95 
96  if(pixlesOn) rawPixels->initHisto(); // use DB-info to create histos
97  qaSort->initRun();// DB must be initialized
98 
99 
100  return kStOK;
101 }
102 
103 //________________________________________________
104 //________________________________________________
106  gMessMgr->Message("","I") <<GetName()<<"::Finish() inputEve="<<nInpEve<<" trigFilterEve="<<nTrigEve<<endm;
107  return kStOK;
108 }
109 
110 //________________________________________________
111 //________________________________________________
112 void MuEzPanitkinMaker::Clear(const Option_t*){
113  qaSort->clear();
114  eHead=0;
115  eETow=0;
116  eESmd=0;
117  eTrig=0;
118  // delete trgAkio; //JAN: perhaps is a memory leak? But crashes
119 }
120 
121 
122 //________________________________________________
123 //________________________________________________
125  nInpEve++;
126  gMessMgr->Message("","D") <<GetName()<<"::Make() is called "<<endm;
127 
128  //.......... acquire EztHeader
129  eHead= mMuDstMaker->muDst()->eztHeader();
130  if(eHead==0) {
131  gMessMgr->Message("","E") <<GetName()<<"::Make() no EztEventHeader, skip event "<<endm; return kStOK;
132  }
133 
134  if(nInpEve==1) eHead->print();
135 
136  if(trigID ) {// filter by triggerID on demand
137  if (! mMuDstMaker->muDst()->event()->triggerIdCollection().nominal().isTrigger(trigID)) return kStOK;
138  }
139  nTrigEve++;
140 
141  //.... get data .....
142  eETow=mMuDstMaker->muDst()->eztETow();
143  eESmd=mMuDstMaker->muDst()->eztESmd();
144  eTrig=mMuDstMaker->muDst()->eztTrig();
145  // printf("pp %p %p %p\n",eETow, eESmd, eTrig);
146 
147  // trgAkio=new StTriggerDataMother(eTrig);
148  //trgAkio->dump();
149  // eETow->print(1);
150  // eESmd->print();
151  // eHead->print();
152 
153  // assert(trgAkio->token()!=0) ; // I want to see zer-token events, JB
154 
155  StMuEvent *muEve = mMuDstMaker -> muDst() -> event();
156  assert(muEve);
157  StEventInfo &info=muEve->eventInfo();
158  int runId=info.runId();
159 
160 
161  // .... process adata ......
162  void *blob=eTrig->trgd->GetArray();
163  StTriggerData2005 trgAkio5x( (const TrgDataType2005 *)blob,runId);
164  StTriggerData2005 *trgAkio5=&trgAkio5x;// this is ugly
165  const unsigned char * dsm0inp= trgAkio5->getDsm0_EEMC();
166  unsigned short int * dsm1inp= trgAkio5->getDsm1_EEMC();
167  unsigned short int * dsm2inp= trgAkio5->getDsm2_EMC();
168  unsigned short int * dsm3inp= trgAkio5->getDsm3();
169 
170  // test1(eETow,6);
171  // .... process adata ......
172 
173  qaSort->sort(eETow,eESmd,eHead->getRunNumber(),
174  trgAkio5->token(),trgAkio5->version(),
175  dsm0inp, dsm1inp, dsm2inp, dsm3inp);
176  // it is assumed cratesOFF were removed by qaSort()
177 
178  if(pixlesOn) {
179  rawPixels->sort(eETow);
180  rawPixels->sort(eESmd);
181  }
182 
183  if(eeSpyOn) qaSort->spy(eETow, eESmd, eHead->getRunNumber(), eHead->getEventNumber());
184 
185 
186  return kStOK;
187 }
188 
189 //---------------------------------------------------
190 // $Log: MuEzPanitkinMaker.cxx,v $
191 // Revision 1.7 2009/12/03 22:35:03 ogrebeny
192 // Fixed compiler warnings, mostly char* -> const char*
193 //
194 // Revision 1.6 2009/02/24 04:07:46 ogrebeny
195 // Fixed part of the trigger histograms
196 //
197 // Revision 1.5 2009/02/04 20:33:27 ogrebeny
198 // Moved the EEMC database functionality from StEEmcDbMaker to StEEmcUtil/database. See ticket http://www.star.bnl.gov/rt2/Ticket/Display.html?id=1388
199 //
200 // Revision 1.4 2006/09/15 01:45:36 balewski
201 // add run# to trg-data unpaker
202 //
203 // Revision 1.3 2005/07/15 15:37:36 balewski
204 // *** empty log message ***
205 //
206 // Revision 1.2 2005/05/05 22:22:08 balewski
207 // added spy for JP
208 //
209 // Revision 1.1 2005/04/28 20:54:46 balewski
210 // start
211 //
212 //
213 
virtual Int_t Finish()
StMuDst * muDst()
Definition: StMuDstMaker.h:425
static EztEmcRawData * eztESmd()
returns pointer to eztESmd +pre/post
Definition: StMuDst.h:459
virtual Int_t Make()
static EztTrigBlob * eztTrig()
returns pointer to eztTrig
Definition: StMuDst.h:448
static EztEventHeader * eztHeader()
returns pointer to eztHeader
Definition: StMuDst.h:442
static EztEmcRawData * eztETow()
returns pointer to ETOW
Definition: StMuDst.h:456
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
Definition: Stypes.h:40