CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RootNeutronWriter.cc
Go to the documentation of this file.
3 
4 using namespace std;
5 #include <iostream>
7 {
8  theFile = new TFile(fileName.c_str(),"update");
9 }
10 
11 
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 }
24 
25 
26 void RootNeutronWriter::initialize(int chamberType)
27 {
28  ostringstream treeName;
29  treeName << "ChamberType" << chamberType;
30  theChamberWriters[chamberType] = RootChamberWriter(treeName.str());
31 }
32 
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 }
50 
51 
52 void RootNeutronWriter::writeCluster(int chamberType, const edm::PSimHitContainer & hits)
53 {
54 std::cout << "ROOTNEUTRONWRITER " << chamberType << " HITS SIZE " << hits.size() <<std::endl;
55  chamberWriter(chamberType).write(hits);
56 }
57 
virtual void initialize(int detType)
static AlgebraicMatrix initialize()
virtual void writeCluster(int chamberType, const edm::PSimHitContainer &hits)
writes out a list of SimHits.
virtual ~RootNeutronWriter()
RootNeutronWriter(const std::string &fileName)
RootChamberWriter & chamberWriter(int chamberType)
tuple cout
Definition: gather_cfg.py:121
std::vector< PSimHit > PSimHitContainer