Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "SimMuon/Neutron/src/RootNeutronWriter.h"
0002 #include "SimMuon/Neutron/src/RootNeutronReader.h"
0003 
0004 
0005 /*
0006  *  should write:
0007  * one event of one hit
0008  * one event of two hits
0009  *  Then read out three events, so it loops back.
0010  */
0011 
0012 using namespace std;
0013 
0014 void testWriting()
0015 {
0016   RootNeutronWriter writer("NeutronsME.root");
0017 
0018   int nevent = 5;
0019   int hitCount = 0;
0020   for(int event = 1; event <= nevent; ++event) {
0021     int detType = (rand() % 10) + 1;
0022     vector<PSimHit> hits;
0023     int nhits = event;
0024     for(int i = 0; i < nhits; ++i) {
0025       int layer   = i%6 + 1;
0026       ++hitCount;
0027       PSimHit pSimHit(LocalPoint(i, hitCount,-0.25), LocalPoint(i, hitCount,0.25),
0028               100., 300., 0.0001, 11, layer, 1, 0., 0.);
0029       hits.push_back(pSimHit);
0030     }
0031     writer.writeCluster(detType, hits);
0032   }
0033 
0034 }
0035 
0036 
0037 void testReading()
0038 {
0039   RootNeutronReader reader("NeutronsME.root");
0040   for(int i = 0; i < 30; ++i) {
0041     for(int detType = 1; detType <= 10; ++detType) 
0042     {
0043       vector<PSimHit> hits;
0044       reader.readNextEvent(detType, hits);
0045       for(unsigned int i = 0; i != hits.size(); ++i) {
0046         cout <<  "OVAL DET " << detType << " " << hits[i] << endl;
0047       }
0048     }
0049   }
0050 
0051 }
0052 
0053 
0054 int main() 
0055 {
0056   testWriting();
0057   testReading();
0058 }
0059   
0060