Skip to content
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

Vertex Reconstruction Update #288

Open
wants to merge 31 commits into
base: Application
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a96a7c7
Update to Vertex Reconstruction, including new FineGrid search and me…
flemmons Mar 8, 2023
aa23607
False Commit to enable checkout; please ignore.
flemmons May 25, 2023
79ed58f
Edited recent vertex reconstruction updates for better mesh with TA code
flemmons Sep 7, 2023
88a949f
Fixed small typo in VtxSeedGenerator.cpp
flemmons Sep 12, 2023
972031c
Fixes to VtxSeedFineGrid. Added new PDF charge fitter to FoMCalculat…
flemmons Oct 17, 2023
4e5411e
bug fixes to recent update
flemmons Oct 18, 2023
b0e369d
Fixes to VtxExtendedVertexFinder, and further progress in experimenta…
flemmons Oct 22, 2023
04544fe
Incremental update on pdf charge fit. Updated to chi2 definition.
flemmons Nov 1, 2023
96305cc
Charge fit update for LikelihoodCheck tool, along with a debug abilit…
flemmons Nov 8, 2023
7fcf3ba
Further debug update of charge fit addition to FoMCalculator
flemmons Nov 8, 2023
7e70f62
Bringing up to date with new charge fitter fixes. Added VGCheck-pdfc…
flemmons Feb 5, 2024
b6f0b26
Merge branch 'Application' into current_temp
flemmons Feb 6, 2024
9411ae1
Merge pull request #2 from flemmons/current_temp
flemmons Feb 6, 2024
3424918
Merge branch 'Application' into Application
marc1uk Feb 16, 2024
196560e
Bringing up to date in 05/29/2024
flemmons May 29, 2024
78a6ddb
Adding PhaseIIRecoFirinne configfiles.
flemmons May 31, 2024
c09f4b5
Create a new reco folder as the placeholder for updating the track di…
wangjingbo04 May 31, 2024
5bd2214
Corrected the config parameters
wangjingbo04 Jun 3, 2024
415eea3
(1) Added a new Tool PhaseIITreeMakerDOE to save the reco information…
wangjingbo04 Jun 4, 2024
a773908
Changed FoMCalculator to accept LAPPD digits as well as PMTs.
flemmons Jun 13, 2024
51bd8e9
Merge branch 'May1' of https://github.com/flemmons/ToolAnalysis2 into…
flemmons Jun 13, 2024
a439c88
Adding DirectionGridCheck
flemmons Jun 14, 2024
d76c30c
(1) Added an angular fitter to the vertex reco tools
wangjingbo04 Aug 13, 2024
d0d3f7a
Merge branch 'Application' into May1
wangjingbo04 Aug 15, 2024
dcf2821
Added LAPPD multiplicity cut in EventSelector w/ support in DigitBuilder
flemmons Aug 16, 2024
e0d63ea
Added multi-event functionality to LikelihoodFitterCheck.
flemmons Aug 22, 2024
f5a8424
Altered LoadWCSim for more accurate Timing
flemmons Aug 25, 2024
5e42d2b
Quick Commit to bring repository up to date and check specific changes.
flemmons Sep 30, 2024
f97eff1
Resetting PhaseIITreeMaker to appropriate version after inadvertant r…
flemmons Oct 1, 2024
ba74e66
Delete configfiles/VertexReco/PhaseIIRecoFirinne directory
flemmons Dec 16, 2024
16f7e62
Delete configfiles/VertexReco/PhaseIIRecoDir directory
flemmons Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,181 changes: 652 additions & 529 deletions DataModel/FoMCalculator.cpp

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion DataModel/FoMCalculator.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*************************************************************************
> File Name: MinuitOptimizer.hh
> File Name: FoMCalculator.hh
> Author: Jingbo Wang, Teal Pershing
> mail: [email protected], [email protected]
> Created Time: MAY 07, 2019
Expand Down Expand Up @@ -50,6 +50,7 @@ class FoMCalculator {
double FindSimpleTimeProperties(double myConeEdge);
void TimePropertiesLnL(double vtxTime, double& vtxFom);
void ConePropertiesFoM(double coneEdge, double& chi2);
void ConePropertiesLnL(double vtxX, double vtxY, double VtxZ, double dirX, double dirY, double dirZ, double coneEdge, double& chi2, TH1D angularDist, double& phimax, double& phimin);
void PointPositionChi2(double vtxX, double vtxY, double vtxZ, double vtxTime, double& fom);
void PointDirectionChi2(double vtxX, double vtxY, double vtxZ, double dirX, double dirY, double dirZ, double coneAngle, double& fom);
void PointVertexChi2(double vtxX, double vtxY, double vtxZ,
Expand All @@ -58,6 +59,9 @@ class FoMCalculator {
void ExtendedVertexChi2(double vtxX, double vtxY, double vtxZ,
double dirX, double dirY, double dirZ,
double coneAngle, double vtxTime, double& fom);
void ExtendedVertexChi2(double vtxX, double vtxY, double vtxZ,
double dirX, double dirY, double dirZ,
double coneAngle, double vtxTime, double& fom, TH1D pdf);
// void ConePropertiesLnL(double coneParam0, double coneParam1, double coneParam2, double& coneAngle, double& coneFOM);
// void CorrectedVertexChi2(double vtxX, double vtxY, double vtxZ,
// double dirX, double dirY, double dirZ,
Expand Down
Empty file modified DataModel/MinuitOptimizer.cpp
100644 → 100755
Empty file.
Empty file modified DataModel/MinuitOptimizer.h
100644 → 100755
Empty file.
154 changes: 123 additions & 31 deletions UserTools/DigitBuilder/DigitBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bool DigitBuilder::Initialise(std::string configfile, DataModel &data){
fParametricModel = 0;
fIsMC = 1;
fDigitChargeThr = 10;


/// Get the Tool configuration variables
m_variables.Get("verbosity",verbosity);
Expand All @@ -43,9 +43,11 @@ bool DigitBuilder::Initialise(std::string configfile, DataModel &data){
m_variables.Get("DigitChargeThr",fDigitChargeThr);
m_variables.Get("ChankeyToPMTIDMap",path_chankeymap);
m_variables.Get("SinglePEGains",singlePEgains);
m_variables.Get("StripHit", striphit);

/// Construct the other objects we'll be setting at event level,
fDigitList = new std::vector<RecoDigit>;
fHitLAPPDs = new std::vector<int>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

does fHitLAPPDs->clear() need to be added to DigitBuilder::Reset?


// Make the RecoDigit Store if it doesn't exist
int recoeventexists = m_data->Stores.count("RecoEvent");
Expand All @@ -57,6 +59,7 @@ bool DigitBuilder::Initialise(std::string configfile, DataModel &data){
Log("DigitBuilder Tool: Error retrieving Geometry from ANNIEEvent!",v_error,verbosity);
return false;
}
std::cout << "Strip Hit Mode:" << striphit << endl;
Copy link
Collaborator

Choose a reason for hiding this comment

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

please remove cout statements. Use Log with suitable logging level for debug.

Copy link
Collaborator

Choose a reason for hiding this comment

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

i won't comment on them all but cout is used multiple times here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noted. I'll go through and replace them.


// Some hard-coded values of old WCSim LAPPDIDs are in this Tool
// I would recommend moving away from the use of WCSim IDs if possible as they are liable to change
Expand Down Expand Up @@ -267,6 +270,7 @@ bool DigitBuilder::BuildMCPMTRecoDigit() {
} else {
calT = hitTimes.at(timesize/2);
}
//calT = frand.Gaus(calT, 1.0);
calQ = 0.;
for(std::vector<double>::iterator it = hitCharges.begin(); it != hitCharges.end(); ++it){
calQ += *it;
Expand Down Expand Up @@ -296,6 +300,7 @@ bool DigitBuilder::BuildMCPMTRecoDigit() {
std::cout << "PMT Charge,Time: " << to_string(calQ) << "," <<
to_string(calT) << std::endl;
}
calT = frand.Gaus(calT, 1.0);
digitType = RecoDigit::PMT8inch;
RecoDigit recoDigit(region, pos_reco, calT, calQ, digitType, PMTId);
//recoDigit.Print();
Expand All @@ -320,9 +325,14 @@ bool DigitBuilder::BuildMCLAPPDRecoDigit() {
int digitType = -999;
Detector* det=nullptr;
Position pos_sim, pos_reco;
int currentLAPPD = 0;
if (fHitLAPPDs->size() > 0) {
fHitLAPPDs->clear();
}

// repeat for LAPPD hits
// MCLAPPDHits is a std::map<unsigned long,std::vector<LAPPDHit>>
if(fMCLAPPDHits){
if(fMCLAPPDHits && fMCLAPPDHits->size() > 0){
Log("DigitBuilder Tool: Num LAPPD Digits = "+to_string(fMCLAPPDHits->size()),v_message,verbosity);
// iterate over the map of sensors with a measurement
for(std::pair<unsigned long,std::vector<MCLAPPDHit>>&& apair : *fMCLAPPDHits){
Expand All @@ -342,45 +352,126 @@ bool DigitBuilder::BuildMCLAPPDRecoDigit() {
if(!isSelectedLAPPD && fLAPPDId.size()>0) continue;
if(verbosity>2){
std::cout << "Loading in digits for LAPPDID " << LAPPDId << std::endl;
std::cout << "located: ";
det->GetPositionInTank().Print();
std::cout << "directed: ";
det->GetDetectorDirection().Print();
}

if(det->GetDetectorElement()=="LAPPD"){ // redundant, MCLAPPDHits are LAPPD hitss
std::vector<MCLAPPDHit>& hits = apair.second;
for(MCLAPPDHit& ahit : hits){
//if(v_message<verbosity) ahit.Print(); // << VERY verbose
// an LAPPDHit has adds (global x-y-z) position, (in-tile x-y) local position
// and time psecs
// convert the WCSim coordinates to the ANNIEreco coordinates
// convert the unit from m to cm
pos_reco.SetX(ahit.GetPosition().at(0)*100.+xshift); //cm
pos_reco.SetY(ahit.GetPosition().at(1)*100.+yshift); //cm
pos_reco.SetZ(ahit.GetPosition().at(2)*100.+zshift); //cm
calT = ahit.GetTime(); //
calT = frand.Gaus(calT, 0.1); // time is smeared with 100 ps time resolution. Harded-coded for now.
calQ = ahit.GetCharge();
if (verbosity>4) {
std::cout << "LAPPD position (X<Y<Z): " <<
to_string(pos_reco.X()) << "," << to_string(pos_reco.Y()) <<
"," << to_string(pos_reco.Z()) << std::endl;
std::cout << "LAPPD Charge,Time: " << to_string(calQ) << "," <<
to_string(calT) << std::endl;
if (det->GetDetectorElement() == "LAPPD") { // redundant, MCLAPPDHits are LAPPD hitss
std::vector<MCLAPPDHit>& hits = apair.second;

std::vector<double> sumposX;
std::vector<double> sumposY;
std::vector<double> sumposZ;
std::vector<double> sumT;
double posX;
std::vector<int> nHitsOnStrip;
int a;
for (int i = 0; i < 28; i++) {
sumposX.push_back(0);
sumposY.push_back(0);
sumposZ.push_back(0);
sumT.push_back(0);
nHitsOnStrip.push_back(0);
}
// I found the charge is 0 for all the hits. In order to test the code,
// here I just set the charge to 1. We should come back to this later. (Jingbo Wang)
calQ = 1.;
digitType = RecoDigit::lappd_v0;
RecoDigit recoDigit(region, pos_reco, calT, calQ, digitType,LAPPDId);
//if(v_message<verbosity) recoDigit.Print();
//make some cuts here. It will be moved to the Hitcleaning tool
if(calT>40 || calT<-10) continue; // cut off delayed hits
fDigitList->push_back(recoDigit);
for(MCLAPPDHit& ahit : hits){
if (LAPPDId != currentLAPPD && hits.size() > 3) {
std::cout << "THERE ARE HITS ON LAPPD " << LAPPDId << endl;
currentLAPPD = LAPPDId;
fHitLAPPDs->push_back(currentLAPPD);
std::cout << "fHitLAPPDs size: " << fHitLAPPDs->size() << endl;
}
if (striphit == 0) {
//if(v_message<verbosity) ahit.Print(); // << VERY verbose
// an LAPPDHit has adds (global x-y-z) position, (in-tile x-y) local position
// and time psecs
// convert the WCSim coordinates to the ANNIEreco coordinates
// convert the unit from m to cm
pos_reco.SetX(ahit.GetPosition().at(0) * 100. + xshift); //cm
pos_reco.SetY(ahit.GetPosition().at(1) * 100. + yshift); //cm
pos_reco.SetZ(ahit.GetPosition().at(2) * 100. + zshift); //cm
calT = ahit.GetTime(); //
calT = frand.Gaus(calT, 0.1); // time is smeared with 100 ps time resolution. Harded-coded for now.
calQ = ahit.GetCharge();
if (verbosity > 4) {
std::cout << "LAPPD position (X<Y<Z): " <<
to_string(pos_reco.X()) << "," << to_string(pos_reco.Y()) <<
"," << to_string(pos_reco.Z()) << std::endl;
std::cout << "LAPPD Charge,Time: " << to_string(calQ) << "," <<
to_string(calT) << std::endl;
}
// I found the charge is 0 for all the hits. In order to test the code,
// here I just set the charge to 1. We should come back to this later. (Jingbo Wang)
calQ = 1.;
digitType = RecoDigit::lappd_v0;
RecoDigit recoDigit(region, pos_reco, calT, calQ, digitType, LAPPDId);
//if(v_message<verbosity) recoDigit.Print();
//make some cuts here. It will be moved to the Hitcleaning tool
if (calT > 40 || calT < -10) continue; // cut off delayed hits
fDigitList->push_back(recoDigit);

}
else {
posX = (ahit.GetPosition().at(0) * 100 + xshift) - (det->GetPositionInTank().X() * 100 + xshift);
double dirX = det->GetDetectorDirection().X();
double AngX = std::asin(dirX);
int strip = (int)((posX / (20.* std::sin(AngX) / 28.)) + 14 - 1);
if (strip > 27 || strip < 0) {
Log("warning: LAPPD hit found off LAPPD: ", v_debug, verbosity);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Warnings should probably be logged with a loglevel of v_warning rather than v_debug.... ?

std::cout << "hit found on strip " << strip << endl;
std::cout << "LAPPD truehit X,Y,Z: " << ahit.GetPosition().at(0) << ", ";
std::cout << ahit.GetPosition().at(1) << ", ";
std::cout << ahit.GetPosition().at(2) << endl;
std::cout << "continuing loop without this hit." << endl;
continue;
}
std::cout << "hit found on strip " << strip << endl;
sumposX.at(strip) += ahit.GetPosition().at(0) * 100 + xshift;
std::cout << "LAPPD truehit X,Y,Z: " << ahit.GetPosition().at(0) << ", ";
sumposY.at(strip) += ahit.GetPosition().at(1) * 100 + yshift;
std::cout << ahit.GetPosition().at(1) << ", ";
sumposZ.at(strip) += ahit.GetPosition().at(2) * 100 + zshift;
std::cout << ahit.GetPosition().at(2) << endl;

if ((striphit == 3 && nHitsOnStrip.at(strip) < 3) || (striphit==2 && nHitsOnStrip.at(strip) == 0) || striphit == 1)
sumT.at(strip) += frand.Gaus(calT, 0.1); // time is smeared with 100 ps time resolution. Harded-coded for now.
nHitsOnStrip.at(strip) += 1;

}
}
if (striphit != 0) {
for (int strip = 0; strip < 28; strip++) {
if (nHitsOnStrip.at(strip) != 0) {
pos_reco.SetX(sumposX.at(strip) / nHitsOnStrip.at(strip));
pos_reco.SetY(sumposY.at(strip) / nHitsOnStrip.at(strip));
pos_reco.SetZ(sumposZ.at(strip) / nHitsOnStrip.at(strip));
if(striphit == 1) calT = sumT.at(strip) / nHitsOnStrip.at(strip);
if (striphit == 3) calT = sumT.at(strip) / 3;
calQ = nHitsOnStrip.at(strip); //set to the number of hits for now.
digitType = RecoDigit::lappd_v0;

std::cout << "LAPPD ID: " << to_string(LAPPDId) << endl;
std::cout << "LAPPD strip-hit position (X<Y<Z): " << to_string(pos_reco.X()) << "," << to_string(pos_reco.Y()) << "," << to_string(pos_reco.Z()) << endl;
std::cout << "LAPPD strip-hit Charge,Time: " << to_string(calQ) << "," << to_string(calT) << endl;
RecoDigit recoDigit(region, pos_reco, calT, calQ, digitType, LAPPDId);
std::cout << "recoDigit created for striphit\n";
fDigitList->push_back(recoDigit);
}
}
}
sumposX.clear();
sumposY.clear();
sumposZ.clear();
sumT.clear();
nHitsOnStrip.clear();
}
} // end loop over MCLAPPDHits
} else {
cout<<"No MCLAPPDHits"<<endl;
return false;
}

return true;
}

Expand Down Expand Up @@ -551,6 +642,7 @@ bool DigitBuilder::BuildDataPMTRecoDigit(){
void DigitBuilder::PushRecoDigits(bool savetodisk) {
Log("DigitBuilder Tool: Push reconstructed digits to the RecoEvent store",v_message,verbosity);
m_data->Stores.at("RecoEvent")->Set("RecoDigit", fDigitList, savetodisk); ///> Add digits to RecoEvent
m_data->Stores.at("RecoEvent")->Set("HitLAPPDs", fHitLAPPDs, savetodisk);
}

void DigitBuilder::Reset() {
Expand Down
3 changes: 2 additions & 1 deletion UserTools/DigitBuilder/DigitBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class DigitBuilder: public Tool {
int verbosity=1;
std::string fInputfile;
unsigned long fNumEvents;

std::vector<int>* fHitLAPPDs;
std::vector<int> fLAPPDId; ///< selected LAPPDs
std::string fPhotodetectorConfiguration; ///< "PMTs_Only", "LAPPDs_Only", "All_Detectors"
bool fParametricModel; ///< configures if PMTs hits for each event are accumulated into one hit per PMT
Expand All @@ -81,6 +81,7 @@ class DigitBuilder: public Tool {
double fDigitChargeThr;
std::string path_chankeymap;
std::string singlePEgains;
int striphit; //0 all LAPPD Hits as true; 1 average all times per strip; 2 use first time for each strip

Geometry* fGeometry=nullptr; ///< ANNIE Geometry
TRandom3 frand; ///< Random number generator
Expand Down
Loading