CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
RootNeutronWriter Class Reference

#include <RootNeutronWriter.h>

Inheritance diagram for RootNeutronWriter:
NeutronWriter

Public Member Functions

RootChamberWriterchamberWriter (int chamberType)
 
void initialize (int detType) override
 
 RootNeutronWriter (const std::string &fileName)
 
void writeCluster (int chamberType, const edm::PSimHitContainer &hits) override
 writes out a list of SimHits. More...
 
 ~RootNeutronWriter () override
 
- Public Member Functions inherited from NeutronWriter
virtual void beginEvent (edm::Event &e, const edm::EventSetup &es)
 
virtual void endEvent ()
 
virtual ~NeutronWriter ()
 

Private Attributes

std::map< int, RootChamberWritertheChamberWriters
 
TFile * theFile
 

Detailed Description

This writes the fields of a SimHit into an ASCII file, which can be read out later to add neutron hits to a muon chamber

Definition at line 13 of file RootNeutronWriter.h.

Constructor & Destructor Documentation

◆ RootNeutronWriter()

RootNeutronWriter::RootNeutronWriter ( const std::string &  fileName)

◆ ~RootNeutronWriter()

RootNeutronWriter::~RootNeutronWriter ( )
override

Definition at line 8 of file RootNeutronWriter.cc.

References makeListRunsInFiles::theFile.

8  {
9  for (std::map<int, RootChamberWriter>::iterator mapItr = theChamberWriters.begin(); mapItr != theChamberWriters.end();
10  ++mapItr) {
11  mapItr->second.tree()->Print();
12  // the tree will remember which file it's from
13  theFile = mapItr->second.tree()->GetCurrentFile();
14  }
15  theFile->Write();
16  // theFile->Close();
17 }
std::map< int, RootChamberWriter > theChamberWriters

Member Function Documentation

◆ chamberWriter()

RootChamberWriter & RootNeutronWriter::chamberWriter ( int  chamberType)

Definition at line 25 of file RootNeutronWriter.cc.

References Exception, and initialize().

25  {
26  std::map<int, RootChamberWriter>::iterator mapItr = theChamberWriters.find(chamberType);
27  if (mapItr != theChamberWriters.end()) {
28  return mapItr->second;
29  } else {
30  throw cms::Exception("NeutronWriter") << "It's dangerous to create ROOT chamber "
31  << "writers during processing. The global file may change";
32 
33  // make a new one
34  initialize(chamberType);
35  return theChamberWriters[chamberType];
36  }
37 }
std::map< int, RootChamberWriter > theChamberWriters
void initialize(int detType) override

◆ initialize()

void RootNeutronWriter::initialize ( int  detType)
overridevirtual

users should use this to create chamberwriters for each chamber type just after creation

Reimplemented from NeutronWriter.

Definition at line 19 of file RootNeutronWriter.cc.

19  {
20  ostringstream treeName;
21  treeName << "ChamberType" << chamberType;
22  theChamberWriters[chamberType] = RootChamberWriter(treeName.str());
23 }
std::map< int, RootChamberWriter > theChamberWriters

◆ writeCluster()

void RootNeutronWriter::writeCluster ( int  detType,
const edm::PSimHitContainer simHits 
)
overridevirtual

writes out a list of SimHits.

Implements NeutronWriter.

Definition at line 39 of file RootNeutronWriter.cc.

References gather_cfg::cout, and hfClusterShapes_cfi::hits.

39  {
40  std::cout << "ROOTNEUTRONWRITER " << chamberType << " HITS SIZE " << hits.size() << std::endl;
41  chamberWriter(chamberType).write(hits);
42 }
RootChamberWriter & chamberWriter(int chamberType)
void write(const edm::PSimHitContainer &hits)

Member Data Documentation

◆ theChamberWriters

std::map<int, RootChamberWriter> RootNeutronWriter::theChamberWriters
private

Definition at line 27 of file RootNeutronWriter.h.

◆ theFile

TFile* RootNeutronWriter::theFile
private

Definition at line 28 of file RootNeutronWriter.h.