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)

Definition at line 6 of file RootNeutronWriter.cc.

6 { theFile = new TFile(fileName.c_str(), "update"); }

References MillePedeFileConverter_cfg::fileName, and interactiveExample::theFile.

◆ ~RootNeutronWriter()

RootNeutronWriter::~RootNeutronWriter ( )
override

Definition at line 8 of file RootNeutronWriter.cc.

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 }

References interactiveExample::theFile.

Member Function Documentation

◆ chamberWriter()

RootChamberWriter & RootNeutronWriter::chamberWriter ( int  chamberType)

Definition at line 25 of file RootNeutronWriter.cc.

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 }

References Exception, and initialize().

◆ 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 }

◆ 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.

39  {
40  std::cout << "ROOTNEUTRONWRITER " << chamberType << " HITS SIZE " << hits.size() << std::endl;
41  chamberWriter(chamberType).write(hits);
42 }

References gather_cfg::cout, and hfClusterShapes_cfi::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.

hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
RootNeutronWriter::theFile
TFile * theFile
Definition: RootNeutronWriter.h:28
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
RootNeutronWriter::theChamberWriters
std::map< int, RootChamberWriter > theChamberWriters
Definition: RootNeutronWriter.h:27
RootNeutronWriter::initialize
void initialize(int detType) override
Definition: RootNeutronWriter.cc:19
RootNeutronWriter::chamberWriter
RootChamberWriter & chamberWriter(int chamberType)
Definition: RootNeutronWriter.cc:25
RootChamberWriter
Definition: RootChamberWriter.h:8
Exception
Definition: hltDiff.cc:246
RootChamberWriter::write
void write(const edm::PSimHitContainer &hits)
Definition: RootChamberWriter.cc:20