9 #include <TLorentzVector.h>
11 #include "JANA/JApplication.h"
46 InitJANAPlugin(locApplication);
62 TDirectory *
main = gDirectory;
63 gDirectory->mkdir(
"FCAL_invmass")->cd();
65 InvMass1 =
new TH1I(
"InvMass1",
"Shower E. > 500 MeV;Invariant Mass [GeV]; Counts / 1 MeV ",500,0.0,0.5);
67 InvMass2 =
new TH1I(
"InvMass2",
"Shower E. > 1000 MeV;Invariant Mass [GeV]; Counts / 1 MeV ",500,0.0,0.5);
69 InvMass3 =
new TH1I(
"InvMass3",
" 500 MeV < Shower E. < 900 MeV ;Invariant Mass [GeV]; Counts / 1 MeV ",500,0.0,0.5);
71 InvMass4 =
new TH1I(
"InvMass4",
" 900 MeV < Shower E. < 1400 MeV ;Invariant Mass [GeV]; Counts / 1 MeV ",500,0.0,0.5);
73 InvMass5 =
new TH1I(
"InvMass5",
" 1400 MeV < Shower E. < 1900 MeV ;Invariant Mass [GeV]; Counts / 1 MeV ",500,0.0,0.5);
75 InvMass6 =
new TH1I(
"InvMass6",
" 1900 MeV < Shower E. < 2400 MeV ;Invariant Mass [GeV]; Counts / 1 MeV ",500,0.0,0.5);
77 InvMass7 =
new TH1I(
"InvMass7",
" 2400 MeV < Shower E. < 2900 MeV ;Invariant Mass [GeV]; Counts / 1 MeV ",500,0.0,0.5);
79 InvMass8 =
new TH1I(
"InvMass8",
" 2900 MeV < Shower E. < 3400 MeV ;Invariant Mass [GeV]; Counts / 1 MeV ",500,0.0,0.5);
81 InvMass9 =
new TH1I(
"InvMass9",
" 3400 MeV < Shower E. < 3900 MeV ;Invariant Mass [GeV]; Counts / 1 MeV ",500,0.0,0.5);
83 hits2D_pi0 =
new TH2I(
"hits2D_pi0",
"FCAL Pi0 Shower Hits; X [4 cm] ; Y [4 cm]", 61, -30, 30, 61, -30, 30 );
85 qualCut_00 =
new TH1I(
"qualCut_00",
"Quality > 0 ; Invariant MAss [GeV]; Counts / 1 MeV", 500, 0.0, 0.5);
87 qualCut_03 =
new TH1I(
"qualCut_03",
"Quality > 0.3 ; Invariant MAss [GeV]; Counts / 1 MeV", 500, 0.0, 0.5);
89 qualCut_05 =
new TH1I(
"qualCut_05",
"Quality > 0.5 ; Invariant MAss [GeV]; Counts / 1 MeV", 500, 0.0, 0.5);
105 double z_target;
double z_fcal;
111 z_diff = z_fcal - z_target;
118 map< const DFCALShower*, double > showerQualityMap;
119 vector< const DNeutralShower* > neutralShowers;
120 vector< const DFCALHit*> hits;
122 vector< const DFCALShower* > locFCALShowers;
123 vector< const DVertex* > kinfitVertex;
124 vector< const DTrackTimeBased* > locTrackTimeBased;
126 locEventLoop->Get( hits );
128 if( hits.size() <= 500 ){
130 locEventLoop->Get(locFCALShowers);
131 locEventLoop->Get(kinfitVertex);
132 locEventLoop->Get(locTrackTimeBased);
133 locEventLoop->Get( neutralShowers );
136 for(
size_t i = 0; i < neutralShowers.size(); ++i ){
138 if( neutralShowers[i]->dDetectorSystem ==
SYS_FCAL ){
141 showerQualityMap[fcalShower] = neutralShowers[i]->dQuality;
146 vector < const DFCALShower * > matchedShowers;
147 vector < const DTrackTimeBased* > matchedTracks;
148 vector <const DChargedTrackHypothesis*> locParticles;
151 Double_t kinfitVertexX = 0.0, kinfitVertexY = 0.0, kinfitVertexZ = 0.0;
153 for (
unsigned int i = 0 ; i < kinfitVertex.size(); i++)
155 kinfitVertexX = kinfitVertex[i]->dSpacetimeVertex.X();
156 kinfitVertexY = kinfitVertex[i]->dSpacetimeVertex.Y();
157 kinfitVertexZ = kinfitVertex[i]->dSpacetimeVertex.Z();
163 for (
unsigned int i=0; i < locTrackTimeBased.size() ; ++i){
164 if(locTrackTimeBased[i]->extrapolations.size() <
SYS_FCAL )
continue;
165 vector<DTrackFitter::Extrapolation_t>extrapolations=locTrackTimeBased[i]->extrapolations.at(
SYS_FCAL);
166 if (extrapolations.size()>0){
167 for (
unsigned int j=0; j< locFCALShowers.size(); ++j){
169 Double_t
x = locFCALShowers[j]->getPosition().X();
170 Double_t
y = locFCALShowers[j]->getPosition().Y();
171 Double_t z = locFCALShowers[j]->getPosition().Z();
174 pos=extrapolations[0].position;
175 Double_t trkmass = locTrackTimeBased[i]->mass();
176 Double_t FOM = TMath::Prob(locTrackTimeBased[i]->chisq, locTrackTimeBased[i]->Ndof);
177 Double_t dRho =
sqrt(((pos.X() -
x)*(pos.X() -
x)) + ((pos.Y() -
y)* (pos.Y() -
y)));
179 if(trkmass < 0.15 && dRho < 5 && FOM > 0.01 ) {
180 matchedShowers.push_back(locFCALShowers[j]);
181 matchedTracks.push_back(locTrackTimeBased[i]);
190 japp->RootFillLock(
this);
191 if (locFCALShowers.size() >=2) {
193 for(
unsigned int i=0; i<locFCALShowers.size(); i++)
195 if (find(matchedShowers.begin(), matchedShowers.end(),locFCALShowers[i]) != matchedShowers.end())
continue;
199 vector<const DFCALCluster*> associated_clusters1;
201 s1->Get(associated_clusters1);
202 Double_t dx1 = s1->
getPosition().X() - kinfitVertexX;
203 Double_t dy1 = s1->
getPosition().Y() - kinfitVertexY;
204 Double_t dz1 = s1->
getPosition().Z() - kinfitVertexZ;
206 Double_t R1 =
sqrt(dx1*dx1 + dy1*dy1 + dz1*dz1);
209 TLorentzVector sh1_p(E1*dx1/R1, E1*dy1/R1, E1*dz1/R1, E1);
211 for(
unsigned int j=i+1; j<locFCALShowers.size(); j++){
214 if (find(matchedShowers.begin(), matchedShowers.end(),s2) != matchedShowers.end())
continue;
216 vector<const DFCALCluster*> associated_clusters2;
217 s2->Get(associated_clusters2);
218 Double_t dx2 = s2->
getPosition().X() - kinfitVertexX;
219 Double_t dy2 = s2->
getPosition().Y() - kinfitVertexY;
220 Double_t dz2 = s2->
getPosition().Z() - kinfitVertexZ;
223 qualH = showerQualityMap[s2];
224 qualL = showerQualityMap[s1];
227 Double_t R2 =
sqrt(dx2*dx2 + dy2*dy2 + dz2*dz2);
231 TLorentzVector sh2_p(E2*dx2/R2, E2*dy2/R2, E2*dz2/R2, E2);
232 TLorentzVector ptot = sh1_p+sh2_p;
233 Double_t inv_mass = ptot.M();
264 for(
unsigned int loc_j = 0; loc_j < associated_clusters1.size(); loc_j++)
266 for(
unsigned int loc_jj = 0; loc_jj < associated_clusters2.size(); loc_jj++)
269 vector< DFCALCluster::DFCALClusterHit_t > hits1 = associated_clusters1[loc_j]->GetHits();
270 vector< DFCALCluster::DFCALClusterHit_t > hits2 = associated_clusters2[loc_jj]->GetHits();
272 Int_t numhits_per_cluster1 = associated_clusters1[loc_j]->GetNHits();
273 Int_t numhits_per_cluster2 = associated_clusters2[loc_jj]->GetNHits();
278 for(
int i = 0; i < numhits_per_cluster1; ++i ){
279 int my_x = hits1[i].x ;
280 int my_y = hits1[i].y ;
282 if (inv_mass > 0.11 && inv_mass < 0.16 && E1 > 1 && E2 > 1 && s1->
getPosition().Pt() > 20*
k_cm && s2->
getPosition().Pt() > 20*
k_cm && (fabs (t1-t2) < 10)){
287 for(
int i = 0; i < numhits_per_cluster2; ++i ){
288 int my_x = hits2[i].x ;
289 int my_y = hits2[i].y ;
291 if (inv_mass > 0.11 && inv_mass < 0.16 && E1 > 1 && E2 > 1 && s1->
getPosition().Pt() > 20*
k_cm && s2->
getPosition().Pt() > 20*
k_cm && (fabs (t1-t2) < 10)){
302 japp->RootFillUnLock(
this);
jerror_t brun(jana::JEventLoop *locEventLoop, int32_t locRunNumber)
Called every time a new run number is detected.
bool GetFCALZ(double &z_fcal) const
z-location of front face of CCAL in cm
jerror_t fini(void)
Called after last event of last event source has been processed.
jerror_t erun(void)
Called every time run number changes, provided brun has been called.
jerror_t init(void)
Called once at program start.
DGeometry * GetDGeometry(unsigned int run_number)
jerror_t evnt(jana::JEventLoop *locEventLoop, uint64_t locEventNumber)
Called every event.
DVector3 getPosition() const
bool GetTargetZ(double &z_target) const
z-location of center of target
int main(int argc, char *argv[])