// // DetPlaneDef.cpp // #include "DetPlaneDef.h" #include "ParseOption.h" #include "DaqSetup.h" #include "LogFile.h" extern "C" { #include #include #include } // ================================================ // // ================================================ int DetPlaneDef::readFromFile (char* detName, DetPlane *plane) { char key[50], arg[100], stringVal[20]; int intVal; double doubleVal; // ------------------------ // open file name // ------------------------ DaqSetup* daq = daq->Instance (); DaqEnv* daqEnv = daq->daqEnv (); ifstream inFile; if ( daqEnv->openFileDirIn (DetDir, detName, inFile) == 0 ) return 0; ParseOption opt (inFile); while ( opt.nextKey (key, arg) ) { // -------- nChannels -------------------- if ( strcmp (key, "chips:") == 0 ) { if ( sscanf (arg, "%d", &intVal ) ) { plane->set_nChan (intVal * 128); // plane->set_counterValue (54); } else { plane->set_nChan (0); plane->set_counterValue (0); } } else if ( strcmp (key, "counterVal:") == 0 ) { if ( sscanf (arg, "%d", &intVal ) ) { plane->set_counterValue (intVal); } } // -------- link ------------------------- //else if ( strcmp (key, "link:") == 0 ) { // if ( sscanf (arg, "%d", &intVal ) ) { // plane->set_link (intVal); // } //} // -------- calib ------------------------ else if ( strcmp (key, "calDelay:") == 0 ) { if ( sscanf (arg, "%d", &intVal ) ) { plane->set_strobeDelay (intVal); } } // -------- hittype ---------------------- else if ( strcmp (key, "hit_type:") == 0 ) { if ( sscanf (arg, "%d", &intVal ) ) { plane->set_hitType (intVal); } } // -------- loops ---------------------- else if ( strcmp (key, "loops:") == 0 ) { if ( sscanf (arg, "%d", &intVal ) ) { plane->set_nLoops (intVal); } } // -------- dac's ------------------------ else if ( strcmp (key, "v_thres:") == 0 ) { doubleVal = atof (arg); plane->setV_thres (doubleVal); } else if ( strcmp (key, "v_ref:") == 0 ) { doubleVal = atof (arg); plane->setV_ref (doubleVal); } else if ( strcmp (key, "v_att:") == 0 ) { doubleVal = atof (arg); plane->setV_att (doubleVal); } else if ( strcmp (key, "v_cal:") == 0 ) { doubleVal = atof (arg); plane->setV_cal (doubleVal); } // -------- ctrlBlocks ------------------- else if ( strcmp (key, "CB_reset:") == 0 ) { } else if ( strcmp (key, "CB_noise:") == 0 ) { } else if ( strcmp (key, "CB_cal:") == 0 ) { int calLine[4]; int stat; stat = sscanf (arg, "%s %d %d %d %d", stringVal, &calLine[0], &calLine[1],&calLine[2],&calLine[3]); for ( int i = 0; i < stat - 1; i++ ) plane->calib.add_cal_line (stringVal, calLine[i]); } } // --------------------------------------------- // print default values to file // --------------------------------------------- logFile << " ======= default value for detPlane ======== " << endl << endl; logFile << " nChan " << plane->nChan () << endl; logFile << " link " << plane->link () << endl; logFile << " counterValue " << plane->counterValue () << endl; logFile << " hitType " << plane->hitType () << endl; logFile << " loops " << plane->nLoops () << endl; logFile << " strobe " << plane->strobeDelay () << endl; logFile << " V_thres " << plane->getV_thres () << endl; logFile << " V_ref " << plane->getV_ref () << endl; logFile << " V_att " << plane->getV_att () << endl; logFile << " V_cal " << plane->getV_cal () << endl; plane->calib.print (); // -------------------------------------------- // // -------------------------------------------- return 1; }