Skip to content

Commit

Permalink
Merge pull request #85 from mbluj/TauClusterVarRefactor_10_3_X
Browse files Browse the repository at this point in the history
New version of templated code based on "trait structs"
  • Loading branch information
mbluj authored Sep 3, 2018
2 parents 43fbbdd + dfecea8 commit 79da684
Show file tree
Hide file tree
Showing 477 changed files with 29,543 additions and 5,020 deletions.
5 changes: 2 additions & 3 deletions Alignment/MillePedeAlignmentAlgorithm/scripts/mps_alisetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,8 @@ def _create_mass_storage_directory(self):

# set directory on eos
self._mss_dir = self._general_options.get("massStorageDir",
"/eos/cms/store/caf/user/"
+os.environ["USER"])
self._mss_dir = os.path.join(self._mss_dir, "MPproduction",
"/eos/cms/store/group/alca_millepede/")
self._mss_dir = os.path.join(self._mss_dir, "MPproductionFiles",
self._mps_dir_name)

cmd = ["mkdir", "-p", self._mss_dir]
Expand Down
9 changes: 8 additions & 1 deletion Alignment/MillePedeAlignmentAlgorithm/scripts/mps_fire.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ def write_HTCondor_submit_file(path, script, config, lib):
action="store_true",
help=("force the submission of the Pede job in case some "+
"Mille jobs are not in the OK state"))
parser.add_argument("--force-merge-manual", dest="forceMergeManual", default=False,
action="store_true",
help=("force the submission of the Pede job in case some "+
"Mille jobs are not in the OK state. Unlike --forceMerge "+
"this option assumes the user has edited theScript.sh and "+
"alignment_merge.py to consistently pick up only the mille "+
"output files that exist"))
parser.add_argument("-p", "--forward-proxy", dest="forwardProxy", default=False,
action="store_true",
help="forward VOMS proxy to batch system")
Expand Down Expand Up @@ -278,7 +285,7 @@ def write_HTCondor_submit_file(path, script, config, lib):
if lib.JOBSTATUS[i] != 'SETUP':
print('Merge job %d status %s not submitted.' % \
(jobNumFrom1, lib.JOBSTATUS[i]))
elif not (mergeOK or args.forceMerge):
elif not (mergeOK or args.forceMerge or args.forceMergeManual):
print('Merge job',jobNumFrom1,'not submitted since Mille jobs error/unfinished (Use -m -f to force).')
else:
# some paths for clarity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,69 @@ clean_up () {
#LSF signals according to http://batch.web.cern.ch/batch/lsf-return-codes.html
trap clean_up HUP INT TERM SEGV USR2 XCPU XFSZ IO

# a helper function to repeatedly try failing copy commands
untilSuccess () {
# trying "${1} ${2} ${3} > /dev/null" until success, if ${4} is a
# positive number run {1} with -f flag,
# break after ${5} tries (with four arguments do up to 5 tries).
if [[ ${#} -lt 4 || ${#} -gt 5 ]]
then
echo ${0} needs 4 or 5 arguments
return 1
fi

TRIES=0
MAX_TRIES=5
if [[ ${#} -eq 5 ]]
then
MAX_TRIES=${5}
fi


if [[ ${4} -gt 0 ]]
then
${1} -f ${2} ${3} > /dev/null
else
${1} ${2} ${3} > /dev/null
fi
while [[ ${?} -ne 0 ]]
do # if not successfull, retry...
if [[ ${TRIES} -ge ${MAX_TRIES} ]]
then # ... but not until infinity!
if [[ ${4} -gt 0 ]]
then
echo ${0}: Give up doing \"${1} -f ${2} ${3} \> /dev/null\".
return 1
else
echo ${0}: Give up doing \"${1} ${2} ${3} \> /dev/null\".
return 1
fi
fi
TRIES=$((${TRIES}+1))
if [[ ${4} -gt 0 ]]
then
echo ${0}: WARNING, problems with \"${1} -f ${2} ${3} \> /dev/null\", try again.
sleep $((${TRIES}*5)) # for before each wait a litte longer...
${1} -f ${2} ${3} > /dev/null
else
echo ${0}: WARNING, problems with \"${1} ${2} ${3} \> /dev/null\", try again.
sleep $((${TRIES}*5)) # for before each wait a litte longer...
${1} ${2} ${3} > /dev/null
fi
done

if [[ ${4} -gt 0 ]]
then
echo successfully executed \"${1} -f ${2} ${3} \> /dev/null\"
else
echo successfully executed \"${1} ${2} ${3} \> /dev/null\"
fi
return 0
}

export X509_USER_PROXY=${RUNDIR}/.user_proxy


# The batch job directory (will vanish after job end):
BATCH_DIR=$(pwd)
echo "Running at $(date) \n on $HOST \n in directory $BATCH_DIR."
Expand Down Expand Up @@ -58,9 +119,9 @@ if [ "$MSSDIRPOOL" != "cmscafuser" ]; then
export STAGER_TRACE=
nsrm -f $MSSDIR/milleBinaryISN.dat.gz
echo "rfcp milleBinaryISN.dat.gz $MSSDIR/"
rfcp milleBinaryISN.dat.gz $MSSDIR/
rfcp treeFile*root $MSSDIR/treeFileISN.root
rfcp millePedeMonitor*root $MSSDIR/millePedeMonitorISN.root
untilSuccess rfcp milleBinaryISN.dat.gz $MSSDIR/ 0
untilSuccess rfcp treeFile*root $MSSDIR/treeFileISN.root 0
untilSuccess rfcp millePedeMonitor*root $MSSDIR/millePedeMonitorISN.root 0
else
MSSCAFDIR=`echo $MSSDIR | perl -pe 's/\/castor\/cern.ch\/cms//gi'`
# ensure the directories exists
Expand All @@ -69,7 +130,7 @@ else
mkdir -p ${MSSCAFDIR}/monitors
# copy the files
echo "xrdcp -f milleBinaryISN.dat.gz ${MSSCAFDIR}/binaries/milleBinaryISN.dat.gz > /dev/null"
xrdcp -f milleBinaryISN.dat.gz ${MSSCAFDIR}/binaries/milleBinaryISN.dat.gz > /dev/null
xrdcp -f treeFile.root ${MSSCAFDIR}/tree_files/treeFileISN.root > /dev/null
xrdcp -f millePedeMonitorISN.root ${MSSCAFDIR}/monitors/millePedeMonitorISN.root > /dev/null
untilSuccess xrdcp milleBinaryISN.dat.gz ${MSSCAFDIR}/binaries/milleBinaryISN.dat.gz 1
untilSuccess xrdcp treeFile.root ${MSSCAFDIR}/tree_files/treeFileISN.root 1
untilSuccess xrdcp millePedeMonitorISN.root ${MSSCAFDIR}/monitors/millePedeMonitorISN.root 1
fi
Original file line number Diff line number Diff line change
Expand Up @@ -57,48 +57,73 @@ trap clean_up HUP INT TERM SEGV USR2 XCPU XFSZ IO

# a helper function to repeatedly try failing copy commands
untilSuccess () {
# trying "${1} ${2} ${3} > /dev/null" until success,
# break after ${4} tries (with three arguments do up to 5 tries).
if [[ ${#} -lt 3 || ${#} -gt 4 ]]
# trying "${1} ${2} ${3} > /dev/null" until success, if ${4} is a
# positive number run {1} with -f flag,
# break after ${5} tries (with four arguments do up to 5 tries).
if [[ ${#} -lt 4 || ${#} -gt 5 ]]
then
echo ${0} needs 3 or 4 arguments
echo ${0} needs 4 or 5 arguments
return 1
fi

TRIES=0
MAX_TRIES=5
if [[ ${#} -eq 4 ]]
if [[ ${#} -eq 5 ]]
then
MAX_TRIES=${4}
MAX_TRIES=${5}
fi

${1} ${2} ${3} > /dev/null

if [[ ${4} -gt 0 ]]
then
${1} -f ${2} ${3} > /dev/null
else
${1} ${2} ${3} > /dev/null
fi
while [[ ${?} -ne 0 ]]
do # if not successfull, retry...
if [[ ${TRIES} -ge ${MAX_TRIES} ]]
then # ... but not until infinity!
echo ${0}: Give up doing \"${1} ${2} ${3} \> /dev/null\".
return 1
if [[ ${4} -gt 0 ]]
then
echo ${0}: Give up doing \"${1} -f ${2} ${3} \> /dev/null\".
return 1
else
echo ${0}: Give up doing \"${1} ${2} ${3} \> /dev/null\".
return 1
fi
fi
TRIES=$((${TRIES}+1))
echo ${0}: WARNING, problems with \"${1} ${2} ${3} \> /dev/null\", try again.
sleep $((${TRIES}*5)) # for before each wait a litte longer...
${1} ${2} ${3} > /dev/null
if [[ ${4} -gt 0 ]]
then
echo ${0}: WARNING, problems with \"${1} -f ${2} ${3} \> /dev/null\", try again.
sleep $((${TRIES}*5)) # for before each wait a litte longer...
${1} -f ${2} ${3} > /dev/null
else
echo ${0}: WARNING, problems with \"${1} ${2} ${3} \> /dev/null\", try again.
sleep $((${TRIES}*5)) # for before each wait a litte longer...
${1} ${2} ${3} > /dev/null
fi
done

echo successsfully executed \"${1} ${2} ${3} \> /dev/null\"
if [[ ${4} -gt 0 ]]
then
echo successfully executed \"${1} -f ${2} ${3} \> /dev/null\"
else
echo successfully executed \"${1} ${2} ${3} \> /dev/null\"
fi
return 0
}

copytreefile () {
CHECKFILE=`echo ${TREEFILELIST} | grep -i ${2}`
if [[ -z "${TREEFILELIST}" ]]
then
untilSuccess ${1} ${2} ${3}
untilSuccess ${1} ${2} ${3} ${4}
else
if [[ -n "${CHECKFILE}" ]]
then
untilSuccess ${1} ${2} ${3}
untilSuccess ${1} ${2} ${3} ${4}
fi
fi
}
Expand All @@ -113,13 +138,13 @@ if [ "${MSSDIRPOOL}" != "cmscafuser" ]; then
export STAGE_SVCCLASS=${MSSDIRPOOL}
export STAGER_TRACE=
echo stager_get -M ${MSSDIR}/milleBinaryISN.dat.gz >> stager_get-commands.txt
echo untilSuccess rfcp ${MSSDIR}/milleBinaryISN.dat.gz ${BATCH_DIR} >> parallel-copy-commands.txt
echo untilSuccess rfcp ${MSSDIR}/milleBinaryISN.dat.gz ${BATCH_DIR} 0 >> parallel-copy-commands.txt
echo stager_get -M ${MSSDIR}/treeFileISN.root >> stager_get-commands.txt
echo copytreefile rfcp ${MSSDIR}/treeFileISN.root ${BATCH_DIR} >> parallel-copy-commands.txt
echo copytreefile rfcp ${MSSDIR}/treeFileISN.root ${BATCH_DIR} 0 >> parallel-copy-commands.txt
else
MSSCAFDIR=`echo ${MSSDIR} | perl -pe 's/\/castor\/cern.ch\/cms//gi'`
echo untilSuccess xrdcp ${MSSCAFDIR}/binaries/milleBinaryISN.dat.gz milleBinaryISN.dat.gz >> parallel-copy-commands.txt
echo copytreefile xrdcp ${MSSCAFDIR}/tree_files/treeFileISN.root treeFileISN.root >> parallel-copy-commands.txt
echo untilSuccess xrdcp ${MSSCAFDIR}/binaries/milleBinaryISN.dat.gz milleBinaryISN.dat.gz 1 >> parallel-copy-commands.txt
echo copytreefile xrdcp ${MSSCAFDIR}/tree_files/treeFileISN.root treeFileISN.root 1 >> parallel-copy-commands.txt
fi
xargs -a stager_get-commands.txt -n 1 -P 10 -I {} bash -c '$@' _ {}
xargs -a parallel-copy-commands.txt -n 1 -P 10 -I {} bash -c '$@' _ {}
Expand Down
29 changes: 13 additions & 16 deletions CalibCalorimetry/CastorCalib/src/CastorDbASCIIIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ void dumpId (std::ostream& fOutput, DetId id) {
fOutput << buffer;
}

template <class T,class S>
bool getCastorObject (std::istream& fInput, T* fObject, S* fCondObject) {
template <class S,class T>
bool getCastorObject (std::istream& fInput, T* fObject) {
if (!fObject) fObject = new T;
char buffer [1024];
while (fInput.getline(buffer, 1024)) {
Expand All @@ -96,10 +96,8 @@ bool getCastorObject (std::istream& fInput, T* fObject, S* fCondObject) {
// edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
// else
// {
fCondObject = new S(id, atof (items [4].c_str()), atof (items [5].c_str()),
atof (items [6].c_str()), atof (items [7].c_str()));
fObject->addValues(*fCondObject);
delete fCondObject;
S fCondObject(id, atof (items [4].c_str()), atof (items [5].c_str()), atof (items [6].c_str()), atof (items [7].c_str()));
fObject->addValues(fCondObject);
// }
}

Expand Down Expand Up @@ -127,8 +125,8 @@ bool dumpCastorObject (std::ostream& fOutput, const T& fObject) {
return true;
}

template <class T,class S>
bool getCastorSingleFloatObject (std::istream& fInput, T* fObject, S* fCondObject) {
template <class S,class T>
bool getCastorSingleFloatObject (std::istream& fInput, T* fObject) {
if (!fObject) fObject = new T;
char buffer [1024];
while (fInput.getline(buffer, 1024)) {
Expand All @@ -145,10 +143,9 @@ bool getCastorSingleFloatObject (std::istream& fInput, T* fObject, S* fCondObjec
// edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
// else
// {
fCondObject = new S(id, atof (items [4].c_str()) );
fObject->addValues(*fCondObject);
delete fCondObject;
// }
S fCondObject(id, atof (items [4].c_str()) );
fObject->addValues(fCondObject);
// }
}
return true;
}
Expand All @@ -172,7 +169,7 @@ bool dumpCastorSingleFloatObject (std::ostream& fOutput, const T& fObject) {
return true;
}

template <class T,class S>
template <class S,class T>
bool getCastorSingleIntObject (std::istream& fInput, T* fObject, S* fCondObject) {
if (!fObject) fObject = new T;
char buffer [1024];
Expand Down Expand Up @@ -218,12 +215,12 @@ bool dumpCastorSingleIntObject (std::ostream& fOutput, const T& fObject) {
}


bool getObject (std::istream& fInput, CastorGains* fObject) {return getCastorObject (fInput, fObject, new CastorGain);}
bool getObject (std::istream& fInput, CastorGains* fObject) {return getCastorObject<CastorGain> (fInput, fObject);}
bool dumpObject (std::ostream& fOutput, const CastorGains& fObject) {return dumpCastorObject (fOutput, fObject);}
bool getObject (std::istream& fInput, CastorGainWidths* fObject) {return getCastorObject (fInput, fObject, new CastorGainWidth);}
bool getObject (std::istream& fInput, CastorGainWidths* fObject) {return getCastorObject<CastorGainWidth> (fInput, fObject);}
bool dumpObject (std::ostream& fOutput, const CastorGainWidths& fObject) {return dumpCastorObject (fOutput, fObject);}

bool getObject (std::istream& fInput, CastorSaturationCorrs* fObject) {return getCastorSingleFloatObject (fInput, fObject, new CastorSaturationCorr);}
bool getObject (std::istream& fInput, CastorSaturationCorrs* fObject) {return getCastorSingleFloatObject<CastorSaturationCorr> (fInput, fObject);}
bool dumpObject (std::ostream& fOutput, const CastorSaturationCorrs& fObject) {return dumpCastorSingleFloatObject (fOutput, fObject);}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,9 @@ class TEcnaHistos : public TObject {

//..... Attributes

// static const Int_t fgMaxCar = 512; <== DANGEROUS !

Int_t fgMaxCar; // Max nb of caracters for char*
Int_t fZerv; // = 0 , for ViewHisto non used arguments
Int_t fUnev; // = 1 , for ViewHisto non used arguments
constexpr static int charArrLen = 512; // Max nb of caracters for char*
Int_t fZerv; // = 0 , for ViewHisto non used arguments
Int_t fUnev; // = 1 , for ViewHisto non used arguments


Int_t fCnaCommand, fCnaError;
Expand Down
Loading

0 comments on commit 79da684

Please sign in to comment.