#include #include #include #include #include #include class Hit : public TObject { public: char const *id; //Particle identity, i.e. alpha, proton ... double e; //Reconstructed kinetic energy of particle. vector det; //List of detectors that were hit. std::vector edep; //Energy deposited in the individual detectors. ClassDef(Hit,1); }; void Minimal() { TFile *f = new TFile("test.root","RECREATE"); TTree *outTree = new TTree("data","Identified particle hits."); TClonesArray hits("Hit",10); outTree->Branch("hits", &hits,32000,0); //Hit 1: Hit *hit1 = (Hit*)hits.ConstructedAt(0); hit1->id = "alpha"; hit1->e = 12.; hit1->det.push_back("D1"); hit1->det.push_back("D2"); hit1->edep.push_back(3.); //Energy deposited by alpha in D1 hit1->edep.push_back(9.); //Energy deposited by alpha in D2 //Hit 2: Hit *hit2 = (Hit*)hits.ConstructedAt(1); hit2->id = "proton"; hit2->e = 25.; hit2->det.push_back("D2"); hit2->det.push_back("D3"); hit2->edep.push_back(8.); //Energy dep. by proton in D2. hit2->edep.push_back(13.); //Energy dep. by proton in D3. outTree->Fill(); outTree->Write(); f->Close(); }