CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RootNeutronWriter.cc
Go to the documentation of this file.
3 
4 using namespace std;
5 #include <iostream>
6 RootNeutronWriter::RootNeutronWriter(const string& fileName) { theFile = new TFile(fileName.c_str(), "update"); }
7 
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 }
18 
19 void RootNeutronWriter::initialize(int chamberType) {
20  ostringstream treeName;
21  treeName << "ChamberType" << chamberType;
22  theChamberWriters[chamberType] = RootChamberWriter(treeName.str());
23 }
24 
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 }
38 
39 void RootNeutronWriter::writeCluster(int chamberType, const edm::PSimHitContainer& hits) {
40  std::cout << "ROOTNEUTRONWRITER " << chamberType << " HITS SIZE " << hits.size() << std::endl;
41  chamberWriter(chamberType).write(hits);
42 }
static AlgebraicMatrix initialize()
~RootNeutronWriter() override
void writeCluster(int chamberType, const edm::PSimHitContainer &hits) override
writes out a list of SimHits.
void initialize(int detType) override
RootNeutronWriter(const std::string &fileName)
RootChamberWriter & chamberWriter(int chamberType)
tuple cout
Definition: gather_cfg.py:144
std::vector< PSimHit > PSimHitContainer