Created
January 28, 2013 19:58
-
-
Save gadamc/4658511 to your computer and use it in GitHub Desktop.
example create KData raw file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
gSystem.Load("libkds"); | |
Int_t nEvents = 500; | |
Int_t nBolos = 3; | |
Int_t nPulses = 4; | |
Int_t pulseSize = 512; | |
Int_t nMuonModules = 5; | |
UInt_t totSize; | |
totSize = 0; | |
KDataWriter *f = new KDataWriter(); | |
f->OpenFile("Event.a.root", KRawEvent::GetClassName()); | |
KRawEvent *event = (KRawEvent *)f->GetEvent(); | |
cout << "starting loop" << endl; | |
for (int ev = 0; ev < nEvents; ev++) { | |
f->NewEvent(); | |
KRawSambaRecord *samba; | |
//KRawSambaRecord *samba = event->AddSamba(); | |
samba = event->AddSamba(); | |
samba->SetRunName("aRun"); | |
samba->SetFileNumber(0); | |
samba->SetSambaDAQNumber(9); | |
for(int i = 0; i < nBolos; i++){ | |
KRawBolometerRecord *bolo = event->AddBolo(); | |
TString name = "bolo_"; name += i; | |
bolo->SetDetectorName(name.Data()); | |
bolo->SetSambaRecord(samba); | |
for(int j = 0; j < nPulses; j++){ | |
KRawBoloPulseRecord *pulse = event->AddBoloPulse(); | |
TString pname = "pulse_"; pname+=i; pname+="_"; pname+=j; | |
pulse->SetChannelName(pname.Data()); | |
pulse->SetBolometerRecord(bolo); | |
bolo->AddPulseRecord(pulse); | |
Short_t* lArray = new Short_t[pulseSize]; | |
for(int k = 0; k < pulseSize; k++) | |
lArray[k] = k; | |
pulse->SetTrace(pulseSize,lArray); | |
delete[] lArray; | |
} | |
} | |
for(int m = 0; m < nMuonModules; m++){ | |
KRawMuonModuleRecord *muon = event->AddMuonModule(); | |
muon->SetModuleNumber(m); | |
muon->SetTdc(0,m*34); | |
muon->SetTdc(1,m*43); | |
muon->SetAdc(0,m*234); | |
muon->SetAdc(0,m*345); | |
} | |
event->SetEventTriggerStamp(ev); | |
totSize += f->Fill(); //fill the tree | |
} | |
cout << "totSize: " << totSize << endl; | |
cout << "tree entries: " << f->GetEntries() <<endl; | |
f->Write(); | |
f->Close(); | |
delete f; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment