-
Notifications
You must be signed in to change notification settings - Fork 0
/
AliGloAlgTask.cxx
executable file
·158 lines (147 loc) · 5.11 KB
/
AliGloAlgTask.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*************************************************************************
* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
* *
* Author: The ALICE Off-line Project. *
* Contributors are mentioned in the code where appropriate. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation strictly for non-commercial purposes is hereby granted *
* without fee, provided that the above copyright notice appears in all *
* copies and that both the copyright notice and this permission notice *
* appear in the supporting documentation. The authors make no claims *
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
#include <TFile.h>
#include <TChain.h>
#include <TTree.h>
#include <TSystem.h>
#include <TROOT.h>
#include "AliAnalysisManager.h"
#include "AliESDInputHandler.h"
#include "AliGloAlgTask.h"
#include "AliLog.h"
#include "AliAlgSteer.h"
#include "AliAlgDOFStat.h"
ClassImp(AliGloAlgTask)
//________________________________________________________________________
AliGloAlgTask::AliGloAlgTask(const char *name)
: AliAnalysisTaskSE(name)
,fOutput(0)
,fTrigSel(0)
,fAlgSteer(0)
,fIniParFileName()
,fConfMacroName()
,fStopWatch()
,fChunks(0)
,fApplyMPSolAlignment(kFALSE)
{
// Constructor
DefineOutput(1, TList::Class());
SetConfMacroName();
//
}
//________________________________________________________________________
AliGloAlgTask::~AliGloAlgTask()
{
// Destructor
if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) { //RRR
printf("Deleteing output\n");
delete fOutput;
fOutput = 0;
}
//
delete fAlgSteer;
//
}
//________________________________________________________________________
void AliGloAlgTask::UserCreateOutputObjects()
{
//
fOutput = new TList();
fOutput->SetOwner();
//
PostData(1, fOutput);
//
}
//________________________________________________________________________
void AliGloAlgTask::NotifyRun()
{
// attach tree to alignment object
AliAnalysisManager* anMan = AliAnalysisManager::GetAnalysisManager();
AliESDInputHandler *handler = (AliESDInputHandler*)anMan->GetInputEventHandler();
fAlgSteer->SetESDTree(handler->GetTree());
}
//________________________________________________________________________
Bool_t AliGloAlgTask::Notify()
{
// notify chunk change
fStopWatch.Stop();
AliInfoF("Processing chunk %d",fChunks++);
fStopWatch.Print();
fStopWatch.Start(kFALSE);
return kTRUE;
}
//________________________________________________________________________
void AliGloAlgTask::UserExec(Option_t *)
{
// Main loop
//
AliAnalysisManager* anMan = AliAnalysisManager::GetAnalysisManager();
AliESDInputHandler *handler = (AliESDInputHandler*)anMan->GetInputEventHandler();
AliESDEvent* esdEv = handler->GetEvent();
AliESDfriend *esdFr = handler->GetESDfriend(); // get the input friend
//
if(!esdEv) {AliInfo("no ESD"); return;}
if(!esdFr || esdFr->GetNumberOfTracks()<esdEv->GetNumberOfTracks()) {
AliDebug(3,"no ESDFriend");
return;
}
// AliInfo(Form("Number of ESD tracks in input = %d ",esdEv->GetNumberOfTracks()));
// AliInfo(Form("Number of tracks in input friends = %d ",esdFr->GetNumberOfTracks()));
//
fAlgSteer->ProcessEvent(esdEv);
//
}
//________________________________________________________________________
void AliGloAlgTask::Terminate(Option_t *)
{
Printf("Terminating...");
fAlgSteer->Terminate();
//
TH1* hstat = 0;
AliAlgDOFStat* dofSt= fAlgSteer->GetDOFStat();
if (dofSt) fOutput->Add(dofSt);
fAlgSteer->DetachDOFStat();
//
hstat = fAlgSteer->GetHistoStat();
if (hstat) fOutput->Add(hstat);
fAlgSteer->DetachHistoStat();
//
fStopWatch.Stop();
AliInfoF("Processed %d chunks",fChunks);
fStopWatch.Print();
//
}
//_________________________________________________________________________
void AliGloAlgTask::LocalInit()
{
// init alignment object by running user provided macro containing a function with
// the same name as the macro and accepting as an argument a pointer to fAlgSteer
AliInfo("Processing");
if (fAlgSteer) AliFatal("Something is wrong, alignment was already initialized");
//
if (fConfMacroName.IsNull() || gSystem->AccessPathName(fConfMacroName.Data(), kFileExists)) {
AliFatalF("Cannot find configuration macro %s",fConfMacroName.Data());
}
//
fAlgSteer = new AliAlgSteer();
gROOT->ProcessLine(Form(".x %s+g((AliAlgSteer*)%p)",fConfMacroName.Data(),fAlgSteer));
//
if (!fIniParFileName.IsNull() && !gSystem->AccessPathName(fIniParFileName.Data(), kFileExists)) {
AliInfoF("Imposing initial parameters from %s",fIniParFileName.Data());
fAlgSteer->ReadParameters(fIniParFileName.Data());
if (fApplyMPSolAlignment) fAlgSteer->ApplyAlignmentFromMPSol();
}
fAlgSteer->Print();
}