17 #include "StEStructAnalysisMaker.h"
19 #include "StEStructPool/EventMaker/StEStructEvent.h"
20 #include "StEStructPool/EventMaker/StEStructTrack.h"
21 #include "StEStructPool/EventMaker/StEStructCentrality.h"
24 #include "StMemoryInfo.hh"
29 #include "StMessMgr.h"
40 mEventProcessedCounter=0;
42 doPrintMemoryInfo=
false;
43 mEventProcessedPerType=0;
44 doReactionPlaneAnalysis=
false;
49 StEStructAnalysisMaker::~StEStructAnalysisMaker() {
51 for(
int i=0;i<numAnalysis;i++)
delete manalysis[i];
52 if(mtimer)
delete mtimer;
57 Int_t StEStructAnalysisMaker::Init()
62 if(!mreader || !numAnalysis){
63 gMessMgr->Error()<<
" StEStructAnalysisMaker::Init() no reader ";
64 gMessMgr->Error()<<
" Or no analysis object: Will Abort "<<endm;
68 mEventProcessedPerType=
new int[numAnalysis];
69 for(
int i=0;i<numAnalysis;i++) mEventProcessedPerType[i]=0;
82 if (doPrintMemoryInfo) {
83 StMemoryInfo::instance()->snapshot();
84 StMemoryInfo::instance()->print();
86 for(
int i=0;i<numAnalysis;i++) manalysis[i]->finish();
102 if (doPrintMemoryInfo)StMemoryInfo::instance()->snapshot();
104 if(!mreader || !manalysis[0] ){
105 gMessMgr->Error()<<
" No Reader in StEStructAnalysisMaker::Make() "<<endm;
120 mCurrentAnalysis = 0;
121 if(!(pEStructEvent=mreader->next())){
122 if(mreader->done())
return kStEOF;
124 int ia = getAnalysisIndex();
128 if(ia>=0 && ia < numAnalysis) {
129 if(doReactionPlaneAnalysis) {
130 pEStructEvent->SetPhiWgt(mWeightFile);
132 pEStructEvent->ShiftPhi();
135 manalysis[ia]->doEvent(pEStructEvent);
136 mEventProcessedCounter++;
137 mEventProcessedPerType[ia]++;
138 if(mQAHists)mQAHists->fillHistograms(pEStructEvent,mreader);
139 mCurrentAnalysis = manalysis[ia];
143 if (doPrintMemoryInfo) {
144 StMemoryInfo::instance()->snapshot();
145 StMemoryInfo::instance()->print();
155 if (doPrintMemoryInfo)StMemoryInfo::instance()->snapshot();
157 if(!ev || !manalysis[0] ){
158 gMessMgr->Error()<<
" No Reader in StEStructAnalysisMaker::Make() "<<endm;
173 mCurrentAnalysis = 0;
176 int ia = getAnalysisIndex();
180 if(ia>=0 && ia < numAnalysis) {
181 if(doReactionPlaneAnalysis) {
182 pEStructEvent->SetPhiWgt(mWeightFile);
184 pEStructEvent->ShiftPhi();
187 manalysis[ia]->doEvent(pEStructEvent);
188 mEventProcessedCounter++;
189 mEventProcessedPerType[ia]++;
190 if(mQAHists)mQAHists->fillHistograms(pEStructEvent,mreader);
191 mCurrentAnalysis = manalysis[ia];
194 if (doPrintMemoryInfo) {
195 StMemoryInfo::instance()->snapshot();
196 StMemoryInfo::instance()->print();
202 int StEStructAnalysisMaker::getAnalysisIndex(){
211 return cent->centrality( pEStructEvent->Centrality() );
215 void StEStructAnalysisMaker::writeQAHists(
const char* fileName){
217 TFile * tfq=
new TFile(fileName,
"RECREATE");
219 gMessMgr->Warning()<<
" QAfile = "<<fileName<<
" NOT OPENED!!"<<endm;
223 if(mQAHists)mQAHists->writeHistograms(tfq);
224 for(
int i=0;i<numAnalysis;i++)manalysis[i]->writeQAHists(tfq);
243 bool StEStructAnalysisMaker::quickSort(
int *arr,
int elements) {
245 #define MAX_LEVELS 1000
247 int piv, beg[MAX_LEVELS], end[MAX_LEVELS], i=0, L, R, pM ;
248 mIndex =
new int[elements];
249 for (
int i=0;i<elements;i++) {
253 beg[0]=0; end[0]=elements;
255 L=beg[i]; R=end[i]-1;
259 if (i==MAX_LEVELS-1)
return false;
261 while (arr[R]>=piv && L<R) R--;
266 while (arr[L]<=piv && L<R) L++;
283 bool StEStructAnalysisMaker::quickSort(
double *arr,
int elements) {
285 #define MAX_LEVELS 1000
288 int beg[MAX_LEVELS], end[MAX_LEVELS], i=0, L, R, pM ;
289 mIndex =
new int[elements];
290 for (
int i=0;i<elements;i++) {
294 beg[0]=0; end[0]=elements;
296 L=beg[i]; R=end[i]-1;
300 if (i==MAX_LEVELS-1)
return false;
302 while (arr[R]>=piv && L<R) R--;
307 while (arr[L]<=piv && L<R) L++;
324 int StEStructAnalysisMaker::GetSortedIndex(
int i) {
329 void StEStructAnalysisMaker::writeDiagnostics(
int opt){
331 for(
int i=0;i<numAnalysis;i++)manalysis[i]->writeDiagnostics();
335 void StEStructAnalysisMaker::startTimer(){
340 void StEStructAnalysisMaker::stopTimer(){
if(mtimer)mtimer->stop(); }
342 void StEStructAnalysisMaker::compiledLoop(){
348 void StEStructAnalysisMaker::SetReactionPlaneAnalysis(
char* weightFile) {
349 doReactionPlaneAnalysis =
true;
350 mWeightFile = weightFile;
351 cout <<
" Setting doReactionPlaneAnalysis = " << doReactionPlaneAnalysis <<
" with a weight file " << mWeightFile << endl;
virtual void Clear(Option_t *option="")
User defined functions.
void Clear(Option_t *option="")
User defined functions.