76 #include "StTagsMaker.h"
77 #include "StEvtHddr.h"
83 #include "TDataMember.h"
84 #include "TDataType.h"
85 #include "tables/St_GlobalTag_Table.h"
88 #include "StTriggerData.h"
89 #include "StEventUtilities/StuRefMult.hh"
90 #include "StEventUtilities/StuFtpcRefMult.hh"
91 #include "StShadowMaker/StShadowMaker.h"
92 static TClass *tabClass = 0;
93 static TTree *fTree = 0;
99 StTagsMaker::StTagsMaker(
const char *name):
StMaker(name){
102 StTagsMaker::~StTagsMaker(){
105 Int_t StTagsMaker::Init(){
106 return StMaker::Init();
110 St_GlobalTag *tagtab=
new St_GlobalTag(
"GlobalTag",1);
AddData(tagtab);
112 memset (&row, 0,
sizeof(GlobalTag_st));
117 row.primaryVertexX = primVertex->position().x();
118 row.primaryVertexY = primVertex->position().y();
119 row.primaryVertexZ = primVertex->position().z();
120 const StMatrixF &m = primVertex->covariantMatrix();
121 if (m(1,1) > 0) row.sigmaPVX = TMath::Sqrt(m(1,1));
122 if (m(2,2) > 0) row.sigmaPVY = TMath::Sqrt(m(2,2));
123 if (m(3,3) > 0) row.sigmaPVZ = TMath::Sqrt(m(3,3));
124 }
else row.primaryVertexFlag = 99;
133 for (
unsigned int islat=0; islat<theCtb.numberOfSlats(); islat++)
134 for (
unsigned int itray=0; itray<theCtb.numberOfTrays(); itray++)
135 ctbsum += theCtb.mips(itray, islat, 0);
138 row.uncorrectedNumberOfPrimaries = uncorrectedNumberOfPrimaries(*event);
139 row.uncorrectedNumberOfFtpcEastPrimaries = uncorrectedNumberOfFtpcEastPrimaries(*event);
140 row.uncorrectedNumberOfFtpcWestPrimaries = uncorrectedNumberOfFtpcWestPrimaries(*event);
144 row.zdcHardSum = trigData->zdcAtChannel(10);
154 vector<unsigned int> nominalVec = nominal->triggerIds();
156 for (vector<unsigned int>::iterator viter = nominalVec.begin();
157 viter != nominalVec.end(); ++viter) {
158 row.TriggerId[i++] = (*viter);
162 tagtab->AddAt(&row);
if (Debug()) tagtab->Print(0,1);
164 if (!fTree) InitTags();
165 if (fTree && fTagsList && tabClass) {
172 while ((set = next())) {
173 TDataSet *ds = GetDataSet(set->GetTitle());
176 if (ds->InheritsFrom(tabClass)) {
180 cl = gROOT->GetClass(ds->GetTitle());
182 else if (strstr(ds->GetName(),
"EvtHddr")){
184 lEvtHddr->FillTag(&fEvtHddr);
186 if (IAttr(
"shadow")) {
187 fEvtHddr.mRunNumber = StShadowMaker::getRunNumber();
188 if (fEvtHddr.mOldRunNumber>0)
189 fEvtHddr.mOldRunNumber = fEvtHddr.mRunNumber;
190 fEvtHddr.mEventNumber = StShadowMaker::getEventNumber(fEvtHddr.mEventNumber);
192 cl = gROOT->GetClass(
"EvtHddr_st");
195 TIter next(cl->GetListOfDataMembers());
196 TDataMember *member = 0;
197 while ( (member = (TDataMember *) next()) ) {
198 TString branchName=ds->GetName();
200 branchName += member->GetName();
201 fTree->SetBranchAddress(branchName.Data(),
202 (
char*)address+member->GetOffset());
212 EDataSetPass StTagsMaker::GetTags (
TDataSet* ds)
214 TString name, leaflist, branchName;
216 Int_t bufsize= 64000;
219 const char *Name=ds->GetName();
221 if (!tabClass) tabClass = gROOT->GetClass(
"TTable");
222 if (ds->InheritsFrom(tabClass) && strstr(Name,
"Tag")) {
223 name = TString(ds->GetTitle());
227 }
else if (strstr(Name,
"EvtHddr")){
228 name = TString(
"EvtHddr_st");
234 cl = gROOT->GetClass(name.Data());
236 TIter next(cl->GetListOfDataMembers());
238 TDataMember *member = 0;
239 while ( (member = (TDataMember *) next()) ) {
240 const Char_t *colName = member->GetName();
243 Int_t nDim = member->GetArrayDim();
245 for (Int_t k=0; k<nDim; k++) {
246 UInt_t indx = member->GetMaxIndex(k);
247 sprintf(buf,
"[%d]",indx);
252 TString Comment = member->GetTitle();
253 Comment=Comment.Strip(TString::kBoth,
' ');
255 Comment.ReplaceAll(
"!",
"");
256 if (!Comment.IsNull()) {
258 Comment.ReplaceAll(
"<",
'<');
259 Comment.ReplaceAll(
">",
'>');
261 Comment.ReplaceAll(
":",
' ');
262 Comment.ReplaceAll(
"/",
' ');
275 if (leaflist.Length()>64) leaflist.Resize(64);
280 TDataType *memberType = member->GetDataType();
281 types = memberType->GetTypeName();
282 if (!strcmp(
"float", types)) leaflist +=
'F';
283 else if (!strcmp(
"int", types)) leaflist +=
'I';
284 else if (!strcmp(
"long", types)) leaflist +=
'I';
285 else if (!strcmp(
"short", types)) leaflist +=
'S';
286 else if (!strcmp(
"double", types)) leaflist +=
'D';
287 else if (!strcmp(
"unsigned int", types)) leaflist +=
'i';
288 else if (!strcmp(
"unsigned long", types)) leaflist +=
'i';
289 else if (!strcmp(
"unsigned short", types))leaflist +=
's';
290 else if (!strcmp(
"unsigned char", types)) leaflist +=
'b';
292 else if (!strcmp(
"char", types)) leaflist +=
'B';
297 branchName += colName;
298 fTree->Branch(branchName.Data(),(
char*)address+member->GetOffset(),
299 leaflist.Data(),bufsize);
302 newds->SetTitle(ds->
Path());
303 fTagsList->Add(newds);
308 Int_t StTagsMaker::InitTags() {
311 TFile *f = chain->GetTFile();
314 fTree =
new TTree(
"Tag",
"BFC chain Tags");
315 chain->
Pass(GetTags);
virtual EDataSetPass Pass(EDataSetPass(*callback)(TDataSet *), Int_t depth=0)
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
Collection of trigger ids as stored in StEvent.
virtual TString Path() const
return the full path of this data set