Look into the example provided in $ROOTSYS/test/Event.
I suggest the following Event model:
class Event: public TObject {
EventHeader header;
RawData *rawdata;
TClonesArray *tracks;
}
with:
class EventHeader {
Int_t run;
Int_t record;
Int_t fill;
Int_t event_number;
...
}
class RawData : public TObject {
TarrayI rawTracker; // arrays of Int_t (or floats, shorts,etc..
TArrayI rawCalo; // with your original raw data
TArrayI rawMuon; // This can be a more sophisticated model !!
..
}
class Track : public TObject {
Float_t px;
Float_t py;
...
}
// Create one file per run/rec/fill
{
char filename[64];
sprintf(filename,"run%i_rec%i_fill%i",run,rec,fill);
TFile dst(filename,"recreate")
TTree T("T",filename);
EVent *event = new Event();
T.Branch("event","Event",&event,8000,1);
// Read raw data file and fill tree
while(..) {
event->ReadRawData();
event->Reconstruct();
T.Fill();
}
T.Write();
}
In this example, ROOT will create a Tree automatically splitting
the event into the following branches:
- one branch for each data member of EventHeader
- one single branch for the raw data. You can structure this part
to force one branch per detector component.
- one superbranch for the tracks. This superbranch will have one
branch
for each data member of Track.
With this structure, when you process the Tree in a Root session:
Root > TFile dst("....);
Root > T.Draw("event_number"); // reads only event_number branch
Root > T.Draw("px"); // reads only subbranch px
You can group many data bases into a logical chain)
TChain rec25("rec25","T");
rec25.Add("dst_run1_rec25_fill1");
rec25.Add("dst_run1_rec25_fill2");
rec25.Add("dst_run1_rec25_fill3");
rec25.Draw("px"); will sequentially process all 3 files
More details are given in the $ROOTSYS/test/Event example.
Rene Brun