Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Emcal_Tower_Masking.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Emcal_Tower_Masking.cc
1 
2 #include "Emcal_Tower_Masking.h"
3 
4 #include <calobase/TowerInfo.h>
5 #include <calobase/TowerInfoContainer.h>
6 #include <calobase/TowerInfoContainerv1.h>
7 
8 #include <caloreco/CaloWaveformProcessing.h> // for CaloWaveformProcessing
14 #include <fun4all/SubsysReco.h> // for SubsysReco
15 
16 #include <phool/PHCompositeNode.h>
17 #include <phool/PHIODataNode.h> // for PHIODataNode
18 #include <phool/PHNode.h> // for PHNode
19 #include <phool/PHNodeIterator.h> // for PHNodeIterator
20 #include <phool/PHObject.h> // for PHObject
21 #include <phool/getClass.h>
22 
23 #include <Event/Event.h>
24 #include <Event/packet.h>
25 
26 #include <iostream> // for operator<<, endl, basic...
27 #include <memory> // for allocator_traits<>::val...
28 #include <vector> // for vector
30 
31 #include <phool/PHCompositeNode.h>
32 
33 //____________________________________________________________________________..
35  SubsysReco(name)
36 {
37 }
38 
39 //____________________________________________________________________________..
41 {
42 }
43 
44 //____________________________________________________________________________..
46 {
47 
49 }
50 
51 //____________________________________________________________________________..
53 {
54  CreateNodeTree(topNode);
55  topNode->print();
57 }
58 
59 //____________________________________________________________________________..
61 {
62  float emcalescale = 1.0;
63 
64  TowerInfoContainer* emcaltowers = findNode::getClass<TowerInfoContainerv1>(topNode, "TOWERS_CEMC");
65  if (!emcaltowers)
66  {
67  std::cout
68  << "MyJetAnalysis::process_event - Error can not find DST TOWERS_CEMC node "
69  << std::endl;
70  exit(-1);
71  }
72  TowerInfoContainer* calib_emcaltowers = findNode::getClass<TowerInfoContainerv1>(topNode, "TOWERINFO_CALIB_CEMC");
73  if (!calib_emcaltowers)
74  {
75  std::cout
76  << "MyJetAnalysis::process_event - Error can not find DST TOWERINFO_CALIB_CEMC node "
77  << std::endl;
78  exit(-1);
79  }
80 
81 
82  GlobalVertexMap *vertexmap = findNode::getClass<GlobalVertexMap>(topNode, "GlobalVertexMap");
83  GlobalVertex *vertex = new GlobalVertexv1(GlobalVertex::VTXTYPE::SVTX);
84  vertex->set_id(vertexmap->size());
85  for (unsigned int i = 0; i < 3; ++i)
86  {
87  vertex->set_position(i, 0);
88  for (unsigned int j = i; j < 3; ++j)
89  {
90  vertex->set_error(i, j, 0);
91  }
92  }
93  vertexmap->insert(vertex);
94 
95 
96  {
97  unsigned int nchannels = emcaltowers->size();
98  for (unsigned int channel = 0; channel < nchannels;channel++)
99  {
100  TowerInfo* tower = emcaltowers->get_tower_at_channel(channel);
101  TowerInfo* calib_tower = calib_emcaltowers->get_tower_at_channel(channel);
102  unsigned int channelkey = emcaltowers->encode_key(channel);
103  unsigned int ieta = emcaltowers->getTowerEtaBin(channelkey);
104  unsigned int iphi = emcaltowers->getTowerPhiBin(channelkey);
105  int n_masked_packets = packetmasklist.size();
106  bool maskpacket = false;
107  if (n_masked_packets > 0 )
108  {
109  for (int i = 0; i < n_masked_packets;i++)
110  {
111  if (channel >= 192*(packetmasklist.at(i)-1) && channel < 192*packetmasklist.at(i))
112  {
113  maskpacket = true;
114  }
115  }
116  }
117  if (maskpacket == true)
118  {
119  calib_tower->set_energy(0);
120  calib_tower->set_time(0);
121  }
122  else
123  {
124  calib_tower->set_energy(tower->get_energy() * emcalescale);
125  calib_tower->set_time(tower->get_time());
126  }
127  int nbads = etamasklist.size();
128  if(nbads > 0 )
129  {
130  for(int q =0 ; q < nbads;q++)
131  {
132  if (ieta == etamasklist.at(q) && iphi == phimasklist.at(q))
133  {
134  calib_tower->set_energy(0);
135  calib_tower->set_time(0);
136  }
137  }
138  }
139 
140  }
141  }
142 
143 
145 }
146 
147 //____________________________________________________________________________..
149 {
150 
152 }
153 
154 //____________________________________________________________________________..
156 {
158 }
159 
160 //____________________________________________________________________________..
162 {
164 }
165 
166 //____________________________________________________________________________..
168 {
170 }
171 
172 //____________________________________________________________________________..
174 {
175  std::cout << "Emcal_Tower_Masking::Print(const std::string &what) const Printing info for " << what << std::endl;
176 }
177 
179 {
180  PHNodeIterator nodeItr(topNode);
181  // DST node
182  PHCompositeNode *dst_node = dynamic_cast<PHCompositeNode *>(
183  nodeItr.findFirst("PHCompositeNode", "DST"));
184  if (!dst_node)
185  {
186  std::cout << "PHComposite node created: DST" << std::endl;
187  dst_node = new PHCompositeNode("DST");
188  topNode->addNode(dst_node);
189  }
190  PHNodeIterator dstItr(dst_node);
191 
192  PHCompositeNode *CEMCNode = dynamic_cast<PHCompositeNode *>(dstItr.findFirst("PHCompositeNode", "CEMC"));
193  if (!CEMCNode)
194  {
195  std::cout << " no CEMC Node? " << std::endl;
196  CEMCNode = new PHCompositeNode("CEMC");
197  }
198  TowerInfoContainer* m_CEMC_calib_container = new TowerInfoContainerv1(TowerInfoContainer::DETECTOR::EMCAL);
199  PHIODataNode<PHObject> *emcal_towerNode = new PHIODataNode<PHObject>(m_CEMC_calib_container, "TOWERINFO_CALIB_CEMC", "PHObject");
200  CEMCNode->addNode(emcal_towerNode);
201 
202 
203  // store the GLOBAL stuff under a sub-node directory
204  PHCompositeNode *globalNode = dynamic_cast<PHCompositeNode *>(dstItr.findFirst("PHCompositeNode", "GLOBAL"));
205  if (!globalNode)
206  {
207  globalNode = new PHCompositeNode("GLOBAL");
208  dst_node->addNode(globalNode);
209  }
210 
211  // create the GlobalVertexMap
212  GlobalVertexMap *vertexes = findNode::getClass<GlobalVertexMap>(topNode, "GlobalVertexMap");
213  if (!vertexes)
214  {
215  vertexes = new GlobalVertexMapv1();
216  PHIODataNode<PHObject> *VertexMapNode = new PHIODataNode<PHObject>(vertexes, "GlobalVertexMap", "PHObject");
217  globalNode->addNode(VertexMapNode);
218  }
219 
220 }