test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
virtual void initialize (int detType)
 
 RootNeutronWriter (const std::string &fileName)
 
virtual void writeCluster (int chamberType, const edm::PSimHitContainer &hits)
 writes out a list of SimHits. More...
 
virtual ~RootNeutronWriter ()
 
- 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 14 of file RootNeutronWriter.h.

Constructor & Destructor Documentation

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

Definition at line 6 of file RootNeutronWriter.cc.

References interactiveExample::theFile.

7 {
8  theFile = new TFile(fileName.c_str(),"update");
9 }
RootNeutronWriter::~RootNeutronWriter ( )
virtual

Definition at line 12 of file RootNeutronWriter.cc.

References interactiveExample::theFile.

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

Member Function Documentation

RootChamberWriter & RootNeutronWriter::chamberWriter ( int  chamberType)

Definition at line 33 of file RootNeutronWriter.cc.

References Exception, and initialize().

34 {
35  std::map<int, RootChamberWriter>::iterator mapItr = theChamberWriters.find(chamberType);
36  if(mapItr != theChamberWriters.end())
37  {
38  return mapItr->second;
39  }
40  else
41  {
42  throw cms::Exception("NeutronWriter") << "It's dangerous to create ROOT chamber "
43  << "writers during processing. The global file may change";
44 
45  // make a new one
46  initialize(chamberType);
47  return theChamberWriters[chamberType];
48  }
49 }
virtual void initialize(int detType)
std::map< int, RootChamberWriter > theChamberWriters
void RootNeutronWriter::initialize ( int  detType)
virtual

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

Reimplemented from NeutronWriter.

Definition at line 26 of file RootNeutronWriter.cc.

27 {
28  ostringstream treeName;
29  treeName << "ChamberType" << chamberType;
30  theChamberWriters[chamberType] = RootChamberWriter(treeName.str());
31 }
std::map< int, RootChamberWriter > theChamberWriters
void RootNeutronWriter::writeCluster ( int  detType,
const edm::PSimHitContainer simHits 
)
virtual

writes out a list of SimHits.

Implements NeutronWriter.

Definition at line 52 of file RootNeutronWriter.cc.

References gather_cfg::cout.

53 {
54 std::cout << "ROOTNEUTRONWRITER " << chamberType << " HITS SIZE " << hits.size() <<std::endl;
55  chamberWriter(chamberType).write(hits);
56 }
RootChamberWriter & chamberWriter(int chamberType)
void write(const edm::PSimHitContainer &hits)
tuple cout
Definition: gather_cfg.py:145

Member Data Documentation

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

Definition at line 29 of file RootNeutronWriter.h.

TFile* RootNeutronWriter::theFile
private

Definition at line 30 of file RootNeutronWriter.h.