pxar
 All Classes Namespaces Functions Variables Typedefs Friends
phdacdacscan.C
1 // -- Usage:
2 // ---------
3 // ../bin/pXar -c '../scripts/phdacdacscan.C("vcal", "phdacdacscan.root", "testROC")'
4 
5 // ----------------------------------------------------------------------
6 // scan all other DACs against "dac1" and display the average pulseheight as a 2D plot
7 // the API is programmed from the macro using PixTest::setDAC which forwards this to the api
8 // (w/o dict direct api interaction is not yet possible)
9 void phdacdacscan(string dac1 = "vcal", string rootfile = "phdacdacscan.root", string cfgdirectory = "testROC") {
10 // gSystem->Load("../lib/libpxar.dylib");
11 // gSystem->Load("../lib/libpxargui.dylib");
12 // gSystem->Load("../lib/libpxartests.dylib");
13 // gSystem->Load("../lib/libpxarutil.dylib");
14 // gSystem->Load("../lib/libpxarana.dylib");
15 
16  ConfigParameters *configParameters = ConfigParameters::Singleton();
17 
18  configParameters->setDirectory(cfgdirectory);
19  string cfgFile = configParameters->getDirectory() + string("/configParameters.dat");
20  configParameters->readConfigParameterFile(cfgFile);
21 
22 
23  PixTestParameters *ptp = new PixTestParameters(configParameters->getDirectory() + "/" + configParameters->getTestParameterFileName());
24 
25  PixSetup *ap = new PixSetup("DEBUG", ptp, configParameters);
26 
27  cout << "pxar: dumping results into " << rootfile << endl;
28  TFile *rfile = TFile::Open(rootfile.c_str(), "RECREATE");
29 
30  PixTestFactory *factory = PixTestFactory::instance();
31 
32  PixTest *pt = factory->createTest("DacDacScan", ap);
33  pt->setDAC("ctrlreg", 4);
34  pt->setParameter("PHmap", "1");
35  pt->setParameter("DAC1", dac1);
36 
37  vector<string> dacs = configParameters->getDacs();
38  for (unsigned int idac = 0; idac < dacs.size(); ++idac) {
39  cout << "===> dacdacscan for vcal vs. " << dacs[idac] << endl;
40  pt->setParameter("DAC2", dacs[idac]);
41  pt->doTest();
42  }
43 
44  delete pt;
45 
46  rfile->Close();
47 
48  ap->killApi();
49 
50  // -- and now plot/save them
51  TFile *f = TFile::Open(rootfile.c_str());
52  TH2D *h2(0);
53  for (unsigned int idac = 0; idac < dacs.size(); ++idac) {
54  h2 = (TH2D*)f->Get(Form("DacDacScan/ph_vcal_%s_c11_r20_C0_V0", dacs[idac].c_str()));
55  if (0 == h2) continue;
56  h2->Draw("colz");
57  c0.SaveAs(Form("ph_vcal_%s.pdf", dacs[idac].c_str()));
58  }
59 
60 }
virtual void doTest()
function connected to "DoTest" button of PixTab
Definition: PixTest.cc:602
virtual void setDAC(std::string parName, uint8_t val)
allow setting DACs in scripts for entire DUT
Definition: PixTest.hh:239
virtual bool setParameter(std::string parName, std::string sval)
set the string value of a parameter
Definition: PixTest.cc:433