-
Notifications
You must be signed in to change notification settings - Fork 53
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
base: Application
Are you sure you want to change the base?
Changes from all commits
a96a7c7
aa23607
79ed58f
88a949f
972031c
4e5411e
b0e369d
04544fe
96305cc
7fcf3ba
7e70f62
b6f0b26
9411ae1
3424918
196560e
78a6ddb
c09f4b5
5bd2214
415eea3
a773908
51bd8e9
a439c88
d76c30c
d0d3f7a
dcf2821
e0d63ea
f5a8424
5e42d2b
f97eff1
ba74e66
16f7e62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
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 | ||
|
@@ -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, | ||
|
@@ -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, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
|
@@ -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>; | ||
|
||
// Make the RecoDigit Store if it doesn't exist | ||
int recoeventexists = m_data->Stores.count("RecoEvent"); | ||
|
@@ -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; | ||
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. please remove cout statements. Use Log with suitable logging level for debug. 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 won't comment on them all but cout is used multiple times here. 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. 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 | ||
|
@@ -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; | ||
|
@@ -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(); | ||
|
@@ -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){ | ||
|
@@ -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); | ||
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. Warnings should probably be logged with a loglevel of |
||
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; | ||
} | ||
|
||
|
@@ -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() { | ||
|
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.
does
fHitLAPPDs->clear()
need to be added toDigitBuilder::Reset
?