+ return returnCode;
+}
+
+// Parameter/cut handling
+//_____________________________________________________________________
+void AliCaloCalibSignal::SetParametersFromFile(const char *parameterFile)
+{ // set parameters from file
+ static const string delimitor("::");
+
+ // open, check input file
+ ifstream in( parameterFile );
+ if( !in ) {
+ printf("in AliCaloCalibSignal::SetParametersFromFile - Using default/run_time parameters.\n");
+ return;
+ }
+
+ // Note: this method is a bit more complicated than it really has to be
+ // - allowing for multiple entries per line, arbitrary order of the
+ // different variables etc. But I wanted to try and do this in as
+ // correct a C++ way as I could (as an exercise).
+
+ // read in
+ char readline[1024];
+ while ((in.rdstate() & ios::failbit) == 0 ) {
+
+ // Read into the raw char array and then construct a string
+ // to do the searching
+ in.getline(readline, 1024);
+ istringstream s(readline);
+
+ while ( ( s.rdstate() & ios::failbit ) == 0 ) {
+
+ string keyValue;
+ s >> keyValue;
+
+ // check stream status
+ if( ( s.rdstate() & ios::failbit ) == ios::failbit ) break;
+
+ // skip rest of line if comments found
+ if( keyValue.substr( 0, 2 ) == "//" ) break;
+
+ // look for "::" in keyValue pair
+ size_t position = keyValue.find( delimitor );
+ if( position == string::npos ) {
+ printf("wrong format for key::value pair: %s\n", keyValue.c_str());
+ }
+
+ // split keyValue pair
+ string key( keyValue.substr( 0, position ) );
+ string value( keyValue.substr( position+delimitor.size(),
+ keyValue.size()-delimitor.size() ) );
+
+ // check value does not contain a new delimitor
+ if( value.find( delimitor ) != string::npos ) {
+ printf("wrong format for key::value pair: %s\n", keyValue.c_str());
+ }
+
+ // debug: check key value pair
+ // printf("AliCaloCalibSignal::SetParametersFromFile - key %s value %s\n", key.c_str(), value.c_str());
+
+ // if the key matches with something we expect, we assign the new value
+ if ( (key == "fAmpCut") || (key == "fReqFractionAboveAmpCutVal") ||
+ (key == "fAmpCutLEDRef") || (key == "fSecInAverage") ||
+ (key == "fDownscale") ) {
+ istringstream iss(value);
+ printf("AliCaloCalibSignal::SetParametersFromFile - key %s value %s\n", key.c_str(), value.c_str());
+
+ if (key == "fAmpCut") {
+ iss >> fAmpCut;
+ }
+ else if (key == "fReqFractionAboveAmpCutVal") {
+ iss >> fReqFractionAboveAmpCutVal;
+ }
+ else if (key == "fAmpCutLEDRef") {
+ iss >> fAmpCutLEDRef;
+ }
+ else if (key == "fSecInAverage") {
+ iss >> fSecInAverage;
+ }
+ else if (key == "fDownscale") {
+ iss >> fDownscale;
+ }
+ } // some match found/expected
+
+ }