14 Error(
"GetCollection",
"No parent directory for %s", name.Data());
18 dir->GetObject(name, ret);
21 Error(
"GetCollection",
"Couldn't find %s in %s",
22 name.Data(), dir->GetName());
40 const TClass* cls=0,
Bool_t verbose=
true)
44 Error(
"GetObject",
"No parent collection for %s", name.Data());
47 TObject* ret = parent->FindObject(name);
50 Error(
"GetObject",
"Couldn't find %s in %s",
51 name.Data(), parent->GetName());
54 if (cls && !ret->IsA()->InheritsFrom(cls)) {
56 Error(
"GetObject",
"%s in %s is a %s, not a %s", name.Data(),
57 parent->GetName(), ret->ClassName(), cls->GetName());
64 while (parent->GetEntries() > 0) {
67 Info(
"RemoveObject",
"Removing %s from %s", name.Data(), parent->GetName());
68 TObject* ret = parent->Remove(o);
70 Warning(
"RemoveObject",
"Failed to remove %s from %s (%p %p)",
71 name.Data(), parent->GetName(), o, ret);
95 const char* other[] = {
"fmdESDFixer",
97 "fmdDensityCalculator",
99 const char** ptr = other;
103 const char* stacks[] = {
"chi2",
"c",
"delta",
"xi",
"sigma",
"sigman",
104 "a2",
"a3",
"a4",
"a5", 0 };
108 const char*
dets[] = {
"FMD1I",
"FMD2I",
"FMD2O",
"FMD3I",
"FMD3O", 0 };
116 const char* subs[] = {
"elossDists",
"elossResults",
"elossResiduals", 0 };
117 const char** sub = subs;
142 const TString& input=
"forward_eloss.root",
147 const char*
fwd =
"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2";
148 gROOT->Macro(Form(
"%s/scripts/LoadLibs.C", fwd));
153 if (outName.IsNull()) {
155 outName.ReplaceAll(
".root",
"_rerun.root");
160 inFile = TFile::Open(input,
"READ");
162 throw TString::Format(
"Failed to open %s", input.Data());
166 if (!inFwdSum) inFwdSum =
GetCollection(inFile,
"forwardQAResults");
167 if (!inFwdSum)
throw new TString(
"Cannot proceed without sums");
168 inFwdSum->SetName(
"ForwardELossSums");
171 if (!inFwdRes) inFwdRes =
GetCollection(inFile,
"forwardQAResults");
174 static_cast<TCollection*
>(inFwdSum->Clone(
"ForwardELossResults"));
177 inFwdRes->SetName(
"ForwardELossResults");
180 if (!inEFSum)
throw new TString(
"Cannot proceed without accumulated data");
183 if (!inEFRes)
throw new TString(
"Cannot proceed without previous results");
193 if (oEvAcc) nEvAcc = oEvAcc->GetEntries();
195 if (nEvAcc > 0 && sys > 0) {
196 Long_t minEvents = 0;
199 case 1: minEvents = 500000;
break;
200 case 2: minEvents = 10000;
break;
202 case 4: minEvents = 100000;
break;
204 if (nEvAcc < minEvents) {
205 Error(
"RerunELossFits",
"Too few events (%ld<%ld) for %d",
206 nEvAcc, minEvents, sys);
211 outFile = TFile::Open(outName,
"RECREATE");
213 throw TString::Format(
"Failed to open %s", outName.Data());
217 fitter->SetDoFits(
true);
218 fitter->SetEnableDeltaShift(shift);
220 if (forceSet || !fitter->ReadParameters(inEFSum)) {
221 Printf(
"Forced settings");
224 if (!etaAxis)
throw new TString(
"Cannot proceed without eta axis");
225 fitter->SetEtaAxis(*etaAxis);
230 fitter->SetNEbins(500);
234 fitter->SetDoFits(kTRUE);
236 fitter->SetDoMakeObject(kTRUE);
238 fitter->SetLowCut(0.4);
241 fitter->SetFitRangeBinWidth(4);
243 fitter->SetNParticles(5);
246 fitter->SetMinEntries(10000);
251 Int_t maxPart = sys == 1 ? 3 : 5;
252 fitter->SetNParticles(maxPart);
253 fitter->SetDoMakeObject(
true);
254 fitter->SetMinEntries(10000);
255 if (fitter->GetLowCut() < .5) fitter->SetLowCut(0.55);
256 if (flags & 0x2) fitter->SetDebug(3);
275 outFwdSum->Write(inFwdSum->GetName(), TObject::kSingleKey);
282 fitter->Fit(static_cast<TList*>(outFwdSum));
291 if (!outEFRes)
break;
292 outFwdRes->Remove(outEFRes);
297 outEFRes =
static_cast<TCollection*
>(tmp->Clone());
298 outEFRes->Add(
new TNamed(
"refitted",
"Refit of the data"));
299 outFwdRes->Add(outEFRes);
304 outFwdRes->Write(inFwdRes->GetName(), TObject::kSingleKey);
305 Printf(
"Wrote results to \"%s\" (%s)", outName.Data(), outFile->GetName());
309 Error(
"RerunELossFits", e->Data());
312 Error(
"RerunELossFits", e.Data());
314 if (inFile) inFile->Close();
316 Printf(
"Wrote new output to \"%s\"", outName.Data());
321 gROOT->Macro(Form(
"%s/corrs/DrawCorrELoss.C(false,false,\"%s\")",
322 fwd, outName.Data()));
TObject * GetObject(const TCollection *parent, const TString &name, const TClass *cls=0, Bool_t verbose=true)
void RerunELossFits(Bool_t forceSet=false, const TString &input="forward_eloss.root", Bool_t shift=true, const TString &output="", UShort_t flags=0x1)
void CleanCollection(TCollection *c)
TCollection * GetCollection(TDirectory *dir, const TString &name, Bool_t verbose=true)
void RemoveObject(TCollection *parent, const TString &name)