6 #include "PixTestFactory.hh"
7 #include "PixTestBareModule.hh"
22 LOG(logDEBUG) <<
"PixTestBareModule ctor(PixSetup &a, string, TGTab *)";
27 PixTestBareModule::PixTestBareModule() :
PixTest() {
28 LOG(logDEBUG) <<
"PixTestBareModule ctor()";
35 for (
unsigned int i = 0; i <
fParameters.size(); ++i) {
38 if (!parName.compare(
"stepmax(1-3)")) {
39 fParMaxSteps = atoi(sval.c_str());
40 LOG(logDEBUG) <<
" setting fParNSteps -> " << fParMaxSteps;
43 if (!parName.compare(
"bbmap")) {
46 fBBMap = atoi(sval.c_str());
49 if (!parName.compare(
"bb2map(desy)")) {
52 fBB2Map = atoi(sval.c_str());
55 if (!parName.compare(
"mincurrent(ma)")) {
58 fminIa = atof(sval.c_str());
69 void PixTestBareModule::init() {
70 LOG(logDEBUG) <<
"PixTestBareModule::init()";
72 fDirectory = gFile->GetDirectory(fName.c_str());
81 fTestTip = string(
"run the test sequence for one ROC up to 'stepmax'.\n")
82 + string(
"stepmax: 1=pretest, 2=alive, 3=BB.");
83 fSummaryTip = string(
"to be implemented");
84 fStopTip = string(
"stop the BareModuleTest after that \n")
85 + string(
"the current step is finished.");
90 void PixTestBareModule::bookHist(
string name) {
91 LOG(logDEBUG) <<
"nothing done with " << name;
96 PixTestBareModule::~PixTestBareModule() {
97 LOG(logDEBUG) <<
"PixTestBareModule dtor";
102 std::transform(command.begin(), command.end(), command.begin(), ::tolower);
103 LOG(logDEBUG) <<
"running command: " << command;
105 if (!command.compare(
"stop")){
107 LOG(logINFO) <<
"PixTestBareModule:: STOP PRESSED. Ending test.";
109 else if (!command.compare(
"checkcontact")) {
120 LOG(logINFO) <<
"PixTestBareModule:: HV and Power are off.";
122 else if (!command.compare(
"dofullsequence")) {
127 LOG(logINFO) <<
"Command " << command <<
" not implemented.";
131 bool PixTestBareModule::checkIfInContact(
bool fullSeq) {
134 LOG(logINFO) <<
"PixTestBareModule:: HV off for safety.";
138 LOG(logINFO) <<
"PixTestBareModule:: checking if probes are in contact.";
140 LOG(logINFO) <<
"PixTestBareModule:: Power on.";
143 bool checkgood =
false;
146 LOG(logINFO) <<
"PixTestBareModule:: contact OK, ia = " << ia <<
" mA";
150 LOG(logWARNING) <<
"PixTestBareModule:: ia < " << fminIa <<
" mA - PLEASE CHECK THE PROBES CONTACT.";
152 LOG(logWARNING) <<
"PixTestBareModule:: enter 'c' to continue OR 's' to stop.";
156 std::getline(cin, input);
157 string::size_type m1 = input.find(
" ");
158 if (m1 != string::npos) {
159 string parameters = input.substr(m1);
160 input = input.substr(0, m1);
162 std::transform(input.begin(), input.end(), input.begin(), ::tolower);
164 if (!input.compare(
"c") || !input.compare(
"C")) {
165 LOG(logINFO) <<
"PixTestBareModule:: test will continue.";
169 else if (!input.compare(
"s") || !input.compare(
"S")) {
170 LOG(logINFO) <<
"PixTestBareModule:: bare module test will be stopped.";
175 LOG(logINFO) <<
"PixTestBareModule:: unvalid input. Please retry.";
180 else checkgood =
false;
185 LOG(logINFO) <<
"PixTestBareModule:: HV on.";
188 LOG(logINFO) <<
"PixTestBareModule:: checkIfInContact done.";
198 bool PixTestBareModule::doStdTest(std::string test) {
202 t = factory->createTest(test,
fPixSetup);
207 string firstname, name;
209 TH1* h = t->nextHist();
210 if (firstname ==
"") firstname = h->GetName();
211 else name = h->GetName();
212 if (firstname == name) newHist =
false;
216 h->Draw(t->getHistOption(h).c_str());
223 bool problem = !(t->testProblem());
225 cout << problem << endl;
230 bool PixTestBareModule::doRocTests(
int MaxStep) {
232 vector<string> suite;
233 suite.push_back(
"pretest");
234 suite.push_back(
"alive");
235 suite.push_back(
"bb");
236 suite.push_back(
"bb2");
239 if (MaxStep >= 1 && !fStop) {
240 if (!doStdTest(suite[0])) {
241 LOG(logWARNING) <<
"PixTestBareModule:: Pretest failed. Sequence stopped.";
249 if (MaxStep >= 2 && !fStop) {
250 if (!doStdTest(suite[1])) {
251 LOG(logWARNING) <<
"PixTestBareModule:: Alive failed. Sequence stopped.";
259 if (MaxStep >= 3 && !fStop) {
260 cout << fBBMap << fBB2Map << endl;
261 if (fBBMap && !fBB2Map) {
262 if (!doStdTest(suite[2])) {
263 LOG(logWARNING) <<
"PixTestBareModule:: BBMap failed. Sequence stopped.";
267 else if (fBB2Map && !fBBMap) {
268 if (!doStdTest(suite[3])) {
269 LOG(logWARNING) <<
"PixTestBareModule:: BB2Map failed. Sequence stopped.";
274 LOG(logWARNING) <<
"PixTestBareModule:: Please select the BB test mode.";
275 LOG(logINFO) <<
"PixTestBareModule:: Test stopped.";
287 LOG(logINFO) <<
"PixTestBareModule:: *******************************";
288 LOG(logINFO) <<
"PixTestBareModule::doTest() start with " << fParMaxSteps <<
" test steps.";
291 bool sequenceEnded =
false;
294 if (checkIfInContact(1)) {
296 sequenceEnded = doRocTests(fParMaxSteps);
306 LOG(logINFO) <<
"PixTestBareModule:: HV and Power are off.";
307 if(sequenceEnded) LOG(logINFO) <<
"PixTestBareModule:: Tests finished, now you can separate.";
309 LOG(logINFO) <<
"PixTestBareModule::doTest() done for.";
static void replaceAll(std::string &str, const std::string &from, const std::string &to)
in str, replace all occurences of from to to
virtual void doTest()
function connected to "DoTest" button of PixTab
std::map< TH1 *, std::string > fHistOptions
options can be stored with each histogram
std::string fStopTip
information for this test
void powerOff()
turn DTB power off
PixSetup * fPixSetup
all necessary stuff in one place
std::vector< std::pair< std::string, std::string > > fParameters
the parameters of this test
TDirectory * fDirectory
where the root histograms will end up
void setToolTips()
implement this to provide updated tool tips if the user changes test parameters
void runCommand(std::string)
allow execution of any button in the test
std::list< TH1 * >::iterator fDisplayedHist
pointer to the histogram currently displayed
std::list< TH1 * > fHistList
list of histograms available in PixTab::next and PixTab::previous
virtual bool setParameter(std::string parName, std::string sval)
set the string value of a parameter
void update()
signal to PixTab to update the canvas
void doTest()
function connected to "DoTest" button of PixTab
void powerOn()
turn DTB power on
pxar::pxarCore * fApi
pointer to the API
void init()
sets all test parameters