StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EzEEsmdCal.cxx
1 // $Id: EzEEsmdCal.cxx,v 1.11 2009/02/04 20:33:22 ogrebeny Exp $
2 
3 #include <assert.h>
4 #include <stdlib.h>
5 
6 #include <TClonesArray.h>
7 
8 #include <TObjArray.h>
9 
10 #include "EzEEsmdCal.h"
11 
12 #include "StEEmcUtil/EEfeeRaw/EEfeeRawEvent.h"
13 #include "StEEmcUtil/EEfeeRaw/EEstarTrig.h"
14 #include "StEEmcUtil/EEfeeRaw/EEmcEventHeader.h"
15 
16 #include "StEEmcUtil/EEfeeRaw/EEfeeDataBlock.h"
17 #include "StEEmcUtil/EEfeeRaw/EEname2Index.h"
18 
19 #include "StEEmcUtil/database/EEmcDbItem.h"
20 
21 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
22 
23 #ifdef StRootFREE
24  #include "EEmcDb/EEmcDb.h"
25 #else
26  #include "StEEmcUtil/database/StEEmcDb.h"
27 #endif
28 
29 
30 ClassImp(EzEEsmdCal)
31 
32 //--------------------------------------------------
33 //--------------------------------------------------
34 EzEEsmdCal::EzEEsmdCal(int sect){
35  printf("EzEEsmdCal() constructed\n");
36  eHead=0;
37  eEve=0;
38  setSector(sect);
39  }
40 
41 //--------------------------------------------------
42 //--------------------------------------------------
43 void EzEEsmdCal::init (){
44  EEsmdCal::init();
45 }
46 
47 //--------------------------------------------------
48 //--------------------------------------------------
49 EzEEsmdCal::~EzEEsmdCal() {/* noop */}
50 
51 
52 //--------------------------------------------------
53 //--------------------------------------------------
54 void EzEEsmdCal::make(){
55 
56  EEsmdCal::clear();
57  unpackEzTree();
58  findSectorMip();// do real analysis
59 
60 }
61 
62 //--------------------------------------------------
63 //--------------------------------------------------
64 void EzEEsmdCal::unpackEzTree(){
65  nInpEve++;
66  // printf(" EzEEsmdCal::getData()is called ......\n");
67 
68  unpackEzTail();
69  unpackEzSmd();
70  return ;
71 }
72 
73 //--------------------------------------------------
74 //--------------------------------------------------
75 void EzEEsmdCal:: unpackEzTail(){
76  // tower/pre/post
77 
78  int nCr=0;
79  int ic;
80  for(ic=0;ic<eEve->block->GetEntries();ic++) {// over dat ablocks
81  EEfeeDataBlock *b=(EEfeeDataBlock *)eEve->block->At(ic);
82  if( !b->isValid() ) continue; // reject corrupted crates corruption
83 
84  int crateID=b->getCrateID();
85  // if(crateID>MaxTwCrateID) continue; // just tower crates
86  nCr++; // count number of valid crates
87 
88  int chan;
89  UShort_t* data=b->getData();
90  int nd=b->getValidDataLen();
91 
92  for(chan=0;chan<nd;chan++) {
93  const EEmcDbItem *x=eeDb->getByCrate(crateID,chan);
94  if(x==0) continue;
95  if(x->isSMD()) break; // abort pre/post crates
96  // (assuming pre/post/tw is not mixed with SMD pixels)
97  if(x->fail ) continue; // drop broken channels
98  if(x->stat & killStat) continue; // drop masked chan
99 
100  // accept this hit
101  int iphi=(x->sec-1)*MaxSubSec+(x->sub-'A');
102  int ieta=x->eta-1;
103  assert(iphi>=0 && iphi<MaxPhiBins);
104  assert(ieta>=0 && ieta<MaxEtaBins);
105 
106  int iT=-1;// store T,P,Q,R depending on 'iT'
107  if(x->name[2]=='T'){
108  iT=0;
109  } else{
110  iT=x->name[2]-'P'+1;
111  }
112  assert(iT>=0 && iT<mxTile);
113 
114  float rawAdc=data[chan];
115  float adc=rawAdc-x->ped;
116  tileAdc[iT][ieta][iphi]=adc;
117  tileThr[iT][ieta][iphi]=rawAdc>x->thr;
118  killT[iT][ieta][iphi]=false;
119  if(x->gain<=0) continue;
120  // ........ only elements with valid gains are processed below
121  tileEne[iT][ieta][iphi]=adc/x->gain;
122  }
123  }
124 
125  return ;
126 
127 }
128 //--------------------------------------------------
129 //--------------------------------------------------
130 void EzEEsmdCal:: unpackEzSmd(){
131  // printf("EzEEsmdCal:: unpackEzSmd()\n");
132  int nCr=0;
133  int ic;
134  for(ic=0;ic<eEve->block->GetEntries();ic++) {// over dat ablocks
135  EEfeeDataBlock *b=(EEfeeDataBlock *)eEve->block->At(ic);
136  if( !b->isValid() ) continue; // reject corrupted crates corruption
137 
138  int crateID=b->getCrateID();
139  if(crateID<=MaxTwCrateID) continue; // drop tower crates
140  nCr++; // count number of valid MAPMT crates
141 
142  int chan;
143  UShort_t* data=b->getData();
144  int nd=b->getValidDataLen();
145 
146  for(chan=0;chan<nd;chan++) {
147  const EEmcDbItem *x=eeDb->getByCrate(crateID,chan);
148  if(x==0) continue;
149 
150  if(!x->isSMD()) break; // abort pre/post crates
151  // (assuming pre/post is not mixed in hrdware with SMD pixels)
152 
153  if(x->fail ) continue; // drop broken channels
154  if(x->stat & killStat) continue; // drop masked chan
155  if(x->sec!=sectID ) continue; // drop data from other sectors
156 
157  float rawAdc=data[chan];
158  float adc=rawAdc-x->ped;
159 
160  if(adc>maxStripAdc) continue; //drop 'jumpy ped'
161  smdAdc[x->plane-'U'][x->strip-1]=adc;
162 
163  if(x->gain<=0)continue; // drop channels w/o gains
164  smdEne[x->plane-'U'][x->strip-1]=adc/x->gain;
165  }
166  }
167 
168  return ;
169 
170 }
int sectID
no. of input events
Definition: EEsmdCal.h:93
char name[StEEmcNameLen]
ASCII name of the channel, see Readme.
Definition: EEmcDbItem.h:20
float smdAdc[MaxSmdPlains][MaxSmdStrips]
30 deg (only for this sector)
Definition: EEsmdCal.h:105
unsigned short killStat
DB access point.
Definition: EEsmdCal.h:113
float tileAdc[mxTile][MaxEtaBins][MaxPhiBins]
Definition: EEsmdCal.h:100