Skip to content

Commit 7a91add

Browse files
author
Devin Connolly
authored
Merge pull request #2 from elzoido238/master
Added SONIK tree (t0) to dragon::MakeChains
2 parents 1899871 + 735b44a commit 7a91add

File tree

2 files changed

+85
-44
lines changed

2 files changed

+85
-44
lines changed

src/utils/RootAnalysis.cxx

Lines changed: 81 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ template <class T> void Zap(T*& t)
100100

101101
// ============ namespace dragon Free Functions ============ //
102102

103-
void dragon::MakeChains(const Int_t* runnumbers, Int_t nruns, const char* format)
103+
void dragon::MakeChains(const Int_t* runnumbers, Int_t nruns, Bool_t sonik, const char* format)
104104
{
105-
MakeChains("t", runnumbers, nruns, format);
105+
MakeChains("t", runnumbers, nruns, sonik, format);
106106
}
107107

108-
void dragon::MakeChains(const char* prefix, const Int_t* runnumbers, Int_t nruns, const char* format)
108+
void dragon::MakeChains(const char* prefix, const Int_t* runnumbers, Int_t nruns, Bool_t sonik, const char* format)
109109
{
110110
///
111111
/// \param [in] runnumbers Pointer to a valid array of desired run numbers to chain together.
@@ -114,56 +114,98 @@ void dragon::MakeChains(const char* prefix, const Int_t* runnumbers, Int_t nruns
114114
///
115115
/// \note Does not return anything, but creates `new` heap-allocated TChains that become part of
116116
/// the present ROOT directory; these must be deleted by the user.
117-
TChain* chain[] = {
118-
new TChain(Form("%s1", "t"), "Head singles event."),
119-
new TChain(Form("%s2", "t"), "Head scaler event."),
120-
new TChain(Form("%s3", "t"), "Tail singles event."),
121-
new TChain(Form("%s4", "t"), "Tail scaler event."),
122-
new TChain(Form("%s5", "t"), "Coincidence event."),
123-
new TChain(Form("%s20", "t"), "Epics event."),
124-
new TChain(Form("%s6", "t"), "Timestamp diagnostics."),
125-
new TChain(Form("%s7", "t"), "Glocal run parameters.")
126-
};
127-
Int_t nchains = sizeof(chain) / sizeof(TChain*);
117+
if ( !(sonik) ){
118+
TChain* chain[] = {
119+
new TChain(Form("%s1", "t"), "Head singles event."),
120+
new TChain(Form("%s2", "t"), "Head scaler event."),
121+
new TChain(Form("%s3", "t"), "Tail singles event."),
122+
new TChain(Form("%s4", "t"), "Tail scaler event."),
123+
new TChain(Form("%s5", "t"), "Coincidence event."),
124+
new TChain(Form("%s20", "t"), "Epics event."),
125+
new TChain(Form("%s6", "t"), "Timestamp diagnostics."),
126+
new TChain(Form("%s7", "t"), "Glocal run parameters.")
127+
};
128+
Int_t nchains = sizeof(chain) / sizeof(TChain*);
128129

129-
for(Int_t i=0; i< nruns; ++i) {
130-
char fname[4096];
131-
sprintf(fname, format, runnumbers[i]);
132-
{
133-
TFile file(fname);
134-
if(file.IsZombie()) {
135-
dutils::Warning("MakeChains", __FILE__, __LINE__)
136-
<< "Skipping run " << runnumbers[i] << ", couldn't find file " << fname;
130+
for(Int_t i=0; i< nruns; ++i) {
131+
char fname[4096];
132+
sprintf(fname, format, runnumbers[i]);
133+
{
134+
TFile file(fname);
135+
if(file.IsZombie()) {
136+
dutils::Warning("MakeChains", __FILE__, __LINE__)
137+
<< "Skipping run " << runnumbers[i] << ", couldn't find file " << fname;
138+
}
139+
}
140+
141+
for(int j=0; j< nchains; ++j) {
142+
chain[j]->AddFile(fname);
137143
}
138144
}
139145

140-
for(int j=0; j< nchains; ++j) {
141-
chain[j]->AddFile(fname);
146+
chain[0]->SetName(Form("%s1", prefix));
147+
chain[1]->SetName(Form("%s2", prefix));
148+
chain[2]->SetName(Form("%s3", prefix));
149+
chain[3]->SetName(Form("%s4", prefix));
150+
chain[4]->SetName(Form("%s5", prefix));
151+
chain[5]->SetName(Form("%s20", prefix));
152+
chain[6]->SetName(Form("%s6", prefix));
153+
chain[7]->SetName(Form("%s7", prefix));
154+
}
155+
else{
156+
TChain* chain[] = {
157+
new TChain(Form("%s0", "t"), "SONIK event."),
158+
// new TChain(Form("%s1", "t"), "Head singles event."), Head DAQ not used with SONIK
159+
// new TChain(Form("%s2", "t"), "Head scaler event."),
160+
new TChain(Form("%s3", "t"), "Tail singles event."),
161+
new TChain(Form("%s4", "t"), "Tail scaler event."),
162+
// new TChain(Form("%s5", "t"), "Coincidence event."), coincidence events not used with SONIK
163+
new TChain(Form("%s20", "t"), "Epics event."),
164+
new TChain(Form("%s6", "t"), "Timestamp diagnostics."),
165+
new TChain(Form("%s7", "t"), "Glocal run parameters.")
166+
};
167+
Int_t nchains = sizeof(chain) / sizeof(TChain*);
168+
169+
for(Int_t i=0; i< nruns; ++i) {
170+
char fname[4096];
171+
sprintf(fname, format, runnumbers[i]);
172+
{
173+
TFile file(fname);
174+
if(file.IsZombie()) {
175+
dutils::Warning("MakeChains", __FILE__, __LINE__)
176+
<< "Skipping run " << runnumbers[i] << ", couldn't find file " << fname;
177+
}
178+
}
179+
180+
for(int j=0; j< nchains; ++j) {
181+
chain[j]->AddFile(fname);
182+
}
142183
}
143-
}
144184

145-
chain[0]->SetName(Form("%s1", prefix));
146-
chain[1]->SetName(Form("%s2", prefix));
147-
chain[2]->SetName(Form("%s3", prefix));
148-
chain[3]->SetName(Form("%s4", prefix));
149-
chain[4]->SetName(Form("%s5", prefix));
150-
chain[5]->SetName(Form("%s20", prefix));
151-
chain[6]->SetName(Form("%s6", prefix));
152-
chain[7]->SetName(Form("%s7", prefix));
185+
chain[0]->SetName(Form("%s0", prefix));
186+
// chain[1]->SetName(Form("%s1", prefix));
187+
// chain[2]->SetName(Form("%s2", prefix));
188+
chain[1]->SetName(Form("%s3", prefix));
189+
chain[2]->SetName(Form("%s4", prefix));
190+
// chain[5]->SetName(Form("%s5", prefix));
191+
chain[3]->SetName(Form("%s20", prefix));
192+
chain[4]->SetName(Form("%s6", prefix));
193+
chain[5]->SetName(Form("%s7", prefix));
194+
}
153195
}
154196

155-
void dragon::MakeChains(const char* prefix, const std::vector<Int_t>& runnumbers, const char* format)
197+
void dragon::MakeChains(const char* prefix, const std::vector<Int_t>& runnumbers, Bool_t sonik, const char* format)
156198
{
157-
MakeChains(prefix, &runnumbers[0], runnumbers.size(), format);
199+
MakeChains(prefix, &runnumbers[0], runnumbers.size(), sonik, format);
158200
}
159201

160-
void dragon::MakeChains(const std::vector<Int_t>& runnumbers, const char* format)
202+
void dragon::MakeChains(const std::vector<Int_t>& runnumbers, Bool_t sonik, const char* format)
161203
{
162204
///
163205
/// \param runnumbers vector of desired run numbers
164206
/// \param format same as the other version
165207
///
166-
MakeChains(&runnumbers[0], runnumbers.size(), format);
208+
MakeChains(&runnumbers[0], runnumbers.size(), sonik, format);
167209
}
168210

169211
void dragon::FriendChain(TChain* chain, const char* friend_name, const char* friend_alias,
@@ -2075,7 +2117,7 @@ UDouble_t dragon::StoppingPowerCalculator::CalculateEbeam(TGraph** plot)
20752117
for(Int_t i=0; i< GetNmeasurements(); ++i) {
20762118

20772119
double md1err = fMd1[i].GetErrLow() < fMd1[i].GetErrHigh() ?
2078-
fMd1[i].GetErrHigh() : fMd1[i].GetErrLow();
2120+
fMd1[i].GetErrHigh() : fMd1[i].GetErrLow();
20792121

20802122
pres[i] = fPressures[i];
20812123
energy[i] = CalculateEnergy(fMd1[i].GetNominal(), md1err, fBeamCharge, fBeamMass, fMd1Constant.GetNominal(), 0);
@@ -2131,8 +2173,7 @@ UDouble_t dragon::StoppingPowerCalculator::CalculateEpsilon(TGraph** plot, UDoub
21312173
for(Int_t i=0; i< GetNmeasurements(); ++i) {
21322174

21332175
double md1err = fMd1[i].GetErrLow() < fMd1[i].GetErrHigh() ?
2134-
fMd1[i].GetErrHigh() : fMd1[i].GetErrLow();
2135-
2176+
fMd1[i].GetErrHigh() : fMd1[i].GetErrLow();
21362177
dens[i] = CalculateDensity(fPressures[i], UDouble_t(fTargetLength.GetNominal(), 0), fNmol, fTemp);
21372178
energy[i] = CalculateEnergy(fMd1[i].GetNominal(), md1err, fBeamCharge, fBeamMass, fMd1Constant.GetNominal(), 0);
21382179
}

src/utils/RootAnalysis.hxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ enum MeasurementType_t {
4242
};
4343

4444
/// Chain together all trees in multiple DRAGON files.
45-
void MakeChains(const char* prefix, const Int_t* runnumbers, Int_t nruns, const char* format = "$DH/rootfiles/run%d.root");
45+
void MakeChains(const char* prefix, const Int_t* runnumbers, Int_t nruns, Bool_t sonik = kFALSE, const char* format = "$DH/rootfiles/run%d.root");
4646

4747
/// Chain together all trees in multiple DRAGON files.
48-
void MakeChains(const Int_t* runnumbers, Int_t nruns, const char* format = "$DH/rootfiles/run%d.root");
48+
void MakeChains(const Int_t* runnumbers, Int_t nruns, Bool_t sonik = kFALSE, const char* format = "$DH/rootfiles/run%d.root");
4949

5050
/// Chain together trees using a vector instead of array
51-
void MakeChains(const std::vector<Int_t>& runnumbers, const char* format = "$DH/rootfiles/run%d.root");
51+
void MakeChains(const std::vector<Int_t>& runnumbers, Bool_t sonik = kFALSE, const char* format = "$DH/rootfiles/run%d.root");
5252

5353
/// Chain together trees using a vector instead of array
54-
void MakeChains(const char* prefix, const std::vector<Int_t>& runnumbers, const char* format = "$DH/rootfiles/run%d.root");
54+
void MakeChains(const char* prefix, const std::vector<Int_t>& runnumbers, Bool_t sonik = kFALSE, const char* format = "$DH/rootfiles/run%d.root");
5555

5656
/// Add another chain of files as a friend to an existing one
5757
void FriendChain(TChain* chain, const char* friend_name, const char* friend_alias,

0 commit comments

Comments
 (0)