AliPhysics  ff1d528 (ff1d528)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalDownscaleFactorsOCDB.cxx
Go to the documentation of this file.
1 #include <iostream>
2 
3 #include <TObjArray.h>
4 
5 /**************************************************************************
6  * Copyright(c) 1998-2016, ALICE Experiment at CERN, All rights reserved. *
7  * *
8  * Author: The ALICE Off-line Project. *
9  * Contributors are mentioned in the code where appropriate. *
10  * *
11  * Permission to use, copy, modify and distribute this software and its *
12  * documentation strictly for non-commercial purposes is hereby granted *
13  * without fee, provided that the above copyright notice appears in all *
14  * copies and that both the copyright notice and this permission notice *
15  * appear in the supporting documentation. The authors make no claims *
16  * about the suitability of this software for any purpose. It is *
17  * provided "as is" without express or implied warranty. *
18  **************************************************************************/
19 #include "AliCDBEntry.h"
20 #include "AliCDBManager.h"
21 #include "AliLog.h"
22 #include "AliTriggerClass.h"
23 #include "AliTriggerConfiguration.h"
24 
26 
30 
31 AliEmcalDownscaleFactorsOCDB *AliEmcalDownscaleFactorsOCDB::fgDownscaleFactors = nullptr;
32 
34  fCurrentRun(0),
35  fDownscaleFactors()
36 {
37 }
38 
40  if(!fgDownscaleFactors) {
42  }
43  return fgDownscaleFactors;
44 }
45 
47  if(runnumber == fCurrentRun) return;
48 
49  fCurrentRun = runnumber;
50  fDownscaleFactors.clear();
51  AliInfoStream() << "Loading downscale factors for run " << fCurrentRun << std::endl;
52 
53  AliCDBManager *mgr = AliCDBManager::Instance();
54  AliCDBEntry *trgcdb = mgr->Get("GRP/CTP/Config");
55  AliTriggerConfiguration *trgconf = static_cast<AliTriggerConfiguration *>(trgcdb->GetObject());
56  for(auto e : trgconf->GetClasses()){
57  AliTriggerClass *trgcls = static_cast<AliTriggerClass *>(e);
58  Double_t downscalefactor;
59  trgcls->GetDownscaleFactor(downscalefactor);
60  fDownscaleFactors.insert(std::pair<TString, Double_t>(trgcls->GetName(), downscalefactor));
61  }
62 }
63 
65  double downscale = 1.;
66  std::map<TString, Double_t>::const_iterator found = fDownscaleFactors.find(trigger);
67  if(found != fDownscaleFactors.end()) downscale = found->second;
68  return downscale;
69 }
70 
72  std::vector<TString> triggerclasses;
73  for(const auto &en : fDownscaleFactors) triggerclasses.push_back(en.first);
74  return triggerclasses;
75 }
double Double_t
Definition: External.C:58
static AliEmcalDownscaleFactorsOCDB * Instance()
Int_t fCurrentRun
Current run number (for which downscale factors are loaded)
Double_t GetDownscaleFactorForTriggerClass(const TString &trigger) const
int Int_t
Definition: External.C:63
std::vector< TString > GetTriggerClasses() const
std::map< TString, Double_t > fDownscaleFactors
Downscale factors for the various trigger classes for the current run.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Handler for downscale factors for various triggers obtained from the OCDB.
static AliEmcalDownscaleFactorsOCDB * fgDownscaleFactors
Singleton object.