CMS 3D CMS Logo

Public Member Functions | Private Attributes

RootNeutronWriter Class Reference

#include <RootNeutronWriter.h>

Inheritance diagram for RootNeutronWriter:
NeutronWriter

List of all members.

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.
virtual ~RootNeutronWriter ()

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.

{
  theFile = new TFile(fileName.c_str(),"update");
}
RootNeutronWriter::~RootNeutronWriter ( ) [virtual]

Definition at line 12 of file RootNeutronWriter.cc.

References interactiveExample::theFile.

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

Member Function Documentation

RootChamberWriter & RootNeutronWriter::chamberWriter ( int  chamberType)

Definition at line 33 of file RootNeutronWriter.cc.

References Exception.

{
  std::map<int, RootChamberWriter>::iterator mapItr = theChamberWriters.find(chamberType);
  if(mapItr != theChamberWriters.end())
  {
    return mapItr->second;
  }
  else
  {
    throw cms::Exception("NeutronWriter") << "It's dangerous to create ROOT chamber "
      << "writers during processing.  The global file may change";
      
    // make a new one
    initialize(chamberType);
    return theChamberWriters[chamberType];
  }
}
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.

{
    ostringstream treeName;
    treeName << "ChamberType" << chamberType;
    theChamberWriters[chamberType] = RootChamberWriter(treeName.str());
}
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.

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

Member Data Documentation

Definition at line 29 of file RootNeutronWriter.h.

TFile* RootNeutronWriter::theFile [private]

Definition at line 30 of file RootNeutronWriter.h.