-
Notifications
You must be signed in to change notification settings - Fork 26
Iss2035 add LUT method tracking to TSTrackProducer #2070
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
base: trunk
Are you sure you want to change the base?
Changes from all commits
fc6aadd
4f156aa
f17ac9e
f567ba8
9fa0fda
e5b95d0
f61d652
fe9106a
823b30f
34378da
40ecb21
9c4667f
9bd018f
84d4ad9
8981aeb
6a739f9
f08c3cd
34a5045
7e96e39
f3b5745
c277559
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #example config which makes digis, clusters, and writes clusters | ||
| #to .txt file using ClusterTripletMaker | ||
|
|
||
| from LDMX.Framework import ldmxcfg | ||
|
|
||
| p = ldmxcfg.Process('nontruthclusters') | ||
| p.input_files = ["SimSamples.root"] | ||
| p.output_files = ["Clusters.root"] | ||
| #an additional output file called clusters.txt will be created as well | ||
|
|
||
| from LDMX.TrigScint.trig_scint import TrigScintDigiProducer | ||
|
|
||
| pad_num = 1 | ||
|
|
||
| digis = [TrigScintDigiProducer.pad1(), | ||
| TrigScintDigiProducer.pad2(), | ||
| TrigScintDigiProducer.pad3() | ||
| ] | ||
|
|
||
| for digi in digis: | ||
| digi.input_collection = f"TriggerPad{pad_num}SimHits" | ||
| pad_num+=1 | ||
|
|
||
| from LDMX.TrigScint.trig_scint import TrigScintClusterProducer | ||
|
|
||
| clusters = [ | ||
| TrigScintClusterProducer.pad1(), | ||
| TrigScintClusterProducer.pad2(), | ||
| TrigScintClusterProducer.pad3(), | ||
| ] | ||
|
|
||
| for cluster, digi in zip(clusters, digis): | ||
| cluster.input_collection = digi.output_collection | ||
| cluster.ampl_weighting = False | ||
| cluster.clustering_threshold = 3.0 | ||
|
|
||
| from LDMX.TrigScint.trig_scint import ClusterTripletMaker | ||
|
|
||
| triplets = ClusterTripletMaker("tripletmaker") | ||
| triplets.output_collection = "clusters.txt" | ||
|
|
||
| p.sequence = [ | ||
| #*truth_hits, | ||
| *digis, | ||
| *clusters, | ||
| triplets | ||
| ] | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #config file to make LUT for tracking using PatternLUTMaker | ||
|
|
||
| from LDMX.Framework import ldmxcfg | ||
|
|
||
| p = ldmxcfg.Process("LUTmaker") | ||
| p.input_files = ["Clusters.root"] #necessary to define but unused, the real input file is defined below | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see what @cjbarton151 means here: you're not really using |
||
|
|
||
| from LDMX.TrigScint.trig_scint import PatternLUTMaker | ||
|
|
||
| make_lut = PatternLUTMaker("LUTmaker") | ||
| make_lut.lut_threshold = 1.0/1000 #or whichever threshold you like | ||
| make_lut.input_collection = "clusters.txt" #here! input list of cluster triplets as produced by ClusterTripletMaker | ||
| make_lut.output_collection = "LUT.txt" | ||
|
|
||
| p.sequence = [make_lut] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #Performs tracking with TrigScintTrackProducer, with and without LUT method for comparison | ||
| from LDMX.Framework import ldmxcfg | ||
|
|
||
| p = ldmxcfg.Process('tracking') | ||
| p.input_files = ["Clusters.root"] | ||
| p.output_files = ["Tracks.root"] | ||
|
|
||
| from LDMX.TrigScint.trig_scint import TrigScintTrackProducer | ||
|
|
||
| tstp_tracks = TrigScintTrackProducer("tstp") | ||
| lut_tracks = TrigScintTrackProducer("lut") | ||
|
|
||
| tstp_tracks.delta_max = 1.0 | ||
| tstp_tracks.verbosity = 1 | ||
| tstp_tracks.output_collection = "tstpTracks" | ||
|
|
||
| lut_tracks.delta_max = 1.0 | ||
| lut_tracks.verbosity = 1 | ||
| lut_tracks.lut_tracking = True | ||
| lut_tracks.lut_file = "LUT.txt" | ||
| lut_tracks.output_collection = "lutTracks" | ||
|
Comment on lines
+17
to
+21
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do these settings differ from the default ones specified in |
||
|
|
||
| p.logger.term_level = 1 | ||
|
|
||
| p.sequence = [tstp_tracks, | ||
| lut_tracks | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /** | ||
| * @file ClusterTripletMaker.h | ||
| * @brief Writes cluster combinations to text file | ||
| * @author Lucia Kvarnstrom, Lund University | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: ö ;) |
||
| */ | ||
|
|
||
| #ifndef TRIGSCINT_CLUSTERTRIPLETMAKER_H | ||
| #define TRIGSCINT_CLUSTERTRIPLETMAKER_H | ||
|
|
||
| // LDMX Framework | ||
| #include "Framework/Configure/Parameters.h" | ||
| #include "Framework/Event.h" | ||
| #include "Framework/EventProcessor.h" | ||
|
|
||
| // TrigScint | ||
| #include <fstream> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "TrigScint/Event/TrigScintCluster.h" | ||
|
|
||
| namespace trigscint { | ||
|
|
||
| /** | ||
| * @class ClusterTripletMaker | ||
| * @brief Write trigger scintillator cluster triplets to a text file | ||
| */ | ||
|
|
||
| class ClusterTripletMaker : public framework::Analyzer { | ||
| public: | ||
| ClusterTripletMaker(const std::string& name, framework::Process& process); | ||
|
|
||
| virtual ~ClusterTripletMaker() = default; | ||
|
|
||
| void configure(framework::config::Parameters& ps) override; | ||
|
|
||
| void analyze(const framework::Event& event) override; | ||
|
|
||
| void onProcessStart() override; | ||
|
|
||
| void onProcessEnd() override; | ||
|
|
||
| private: | ||
| // verbosity | ||
| int verbose_{0}; | ||
|
|
||
| // specific pass name | ||
| std::string pass_name_{""}; | ||
|
|
||
| // input cluster collections | ||
| std::vector<std::string> cluster_input_collections_; | ||
|
|
||
| // output text file | ||
| std::string output_collection_{"clusters.txt"}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you name it something else than |
||
|
|
||
| // output stream | ||
| std::ofstream output_stream_; | ||
| }; | ||
|
|
||
| } // namespace trigscint | ||
|
|
||
| #endif // TRIGSCINT_CLUSTERTRIPLETMAKER_H | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /** | ||
| * @file PatternLUTMaker.h | ||
| * @brief Writes LUT based on frequency of track propagation patterns for | ||
| * LUT-based TS tracking. | ||
| * @author Lucia Kvarnstrom, Lund University | ||
| */ | ||
|
|
||
| #ifndef TRIGSCINT_PATTERNLUTMAKER_H | ||
| #define TRIGSCINT_PATTERNLUTMAKER_H | ||
| #include <fstream> | ||
| #include <map> | ||
| #include <string> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| #include "Framework/Configure/Parameters.h" | ||
| #include "Framework/EventProcessor.h" | ||
|
|
||
| namespace trigscint { | ||
|
|
||
| class PatternLUTMaker : public framework::Analyzer { | ||
| public: | ||
| struct Line { | ||
| int event_; | ||
| float p1_, p2_, p3_; | ||
| }; | ||
|
|
||
| PatternLUTMaker(const std::string& name, framework::Process& process); | ||
|
|
||
| virtual ~PatternLUTMaker() = default; | ||
|
|
||
| void configure(framework::config::Parameters& parameters) override; | ||
|
|
||
| void analyze(const framework::Event& event) override; | ||
|
|
||
| void onProcessStart() override; | ||
|
|
||
| void onProcessEnd() override; | ||
|
|
||
| private: | ||
| // verbosity | ||
| int verbose_{0}; | ||
|
|
||
| // input text file of clusters | ||
| std::string input_collection_; | ||
|
|
||
| // output LUT file name | ||
| std::string output_collection_; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment, rename from collection if possible |
||
|
|
||
| // minimum frequency of a specific pattern to be written to the LUT | ||
| double lut_threshold_{0.0008}; | ||
|
|
||
| std::ifstream infile_; | ||
| std::ofstream outfile_; | ||
|
|
||
| // to group cluster combinations by track pattern | ||
| std::map<std::pair<float, float>, std::vector<Line>> groups_; | ||
|
|
||
| int total_lines_{0}; | ||
| }; | ||
|
|
||
| } // namespace trigscint | ||
|
|
||
| #endif /* TRIGSCINT_PATTERNLUTMAKER_H */ | ||
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.
if you want these commented here as an indication that including them is optional, i suggest either
truth_hitsand use them as input collection to the later processors (at least digi))