Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:49

0001 #include "SimMuon/Neutron/src/RootChamberWriter.h"
0002 #include "SimMuon/Neutron/src/RootSimHit.h"
0003 
0004 #include <iostream>
0005 using namespace std;
0006 
0007 RootChamberWriter::RootChamberWriter(const std::string& treeName) {
0008   theHits = new TClonesArray("RootSimHit");
0009   theTree = new TTree(treeName.c_str(), "Neutron Background");
0010   theTree->Bronch("Hits", "TClonesArray", &theHits);
0011 }
0012 
0013 RootChamberWriter::~RootChamberWriter() {
0014   //std::cout << "WRITING " << theTree->GetEntries() << std::endl;
0015   //  theTree->Write();
0016   //delete theHits;
0017   //delete theTree;
0018 }
0019 
0020 void RootChamberWriter::write(const edm::PSimHitContainer& hits) {
0021   std::cout << "ENTRIES BEFORE " << theTree->GetEntries() << std::endl;
0022   theHits->Delete();
0023   theHits->Expand(hits.size());
0024   for (unsigned int i = 0; i < hits.size(); ++i) {
0025     new ((*theHits)[i]) RootSimHit(hits[i]);
0026   }
0027   theTree->Fill();
0028   std::cout << "ENTRIES AFTER " << theTree->GetEntries() << std::endl;
0029 }