StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StGmtRawMaker.cxx
1 //
2 // \class StGmtRawMaker
3 // \authors K.S. Engle and Richard Witt (witt@usna.edu)
4 // based on StFgtRawMaker
5 //
6 
7 // StRoot headers
8 #include "St_base/StMessMgr.h"
9 #include "St_base/Stypes.h"
10 #include "StChain/StRtsTable.h"
11 #include "StEvent/StEvent.h"
12 #include "DAQ_FGT/daq_fgt.h"
13 #include "DAQ_READER/daq_dta.h"
14 #include "StEvent/StGmtCollection.h"
15 #include "StEvent/StGmtStripCollection.h"
16 #include "StEvent/StGmtStrip.h"
17 #include "StGmtUtil/geometry/StGmtGeom.h"
18 #include "St_base/StMessMgr.h"
19 #include "St_base/Stypes.h"
20 #include "StGmtRawMaker.h"
21 
22 const Int_t mChIdToSeqId[128] = {
23  0,16,32,48,64,80,96,112,4,20,36,52,68,84,100,116,8,
24  24,40,56,72,88,104,120,12,28,44,60,76,92,108,124,1,
25  17,33,49,65,81,97,113,5,21,37,53,69,85,101,117,9,
26  25,41,57,73,89,105,121,13,29,45,61,77,93,109,125,2,
27  18,34,50,66,82,98,114,6,22,38,54,70,86,102,118,10,
28  26,42,58,74,90,106,122,14,30,46,62,78,94,110,126,3,
29  19,35,51,67,83,99,115,7,23,39,55,71,87,103,119,11,
30  27,43,59,75,91,107,123,15,31,47,63,79,95,111,127
31 };
32 
33 //________________________________________________________________________________
38  StEvent* eventPtr = (StEvent*)StRTSBaseMaker::GetInputDS("StEvent");
39  if (! eventPtr) return kStFatal;
40  mGmtCollectionPtr = eventPtr->gmtCollection();
41  if(!mGmtCollectionPtr) {
42  mGmtCollectionPtr = new StGmtCollection();
43  if(!mGmtCollectionPtr) {
44  LOG_DEBUG <<"::prepareEnvironment could not create StGmtCollection" <<endm;
45  return kStFatal;
46  }
47  eventPtr->setGmtCollection(mGmtCollectionPtr);
48  LOG_DEBUG <<"::prepareEnvironment() has added a non existing StGmtCollection()"<<endm;
49  } else {
50  //this should be unncessary if the member clear function is called
51  mGmtCollectionPtr->Clear();
52  }
53  return kStOK;
54 }
55 
56 //________________________________________________________________________________
61 
62  LOG_DEBUG <<"StGmtRawMaker::Make()******************************************************************"<<endm;
63 
64  if( prepareEnvironment()!=kStOK ) {
65  LOG_ERROR << "Error preparing enviroment" << endm;
66  return kStFatal;
67  } else {
68  return fillHits();
69  }
70 }
71 
72 //________________________________________________________________________________
77 
78  Int_t rdo=0;
79  Int_t arm=0;
80  Int_t apv=0;
81  Int_t port=-999;
82  Int_t channel=0;
83  Short_t adc=0;
84  Short_t timebin=0;
85  Short_t moduleIdx=0;
86  Short_t coordNum=0;
87  Double_t position=0;
88 
89  // LOG_INFO << "StGmtRawMaker::fillHits() Trying to find fgt/adc... " << endm;
90  LOG_INFO << "StGmtRawMaker::fillHits() Trying to find gmt/adc... " << endm;
91 
93  //now grab the constants from the header file, loop over the raw data and fill the hits...
94  TString query("gmt/adc");
95  // TString query("gmt/zs");
96 
97  while(GetNextDaqElement(query.Data())) {
98  StRtsTable* rts_tbl=DaqDta();
99  Int_t count = 0;
100 
101  for(StRtsTable::iterator it=rts_tbl->begin(); it!=rts_tbl->end(); it++) {
102  fgt_adc_t *mGmtRawData=(fgt_adc_t*)*it;
103  rdo=rts_tbl->Rdo();
104  Int_t chanTmp=mGmtRawData->ch;
105  channel=mChIdToSeqId[chanTmp];
106  //this is different from rts_example
107  timebin=mGmtRawData->tb;
108  //look at rts_example for the mapping
109  adc=mGmtRawData->adc;
110  arm=rts_tbl->Sector();
111  apv=rts_tbl->Pad();
112  // the next segment is needed because of a lack of ARM port information
113  if ( (apv >= 0) && (apv <= 3)) {
114  port = 0;
115  }
116  else if ( (apv >= 12) && (apv <= 15) ) {
117  // cout<<"APV "<<apv<<endl;
118  port = 1;
119  }
120 
121  count++;
122  if(Debug()) {
123  LOG_INFO << "StGmtRawMaker::fillHits() Got: " <<
124  "rdo: " << rdo <<
125  " arm: " << arm <<
126  " apv: " << apv <<
127  " port: " << port <<
128  " channel: " << channel <<
129  " timebin: " << timebin <<
130  " adc: " << adc <<
131  endm;
132  }
134  Int_t geoId=-1;
135  Int_t layer=-1;
136  Short_t strip=-1;
137  moduleIdx = StGmtGeom::getModuleIdFromElecCoord( rdo, arm, apv );
138  coordNum = StGmtGeom::getCoordNumFromElecCoord( rdo, arm, apv, channel );
139  position = StGmtGeom::getPositionFromElecCoord( rdo, arm, apv, channel );
140  // the next segment is needed because of a lack of ARM port information
141  geoId = StGmtGeom::encodeGeoId( rdo, arm, apv, channel ); // geoId same as elecId for now (RW 3/29/2013)
142  StGmtGeom::decodeGeoId( geoId, moduleIdx, layer, strip );
143  StGmtStripCollection *stripCollectionPtr = mGmtCollectionPtr->getStripCollection( moduleIdx );
144  if( stripCollectionPtr ) {
145  geoId = StGmtGeom::encodeGeoId( rdo, arm, apv, channel );
146  StGmtStrip* stripPtr = stripCollectionPtr->getStrip( geoId );
147  if( coordNum == 999 ) { // these are not connected
148  stripPtr->setAdc( 0, timebin );
149  stripPtr->setCharge( 0 ); // was done in separate maker for FGT (StFgtA2CMaker), assume gain=1 for now
150  stripPtr->setChargeUncert( 0 ); // was done in separate maker for FGT (StFgtA2CMaker), assume gain=1 for now
151  stripPtr->setGeoId( geoId );
152  stripPtr->setModule( moduleIdx );
153  stripPtr->setIsY( layer );
154  stripPtr->setPosition( position );
155  stripPtr->setElecCoords( rdo, arm, apv, channel );
156  stripPtr->setCoordNum( coordNum );
157  stripPtr->setPed( 0 );
158  stripPtr->setPedStdDev( 0 );
159  stripPtr->setPedErr( 0 );
160  }
161  else {// these are connected (mapping in StGmtGeom.cxx)
162 
163  if(layer) {// layer here is just an indicator for either a X ( i.e. strip (=0) ) or Y ( i.e. pad (=1) ) element
164  stripPtr->setCoordNum( coordNum + kGmtNumStrips ); // map Y into 128-255
165  //never returns more certain ids
166  if(channel==100) {
167  LOG_INFO << "Str.=" << channel << "\tLay0\tgeoid=" << geoId<< "\tposition=" << position << endl;
168  }
169  }
170  else {
171  stripPtr->setCoordNum( coordNum ); // map X into 0-127
172  if(channel==50) {
173  LOG_INFO << "Str.=" << channel << "\tLay0\tgeoid=" << geoId<< "\tposition=" << position << endl;
174  }
175  }
176  stripPtr->setAdc( adc, timebin );
177  stripPtr->setCharge( adc ); // was done in separate maker for FGT (StFgtA2CMaker), assume gain=1 for now
178  stripPtr->setChargeUncert( sqrt(adc) ); // was done in separate maker for FGT (StFgtA2CMaker), assume gain=1 for now
179  stripPtr->setGeoId( geoId );
180  stripPtr->setModule( moduleIdx );
181  stripPtr->setIsY( layer );
182  stripPtr->setPosition( position );
183  stripPtr->setElecCoords( rdo, arm, apv, channel );
184  } // else
185 
186  if (Debug()) {
187  LOG_INFO << "StGmtRawMaker::fillHits() Set: " << *stripPtr << endm;
188  }
189  }
190  else {
191  LOG_WARN << "StGmtRawMaker::Make() -- Could not access module " << moduleIdx << endm;
192  }
193  } // for(StRtsTable::iterator it=rts_tbl->begin();it!=rts_tbl->end();it++)
194  } // while
195  return kStOK;
196 }
Holds collections of GMT data.
void Clear(Option_t *opts="")
Clear method.
StRtsTable * GetNextDaqElement(const char *elementPath)
Query the STAR production chain for the DAQ data.
void setPed(Float_t ped)
Set pedestal.
Definition: StGmtStrip.h:131
void setPedErr(Float_t pedErr)
Set pedestal error.
Definition: StGmtStrip.h:135
void setElecCoords(Int_t rdo, Int_t arm, Int_t apv, Int_t chan)
Set coordinates from electronics.
Definition: StGmtStrip.h:128
void setPosition(Float_t position)
Set position relative to local origin (in module)
Definition: StGmtStrip.h:107
void setPedStdDev(Float_t pedStdDev)
Set pedestal standard deviation.
Definition: StGmtStrip.h:133
void setCharge(Float_t charge)
Set charge before the GEM (in C)
Definition: StGmtStrip.h:124
StRtsTable * DaqDta()
Return the current DAQ data block. This member function is provided for convenience.
void setIsY(Int_t isY)
Set is it a pad.
Definition: StGmtStrip.h:103
void setChargeUncert(Float_t chargeUncert)
Set charge uncertainty.
Definition: StGmtStrip.h:126
void setGeoId(Int_t geoId)
Set detector GeoId.
Definition: StGmtStrip.h:97
void setCoordNum(Int_t coord)
Set coordinate.
Definition: StGmtStrip.h:101
Definition: Stypes.h:40
void setAdc(Short_t adc, Int_t tb=-1)
Set ADC for the given time bucket.
Definition: StGmtStrip.h:109
StGmtStripCollection * getStripCollection(unsigned short moduleIdx)
Pointer to the GMT strip collection in the i-th module.
Holds data for the strip in GMT.
Definition: StGmtStrip.h:21
void setModule(Int_t module)
Set module.
Definition: StGmtStrip.h:99
Int_t prepareEnvironment()