Skip to content

Commit

Permalink
Revert to outputting one event per event (not combo!), some bug fixes…
Browse files Browse the repository at this point in the history
…, add Delta T(RF) cut
  • Loading branch information
sdobbs committed Jun 25, 2018
1 parent 837c19e commit a8a2746
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jerror_t DReaction_factory_pi0calib::init(void)
locReactionStep->Set_InitialParticleID(Pi0);
locReactionStep->Add_FinalParticleID(Gamma);
locReactionStep->Add_FinalParticleID(Gamma);
locReactionStep->Set_KinFitConstrainInitMassFlag(false);
locReactionStep->Set_KinFitConstrainInitMassFlag(false);
locReaction->Add_ReactionStep(locReactionStep);
dReactionStepPool.push_back(locReactionStep); //register so will be deleted later: prevent memory leak

Expand All @@ -60,19 +60,20 @@ jerror_t DReaction_factory_pi0calib::init(void)
/**************************************************** pi0calib Analysis Actions ****************************************************/

// Recommended: Analysis actions automatically performed by the DAnalysisResults factories to histogram useful quantities.
//These actions are executed sequentially, and are executed on each surviving (non-cut) particle combination
//Pre-defined actions can be found in ANALYSIS/DHistogramActions.h and ANALYSIS/DCutActions.h

locReaction->Set_MaxExtraGoodTracks(1);
//locReaction->Set_InvariantMassCut(Pi0, 0.05, 0.22); // Use default AnLib cut of M(gg) = 80 - 190 MeV
//These actions are executed sequentially, and are executed on each surviving (non-cut) particle combination
//Pre-defined actions can be found in ANALYSIS/DHistogramActions.h and ANALYSIS/DCutActions.h

locReaction->Set_NumPlusMinusRFBunches(0); // no accidentals!
locReaction->Set_MaxExtraGoodTracks(1);
//locReaction->Set_InvariantMassCut(Pi0, 0.05, 0.22); // Use default AnLib cut of M(gg) = 80 - 190 MeV

// Require BCAL photons
locReaction->Add_AnalysisAction(new DCustomAction_CutPhotonKin(locReaction));

// Make some back-to-backness and other exclusivity cuts
locReaction->Add_AnalysisAction(new DCustomAction_p2gamma_cuts(locReaction, false));

// Require kin fit CL > 1%
locReaction->Add_AnalysisAction(new DCustomAction_p2gamma_cuts(locReaction, false));
// Require kin fit CL > 1%
locReaction->Add_AnalysisAction(new DCutAction_KinFitFOM(locReaction, 0.01));

_data.push_back(locReaction); //Register the DReaction with the factory
Expand Down
36 changes: 22 additions & 14 deletions src/plugins/Utilities/exclusivepi0skim/JEventProcessor_pi0calib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,34 +101,37 @@ jerror_t JEventProcessor_pi0calib::evnt(JEventLoop *loop, uint64_t eventnumber)
break;
}

if(locSuccessFlag) { // there are combos that satisfy our reaction
if( (locAnalysisResultsVector.size() > 0) && (locAnalysisResultsVector[0]->Get_NumPassedParticleCombos() != 0) ) {
if( (locAnalysisResultsVector.size() > 0) && locSuccessFlag) { // there are combos that satisfy our reaction
//if( (locAnalysisResultsVector.size() > 0) && (locAnalysisResultsVector[0]->Get_NumPassedParticleCombos() != 0) ) {
// SIMPLE - write out the full event
//eventWriterEVIO->Write_EVIOEvent(loop, "exclusivepi0");

// Instead: Write out each combo as an "event", only saving the combo vertex, RF bunch, and showers associated with the combo
// This should be a lot smaller

vector< const JObject* > locObjectsToSave;

vector<const DEventRFBunch*> locEventRFBunches;
loop->Get(locEventRFBunches);

//locObjectsToSave.push_back(static_cast<const JObject *>(locEventRFBunches));
locObjectsToSave.push_back(locEventRFBunches[0]);

vector<const DVertex*> kinfitVertex;
loop->Get(kinfitVertex);
locObjectsToSave.push_back(kinfitVertex[0]);

if(kinfitVertex.size() > 0) { // pretty sure this should always be true if we have a combo....
for( auto result : locAnalysisResultsVector ) {
deque<const DParticleCombo*> combos;
result->Get_PassedParticleCombos(combos);
for( auto combo : combos ) {
// one event per combo
vector< const JObject* > locObjectsToSave;

// need to save the RF bunch info
locObjectsToSave.push_back(static_cast<const JObject *>(combo->Get_EventRFBunch()));
//locObjectsToSave.push_back(static_cast<const JObject *>(combo->Get_EventRFBunch()));
// need to make a new vertex object - base it on the old one
// we probably don'e need most of this information, but keep it reasonable I guess
DVertex *comboVertex = new DVertex(*(kinfitVertex[0]));
comboVertex->dSpacetimeVertex = combo->Get_EventVertex();
//DVertex *comboVertex = new DVertex(*(kinfitVertex[0]));
//comboVertex->dSpacetimeVertex = combo->Get_EventVertex();

// Save the actual showers - the EVIO writer will only write out the associated hits
//set< const JObject *> bcalShowers;
Expand All @@ -137,25 +140,30 @@ jerror_t JEventProcessor_pi0calib::evnt(JEventLoop *loop, uint64_t eventnumber)
if(ParticleCharge(particle->PID()) == 0) {
auto locNeutralParticleHypothesis = static_cast<const DNeutralParticleHypothesis*>(particle);
auto locNeutralShower = locNeutralParticleHypothesis->Get_NeutralShower();
locObjectsToSave.push_back(locNeutralShower->dBCALFCALShower);
if(find(locObjectsToSave.begin(),locObjectsToSave.end(),locNeutralShower->dBCALFCALShower) == locObjectsToSave.end())
locObjectsToSave.push_back(locNeutralShower->dBCALFCALShower);
//bcalShowers.insert(locNeutralShower->dBCALFCALShower);
}
}

// actually write the event out
eventWriterEVIO->Write_EVIOEvent( loop, "exclusivepi0", locObjectsToSave );
//eventWriterEVIO->Write_EVIOEvent( loop, "exclusivepi0", locObjectsToSave );
}
}
}
}

// actually write the event out
eventWriterEVIO->Write_EVIOEvent( loop, "exclusivepi0", locObjectsToSave );

//}

//for( auto *shower_ptr : bcalShowers ) {
// locObjectsToSave.push_back(static_cast<const JObject *>(shower_ptr));
//}

}
}

if( WRITE_ROOT_TREE ){

//Recommended: Write surviving particle combinations (if any) to output ROOT TTree
Expand Down

0 comments on commit a8a2746

Please sign in to comment.