Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DeadHotMapLoader.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DeadHotMapLoader.cc
1 // $Id: $
2 
11 #include "DeadHotMapLoader.h"
12 
13 #include <calobase/RawTowerDeadMap.h>
14 #include <calobase/RawTowerDeadMapv1.h>
15 #include <calobase/RawTowerDefs.h>
16 #include <calobase/TowerInfoDefs.h>
17 
18 #include <cdbobjects/CDBTTree.h>
19 
21 
23 #include <fun4all/SubsysReco.h>
24 
25 #include <phool/PHCompositeNode.h>
26 #include <phool/PHIODataNode.h>
27 #include <phool/PHNode.h>
28 #include <phool/PHNodeIterator.h>
29 #include <phool/PHObject.h>
30 #include <phool/getClass.h>
31 #include <phool/phool.h> // for PHWHERE
32 
33 #include <cassert>
34 #include <iostream>
35 #include <stdexcept>
36 #include <string>
37 
39  : SubsysReco("DeadHotMapLoader_" + detector)
40  , m_detector(detector)
41 {
42 }
43 
45 {
46  PHNodeIterator iter(topNode);
47  PHCompositeNode *runNode = static_cast<PHCompositeNode *>(iter.findFirst(
48  "PHCompositeNode", "RUN"));
49  if (!runNode)
50  {
51  std::cerr << Name() << "::" << m_detector << "::" << __PRETTY_FUNCTION__
52  << "Run Node missing, doing nothing." << std::endl;
53  throw std::runtime_error("Failed to find Run node in RawTowerCalibration::CreateNodes");
54  }
55 
56  // Create the tower nodes on the tree
57  PHNodeIterator dstiter(runNode);
58  PHCompositeNode *DetNode = dynamic_cast<PHCompositeNode *>(dstiter.findFirst("PHCompositeNode", m_detector));
59  if (!DetNode)
60  {
61  DetNode = new PHCompositeNode(m_detector);
62  runNode->addNode(DetNode);
63  }
64 
65  // Be careful as a previous calibrator may have been registered for this detector
66  std::string deadMapName = "DEADMAP_" + m_detector;
67  RawTowerDeadMap *m_deadmap = findNode::getClass<RawTowerDeadMapv1>(DetNode, deadMapName);
68  if (!m_deadmap)
69  {
71 
72  m_deadmap = new RawTowerDeadMapv1(caloid);
73  PHIODataNode<PHObject> *towerNode = new PHIODataNode<PHObject>(m_deadmap, deadMapName, "PHObject");
74  DetNode->addNode(towerNode);
75  }
76 
77  // assert(m_deadmap);
78 
80  if(url.empty())
81  {
82  std::cout << PHWHERE << " Could not get Dead Map for CDB. Detector: " << m_detector << std::endl;
84  }
85 
86  m_CDBTTree = new CDBTTree(url);
87 
88  if(!m_CDBTTree)
89  {
90  std::cout << "No CDB TTree found from url " << url << std::endl;
92  }
93 
94  int etabins;
95  int phibins;
96 
97  if (m_detector.c_str()[0] == 'H')
98  {//HCal towers
99  etabins = 24;
100  phibins = 64;
101 
102 
103  for(int i = 0; i < etabins*phibins; i++)
104  {
105  int isDead = m_CDBTTree->GetIntValue(i,"status");
106  if(isDead > 0)
107  {
108  unsigned int key = TowerInfoDefs::encode_hcal(i);
109  int ieta = TowerInfoDefs::getCaloTowerEtaBin(key);
110  int iphi = TowerInfoDefs::getCaloTowerPhiBin(key);
111  m_deadmap->addDeadTower(ieta, iphi);
112  }
113  }
114  }
115 
116  else if(m_detector.c_str()[0] == 'C')
117  {
118  etabins = 96;
119  phibins = 256;
120 
121  for(int i = 0; i < 96*256; i++)
122  {
123  int isDead = m_CDBTTree->GetIntValue(i,"status");
124  if(isDead > 0)
125  {
126  unsigned int key = TowerInfoDefs::encode_emcal(i);
127  int ieta = TowerInfoDefs::getCaloTowerEtaBin(key);
128  int iphi = TowerInfoDefs::getCaloTowerPhiBin(key);
129  m_deadmap->addDeadTower(ieta, iphi);
130  }
131  }
132  }
133 
134 
135  if (Verbosity())
136  {
137  std::cout << "DeadHotMapLoader::" << m_detector << "::InitRun - loading dead map completed : ";
138  m_deadmap->identify();
139  }
141 }