-
Notifications
You must be signed in to change notification settings - Fork 59
ClusterSearcher and RecoCluster #365
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: Application
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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.
Should this be fixed now?
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line seems unnecessary. While loop already includes this condition
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this for loop inside of a while loop?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this has been mentioned before. Please include verbosity conditions, preferably as Log functions
| double sumY=0; | ||
| Position pos; | ||
| //std::vector<RecoDigits> hullDigits; | ||
| std::sort(fDigitList.begin(), fDigitList.end()); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems redundant. If the previous allocation didn't succeed it would have thrown bad_alloc.
| } | ||
|
|
||
| if( fgClusterSearcher ){ | ||
|
|
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 (!fisMC){ | ||
| ifstream file_singlepe(singlePEgains.c_str()); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better for magic numbers to be configuration variables, especially if they are subject to change
-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