7 #include "StEvent/StEvent.h"
8 #include "StEvent/StTpcHit.h"
9 #include "StEvent/StTpcHitCollection.h"
10 #include "StEvent/StTriggerData.h"
11 #include "StDetectorDbMaker/St_EbyET0C.h"
29 StEbyET0::~StEbyET0() {
34 void StEbyET0::finishCalib() {
37 delete (mTree->GetDirectory()->GetFile());
40 double StEbyET0::getTime(
StEvent* event,
int mode) {
43 if (event->runId() == mRunId &&
event->id() == mEventId)
return mTime;
45 mRunId =
event->runId();
46 mEventId =
event->id();
51 if (mode == 1) fillTree(event);
55 St_EbyET0C* ebyeTable = St_EbyET0C::instance();
56 for (
int row = 0; row < ebyeTable->GetNRows(); row++) {
57 memset(info,0,12*
sizeof(
double));
58 int detector = ebyeTable->detector(row);
59 if (detector < 0)
break;
61 double coordinate = -9e23;
68 case 3 : getTriggerInfo(event,static_cast<trigDetType> (detector),info);
69 if (info[0] > 0 && info[1] > 0)
70 coordinate = 0.5*(info[0]+info[1]);
75 case 7 : getTriggerInfo(event,static_cast<trigDetType> (detector-4),info);
82 case 11 : getTriggerInfo(event,static_cast<trigDetType> (detector-8),info);
89 if (coordinate < -8e23 ||
90 (ebyeTable->min(row) < ebyeTable->max(row) &&
91 (ebyeTable->min(row) > coordinate ||
92 ebyeTable->max(row) < coordinate)))
continue;
95 mTime = ebyeTable->time(row,coordinate);
101 if (mode == 2) fillTree(event);
106 void StEbyET0::fillTree(
StEvent* event) {
109 new TFile(Form(
"EbyET0.%d.%d.root",mRunId,mEventId),
"RECREATE");
110 mTree =
new TNtupleD(
"ebyeT0tree",
"Event by Event T0 tree",
112 ":vpde:vpdw:epde:epdw:bbce:bbcw:zdce:zdcw"
113 ":tpctie:tpcnie:tpcrie"
114 ":tpctiw:tpcniw:tpcriw"
115 ":tpctoe:tpcnoe:tpcroe"
116 ":tpctow:tpcnow:tpcrow");
120 int treeEntries = mTree->GetEntriesFast();
121 switch (treeEntries) {
122 case 0 : mTree->SetAutoSave( 5);
break;
123 case 25 : mTree->SetAutoSave( 20);
break;
124 case 250 : mTree->SetAutoSave(100);
break;
125 case 1250 : mTree->SetAutoSave(250);
break;
129 memset(info,0,23*
sizeof(
double));
130 info[0] = (double) mRunId;
131 info[1] = (double) mEventId;
132 info[2] = (double) (event->time());
133 getTriggerInfo(event,kVPD,&(info[3]));
134 getTriggerInfo(event,kEPD,&(info[5]));
135 getTriggerInfo(event,kBBC,&(info[7]));
136 getTriggerInfo(event,kZDC,&(info[9]));
137 getTpcInfo(event,&(info[11]));
143 void StEbyET0::getTriggerInfo(
StEvent* event, trigDetType trigDet,
double* info) {
146 if (!trigdata)
return;
148 case kVPD : info[0] = (double) (trigdata->vpdEarliestTDC(StBeamDirection::east,0));
149 info[1] = (double) (trigdata->vpdEarliestTDC(StBeamDirection::west,0));
151 case kEPD : info[0] = (double) (trigdata->epdEarliestTDC(StBeamDirection::east,0));
152 info[1] = (double) (trigdata->epdEarliestTDC(StBeamDirection::west,0));
154 case kBBC : info[0] = (double) (trigdata->bbcEarliestTDC(StBeamDirection::east,0));
155 info[1] = (double) (trigdata->bbcEarliestTDC(StBeamDirection::west,0));
157 case kZDC : info[0] = (double) (trigdata->zdcEarliestTDC(StBeamDirection::east,0));
158 info[1] = (double) (trigdata->zdcEarliestTDC(StBeamDirection::west,0));
160 default : info[0] = -999.;
167 void StEbyET0::getTpcInfo(
StEvent* event,
double* info) {
256 info[ 0] = (nie > 0 ? tie/nie : 0); info[ 1] = nie; info[ 2] = (nie > 0 ? rie/nie : 0);
257 info[ 3] = (niw > 0 ? tiw/niw : 0); info[ 4] = niw; info[ 5] = (niw > 0 ? riw/niw : 0);
258 info[ 6] = (noe > 0 ? toe/noe : 0); info[ 7] = noe; info[ 8] = (noe > 0 ? roe/noe : 0);
259 info[ 9] = (now > 0 ? tow/now : 0); info[10] = now; info[11] = (now > 0 ? row/now : 0);