AliPhysics  a3b326c (a3b326c)
AliEmcalDownscaleFactorsOCDB.cxx
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (C) 2017, Copyright Holders of the ALICE Collaboration *
3  * All rights reserved. *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions are met: *
7  * * Redistributions of source code must retain the above copyright *
8  * notice, this list of conditions and the following disclaimer. *
9  * * Redistributions in binary form must reproduce the above copyright *
10  * notice, this list of conditions and the following disclaimer in the *
11  * documentation and/or other materials provided with the distribution. *
12  * * Neither the name of the <organization> nor the *
13  * names of its contributors may be used to endorse or promote products *
14  * derived from this software without specific prior written permission. *
15  * *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND *
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
19  * DISCLAIMED. IN NO EVENT SHALL ALICE COLLABORATION BE LIABLE FOR ANY *
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
26  ************************************************************************************/
27 #include <iostream>
28 
29 #include <TObjArray.h>
30 
31 #include "AliCDBEntry.h"
32 #include "AliCDBManager.h"
33 #include "AliLog.h"
34 #include "AliTriggerClass.h"
35 #include "AliTriggerConfiguration.h"
36 
38 
42 
43 using namespace PWG::EMCAL;
44 
45 AliEmcalDownscaleFactorsOCDB *AliEmcalDownscaleFactorsOCDB::fgDownscaleFactors = nullptr;
46 
48  fCurrentRun(0),
49  fDownscaleFactors()
50 {
51 }
52 
53 AliEmcalDownscaleFactorsOCDB *AliEmcalDownscaleFactorsOCDB::Instance(){
54  if(!fgDownscaleFactors) {
56  }
57  return fgDownscaleFactors;
58 }
59 
61  if(runnumber == fCurrentRun) return;
62 
63  fCurrentRun = runnumber;
64  fDownscaleFactors.clear();
65  AliInfoStream() << "Loading downscale factors for run " << fCurrentRun << std::endl;
66 
67  AliCDBManager *mgr = AliCDBManager::Instance();
68  AliCDBEntry *trgcdb = mgr->Get("GRP/CTP/Config");
69  AliTriggerConfiguration *trgconf = static_cast<AliTriggerConfiguration *>(trgcdb->GetObject());
70  for(auto e : trgconf->GetClasses()){
71  AliTriggerClass *trgcls = static_cast<AliTriggerClass *>(e);
72  Double_t downscalefactor;
73  trgcls->GetDownscaleFactor(downscalefactor);
74  fDownscaleFactors.insert(std::pair<TString, Double_t>(trgcls->GetName(), downscalefactor));
75  }
76 }
77 
79  double downscale = 1.;
80  std::map<TString, Double_t>::const_iterator found = fDownscaleFactors.find(trigger);
81  if(found != fDownscaleFactors.end()) downscale = found->second;
82  return downscale;
83 }
84 
86  std::vector<TString> triggerclasses;
87  for(const auto &en : fDownscaleFactors) triggerclasses.push_back(en.first);
88  return triggerclasses;
89 }
double Double_t
Definition: External.C:58
Double_t GetDownscaleFactorForTriggerClass(const TString &trigger) const
Namespace for EMCAL framework classes and task.
int Int_t
Definition: External.C:63
Int_t fCurrentRun
Current run number (for which downscale factors are loaded)
static AliEmcalDownscaleFactorsOCDB * fgDownscaleFactors
Singleton object.
Namespace for PWG framework classes.
Handler for downscale factors for various triggers obtained from the OCDB.
std::map< TString, Double_t > fDownscaleFactors
Downscale factors for the various trigger classes for the current run.