4 #include <AliDataFile.h> 11 #include <TParameter.h> 12 #include <TFileMerger.h> 67 for (
Int_t i = 0; i < n; i++) {
75 if (&o ==
this)
return *
this;
90 for (
Int_t i = 0; i < n; i++) {
102 #define PF(N,V,...) \ 103 AliForwardUtil::PrintField(N,V, ## __VA_ARGS__) 104 #define PFB(N,FLAG) \ 106 AliForwardUtil::PrintName(N); \ 107 std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \ 109 #define PFV(N,VALUE) \ 111 AliForwardUtil::PrintName(N); \ 112 std::cout << (VALUE) << std::endl; } while(false) 119 gROOT->IncreaseDirLevel();
126 PFB(
"For simulations",
fMC);
131 if (opt.Contains(
"R")) {
134 for (
Int_t id = 0;
id < n;
id++) {
140 gROOT->DecreaseDirLevel();
155 for (
Int_t id = 0;
id < n;
id++) {
157 const char* old = c->GetTitle();
173 const char* meth)
const 177 for (
Int_t id = 0;
id < n;
id++) {
179 if (!o->IsA()->InheritsFrom(c->
fCls))
continue;
181 ret = c->
StoreIt(
fDB, o, runNo, sys, sNN, field, mc, sat, file, meth);
190 const TString& destination)
const 192 if (addition.IsNull()) {
193 AliWarning(
"No addition specified");
198 TString bn = Form(
"OADB/PWGLF/FORWARD/CORRECTIONS/data/%s",
200 dest = AliDataFile::GetFileNameOADB(bn.Data()).c_str();
201 AliWarningF(
"No destination storage specified, assuming default: %s",
205 merger.SetPrintLevel(1);
206 merger.OutputFile(destination,
"UPDATE");
207 merger.AddFile(addition);
208 if (!merger.PartialMerge()) {
209 AliInfoF(
"Failed to merge %s with %s",
210 addition.Data(), destination.Data());
213 if (destination.BeginsWith(
"$OADB_PATH") ||
214 destination.BeginsWith(
"$ALICE_PHYSICS"))
215 AliInfoF(
"Now commit %s to git", destination.Data());
227 for (
Int_t i = 0; i < 32; i++) {
232 Info(
"CleanUp",
"Table %s not enabled", c->GetName());
235 Info(
"CleanUp",
"Will clean up table %s", c->GetName());
236 c->
CleanIt(db, destination, verb, all);
246 for (
Int_t i = 0; i < 32; i++) {
256 for (
Int_t i = 0; i < 32; i++) {
257 Bool_t enabled = (1 << i) & what;
258 if (!enabled)
continue;
263 AliWarningF(
"No correction registered for bit %d", i);
270 AliWarningF(
"Correction %s (bit %d) not initialized!", c->GetName(), i);
285 return cls->GetName();
304 TString d = Form(
"PWGLF/FORWARD/CORRECTIONS/data/%s", fileName.Data());
305 if (!d.EndsWith(
".root")) d.Append(
".root");
306 TString p = AliDataFile::GetFileNameOADB(d.Data()).c_str();
314 if (id < 0 || id >
fCorrections.GetEntriesFast())
return 0;
322 if (id < 0 || id >
fCorrections.GetEntriesFast())
return 0;
340 for (
Int_t id = 0;
id < n;
id++) {
342 if (what.EqualTo(c->GetName(), TString::kIgnoreCase))
return id;
353 AliWarningF(
"Cannot enable non-existing correction at %d",
id);
364 TClass* ocl = obj->IsA();
365 for (
Int_t id = 0;
id < n;
id++) {
367 if (ocl->InheritsFrom(c->
fCls))
return id;
377 AliWarningF(
"Cannot find correction with id %d",
id);
388 AliWarningF(
"Cannot find correction with id %d",
id);
428 AliInfo(
"We are already initialised - checking settings...");
434 AliWarningF(
"Initialised collision system %s (%d) and " 435 "passed same %s (%d) does not match",
440 if (TMath::Abs(
fSNN - sNN) >= 10) {
441 AliWarningF(
"Initialised center of mass energy per nuclean " 442 "%s (%d) and passed same %s (%d) does not match",
448 AliWarningF(
"Initialied L3 magnetic field %s (%d) and passed " 449 "same %s (%d) does not match",
455 AliWarningF(
"Initialied data type (%s) and passed " 456 "same (%s) does not match",
457 (
fMC ?
"MC" :
"real"), (mc ?
"MC" :
"real"));
461 AliWarningF(
"Initialied collision ip type (%s) and passed " 462 "same (%s) does not match",
464 (sat ?
"satellite" :
"nominal"));
468 AliWarning(
"Intialised parameters and these are not the same " 469 "- PROCEED WITH CAUTION!");
472 AliInfo(
"Initialized values consistent with data");
514 TMath::Abs(
fSNN - sNN) < 11) {
533 for (
Int_t id = 0;
id < n;
id++)
534 if (!
ReadCorrection(
id, run, sys, sNN, fld, mc, sat)) ret =
false;
555 :
TNamed(tableName, fileName),
579 if (&o ==
this)
return *
this;
580 SetName(o.GetName());
581 SetTitle(o.GetTitle());
618 if (run <= 197388 && run >= 196433) {
622 if (sNN == 27615) sNN = 2760;
632 Warning(
"OpenIt",
"No DB passed");
637 if (db->
FindTable(fName,
true))
return true;
640 if (db->
Open(fTitle, fName,
false, vrb, fallback))
return true;
643 AliWarningF(
"Failed to open table %s from %s", GetName(), GetTitle());
644 AliWarningF(
"content of %s for %s:",
645 gSystem->WorkingDirectory(), GetName());
663 AliWarningF(
"Correction %s not enabled", GetName());
673 if (!
OpenIt(db, vrb, fallback))
return false;
677 sys, sNN, fld, mc, sat);
679 if (!e || !e->
fData) {
680 AliWarningF(
"Failed to get %s from database in %s with " 681 "run=%lu sys=%hu sNN=%hu fld=%hd %s %s",
682 GetName(), GetTitle(), run, sys, sNN, fld,
683 (mc ?
"MC" :
"real"), (sat ?
"satellite" :
"nominal"));
690 AliWarningF(
"Entry %p \"%s\" has no data! (%p)", e, e->
GetTitle(), o);
695 if (!o->IsA()->InheritsFrom(cl)) {
696 AliWarningF(
"%p is not pointer to a %s object but a %s",
697 o,
fCls->GetName(), o->ClassName());
719 const char* meth)
const 726 if (!obj->IsA()->InheritsFrom(cl)) {
727 AliWarningF(
"%p is not pointer to a %s object but a %s",
728 obj, cl->GetName(), obj->ClassName());
732 Bool_t local = file || !db;
737 if (!tdb->
Open(fileName, Form(
"%s/%s", GetName(), meth),
true,
false)) {
738 AliWarningF(
"Failed to open table %s in %s", GetName(), fileName.Data());
746 if (!tdb->
Insert(fName, obj, run, sys, sNN, fld, mc, sat)) {
747 AliWarningF(
"Failed to insert into %s off database in %s with " 748 "run=%lu sys=%hu sNN=%hu fld=%hd %s %s",
749 GetName(), GetTitle(), run, sys, sNN, fld,
750 (mc ?
"MC" :
"real"), (sat ?
"satellite" :
"nominal"));
758 AliInfoF(
"Correction object %s written to DB in %s - merge this with " 759 "%s to store for good", obj->GetName(), fileName.Data(),
771 AliWarningF(
"Correction %s not enabled", GetName());
781 AliWarningF(
"Correction %s not enabled", GetName());
793 AliErrorF(
"No class name set for correction %s", GetName());
798 AliErrorF(
"Couldn't get class %s for correction %s",
810 gROOT->IncreaseDirLevel();
813 gROOT->DecreaseDirLevel();
824 if (flds.BeginsWith(
"|")) flds.Remove(0,1);
828 PFV(
"Path",GetTitle());
829 PFV(
"Data class", cl->GetName());
830 PFV(
"Query fields", flds);
836 if (opt.Contains(
"D") &&
fObject) {
837 gROOT->IncreaseDirLevel();
839 gROOT->DecreaseDirLevel();
841 gROOT->DecreaseDirLevel();
848 b->Add(const_cast<TClass*>(
fCls),
"Class");
856 if (flds.BeginsWith(
"|")) flds.Remove(0,1);
858 b->Add(
new TObjString(flds),
"Query fields");
871 if (!
OpenIt(db, verb ,
false)) {
872 Warning(
"CleanIt",
"Failed to open table for %s", GetName());
879 Warning(
"CleanIt",
"Failed to get table for %s", GetName());
885 Int_t nEnt = tree->GetEntries();
891 Info(
"CleanIt",
"Looping over %d entries in tree", nEnt);
892 for (
Int_t i = 0; i < nEnt; i++) {
894 copy.SetBitNumber(i,
true);
920 sys, sNN, fld, mc, sat);
922 Warning(
"CleanIt",
"Uh! didn't get an entry for %s (%d)",
932 if (sNN == 900 && fld <= 0) r = -1;
933 else if (sNN == 7000 && fld >= 0) r = -1;
934 else if (sNN == 2760 && fld >= 0) r = -1;
937 if (fld >= 0) r = -1;
943 Printf(
"%-10s (%3d %3d): %s %s",
944 (i==r ?
"copied" :
"ignored"), i, r, txt.Data(), GetName());
946 if (r != i)
continue;
950 copy.SetBitNumber(i,
true);
957 for (
Int_t i = 0; i < nEnt; i++) {
959 if (!copy.TestBitNumber(i))
continue;
979 Printf(
"Storing %3d: %s -> %9lu/%d/%05d/%2d/%s/%s %s",
980 i, txt.Data(), run, sys, sNN, fld, (mc?
"simu":
"real"),
981 (sat?
"sat":
"nom"), GetName());
982 if (!
StoreIt(0, obj, run, sys, sNN, fld, mc, sat, dest.Data(),
984 Warning(
"CleanIt",
"Failed to write new entry to %s", dest.Data());
990 Printf(
"Copied %6d entries of %6d for %s", nCpy, nEnt, fName.Data());
Base class for correction managers.
void EnableCorrection(Int_t id, Bool_t enable=true)
static const char * CenterOfMassEnergyString(UShort_t cms)
virtual void SetPrefix(const TString &prefix)
void SetFile(const TString &fileName)
virtual void EnableCorrections(UInt_t what)
Bool_t ReadCorrection(Int_t id, ULong_t run, UShort_t sys, UShort_t sNN, Short_t fld, Bool_t mc, Bool_t sat)
AliCorrectionManagerBase()
Bool_t InitCorrections(ULong_t run, UShort_t sys, UShort_t sNN, Short_t fld, Bool_t mc, Bool_t sat, Bool_t force=false)
static const char * Mode2String(ERunSelectMode mode)
Bool_t fDebug
do not store
void Print(Option_t *option="") const
void RegisterCorrection(Int_t id, Correction *corr)
void CorrectFields(ULong_t &run, UShort_t &sys, UShort_t &sNN, Short_t &fld, Bool_t &mc, Bool_t &sat) const
virtual Bool_t CleanUp(const TString &destination, Bool_t verb=false, Bool_t all=false) const
Bool_t ReadIt(AliOADBForward *db, ULong_t run, UShort_t sys, UShort_t sNN, Short_t fld, Bool_t mc, Bool_t sat, Bool_t vrb=false, Bool_t fbk=false)
Table * FindTable(const TString &name, Bool_t quite=false) const
static const char * MagneticFieldString(Short_t field)
AliCorrectionManagerBase & operator=(const AliCorrectionManagerBase &o)
void SetCorrectionFile(Int_t id, const TString &fileName) const
virtual Bool_t Store(TObject *o, ULong_t runNo, UShort_t sys, UShort_t sNN, Short_t field, Bool_t mc, Bool_t sat, const char *file, const char *meth="NEAR") const
Various utilities used in PWGLF/FORWARD.
virtual Bool_t CheckCorrections(UInt_t what, Bool_t verbose=true) const
Bool_t CleanIt(AliOADBForward *db, const TString &dest, Bool_t verb=false, Bool_t all=false) const
const char * GetObjectName(Int_t what) const
Int_t GetId(const TString &what) const
const char * GetTitle() const
virtual void Browse(TBrowser *b)
static void PrintTask(const TObject &o)
Correction * GetCorrection(Int_t id)
Bool_t CheckConditions(ULong_t run, UShort_t sys, UShort_t sNN, Short_t fld, Bool_t mc, Bool_t sat)
Correction & operator=(const Correction &o)
Bool_t ReadCorrections(ULong_t run, UShort_t sys, UShort_t sNN, Short_t fld, Bool_t mc, Bool_t sat)
virtual void Print(Option_t *option="") const
virtual Bool_t Append(const TString &addition, const TString &destination="") const
TFile * file
TList with histograms for a given trigger.
Bool_t Insert(const TString &table, TObject *o, ULong_t runNo, UShort_t sys, UShort_t sNN, Short_t field, Bool_t mc=false, Bool_t sat=false, ULong_t aliRev=0, const TString &author="")
const TClass * TheClass() const
Entry * Get(const TString &table, ULong_t run=0, ERunSelectMode mode=kNear, UShort_t sys=0, UShort_t sNN=0, Short_t fld=0, Bool_t mc=false, Bool_t sat=false) const
Bool_t OpenIt(AliOADBForward *db, Bool_t vrb=false, Bool_t fallback=false) const
static const char * CollisionSystemString(UShort_t sys)
Int_t GetEntry(ULong_t run=0, ERunSelectMode mode=kNear, UShort_t sys=0, UShort_t sNN=0, Short_t fld=0, Bool_t mc=false, Bool_t sat=false) const
Bool_t Open(const TString &fileName, const TString &tables="*", Bool_t rw=false, Bool_t verb=false, Bool_t fallback=false)
virtual ~AliCorrectionManagerBase()
Bool_t StoreIt(AliOADBForward *db, TObject *o, ULong_t run, UShort_t sys, UShort_t sNN, Short_t fld, Bool_t mc, Bool_t sat, const char *file=0, const char *meth="NEAR") const
const TString fClientCls
Class of correction objects.
void MassageFields(ULong_t &run, UShort_t &sys, UShort_t &sNN, Short_t &fld, Bool_t &mc, Bool_t &sat) const