Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SubtractTowers.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SubtractTowers.cc
1 #include "SubtractTowers.h"
2 
3 #include "TowerBackground.h"
4 
5 // sPHENIX includes
6 #include <calobase/RawTower.h>
7 #include <calobase/RawTowerContainer.h>
8 #include <calobase/RawTowerDefs.h>
9 #include <calobase/RawTowerGeom.h>
10 #include <calobase/RawTowerGeomContainer.h>
11 #include <calobase/RawTowerv1.h>
12 
13 #include <calobase/TowerInfo.h>
14 #include <calobase/TowerInfoContainer.h>
15 #include <calobase/TowerInfov1.h>
16 #include <calobase/TowerInfoContainerv1.h>
17 
19 #include <fun4all/SubsysReco.h>
20 
21 #include <phool/PHCompositeNode.h>
22 #include <phool/PHIODataNode.h>
23 #include <phool/PHNode.h>
24 #include <phool/PHNodeIterator.h>
25 #include <phool/PHObject.h>
26 #include <phool/getClass.h>
27 #include <phool/phool.h>
28 
29 // standard includes
30 #include <cmath>
31 #include <iostream>
32 #include <map>
33 #include <utility>
34 #include <vector>
35 
37  : SubsysReco(name)
38  , _use_flow_modulation(false)
39 {
40 }
41 
43 {
44  CreateNode(topNode);
45 
47 }
48 
50 {
51  if (Verbosity() > 0)
52  std::cout << "SubtractTowers::process_event: entering, with _use_flow_modulation = " << _use_flow_modulation << std::endl;
53 
54  // pull out the tower containers and geometry objects at the start
55  RawTowerContainer *towersEM3 = nullptr;
56  RawTowerContainer *towersIH3 = nullptr;
57  RawTowerContainer *towersOH3 = nullptr;
58  TowerInfoContainer *towerinfosEM3 = nullptr;
59  TowerInfoContainer *towerinfosIH3 = nullptr;
60  TowerInfoContainer *towerinfosOH3 = nullptr;
61 
62 
63  if (m_use_towerinfo)
64  {
65  towerinfosEM3 = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_CEMC_RETOWER");
66  towerinfosIH3 = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_HCALIN");
67  towerinfosOH3 = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_HCALOUT");
68 
69  if (Verbosity() > 0)
70  {
71  std::cout << "SubtractTowers::process_event: " << towerinfosEM3->size() << " TOWER_CALIB_CEMC_RETOWER towers" << std::endl;
72  std::cout << "SubtractTowers::process_event: " << towerinfosIH3->size() << " TOWER_CALIB_HCALIN towers" << std::endl;
73  std::cout << "SubtractTowers::process_event: " << towerinfosOH3->size() << " TOWER_CALIB_HCALOUT towers" << std::endl;
74  }
75  }
76  else
77  {
78  towersEM3 = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_CEMC_RETOWER");
79  towersIH3 = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALIN");
80  towersOH3 = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALOUT");
81 
82  if (Verbosity() > 0)
83  {
84  std::cout << "SubtractTowers::process_event: " << towersEM3->size() << " TOWER_CALIB_CEMC_RETOWER towers" << std::endl;
85  std::cout << "SubtractTowers::process_event: " << towersIH3->size() << " TOWER_CALIB_HCALIN towers" << std::endl;
86  std::cout << "SubtractTowers::process_event: " << towersOH3->size() << " TOWER_CALIB_HCALOUT towers" << std::endl;
87  }
88  }
89 
90 
91  RawTowerGeomContainer *geomIH = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALIN");
92  RawTowerGeomContainer *geomOH = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALOUT");
93 
94 
95  // these should have already been created during InitRun()
96  RawTowerContainer *emcal_towers = nullptr;
97  RawTowerContainer *ihcal_towers = nullptr;
98  RawTowerContainer *ohcal_towers = nullptr;
99  TowerInfoContainer *emcal_towerinfos = nullptr;
100  TowerInfoContainer *ihcal_towerinfos = nullptr;
101  TowerInfoContainer *ohcal_towerinfos = nullptr;
102  if (m_use_towerinfo)
103  {
104  emcal_towerinfos = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_CEMC_RETOWER_SUB1");
105  ihcal_towerinfos = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_HCALIN_SUB1");
106  ohcal_towerinfos = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_HCALOUT_SUB1");
107  }
108  if (Verbosity() > 0)
109  {
110  std::cout << "SubtractTowers::process_event: starting with " << emcal_towerinfos->size() << " TOWER_CALIB_CEMC_RETOWER_SUB1 towers" << std::endl;
111  std::cout << "SubtractTowers::process_event: starting with " << ihcal_towerinfos->size() << " TOWER_CALIB_HCALIN_SUB1 towers" << std::endl;
112  std::cout << "SubtractTowers::process_event: starting with " << ohcal_towerinfos->size() << " TOWER_CALIB_HCALOUT_SUB1 towers" << std::endl;
113  }
114 
115  else
116  {
117  emcal_towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_CEMC_RETOWER_SUB1");
118  ihcal_towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALIN_SUB1");
119  ohcal_towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALOUT_SUB1");
120  if (Verbosity() > 0)
121  {
122  std::cout << "SubtractTowers::process_event: starting with " << emcal_towers->size() << " TOWER_CALIB_CEMC_RETOWER_SUB1 towers" << std::endl;
123  std::cout << "SubtractTowers::process_event: starting with " << ihcal_towers->size() << " TOWER_CALIB_HCALIN_SUB1 towers" << std::endl;
124  std::cout << "SubtractTowers::process_event: starting with " << ohcal_towers->size() << " TOWER_CALIB_HCALOUT_SUB1 towers" << std::endl;
125  }
126  }
127 
128  TowerBackground *towerbackground;
129  if (m_use_towerinfo)
130  {
131  towerbackground = findNode::getClass<TowerBackground>(topNode, "TowerInfoBackground_Sub2");
132  }
133  else
134  {
135  towerbackground = findNode::getClass<TowerBackground>(topNode, "TowerBackground_Sub2");
136  }
137  // read these in to use, even if we don't use flow modulation in the subtraction
138  float background_v2 = towerbackground->get_v2();
139  float background_Psi2 = towerbackground->get_Psi2();
140 
141  // EMCal
142 
143  // replicate existing towers
144  if (m_use_towerinfo)
145  {
146  unsigned int nchannels_em = towerinfosEM3->size();
147  for (unsigned int channel = 0; channel < nchannels_em;channel++)
148  {
149  TowerInfo *tower = towerinfosEM3->get_tower_at_channel(channel);
150  unsigned int towerkey = towerinfosEM3->encode_key(channel);
151  int ieta = towerinfosEM3->getTowerEtaBin(towerkey);
152  int iphi = towerinfosEM3->getTowerPhiBin(towerkey);
153  float raw_energy = tower->get_energy();
154  float UE = towerbackground->get_UE(0).at(ieta);
156  {
158  float tower_phi = geomIH->get_tower_geometry(key)->get_phi();
159  UE = UE * (1 + 2 * background_v2 * cos(2 * (tower_phi - background_Psi2)));
160  }
161  float new_energy = raw_energy - UE;
162  //if a tower has time = -10 or -11 it is masked, leave it at zero
163  if( tower->get_time() == -10 || tower->get_time() == -11 ) new_energy = 0;
164 
165  emcal_towerinfos->get_tower_at_channel(channel)->set_time(tower->get_time());
166  emcal_towerinfos->get_tower_at_channel(channel)->set_energy(new_energy);
167 
168  if (Verbosity() > 5)
169  std::cout << " SubtractTowers::process_event : EMCal tower at ieta / iphi = " << ieta << " / " << iphi<< ", pre-sub / after-sub E = " << raw_energy << " / " << new_energy << std::endl;
170  }
171  }
172  else
173  {
174  RawTowerContainer::ConstRange begin_end_EM = towersEM3->getTowers();
175  for (RawTowerContainer::ConstIterator rtiter = begin_end_EM.first; rtiter != begin_end_EM.second; ++rtiter)
176  {
177  RawTower *tower = rtiter->second;
178 
179  int this_etabin = tower->get_bineta();
180  int this_phibin = tower->get_binphi();
181  float this_E = tower->get_energy();
182 
183  RawTower *new_tower = new RawTowerv1();
184  new_tower->set_energy(this_E);
185  emcal_towers->AddTower(this_etabin, this_phibin, new_tower);
186  }
187 
188  // now fill in additional towers with zero energy to fill out the full grid
189  // but note: after retowering, all of these should already exist...
190  for (int eta = 0; eta < geomIH->get_etabins(); eta++)
191  {
192  for (int phi = 0; phi < geomIH->get_phibins(); phi++)
193  {
194  if (!emcal_towers->getTower(eta, phi))
195  {
196  RawTower *new_tower = new RawTowerv1();
197  new_tower->set_energy(0);
198  emcal_towers->AddTower(eta, phi, new_tower);
199  }
200  }
201  }
202  // update towers for background subtraction...
203  for (RawTowerContainer::ConstIterator rtiter = emcal_towers->getTowers().first; rtiter != emcal_towers->getTowers().second; ++rtiter)
204  {
205  RawTower *tower = rtiter->second;
206  float raw_energy = tower->get_energy();
207  float UE = towerbackground->get_UE(0).at(tower->get_bineta());
209  {
210  float tower_phi = geomIH->get_tower_geometry(tower->get_key())->get_phi();
211  UE = UE * (1 + 2 * background_v2 * cos(2 * (tower_phi - background_Psi2)));
212  }
213  float new_energy = raw_energy - UE;
214  if( raw_energy == 0 ) new_energy = 0;
215  tower->set_energy(new_energy);
216  if (Verbosity() > 5)
217  std::cout << "SubtractTowers::process_event : EMCal tower at eta / phi = " << tower->get_bineta() << " / " << tower->get_binphi() << ", pre-sub / after-sub E = " << raw_energy << " / " << tower->get_energy() << std::endl;
218  }
219  }
220  // IHCal
221  // replicate existing towers
222  if (m_use_towerinfo)
223  {
224  unsigned int nchannels_ih = towerinfosIH3->size();
225  for (unsigned int channel = 0; channel < nchannels_ih;channel++)
226  {
227  TowerInfo *tower = towerinfosIH3->get_tower_at_channel(channel);
228  unsigned int towerkey = towerinfosIH3->encode_key(channel);
229  int ieta = towerinfosIH3->getTowerEtaBin(towerkey);
230  int iphi = towerinfosIH3->getTowerPhiBin(towerkey);
231 
232  float raw_energy = tower->get_energy();
233  float UE = towerbackground->get_UE(1).at(ieta);
235  {
237  float tower_phi = geomIH->get_tower_geometry(key)->get_phi();
238  UE = UE * (1 + 2 * background_v2 * cos(2 * (tower_phi - background_Psi2)));
239  }
240  float new_energy = raw_energy - UE;
241  //if a tower has time = -10 or -11 it is masked, leave it at zero
242  if( tower->get_time() == -10 || tower->get_time() == -11 ) new_energy = 0;
243 
244  ihcal_towerinfos->get_tower_at_channel(channel)->set_time(tower->get_time());
245  ihcal_towerinfos->get_tower_at_channel(channel)->set_energy(new_energy);
246  if (Verbosity() > 5)
247  std::cout << "SubtractTowers::process_event : IHCal tower at ieta / iphi = " << ieta << " / " << iphi<< ", pre-sub / after-sub E = " << raw_energy << " / " << new_energy << std::endl;
248  }
249  }
250  else
251  {
252 
253  RawTowerContainer::ConstRange begin_end_IH = towersIH3->getTowers();
254  for (RawTowerContainer::ConstIterator rtiter = begin_end_IH.first; rtiter != begin_end_IH.second; ++rtiter)
255  {
256  RawTower *tower = rtiter->second;
257  RawTowerGeom *tower_geom = geomIH->get_tower_geometry(tower->get_key());
258 
259  int this_etabin = geomIH->get_etabin(tower_geom->get_eta());
260  int this_phibin = geomIH->get_phibin(tower_geom->get_phi());
261  float this_E = tower->get_energy();
262 
263  RawTower *new_tower = new RawTowerv1();
264  new_tower->set_energy(this_E);
265  ihcal_towers->AddTower(this_etabin, this_phibin, new_tower);
266  }
267 
268  // now fill in additional towers with zero energy to fill out the full grid
269  for (int eta = 0; eta < geomIH->get_etabins(); eta++)
270  {
271  for (int phi = 0; phi < geomIH->get_phibins(); phi++)
272  {
273  if (!ihcal_towers->getTower(eta, phi))
274  {
275  RawTower *new_tower = new RawTowerv1();
276  new_tower->set_energy(0);
277  ihcal_towers->AddTower(eta, phi, new_tower);
278  }
279  }
280  }
281 
282  // update towers for background subtraction...
283  for (RawTowerContainer::ConstIterator rtiter = ihcal_towers->getTowers().first; rtiter != ihcal_towers->getTowers().second; ++rtiter)
284  {
285  RawTower *tower = rtiter->second;
286  float raw_energy = tower->get_energy();
287  float UE = towerbackground->get_UE(1).at(tower->get_bineta());
289  {
290  float tower_phi = geomIH->get_tower_geometry(tower->get_key())->get_phi();
291  UE = UE * (1 + 2 * background_v2 * cos(2 * (tower_phi - background_Psi2)));
292  }
293  float new_energy = raw_energy - UE;
294  if( raw_energy == 0 ) new_energy = 0;
295  tower->set_energy(new_energy);
296  }
297  }
298  // OHCal
299 
300  // replicate existing towers
301  if (m_use_towerinfo)
302  {
303  unsigned int nchannels_oh = towerinfosOH3->size();
304  for (unsigned int channel = 0; channel < nchannels_oh;channel++)
305  {
306  TowerInfo *tower = towerinfosOH3->get_tower_at_channel(channel);
307  unsigned int towerkey = towerinfosOH3->encode_key(channel);
308  int ieta = towerinfosOH3->getTowerEtaBin(towerkey);
309  int iphi = towerinfosOH3->getTowerPhiBin(towerkey);
310  float raw_energy = tower->get_energy();
311  float UE = towerbackground->get_UE(2).at(ieta);
313  {
315  float tower_phi = geomOH->get_tower_geometry(key)->get_phi();
316  UE = UE * (1 + 2 * background_v2 * cos(2 * (tower_phi - background_Psi2)));
317  }
318  float new_energy = raw_energy - UE;
319  //if a tower has time = -10 or -11 it is masked, leave it at zero
320  if( tower->get_time() == -10 || tower->get_time() == -11 ) new_energy = 0;
321 
322  ohcal_towerinfos->get_tower_at_channel(channel)->set_time(tower->get_time());
323  ohcal_towerinfos->get_tower_at_channel(channel)->set_energy(new_energy);
324  if (Verbosity() > 5)
325  std::cout << "SubtractTowers::process_event : OHCal tower at ieta / iphi = " << ieta << " / " << iphi<< ", pre-sub / after-sub E = " << raw_energy << " / " << new_energy << std::endl;
326  }
327  }
328  else
329  {
330  RawTowerContainer::ConstRange begin_end_OH = towersOH3->getTowers();
331  for (RawTowerContainer::ConstIterator rtiter = begin_end_OH.first; rtiter != begin_end_OH.second; ++rtiter)
332  {
333  RawTower *tower = rtiter->second;
334  RawTowerGeom *tower_geom = geomOH->get_tower_geometry(tower->get_key());
335 
336  int this_etabin = geomOH->get_etabin(tower_geom->get_eta());
337  int this_phibin = geomOH->get_phibin(tower_geom->get_phi());
338  float this_E = tower->get_energy();
339 
340  RawTower *new_tower = new RawTowerv1();
341  new_tower->set_energy(this_E);
342  ohcal_towers->AddTower(this_etabin, this_phibin, new_tower);
343  }
344 
345  // now fill in additional towers with zero energy to fill out the full grid
346  for (int eta = 0; eta < geomOH->get_etabins(); eta++)
347  {
348  for (int phi = 0; phi < geomOH->get_phibins(); phi++)
349  {
350  if (!ohcal_towers->getTower(eta, phi))
351  {
352  RawTower *new_tower = new RawTowerv1();
353  new_tower->set_energy(0);
354  ohcal_towers->AddTower(eta, phi, new_tower);
355  }
356  }
357  }
358 
359  // update towers for background subtraction...
360  for (RawTowerContainer::ConstIterator rtiter = ohcal_towers->getTowers().first; rtiter != ohcal_towers->getTowers().second; ++rtiter)
361  {
362  RawTower *tower = rtiter->second;
363  float raw_energy = tower->get_energy();
364  float UE = towerbackground->get_UE(2).at(tower->get_bineta());
366  {
367  float tower_phi = geomOH->get_tower_geometry(tower->get_key())->get_phi();
368  UE = UE * (1 + 2 * background_v2 * cos(2 * (tower_phi - background_Psi2)));
369  }
370  float new_energy = raw_energy - UE;
371  if( raw_energy == 0 ) new_energy = 0;
372  tower->set_energy(new_energy);
373  }
374  }
375 
376  if (Verbosity() > 0)
377  {
378  if (!m_use_towerinfo)
379  {
380  std::cout << "SubtractTowers::process_event: ending with " << emcal_towers->size() << " TOWER_CALIB_CEMC_RETOWER_SUB1 towers" << std::endl;
381  std::cout << "SubtractTowers::process_event: ending with " << ihcal_towers->size() << " TOWER_CALIB_HCALIN_SUB1 towers" << std::endl;
382  std::cout << "SubtractTowers::process_event: ending with " << ohcal_towers->size() << " TOWER_CALIB_HCALOUT_SUB1 towers" << std::endl;
383  }
384  else
385  {
386  std::cout << "SubtractTowers::process_event: ending with " << emcal_towerinfos->size() << " TOWER_CALIB_CEMC_RETOWER_SUB1 towers" << std::endl;
387  std::cout << "SubtractTowers::process_event: ending with " << ihcal_towerinfos->size() << " TOWER_CALIB_HCALIN_SUB1 towers" << std::endl;
388  std::cout << "SubtractTowers::process_event: ending with " << ohcal_towerinfos->size() << " TOWER_CALIB_HCALOUT_SUB1 towers" << std::endl;
389  }
390  }
391 
392  if (Verbosity() > 0) std::cout << "SubtractTowers::process_event: exiting" << std::endl;
393 
395 }
396 
398 {
399  PHNodeIterator iter(topNode);
400 
401  // Looking for the DST node
402  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
403  if (!dstNode)
404  {
405  std::cout << PHWHERE << "DST Node missing, doing nothing." << std::endl;
407  }
408 
409  TowerInfoContainer *hcal_towers = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_HCALIN");
410  if(m_use_towerinfo && !hcal_towers)
411  {
412  std::cout << PHWHERE << "Cannot find TOWERINFO_CALIB_HCALIN for creating new tower containers. Exiting" << std::endl;
413  exit(1);
414  }
415 
416  // store the new EMCal towers
417 
418  PHCompositeNode *emcalNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "CEMC"));
419  if (!emcalNode)
420  {
421  std::cout << PHWHERE << "EMCal Node note found, doing nothing." << std::endl;
422  }
423  if (m_use_towerinfo)
424  {
425  TowerInfoContainer *test_emcal_tower = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_CEMC_RETOWER_SUB1");
426  if (!test_emcal_tower)
427  {
428  if (Verbosity() > 0) std::cout << "SubtractTowers::CreateNode : creating TOWERINFO_CALIB_CEMC_RETOWER_SUB1 node " << std::endl;
429 
430  TowerInfoContainer *emcal_towers = dynamic_cast<TowerInfoContainer *> (hcal_towers->CloneMe());
431  PHIODataNode<PHObject> *emcalTowerNode = new PHIODataNode<PHObject>(emcal_towers, "TOWERINFO_CALIB_CEMC_RETOWER_SUB1", "PHObject");
432  emcalNode->addNode(emcalTowerNode);
433  }
434  else
435  {
436  std::cout << "SubtractTowers::CreateNode : TOWER_CALIB_CEMC_RETOWER_SUB1 already exists! " << std::endl;
437  }
438  }
439  else
440  {
441  RawTowerContainer *test_emcal_tower = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_CEMC_RETOWER_SUB1");
442  if (!test_emcal_tower)
443  {
444  if (Verbosity() > 0) std::cout << "SubtractTowers::CreateNode : creating TOWER_CALIB_CEMC_RETOWER_SUB1 node " << std::endl;
445 
447  PHIODataNode<PHObject> *emcalTowerNode = new PHIODataNode<PHObject>(emcal_towers, "TOWER_CALIB_CEMC_RETOWER_SUB1", "PHObject");
448  emcalNode->addNode(emcalTowerNode);
449  }
450  else
451  {
452  std::cout << "SubtractTowers::CreateNode : TOWER_CALIB_CEMC_RETOWER_SUB1 already exists! " << std::endl;
453  }
454  }
455 
456 
457  // store the new IHCal towers
458  PHCompositeNode *ihcalNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "HCALIN"));
459  if (!ihcalNode)
460  {
461  std::cout << PHWHERE << "IHCal Node note found, doing nothing." << std::endl;
462  }
463  if (m_use_towerinfo)
464  {
465  TowerInfoContainer *test_ihcal_tower = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_HCALIN_SUB1");
466  if (!test_ihcal_tower)
467  {
468  if (Verbosity() > 0) std::cout << "SubtractTowers::CreateNode : creating TOWERINFO_CALIB_HCALIN_SUB1 node " << std::endl;
469 
470  TowerInfoContainer *ihcal_towers = dynamic_cast<TowerInfoContainer *> (hcal_towers->CloneMe());
471  PHIODataNode<PHObject> *ihcalTowerNode = new PHIODataNode<PHObject>(ihcal_towers, "TOWERINFO_CALIB_HCALIN_SUB1", "PHObject");
472  ihcalNode->addNode(ihcalTowerNode);
473  }
474  else
475  {
476  std::cout << "SubtractTowers::CreateNode : TOWER_CALIB_HCALIN_SUB1 already exists! " << std::endl;
477  }
478 
479  }
480  else
481  {
482  RawTowerContainer *test_ihcal_tower = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALIN_SUB1");
483  if (!test_ihcal_tower)
484  {
485  if (Verbosity() > 0) std::cout << "SubtractTowers::CreateNode : creating TOWER_CALIB_HCALIN_SUB1 node " << std::endl;
486 
488  PHIODataNode<PHObject> *ihcalTowerNode = new PHIODataNode<PHObject>(ihcal_towers, "TOWER_CALIB_HCALIN_SUB1", "PHObject");
489  ihcalNode->addNode(ihcalTowerNode);
490  }
491  else
492  {
493  std::cout << "SubtractTowers::CreateNode : TOWER_CALIB_HCALIN_SUB1 already exists! " << std::endl;
494  }
495 
496  }
497 
498  // store the new OHCal towers
499  PHCompositeNode *ohcalNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "HCALOUT"));
500  if (!ohcalNode)
501  {
502  std::cout << PHWHERE << "OHCal Node note found, doing nothing." << std::endl;
503  }
504  if (m_use_towerinfo)
505  {
506  TowerInfoContainer *test_ohcal_tower = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_HCALOUT_SUB1");
507  if (!test_ohcal_tower)
508  {
509  if (Verbosity() > 0) std::cout << "SubtractTowers::CreateNode : creating TOWERINFO_CALIB_HCALOUT_SUB1 node " << std::endl;
510 
511  TowerInfoContainer *ohcal_towers = dynamic_cast<TowerInfoContainer *> (hcal_towers->CloneMe());
512  PHIODataNode<PHObject> *ohcalTowerNode = new PHIODataNode<PHObject>(ohcal_towers, "TOWERINFO_CALIB_HCALOUT_SUB1", "PHObject");
513  ohcalNode->addNode(ohcalTowerNode);
514  }
515  else
516  {
517  std::cout << "SubtractTowers::CreateNode : TOWER_CALIB_HCALOUT_SUB1 already exists! " << std::endl;
518  }
519  }
520  else
521  {
522  RawTowerContainer *test_ohcal_tower = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALOUT_SUB1");
523  if (!test_ohcal_tower)
524  {
525  if (Verbosity() > 0) std::cout << "SubtractTowers::CreateNode : creating TOWER_CALIB_HCALOUT_SUB1 node " << std::endl;
526 
528  PHIODataNode<PHObject> *ohcalTowerNode = new PHIODataNode<PHObject>(ohcal_towers, "TOWER_CALIB_HCALOUT_SUB1", "PHObject");
529  ohcalNode->addNode(ohcalTowerNode);
530  }
531  else
532  {
533  std::cout << "SubtractTowers::CreateNode : TOWER_CALIB_HCALOUT_SUB1 already exists! " << std::endl;
534  }
535  }
537 }