Skip to content

Commit

Permalink
add unit tests for ZMuMuMassConstraintParameterFinder
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Feb 11, 2024
1 parent 3cc467e commit 156107b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Alignment/MillePedeAlignmentAlgorithm/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
<test name="test-pede" command="pede -t">
<use name="millepede"/>
</test>
<test name="testPedeCampaign" command="test_pede.sh"/>
<test name="testPayloadSanity" command="test_payload_sanity.sh">
<test name="test_PedeCampaign" command="test_pede.sh"/>
<test name="test_PayloadSanity" command="test_payload_sanity.sh">
<flags PRE_TEST="testPedeCampaign"/>
</test>
<test name="test_ZMuMuMassConstraintParameterFinder" command="test_ZMuMuMassConstraintParameterFinder.sh"/>
<bin file="testFindMassContraintParameters.cpp" name="test_ExtractMassConstraint">
<flags PRE_TEST="test_ZMuMuMassConstraintParameterFinder"/>
<use name="rootcore"/>
</bin>
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
#include <TFile.h>
#include <TTree.h>
#include <TPad.h>
#include <TH1F.h>
#include <iostream>

bool isValidFile(const TString& fileName) {
TFile* file = TFile::Open(fileName, "read");
if (!file || file->IsZombie()) {
std::cout << "Error: Invalid file or file is a zombie.\n";
return false;
}
return true;
}

void printParameters(const TString& fileName) {
if (!isValidFile(fileName)) {
exit(EXIT_FAILURE);
}

TFile* file = TFile::Open(fileName, "read");
TTree* tree = static_cast<TTree*>(file->Get("zMuMuMassConstraintParameterFinder/di_muon_from_Z"));
tree->Draw("di_muon_mass>>htemp", "in_mass_window");
Expand All @@ -10,4 +29,6 @@ void printParameters(const TString& fileName) {
std::cout << " PrimaryMass = " << htemp->GetMean() << "\n";
std::cout << " PrimaryWidth = " << htemp->GetRMS() << "\n";
std::cout << "========================================\n";

exit(EXIT_SUCCESS);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <iostream>
#include <sstream>
#include "Alignment/MillePedeAlignmentAlgorithm/test/ZMuMuMassConstraintParameterFinder/printParameters.C"

int main(int argc, char** argv) { printParameters("output.root"); }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
function die { echo $1: status $2; exit $2; }

(cmsRun ${SCRAM_TEST_PATH}/ZMuMuMassConstraintParameterFinder/zmumudistribution_cfg.py inputFiles=/store/relval/CMSSW_14_0_0_pre2/RelValZMM_14/GEN-SIM/133X_mcRun3_2024_realistic_v5_STD_2024_PU-v1/2590000/c38cee3f-99d7-48aa-b236-86f6bbc869b3.root,/store/relval/CMSSW_14_0_0_pre2/RelValZMM_14/GEN-SIM/133X_mcRun3_2024_realistic_v5_STD_2024_PU-v1/2590000/5bf98cca-d491-4e95-98b0-d3acb6ea0807.root,/store/relval/CMSSW_14_0_0_pre2/RelValZMM_14/GEN-SIM/133X_mcRun3_2024_realistic_v5_STD_2024_PU-v1/2590000/1e362cc1-235b-4c32-bb24-178ccac4659f.root) || die 'failed running ZMuMuMassConstraintParameterFinder' $?

0 comments on commit 156107b

Please sign in to comment.