69 #include "StStrangeControllerInclude.h"
70 #include "StStrangeMuDst.hh"
81 TNamed(strTypeNames[type],"StStrangeController") {
83 masterMaker = currentMaker;
84 doMc = masterMaker->GetDoMc();
85 if ((dstMaker = masterMaker->GetSubDst())) {
86 if (doMc) dstMaker->DoMc();
87 dstMaker->Do(dstType);
102 assocName +=
"Assoc";
105 ((str =
"St") +=
GetName()) +=
"MuDst";
106 dataClass = gROOT->GetClass(str.Data());
107 (str =
"St") += mcName;
108 mcClass = gROOT->GetClass(str.Data());
109 assocClass = gROOT->GetClass(
"StStrangeAssoc");
111 dataArray =
new TClonesArray(dataClass->GetName(),max);
112 if (doMc && !(dstMaker)) {
113 mcArray =
new TClonesArray(mcClass->GetName(),max);
114 assocArray =
new TClonesArray(assocClass->GetName(),max);
128 StStrangeControllerBase::~StStrangeControllerBase() {
129 delete dataArray; dataArray = 0;
130 delete mcArray; mcArray = 0;
131 delete assocArray; assocArray = 0;
132 delete selections; selections = 0;
133 delete keepers; keepers = 0;
137 TString nom = strTypeNames[type];
139 first.Remove(1).ToUpper();
140 nom.Replace(0,1,first);
141 nom.Prepend(
"St").Append(
"Controller");
142 TClass* controlClass = gROOT->GetClass(nom.Data());
146 void StStrangeControllerBase::InitReadDst() {
147 tree = masterMaker->GetTree();
149 (statName =
GetName()) +=
".*";
150 tree->SetBranchStatus(statName.Data(),1);
151 tree->SetBranchAddress(
GetName(),&dataArray);
153 if (!tree->GetBranch(mcName.Data()))
156 if (!tree->GetBranch(mcName.Data())) {
157 gMessMgr->Warning() << IsA()->GetName() <<
158 ": No MC data available, continuing without." << endm;
161 (statName = mcName) +=
".*";
162 tree->SetBranchStatus(statName.Data(),1);
163 (statName = assocName) +=
".*";
164 tree->SetBranchStatus(statName.Data(),1);
165 tree->SetBranchAddress(mcName.Data(),&mcArray);
166 tree->SetBranchAddress(assocName.Data(),&assocArray);
171 void StStrangeControllerBase::InitCreateDst() {
172 tree = masterMaker->GetTree();
173 file = masterMaker->GetFile();
174 AssignBranch(
GetName(),&dataArray);
175 if (doMc && !(dstMaker)) {
176 AssignBranch(GetMcName(),&mcArray);
177 AssignBranch(GetAssocName(),&assocArray);
181 void StStrangeControllerBase::InitCreateSubDst() {
182 selections =
new TArrayI(max);
183 keepers =
new TArrayS(max);
185 tempArray = dstController->GetDataArray();
187 if (!dstMaker->GetTree()->GetBranch(mcName.Data()))
190 if (!dstMaker->GetTree()->GetBranch(mcName.Data())) {
191 gMessMgr->Warning() << IsA()->GetName() <<
192 ": No MC data available, continuing without." << endm;
195 mcArray = dstController->GetMcArray();
196 assocArray = dstController->GetAssocArray();
197 AssignBranch(GetMcName(),&mcArray);
198 AssignBranch(GetAssocName(),&assocArray);
203 TBranch* StStrangeControllerBase::AssignBranch(
const char* name,
204 TClonesArray** address) {
206 static Int_t split=99;
207 TBranch* branch = tree->Branch(name,address,bsize,split);
211 Int_t StStrangeControllerBase::MakeCreateSubDst() {
214 if (doMc) THack::ClearClonesArray(assocArray);
219 if (doMc && (selections->At(0) >= 0)) {
220 for (Int_t j=0;j<GetNAssoc(); j++) {
222 Int_t inReAr = assocEntry->indexRecoArray();
223 if (keepers->At(inReAr)) {
225 while (selections->At(k) != inReAr) { k++; }
226 assocEntry->setIndexRecoArray(k);
228 assocArray->RemoveAt(j);
231 assocArray->Compress();
234 Int_t classSize = dataClass->Size();
236 if (selections->At(0) < 0) {
237 tree->SetBranchAddress(
GetName(),&tempArray);
238 }
else if (entries) {
239 Int_t asize = dataArray->GetSize();
240 if (entries > asize) dataArray->Expand(entries+increment);
242 for (Int_t k=0; k<entries; k++) {
246 memcpy((*dataArray)[k],dstController->Get(selections->At(k)),classSize);
249 PrintNumCand(
"copying",entries);
255 void StStrangeControllerBase::Clear(Option_t* opt) {
261 if (tree->GetBranch(
GetName())->GetAddress() != (
char*) &dataArray) {
262 tree->SetBranchAddress(
GetName(),&dataArray);
266 THack::ClearClonesArray(dataArray);
269 THack::ClearClonesArray(mcArray);
271 THack::ClearClonesArray(assocArray);
277 void StStrangeControllerBase::Finish() {
278 TString fin =
"Total ";
279 if (masterMaker->GetMode() == StrangeRead) fin +=
"read:";
281 PrintNumCand(fin.Data(),nEntries);
284 void StStrangeControllerBase::Select(Int_t i) {
285 if ((!selections) || (!dstMaker) || (selections->At(0) < 0))
return;
286 Int_t ent = GetDstController()->GetN();
289 selections->AddAt(i,0);
292 }
else if (i < ent) {
293 if (ent > selections->GetSize()) selections->Set(ent+increment);
294 if (ent > keepers->GetSize()) keepers->Set(ent);
295 if (!(keepers->At(i))) {
296 selections->AddAt(i,entries++);
302 void StStrangeControllerBase::Unselect(Int_t i) {
303 if ((!selections) || (!dstMaker) || (!entries))
return;
306 selections->AddAt(0,0);
310 Int_t ent = GetDstController()->GetN();
311 if (i >= ent)
return;
312 if (selections->At(0) < 0) {
315 for (Int_t entry=0; entry<ent; entry++) {
316 if (i != entry) Select(entry);
320 for (Int_t entry=(entries-1); entry>=0; entry--) {
321 if (i == selections->At(entry)) {
325 if (entries) selections->AddAt(selections->At(entries),entry);
332 void StStrangeControllerBase::PrintNumMc() {
333 gMessMgr->Info(
"",
"O-") << IsA()->GetName() <<
": found " <<
334 mcEntries <<
" Monte Carlo " <<
GetName() <<
"s" << endm;
335 gMessMgr->Info(
"",
"O-") << IsA()->GetName() <<
": found " <<
336 assocEntries <<
" " <<
GetName() <<
" associations" << endm;
339 TClonesArray* StStrangeControllerBase::GetArray(Int_t branchType) {
340 switch (branchType) {
341 case (dataBranch) :
return dataArray;
342 case (mcBranch) :
return mcArray;
343 case (assocBranch) :
return assocArray;
virtual const char * GetName() const
special overload