14 #include "JANA/JApplication.h"
15 #include <TLorentzVector.h>
17 #include "JANA/JApplication.h"
130 vector< const DFCALShower* > locFCALShowers;
131 vector< const DVertex* > kinfitVertex;
132 loop->Get(locFCALShowers);
133 loop->Get(kinfitVertex);
135 vector< const DTrackTimeBased* > locTrackTimeBased;
136 loop->Get(locTrackTimeBased);
138 vector < const DFCALShower * > matchedShowers;
141 loop->GetSingle(locEventWriterEVIO);
158 vector< const JObject* > locObjectsToSave;
160 bool Candidate =
false;
162 Double_t kinfitVertexX = 0.0, kinfitVertexY = 0.0, kinfitVertexZ = 0.0;
164 for (
unsigned int i = 0 ; i < kinfitVertex.size(); i++)
167 locObjectsToSave.push_back(static_cast<const JObject *>(kinfitVertex[0]));
169 kinfitVertexX = kinfitVertex[i]->dSpacetimeVertex.X();
170 kinfitVertexY = kinfitVertex[i]->dSpacetimeVertex.Y();
171 kinfitVertexZ = kinfitVertex[i]->dSpacetimeVertex.Z();
174 vector<const DEventRFBunch*> locEventRFBunches;
175 loop->Get(locEventRFBunches);
176 if(locEventRFBunches.size() > 0) {
177 locObjectsToSave.push_back(static_cast<const JObject *>(locEventRFBunches[0]));
185 for (
unsigned int i=0; i < locTrackTimeBased.size() ; ++i){
186 vector<DTrackFitter::Extrapolation_t>extrapolations=locTrackTimeBased[i]->extrapolations.at(
SYS_FCAL);
187 if (extrapolations.size()==0)
continue;
189 for (
unsigned int j=0; j< locFCALShowers.size(); ++j){
191 Double_t
x = locFCALShowers[j]->getPosition().X();
192 Double_t
y = locFCALShowers[j]->getPosition().Y();
205 pos=extrapolations[0].position;
210 Double_t trkmass = locTrackTimeBased[i]->mass();
211 Double_t FOM = TMath::Prob(locTrackTimeBased[i]->chisq, locTrackTimeBased[i]->Ndof);
217 Double_t dRho =
sqrt(((pos.X() -
x)*(pos.X() -
x)) + ((pos.Y() -
y)* (pos.Y() -
y)));
220 if(trkmass < 0.15 && dRho < 5 && FOM > 0.01 ) {
221 matchedShowers.push_back(locFCALShowers[j]);
232 for(
unsigned int i=0; i<locFCALShowers.size(); i++)
234 if (find(matchedShowers.begin(), matchedShowers.end(),locFCALShowers[i]) != matchedShowers.end())
continue;
238 vector<const DFCALCluster*> associated_clusters1;
240 s1->Get(associated_clusters1);
241 Double_t dx1 = s1->
getPosition().X() - kinfitVertexX;
242 Double_t dy1 = s1->
getPosition().Y() - kinfitVertexY;
243 Double_t dz1 = s1->
getPosition().Z() - kinfitVertexZ;
244 Double_t R1 =
sqrt(dx1*dx1 + dy1*dy1 + dz1*dz1);
247 TLorentzVector sh1_p(E1*dx1/R1, E1*dy1/R1, E1*dz1/R1, E1);
249 for(
unsigned int j=i+1; j<locFCALShowers.size(); j++)
252 if (find(matchedShowers.begin(), matchedShowers.end(),s2) != matchedShowers.end())
continue;
254 vector<const DFCALCluster*> associated_clusters2;
255 s2->Get(associated_clusters2);
256 Double_t dx2 = s2->
getPosition().X() - kinfitVertexX;
257 Double_t dy2 = s2->
getPosition().Y() - kinfitVertexY;
258 Double_t dz2 = s2->
getPosition().Z() - kinfitVertexZ;
259 Double_t R2 =
sqrt(dx2*dx2 + dy2*dy2 + dz2*dz2);
263 TLorentzVector sh2_p(E2*dx2/R2, E2*dy2/R2, E2*dz2/R2, E2);
264 TLorentzVector ptot = sh1_p+sh2_p;
265 Double_t inv_mass = ptot.M();
268 Candidate |= (E1 > 0.5 && E2 > 0.5 && (fabs (t1-t2) < 10) && (inv_mass<0.30) ) ;
271 if(E1 > 0.5 && E2 > 0.5 && (fabs (t1-t2) < 10) && (inv_mass<0.30) ) {
272 if(find(locObjectsToSave.begin(), locObjectsToSave.end(), locFCALShowers[i]) == locObjectsToSave.end())
273 locObjectsToSave.push_back(static_cast<const JObject *>(locFCALShowers[i]));
274 if(find(locObjectsToSave.begin(), locObjectsToSave.end(), locFCALShowers[j]) == locObjectsToSave.end())
275 locObjectsToSave.push_back(static_cast<const JObject *>(locFCALShowers[j]));
284 locEventWriterEVIO->
Write_EVIOEvent( loop,
"pi0fcalskim", locObjectsToSave );
jerror_t init(void)
Called once at program start.
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
jerror_t fini(void)
Called after last event of last event source has been processed.
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
bool Write_EVIOEvent(JEventLoop *locEventLoop, string locOutputFileNameSubString) const
JEventProcessor_pi0fcalskim()
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
DVector3 getPosition() const
~JEventProcessor_pi0fcalskim()