21 #include "StFgtSingleEventDisplay.h"
22 #include "StRoot/StFgtUtil/StFgtConsts.h"
28 #include "StRoot/StFgtUtil/geometry/StFgtGeom.h"
29 #include "StRoot/StFgtDbMaker/StFgtDb.h"
31 #include "StRoot/StEvent/StEvent.h"
32 #include "StRoot/StEvent/StFgtCollection.h"
33 #include "StRoot/StEvent/StFgtStripCollection.h"
34 #include "StRoot/StEvent/StFgtStrip.h"
37 StFgtSingleEventDisplay::StFgtSingleEventDisplay(
const Char_t* name,
const Char_t* fname ) :
StMaker( name ) {
44 void StFgtSingleEventDisplay::readFgtStripDb(){
46 double pi=2.*acos(0.);
47 double rad2deg=pi/180.;
52 mFgtDbMkr =
static_cast< StFgtDbMaker*
>( GetMakerInheritsFrom(
"StFgtDbMaker" ) );
54 LOG_FATAL <<
"Error finding StFgtDbMaker" << endm;
59 mDb = mFgtDbMkr->getDbTables();
65 for (
int rdo=1;rdo<=2;rdo++){
66 for (
int arm=0;arm<6;arm++){
67 for (
int apv=0;apv<=21;apv++){
68 if ((apv==10)||(apv==11))
continue;
69 for (
int channel=0;channel<128;channel++){
71 geoId=mDb->getGeoIdFromElecCoord(rdo, arm, apv, channel);
72 if (geoId<0)
continue;
73 std::string geoName=mDb->getGeoNameFromElecCoord(rdo,arm,apv,channel);
75 S = &(stripDb[numFgtElect]);
77 entryForGeoId[geoId] = numFgtElect++;
79 Double_t ordinate,lowerSpan,upperSpan;
80 StFgtGeom::decodeGeoId(S->geoId,S->disc,S->quad,S->layer,S->strip);
81 StFgtGeom::getGlobalPhysicalCoordinate(geoName,S->disc,S->quad,S->layer,ordinate, lowerSpan, upperSpan);
84 S->phi1=S->phi2=ordinate;
87 S->x1=S->r1*cos(S->phi1);
88 S->x2=S->r2*cos(S->phi2);
89 S->y1=S->r1*sin(S->phi1);
90 S->y2=S->r2*sin(S->phi2);
95 S->phi1Deg=S->phi1/rad2deg;
96 S->phi2Deg=S->phi2/rad2deg;
103 S->ped = mDb->getPedestalFromElecCoord(rdo,arm,apv,channel);
104 S->sigPed= mDb->getPedestalSigmaFromElecCoord(rdo,arm,apv,channel);
105 S->stat = mDb->getStatusFromElecCoord(rdo,arm,apv,channel);
106 S->electId = StFgtGeom::getElectIdFromElecCoord(rdo,arm,apv,channel);
107 S->Z = StFgtGeom::getDiscZ(S->disc);
126 StFgtSingleEventDisplay::~StFgtSingleEventDisplay(){
129 Int_t StFgtSingleEventDisplay::Init(){
141 mFgtCollectionPtr = 0;
143 if (mDb == NULL) readFgtStripDb();
145 for(
int j = 0; j < numFgtElect; j++) {
149 eventPtr = (
StEvent*)GetInputDS(
"StEvent");
151 LOG_ERROR <<
"Error getting pointer to StEvent in '" << ClassName() <<
"'" << endm;
154 mFgtCollectionPtr=eventPtr->fgtCollection();
156 if( !mFgtCollectionPtr) {
157 LOG_ERROR <<
"Error getting pointer to StFgtCollection in '" << ClassName() <<
"'" << endm;
163 for( Int_t disc = 0; disc < kFgtNumDiscs; ++disc ){
167 stripCollectionPtr = mFgtCollectionPtr->getStripCollection( disc );
171 if( stripCollectionPtr ){
172 const StSPtrVecFgtStrip &stripVec = stripCollectionPtr->getStripVec();
173 StSPtrVecFgtStripConstIterator stripIter;
174 stripIter = stripVec.begin();
177 for( stripIter = stripVec.begin(); stripIter != stripVec.end(); ++stripIter ){
179 Int_t geoId = (*stripIter)->getGeoId();
181 if(geoId < 0)
continue;
185 Short_t disc, quad, strip;
187 StFgtGeom::decodeGeoId( geoId, disc, quad, layer, strip );
188 Int_t entry = getEntryForGeoId(geoId);
189 Short_t ped = stripDb[entry].ped;
190 Double_t pedDb=mDb->getPedestalFromGeoId(geoId);
191 Short_t statDb=mDb->getStatusFromGeoId(geoId);
193 Short_t sigPed = stripDb[entry].sigPed;
200 for( Int_t tb = 0; tb < kFgtNumTimeBins; ++tb ){
201 Short_t adc = (*stripIter)->getAdc(tb);
211 Bool_t octIsShort = ( layer ==
'R' ? (strip > 279) : (strip > 359) );
215 stripDb[entry].adc[tb] = adc;
218 if(adc > ped + 6 * sigPed) {
220 stripDb[entry].hit += 1<<tb;
234 void StFgtSingleEventDisplay::drawStrip(Int_t geoId, Color_t lineColor) {
239 Double_t x1; Double_t y1;
240 Double_t x2; Double_t y2;
244 Int_t entry = getEntryForGeoId(geoId);
248 x1 = stripDb[entry].x1;
249 y1 = stripDb[entry].y1;
250 x2 = stripDb[entry].x2;
251 y2 = stripDb[entry].y2;
252 z = stripDb[entry].Z;
254 disc = stripDb[entry].disc;
255 quad = stripDb[entry].quad;
256 layer = stripDb[entry].layer;
257 strip = stripDb[entry].strip;
258 Short_t ped = stripDb[entry].ped;
259 Short_t sigPed = stripDb[entry].sigPed;
262 for (
int l = 0; l < kFgtNumTimeBins-1; l++) {
263 if(stripDb[entry].adc[l] > maxAdc) {
264 maxAdc = stripDb[entry].adc[l];
269 Char_t stripName[256];
270 sprintf(stripName,
"FGT%d %d%c%c%d %d%c%d %d",geoId,disc,quad,layer,strip,ped,177,sigPed,maxAdc);
274 #define NUM_SEGMENTS 10
276 float xyz[NUM_SEGMENTS][3];
295 gEventDisplay->
Line(2, (
float *) xyz, lineColor);
296 gEventDisplay->SetComment(stripName);
305 Double_t mx1, my1, phi1, phi2, r1;
306 r1 = stripDb[entry].r1;
307 phi1 = stripDb[entry].phi1;
308 phi2 = stripDb[entry].phi2;
309 phiDiff = (phi2 - phi1)/ (NUM_SEGMENTS - 1.0);
310 for (
int j = 0; j < NUM_SEGMENTS; j++) {
312 mx1=r1*cos(phi1 + phiDiff*j);
313 my1=r1*sin(phi1 + phiDiff*j);
321 gEventDisplay->
Line(NUM_SEGMENTS, (
float*) xyz, lineColor );
323 gEventDisplay->SetComment(stripName);
virtual TObject * Line(int n, const double *xyz, Color_t col=Color_t(-1), Style_t sty=Style_t(-1), Size_t siz=Size_t(-1))
This is an overloaded member function, provided for convenience.