#include #include #include #include #include #include #include #include #include #include "DataLib.hh" #define HITS 3000 #define EVENTS 1000 int main(int argc,char ** argv) { const char *fileName = "test.root"; int verbose =1; if(verbose>0)std::cout << "\n--- Initializing........." < * testHitCollection = new std::vector; TFile *output_file = new TFile(fileName,"RECREATE"); output_file->cd(); TTree *output_tree = new TTree("datatree","Tree di esempio"); //TBranch *branch0 = output_tree->Branch("test",testD); TBranch *branch = output_tree->Branch(MChits_->getRecordName().c_str(),MChits_); branch->SetBasketSize(64000); //random double for values TRandom3 * rand3 = new TRandom3(0); //event loop for (int i=0; isetEventID(i); if(verbose>0)std::cout << "\n*** Event: " << i << "\n============================================\n"; //fill the hit collection with random values for(int j=0;jRndm()*100); double rndmDouble2 = (rand3->Rndm()*100); double rndmDouble3 = (rand3->Rndm()*100); double rndmDouble4 = (rand3->Rndm()*100); int rndmInt = (int)rndmDouble; TLorentzVector muonpos( rndmDouble2,rndmDouble3,rndmDouble3,0.0); ParticleDescrShortRecord muon(rndmInt, muonpos ); sdHit.setEdep(rndmDouble); sdHit.setNSteps(rndmInt); TLorentzVector pos( rndmDouble2,rndmDouble3,rndmDouble3,0.0); sdHit.setPosition(pos); TLorentzVector p4(rndmDouble,rndmDouble2,rndmDouble3,rndmDouble4); sdHit.setP4(p4); sdHit.setPDG( rndmInt); sdHit.setTrackID( rndmInt ); sdHit.setParentID( rndmInt); sdHit.setKinEnergy( rndmDouble); sdHit.setMuon(muon); sdHit.setTrackLeftVolume(true); if((j % 1000 == 0) && verbose>1)sdHit.printToStream(std::cout); testHitCollection->push_back(sdHit); } //copy the hit collection to SimulData MChits_->setSDHits(*testHitCollection); //clear hitcollection std::vector().swap(*testHitCollection); testHitCollection->clear(); testHitCollection->resize(0); //fill the branch output_tree->Fill(); //if((i % 10 == 0) && verbose>0)output_tree->Print(); //clear the hit collection vector in the SimulData after fill MChits_->clearSDHits(); } output_file->cd(); output_tree->Write(); output_file->Close(); return 0; }