ClusterSearcher and RecoCluster#365
Conversation
…ClusterFinder's corresponding functions --Added some extra features, such as hit LAPPD count and strip-by-strip LAPPD hits. -Added ClusterSearcher to replace ClusterFinder using RecoDigit and RecoCluster classes -Updated RecoDigit and RecoCluster classes for corresponding use and new features, such as various cluster parameters -Added NeutronCheck tool as output for RecoCluster information -Added sample toolchain configfolder for using the new tools
| } | ||
|
|
||
|
|
||
| /*while (!file_singlepe.eof()) { |
There was a problem hiding this comment.
Please delete the old commented out code. It unnecessarily clutters the file.
| //} | ||
| } | ||
| } | ||
| //FIXME: Need a method to have the 123 be equal to the number of operating detectors |
DataModel/RecoCluster.cpp
Outdated
| double max_angle = 0; | ||
| double angle; | ||
| Position i_position, j_position; | ||
| for (int i = 0; i < fDigitList.size(); i++) { |
There was a problem hiding this comment.
There are many separate loops of the same size with the same index going on. Could we combine them? If this is a DataModel function, it could be used across multiple Tools so it would be best to improve efficiency within reason.
| LappdNumStrips 60 ## num channels to construct from each LAPPD | ||
| LappdStripLength 100 ## relative x position of each LAPPD strip, for dual-sided readout [mm] | ||
| LappdStripSeparation 10 ## stripline separation, for calculating relative y position of each LAPPD strip [mm] | ||
| PMTMask configfiles/BeamClusterAnalysisMC/DeadPMTIDs_p2v7.txt ## Which PMTs should be masked out? / are dead? |
There was a problem hiding this comment.
You can point to the most up to date path configfiles/LoadWCSim/DeadPMTIDs_p2v7.txt
| if (!fisMC){ | ||
| int pmtid = recoDigit->GetDetectorID(); | ||
| unsigned long chankey = pmt_tubeid_to_channelkey[pmtid]; | ||
| if (pmt_gains[chankey]>0) qep/=pmt_gains[chankey]; |
There was a problem hiding this comment.
In line 77 (m_variables.Get("SinglePEGains",singlePEgains);) you grab the SPE gains from the gains file then use it to convert from nQ --> pe for data. It doesn't look like you ever specify the gains file in the Config file. Could you add it to ClusterSearcherConfig? Alternatively you can grab that directly from the Store since the LoadGeometry tool populates it for downstream tools (like this one) to use. See PhaseIITreeMaker for an example.
There was a problem hiding this comment.
The current configuration in the provided toolchain is for use on MC simulations, which do not require the conversion. So this variable is not necessary within the configuration. I will add it to the readme file.
Though as I start looking at Data in the next couple of weeks, I'll likely move into taking the gains from the store in the next update to this tool. Thank you for the suggestion.
| if(fMCParticles->at(i).GetPdgCode()==2112 && fMCParticles->at(i).GetParentPdg()==0) { | ||
| fTrueNeutronMult++; | ||
|
|
||
| if(fMCParticles->at(i).GetStopTime()>10000) fTrueNeutronDelayed++; |
There was a problem hiding this comment.
It might be wise to make this a configurable variable in case someone needs to look for neutrons in a different region of interest. Especially considering 10us is used extensively throughout the code.
| //true_Emu*=1000; //GeV->MeV to match other energies(unneeded, possibly) | ||
|
|
||
| double theta = truevtx->GetDirection().GetTheta(); | ||
| double p = sqrt(pow(true_Emu,2)-pow(105.7,2)); |
There was a problem hiding this comment.
@jminock is there a way to grab the momentum and Q^2 from the Store? I thought the LoadGenieEvent tool will store those values for use.
There was a problem hiding this comment.
There absolutely is via: m_data->Stores["GenieInfo"]->Get("EventQ2",TrueQ2). Magnitude of muon momentum is not saved to the Store so this is the intended method to get the true muon momentum
jminock
left a comment
There was a problem hiding this comment.
Please make the changes listed. I worry with the large number of pointers if memory is being handled properly. I don't know how necessary all of the pointers are, and I am not enough of an expert on it to make a certain statement. I recommend double checking all are fitting general best practice before this gets sent off to Level 0 review
DataModel/RecoCluster.cpp
Outdated
| double maxCharge=0; | ||
| int tempPDG = -5; | ||
| for (RecoDigit* i_digit : fDigitList) { | ||
| cout<<"Digit parent list size: "<<i_digit->GetParents().size()<<endl; |
There was a problem hiding this comment.
Please add verbosity conditions to the cout's throughout this file and others. Preferably Log functions if you would like Marcus to give approval down the road
|
|
||
| // Default Clustering parameters | ||
| fConfig = ClusterSearcher::kPulseHeightAndClusters; | ||
| fPmtMinPulseHeight = 5.0; // minimum pulse height (PEs) //Ioana... initial 1.0 |
There was a problem hiding this comment.
The configuration file should take care of the initialization. Leave the default parameters in the configuration file. If any of these NEED to be initialized outside of the configuration file, please do so in the header file upon declaration. It cuts down on clutter
| double temp_gain; | ||
| while (!file_singlepe.eof()){ | ||
| file_singlepe >> temp_chankey >> temp_gain; | ||
| if (file_singlepe.eof()) break; |
There was a problem hiding this comment.
This line seems unnecessary. While loop already includes this condition
There was a problem hiding this comment.
i think it would also prevent the emplace call for the last line of the file.
|
|
||
| carryon = 1; | ||
| while( carryon ){ | ||
| carryon = 0; |
There was a problem hiding this comment.
Why is this for loop inside of a while loop?
There was a problem hiding this comment.
Seemingly because only one of the two loops had a well-defined range over which to run. This code was inherited from the HitCleaner tool, so I can't answer the why of that decision with complete certainty, but the code flows to my reading, and works as needed.
This seems like a pet peeve, more than a problem, so for the time being, I'll stand by it as is.
|
|
||
| /////////////////// Usefull header /////////////////////// | ||
| if(verbosity) cout<<"Initializing Tool DigitBuilder"<<endl; | ||
| cout<<"Initializing Tool DigitBuilder"<<endl; |
There was a problem hiding this comment.
I think this has been mentioned before. Please include verbosity conditions, preferably as Log functions
DataModel/RecoCluster.cpp
Outdated
| double sumY=0; | ||
| Position pos; | ||
| //std::vector<RecoDigits> hullDigits; | ||
| std::sort(fDigitList.begin(), fDigitList.end()); |
There was a problem hiding this comment.
is sorting a vector of pointers with the default comparator going to do what you expect? I see you have a operator< for RecoDigit, but think you still need to provide a comparitor lambda to perform the pointer de-reference:
std::sort(fDigitList.begin(), fDigitList.end(), [](const RecoDigit* a, const RecoDigit* b){ return a < b; });
There was a problem hiding this comment.
I'm... just going to remove the RecoCluster::ConvexHull function, at least for now. It's not actually useful right now.
| } | ||
|
|
||
| if( !fgClusterSearcher ){ | ||
| assert(fgClusterSearcher); |
There was a problem hiding this comment.
this seems redundant. If the previous allocation didn't succeed it would have thrown bad_alloc.
| } | ||
|
|
||
| if( fgClusterSearcher ){ | ||
|
|
| } | ||
|
|
||
| if (!fisMC){ | ||
| ifstream file_singlepe(singlePEgains.c_str()); |
There was a problem hiding this comment.
recommend adding a check file_singlepe.is_open() to catch typos in filename.
|
|
||
| // run clustering algorithm | ||
| // ======================== | ||
| std::vector<RecoCluster*>* ClusterList = (std::vector<RecoCluster*>*)(this->RecoClusters(DigitList)); |
There was a problem hiding this comment.
again shouldn't need the c-style cast - in fact the local variable ClusterList is just an alias for the member variable fRecoClusters, so seems redundant. The aliasing in this Tool makes it hard to track objects.
| // =================== | ||
| for(int idigit=0; idigit<int(fSelectByNeighbours->size()); idigit++ ){ | ||
| RecoDigit* recoDigit = (RecoDigit*)(fSelectByNeighbours->at(idigit)); | ||
| RecoClusterDigit* clusterDigit = new RecoClusterDigit(recoDigit); |
There was a problem hiding this comment.
why do the digits need to be on the heap?
| //Loop over lines, collect all detector data (should only be one line here) | ||
| while (getline(file_singlepe, line)) { | ||
| if (verbosity > 3) std::cout << line << std::endl; //has our stuff; | ||
| if (line.find("#") != std::string::npos) continue; |
There was a problem hiding this comment.
be wary that this will skip lines with trailing comments, as well as commented-out lines.
perhaps if(line.empty() || line[0]=='#') continue is a safer/clearer check
| if (verbosity > 3) std::cout << line << std::endl; //has our stuff; | ||
| if (line.find("#") != std::string::npos) continue; | ||
| std::vector<std::string> DataEntries; | ||
| boost::split(DataEntries, line, boost::is_any_of(","), boost::token_compress_on); |
There was a problem hiding this comment.
i think token_compress_on merges repeated tokens? Is this desirable? If there are repeated tokens, doesn't this suggest an empty column, and by compressing that, your later columns will be shifted?
| Log("This HIT'S TIME AND CHARGE: " + to_string(ahit.GetTime()) + ", " + to_string(ahit.GetCharge()),v_debug,verbosity); | ||
| double hitTime = ahit.GetTime()*1.0; | ||
| if(hitTime>-10 && hitTime<40) { | ||
| if(hitTime>-10 && hitTime<70) { |
There was a problem hiding this comment.
better for magic numbers to be configuration variables, especially if they are subject to change
-Changed RecoCluster and RecoDigit lists in several tools to be vectors of objects, rather than vectors of pointers, to avoid memory complications -removed unused convex hull function from RecoCluster class -simplified CalcAS function in RecoCluster class by consolidating for loops -removed several instances of commented-out code from older versions -removed several debug outputs -altered hard-coded time window values in several instances to rely on configuration input -added use of the true Q2 value from the GenieInfo store to NeutronCheck's output. -removed several uncontrolled cout lines, and replaced useful ones with Log. -Tidied the Instance() function of ClusterSearcher -Added vertex information to NeutronCheck
|
Thank you @flemmons for the updates! Unfortunately, this branch has conflicts with the main branch that must be resolved in order to be merged. I will wait for the conflicts to be resolved and for the workflow check to be performed such that ToolAnalysis is confirmed to compile before I review the actual changes to the files |
|
Conflicts were just Factory and Unity listing different added tools. I've cleared them. |
|
Okay, but could you still resolve those conflicts? Also, it's great that ToolAnalysis can compile in your workspace, but it would be better to get confirmation that ToolAnalysis can compile in a general workspace (on GitHub via workflow). Given that this PR is self contained, there is no reason to not resolve these conflicts. I will look at the other files in the meantime. |
-Updated DigitBuilder to be more consistent with and independent of ClusterFinder's corresponding functions
--Added some extra features, such as hit LAPPD count and strip-by-strip LAPPD hits. (some of these are considered experimental/preliminary)
-Added ClusterSearcher to replace ClusterFinder using RecoDigit and RecoCluster classes
-Updated RecoDigit and RecoCluster classes for corresponding use and new features, such as various cluster parameters
-Added NeutronCheck tool as output for RecoCluster information
-Added sample toolchain configfolder for using the new tools