Skip to content

Conversation

@mmusich
Copy link

@mmusich mmusich commented May 12, 2021

@connorpa
Copy link

It seems that certain options in testZmumu.yaml are not used in Zmumu_cfg.py, e.g. maxevents or usefit. Make sure that the given options are used or remove them from the example.

In Zmumumerge.cc, in the Zmumumerge function:

  • I am not sure to understand why you clear newly created vectors.
  • A ptree validation is declared but not used: don't you need it to extract certain information from the yaml file? Like the minimum or the legendoptions? We should be consistent.
  • I am not sure to understand why you extract information from the ptree alignments to fill several vectors, and then use the vectors instead of the ptree in a later loop. You could shorten your code by using directly the information from the ptree in the loop where you call the Fitting... and Draw... functions.

@mmusich
Copy link
Author

mmusich commented May 26, 2021

Just to be clear, that's not my code.... it's An Gu (@gu180)

@connorpa
Copy link

@gu180 Are you working on it?

@mmusich
Copy link
Author

mmusich commented Jun 10, 2021

@connorpa please introduce comments directly within the code. I think that would substantially speed up the review.

@gu180
Copy link

gu180 commented Jun 10, 2021 via email

@mmusich
Copy link
Author

mmusich commented Jun 10, 2021

@gu180 please start from the version of this branch, I substantially streamlined the configuration part in c13317c

#include <boost/filesystem.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/optional.hpp>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anywhere where you are using boost::optional: why do you load the header?

This comment may apply to RooFit headers are well -- please check.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have deleted it.

in the last push I've taken the latest version from https://github.com/gu180/TrackderAlignment_DiMuonValidation/tree/all-in-one.
I am not sure all the comments have been addressed.
Unfortunately since apparently @gu180 is using dos formatting while everybody else is using unix, the comparison gets spoiled as the entire file looks changed.

I have renewed the DiMuonValidation.cc file. Is there still dos and unix problem?

FitOut(double a, double b, double c, double d) : mean(a), mean_err(b), sigma(c), sigma_err(d) {}
};

FitOut ZMassBinFit_OldTool(TH1D* th1d_input, TString s_name = "zmumu_fitting", TString output_path = "./") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why OldToot? This naming convention is unclear.

Also, it could be of advantage to write comments à la doxygen to explain what each function is doing.

fitter->fit(th1d_input, "breitWignerTimesCB", "exponential", xMin, xMax, false);

c1->Print(Form("%s/fitResultPlot/%s_oldtool.pdf", output_path.Data(), s_name.Data()));
c1->Print(Form("%s/fitResultPlot/%s_oldtool.root", output_path.Data(), s_name.Data()));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oldtool?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fitting of mumu invariant mass spectrum is from the old Zmumu tool.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe but this is not a proper naming convention. If the function is being actively used, then just remove _oldtool. If the function is no longer used, remove it from the code.

}

gSystem->Exec(Form("mkdir -p %s", output_path.Data()));
gSystem->Exec(Form("mkdir -p %s/fitResultPlot", output_path.Data()));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to use the filesystem library to create directories and handle files in general. You are actually loading the header of boost::filesystem. Here it would be sth like:

using fs = boost::filesystem; // after the headers
// ...
fs::path p = output_path.Data();
p /= "fitResultPlot";
fs::create_directories(p);
assert(fs::exists(p));

vector<TString> vec_global_tag;
vec_single_file_path.clear();
vec_single_file_name.clear();
vec_global_tag.clear();
Copy link

@connorpa connorpa Jun 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using clear right after declaring the vectors? Is there a particular reason?

Naïvely, I'd say that these lines aren't necessary, but I might be missing sth.

But maybe you don't need these vectors at all -- see comments below.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have deleted these codes.

pt::read_json(options.config, main_tree);
pt::ptree alignments = main_tree.get_child("alignments");
pt::ptree validation = main_tree.get_child("validation");
for (const std::pair<std::string, pt::ptree>& childTree : alignments) {
Copy link

@connorpa connorpa Jun 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just use auto here.

Also childTree is not a really good name. Why not calling it alignment?

pt::ptree validation = main_tree.get_child("validation");
for (const std::pair<std::string, pt::ptree>& childTree : alignments) {
vec_single_file_path.push_back(childTree.second.get<std::string>("file"));
vec_single_file_name.push_back(childTree.second.get<std::string>("file") + "/Zmumu.root");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure to understand why you declare vectors in which you simply copy the information of the ptrees. Why not using directly the content of the ptrees? Then you would have one loop less, and you would be able to pass additional options if this is requested from the JSON config file.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function Draw_TH1D_forMultiRootFiles() need vectors as input.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly: please change this function too, so that you don't have to convert a ptree to a vector.

#ifndef DOXYGEN_SHOULD_SKIP_THIS
int main(int argc, char* argv[]) {
return Zmumumerge(argc, argv);
//return Zmumumerge(argc, argv);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//return Zmumumerge(argc, argv);
This is deleted.

using namespace AllInOneConfig;
namespace pt = boost::property_tree;
static const int colors_array[] = {4, 8, 2, 3, 4, 7, 30, 6, 9, 46, 36, 8, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The colours (and the style options in general) should be retrieved from the JSON file. You don't need such an array here.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been solved, now the color and markerstyle is retrieved from the JSON file.
https://github.com/gu180/TrackderAlignment_DiMuonValidation/tree/all-in-one

Copy link

@connorpa connorpa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gu180 I have reviewed a few things in the code directly, as suggested by @musich

Please take a look, thanks.

th1d_input[0]->SetTitle("");
for (int idx_file = 0; idx_file < file_number; idx_file++) {
th1d_input[idx_file]->SetMarkerColor(colors_array[idx_file]);
th1d_input[idx_file]->SetLineColor(colors_array[idx_file]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As said above: don't use a fixed scheme for the colours. Use the options in the JSON file.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have modified the code so that the color and markerstyle can be setted in the JSON file.
https://github.com/gu180/TrackderAlignment_DiMuonValidation/tree/all-in-one

###################################################################
# The Di Muon Mass Validation module
###################################################################
process.DiMuonMassValidation = cms.EDAnalyzer('DiMuonValidation',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, here, it would be worthwhile to give the possibility to the lambda user to override all the following options from the config file. The arguments shouldn't be mandatory, so if the value exists, use it, otherwise use the default value.

Copy link

@gu180 gu180 Jun 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not quite understand this comment. Do you mean change those values to something like this:
cms.untracked.int32(config["validation"].get("maxevents", 2000000)) ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the idea: don't hardcode the value, but give the possibility to the aligner to overwrite these values from the config file (while keeping a default value if he does not want to overwrite it). Take a look at the implementation of other validations.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are physical geometrical boundaries. Was the Z->mm validation ever run with partial coverage of the phase-space ?
In my opinion only the number of bins could make sense to be configurable. Too much freedom to the users quickly leads to nonsense.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the past we did it.

Anyway, the smart aligner will know where to change the value if necessary. I agree that it is an exotic case, so ok if you prefer fixing it once for all.

However, the number of bins is certainly sth needed indeed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the past we did it.

I think what was done in the past was to limit the acceptance of the single muon track to disentangle barrel from endcaps, not to plot the mass bias only up to some η or φ value. The two things are different.
By the way, the current code doesn't provide for the former functionality.

Zmumu:
merge:
Legacy:
methods:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this option used in your code? I haven't found it.

Check this for all options: it would make no sense to give options that aren't used...

@mmusich
Copy link
Author

mmusich commented Jun 16, 2021

in the last push I've taken the latest version from https://github.com/gu180/TrackderAlignment_DiMuonValidation/tree/all-in-one.
I am not sure all the comments have been addressed.
Unfortunately since apparently @gu180 is using dos formatting while everybody else is using unix, the comparison gets spoiled as the entire file looks changed.

@mmusich
Copy link
Author

mmusich commented Jul 15, 2021

@gu180 @connorpa have all the comments been addressed? when can we merge this?

@connorpa
Copy link

@gu180 @connorpa have all the comments been addressed? when can we merge this?

IMHO things could still be improved, but I don't think that the comments are critical. If time is running out, we can proceed with the code as it is.

@mmusich
Copy link
Author

mmusich commented Jan 9, 2023

Integrated in main cmssw fork via cms-sw#40346

@mmusich mmusich closed this Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants