-
Notifications
You must be signed in to change notification settings - Fork 1
[WIP] Z->mm in to new all in one tool #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Z->mm in to new all in one tool #21
Conversation
|
It seems that certain options in In
|
|
Just to be clear, that's not my code.... it's An Gu (@gu180) |
|
@gu180 Are you working on it? |
|
@connorpa please introduce comments directly within the code. I think that would substantially speed up the review. |
|
I am still trying to include ome other variables in the configuration.
Best Regards.
An Gu
…________________________________
发件人: Patrick Connor ***@***.***>
发送时间: 2021年6月10日 3:04
收件人: cms-trackeralign/cmssw ***@***.***>
抄送: An Gu ***@***.***>; Mention ***@***.***>
主题: Re: [cms-trackeralign/cmssw] [WIP] Z->mm in to new all in one tool (#21)
@gu180<https://github.com/gu180> Are you working on it?
―
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#21 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AH3QTF4YHLYRCFDQK2CG5Y3TSBPXDANCNFSM44YIOD6Q>.
|
| #include <boost/filesystem.hpp> | ||
| #include <boost/property_tree/ptree.hpp> | ||
| #include <boost/property_tree/json_parser.hpp> | ||
| #include <boost/optional.hpp> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 = "./") { |
There was a problem hiding this comment.
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())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oldtool?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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())); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
connorpa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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]); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)) ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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...
|
in the last push I've taken the latest version from https://github.com/gu180/TrackderAlignment_DiMuonValidation/tree/all-in-one. |
|
Integrated in main cmssw fork via cms-sw#40346 |
Just starting to push the existing code from https://github.com/gu180/TrackderAlignment_DiMuonValidation/tree/all-in-one.
@connorpa @vbotta @antoniovagnerini