Skip to content

Commit

Permalink
-> corrected typo in Database.hxx
Browse files Browse the repository at this point in the history
-> changed type of calibrated 2D histo from TH2F to TH2D in
Calibration.hxx
-> added missing elements to returned junk array for failed
GetParams in Calibration.cxx
  • Loading branch information
elzoido238 committed Feb 13, 2018
1 parent a233fca commit 85f3612
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/midas/Database.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <TNamed.h>

#if ROOT_VERSION_CODE < ROOT_VERSION(5,30,0)
#define NO_AUTO_PTR1
#define NO_AUTO_PTR 1

//
// ROOT doesn't play nice with std::auto_ptr until version 5.30 or so.
Expand Down Expand Up @@ -45,7 +45,7 @@ class Database
#endif
{
public:
#ifdef NO_AUTO_PTR1
#ifdef NO_AUTO_PTR
#define XML_POINTER_t dragon::utils::AutoPtr<midas::Xml>
#else
#define XML_POINTER_t std::auto_ptr<midas::Xml>
Expand Down
53 changes: 36 additions & 17 deletions src/utils/Calibration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void dutils::DsssdCalibrator::DrawSummaryCal(Option_t* opt)
if(gDirectory->Get("fHdcal"))
gDirectory->Get("fHdcal")->Delete();

fHdcal = new TH2F("fHdcal", "", NDSSSD, 0, NDSSSD, 4096, 0, 4095);
fHdcal = new TH2D("fHdcal", "", NDSSSD, 0, NDSSSD, 4096, 0, 4095);
dragon::Tail* tail = new dragon::Tail();
fTree->SetBranchAddress("tail", &tail);
for(Long_t evt = 0; evt < fTree->GetEntries(); ++evt) {
Expand Down Expand Up @@ -112,7 +112,7 @@ dutils::DsssdCalibrator::Param_t dutils::DsssdCalibrator::GetParams(Int_t channe
{
if((UInt_t)channel > NDSSSD - 1) {
std::cerr << "Invalid channel " << channel << ", valid range is [0, 31].\n";
Param_t junk = {0,0};
Param_t junk = {0, 0, 0, 0};
return junk;
}
return fParams[channel];
Expand All @@ -125,7 +125,7 @@ dutils::DsssdCalibrator::Param_t dutils::DsssdCalibrator::GetOldParams(Int_t cha
{
if((UInt_t)channel > NDSSSD - 1) {
std::cerr << "Invalid channel " << channel << ", valid range is [0, 31].\n";
Param_t junk = {0,0};
Param_t junk = {0, 0, 0, 0};
return junk;
}
return fOldParams[channel];
Expand Down Expand Up @@ -291,7 +291,8 @@ void dutils::DsssdCalibrator::PrintResults(const char* outfile)
fprintf(f, "%-7s \t %-8s \t %-7s \t %-7s\n","=======","======","======","======");
// fprintf(f, "Channel\tSlope\tOffset\n");
for(Int_t i = 0; i < NDSSSD; ++i) {
fprintf(f, "%7i \t %-6g \t %-6g \t %-6g\n", i, GetParams(i).offset, GetParams(i).slope, GetParams(i).inl);
fprintf(f, "%7i \t %-6g \t %-6g \t %-6g\n", i, GetParams(i).offset, GetParams(i).slope, 0.0);
// fprintf(f, "%7i \t %-6g \t %-6g \t %-6g\n", i, GetParams(i).offset, GetParams(i).slope, GetParams(i).inl);
// fprintf(f, "%2d\t%.6g\t%.6g\n", i, GetParams(i).slope, GetParams(i).offset);
}

Expand Down Expand Up @@ -397,35 +398,53 @@ void dutils::DsssdCalibrator::WriteXml(const char* outfile)
std::ofstream ofs(gSystem->ExpandPathName(outfile));

ofs << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
ofs << "<odb root=\"/dragon/dsssd/variables/adc\" filename=\"" <<
ofs << "<odb root=\"/\" filename=\"" <<
outfile << "\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"/Users/dragon/packages/midas/odb.xsd\">\n";

ofs << " <keyarray name=\"channel\" type=\"INT\" num_values=\"32\">\n";
ofs << " <dir name=\"dragon\">\n";
ofs << " <dir name=\"dsssd\">\n";
ofs << " <dir name=\"variables\">\n";
ofs << " <dir name=\"adc\">\n";
ofs << " <keyarray name=\"channel\" type=\"INT\" num_values=\"32\">\n";
for(int i = 0; i < NDSSSD; ++i) {
ofs << " <value index=\"" << i << "\">" << i << "</value>\n";
ofs << " <value index=\"" << i << "\">" << i << "</value>\n";
}
ofs << " </keyarray>\n";
ofs << " </keyarray>\n";

ofs << " <keyarray name=\"module\" type=\"INT\" num_values=\"32\">\n";
ofs << " <keyarray name=\"module\" type=\"INT\" num_values=\"32\">\n";
for(int i = 0; i< NDSSSD; ++i) {
ofs << " <value index=\"" << i << "\">1</value>\n";
ofs << " <value index=\"" << i << "\">1</value>\n";
}
ofs << " </keyarray>\n";
ofs << " </keyarray>\n";

ofs << " <keyarray name=\"slope\" type=\"DOUBLE\" num_values=\"32\">\n";
ofs << " <keyarray name=\"slope\" type=\"DOUBLE\" num_values=\"32\">\n";
for(int i = 0; i< NDSSSD; ++i) {
ofs << " <value index=\"" << i << "\">" << GetParams(i).slope << "</value>\n";
ofs << " <value index=\"" << i << "\">" << GetParams(i).slope << "</value>\n";
}
ofs << " </keyarray>\n";
ofs << " </keyarray>\n";

ofs << " <keyarray name=\"offset\" type=\"DOUBLE\" num_values=\"32\">\n";
for(int i = 0; i< NDSSSD; ++i) {
ofs << " <value index=\"" << i << "\">" << GetParams(i).offset << "</value>\n";
ofs << " <value index=\"" << i << "\">" << GetParams(i).offset << "</value>\n";
}
ofs << " </keyarray>\n";
ofs << " </keyarray>\n";
ofs << " </dir>\n";
ofs << " <dir name=\"tdc_front\">\n";
ofs << " <key name=\"channel\" type=\"INT\">4</key>\n";
ofs << " <key name=\"slope\" type=\"DOUBLE\">0.1</key>\n";
ofs << " <key name=\"offset\" type=\"DOUBLE\">0</key>\n";
ofs << " </dir>\n";
ofs << " <dir name=\"tdc_back\">\n";
ofs << " <key name=\"channel\" type=\"INT\">5</key>\n";
ofs << " <key name=\"slope\" type=\"DOUBLE\">0.1</key>\n";
ofs << " <key name=\"offset\" type=\"DOUBLE\">0</key>\n";
ofs << " </dir>\n";
ofs << " </dir>\n";
ofs << " </dir>\n";
ofs << " </dir>\n";
ofs << "</odb>\n";

ofs.close();

std::cout << "ATTENTION: Current odb state saved to dsssdcal.xml in ${DH}/../calibration/ !\n";
std::cout << "ATTENTION: Current odb state saved as " << outfile << "\n";
}
5 changes: 3 additions & 2 deletions src/utils/Calibration.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
#include "Dragon.hxx"

class TH1;
class TH2F;
class TH2;
class TH1D;
class TH2D;
class TTree;

namespace midas { class Database; }
Expand All @@ -28,7 +29,7 @@ public:
struct Param_t { Double_t slope; Double_t offset; Double_t inl; Double_t intercept; };
public:
Double_t fMaxSlope, fMinChan;
TH2F* fHdcal;
TH2D* fHdcal;
TH1D* fFrontcal;
public:
DsssdCalibrator(TTree* t, midas::Database* db);
Expand Down

0 comments on commit 85f3612

Please sign in to comment.