2 #include <TLorentzVector.h>
4 #include "JANA/JApplication.h"
30 InitJANAPlugin(locApplication);
43 japp->RootWriteLock();
55 InvMass2 =
new TH1F(
"InvMass2",
"FCAL diphoton mass (Cluster E > 1000 MeV)",500,0.0,0.5);
56 InvMass2->GetXaxis()->SetTitle(
"invariant mass [GeV]");
57 InvMass2->GetYaxis()->SetTitle(
"Counts / 1 MeV");
60 h2D_mC =
new TH2F(
"h2D_mC",
"C Matrix as TH2F",
64 h1D_massbias =
new TH1F(
"h1D_massbias",
"Mass Bias Value (in bin 2)",5,0.,5.);
66 h1D_mPi0 =
new TH1F(
"h1D_mPi0",
"Reconstructed Pi0 Mass (pre-cuts)",54,0.03,0.3);
68 h1D_mPi0->SetYTitle(
"Counts / 5 MeV");
70 h1D_massDiff =
new TH1F(
"h1D_massDiff",
"Mass Reconst^2 - Mass Pi0^2",50,-0.15,0.15);
74 h1D_mPi0cuts =
new TH1F(
"h1D_mPi0cuts",
"Reconstructed Pi0 Mass (post-cuts)",54,0.03,0.3);
78 h1D_mPi0_window =
new TH1F(
"h1D_mPi0_window",
"Reconstructed Pi0 Mass (post-cuts) actually used",54,0.03,0.3);
82 h1D_nhits_unordered =
new TH1F(
"h1D_nhits_unordered",
"Number of hits at channel" ,100,0,100);
85 h1D_nhits =
new TH1F(
"h1D_nhits",
"Number of hits as function of channel number" ,
n_channels,0,2799);
127 pair<int,int> xy = make_pair(column,row);
138 double z_target;
double z_fcal;
144 z_diff = z_fcal - z_target;
176 vector< const DFCALHit*> hits;
177 locEventLoop->Get( hits );
179 vector< const DFCALShower* > locFCALShowers;
180 vector< const DVertex* > kinfitVertex;
181 vector< const DTrackTimeBased* > locTrackTimeBased;
182 if( hits.size() <= 500 ){
184 locEventLoop->Get(locFCALShowers);
185 locEventLoop->Get(kinfitVertex);
186 locEventLoop->Get(locTrackTimeBased);
189 vector < const DFCALShower * > matchedShowers;
190 vector < const DTrackTimeBased* > matchedTracks;
191 vector <const DChargedTrackHypothesis*> locParticles;
196 Double_t kinfitVertexX = 0.0, kinfitVertexY = 0.0, kinfitVertexZ = 0.0;
198 for (
unsigned int i = 0 ; i < kinfitVertex.size(); i++)
200 kinfitVertexX = kinfitVertex[i]->dSpacetimeVertex.X();
201 kinfitVertexY = kinfitVertex[i]->dSpacetimeVertex.Y();
202 kinfitVertexZ = kinfitVertex[i]->dSpacetimeVertex.Z();
209 for (
unsigned int i=0; i < locTrackTimeBased.size() ; ++i){
210 for (
unsigned int j=0; j< locFCALShowers.size(); ++j){
212 Double_t
x = locFCALShowers[j]->getPosition().X();
213 Double_t
y = locFCALShowers[j]->getPosition().Y();
216 if (locTrackTimeBased[i]->rt->GetIntersectionWithPlane(pos_FCAL,norm,pos,mom,NULL,NULL,NULL,
SYS_FCAL)==NOERROR)
218 Double_t trkmass = locTrackTimeBased[i]->mass();
219 Double_t FOM = TMath::Prob(locTrackTimeBased[i]->chisq, locTrackTimeBased[i]->Ndof);
220 Double_t dRho =
sqrt(((pos.X() -
x)*(pos.X() -
x)) + ((pos.Y() -
y)* (pos.Y() -
y)));
221 if(trkmass < 0.15 && dRho < 5 && FOM > 0.01 ) {
222 matchedShowers.push_back(locFCALShowers[j]);
230 japp->RootWriteLock();
232 if (locFCALShowers.size() >=2) {
234 for(
unsigned int i=0; i<locFCALShowers.size(); i++)
236 if (find(matchedShowers.begin(), matchedShowers.end(),locFCALShowers[i]) != matchedShowers.end())
continue;
240 vector<const DFCALCluster*> associated_clusters1;
242 s1->Get(associated_clusters1);
243 Double_t dx1 = s1->
getPosition().X() - kinfitVertexX;
244 Double_t dy1 = s1->
getPosition().Y() - kinfitVertexY;
245 Double_t dz1 = s1->
getPosition().Z() - kinfitVertexZ;
247 Double_t R1 =
sqrt(dx1*dx1 + dy1*dy1 + dz1*dz1);
250 TLorentzVector sh1_p(E1*dx1/R1, E1*dy1/R1, E1*dz1/R1, E1);
252 for(
unsigned int j=i+1; j<locFCALShowers.size(); j++){
254 if (find(matchedShowers.begin(), matchedShowers.end(),s2) != matchedShowers.end())
continue;
256 vector<const DFCALCluster*> associated_clusters2;
257 s2->Get(associated_clusters2);
258 Double_t dx2 = s2->
getPosition().X() - kinfitVertexX;
259 Double_t dy2 = s2->
getPosition().Y() - kinfitVertexY;
260 Double_t dz2 = s2->
getPosition().Z() - kinfitVertexZ;
262 Double_t R2 =
sqrt(dx2*dx2 + dy2*dy2 + dz2*dz2);
266 TLorentzVector sh2_p(E2*dx2/R2, E2*dy2/R2, E2*dz2/R2, E2);
267 TLorentzVector ptot = sh1_p+sh2_p;
268 Double_t inv_mass = ptot.M();
275 if(E1 < 1 || E2 < 1)
continue;
277 if(fabs(t1-t2) >= 10.)
continue;
280 if(inv_mass < 0.03 || inv_mass > 0.3)
continue;
282 if(inv_mass < MASS_CUT_LO || inv_mass >
MASS_CUT_HI)
continue;
290 for(
unsigned int loc_j = 0; loc_j < associated_clusters1.size(); loc_j++)
292 for(
unsigned int loc_jj = 0; loc_jj < associated_clusters2.size(); loc_jj++)
295 vector< DFCALCluster::DFCALClusterHit_t > hits1 = associated_clusters1[loc_j]->GetHits();
296 vector< DFCALCluster::DFCALClusterHit_t > hits2 = associated_clusters2[loc_jj]->GetHits();
301 vector< std::pair <double, pair<int,int> > > frac_en;
303 double e_sum1=0;
double e_sum2=0;
306 Int_t numhits_per_cluster1 = associated_clusters1[loc_j]->GetNHits();
307 Int_t numhits_per_cluster2 = associated_clusters2[loc_jj]->GetNHits();
312 if(numhits_per_cluster1 == 1 || numhits_per_cluster2 == 1)
continue;
313 for(
int i = 0; i < numhits_per_cluster1; ++i ){
326 for(
int i = 0; i < numhits_per_cluster2; ++i ){
346 for(
int i = 0; i < numhits_per_cluster1; ++i ){
347 int my_x = hits1[i].x;
348 int my_y = hits1[i].y;
349 double my_E = hits1[i].E;
353 frac_en.push_back(make_pair( (my_E / e_sum1), make_pair(my_x,my_y)));
356 for(
int i = 0; i < numhits_per_cluster2; ++i ){
357 int my_x = hits2[i].x ;
358 int my_y = hits2[i].y ;
359 double my_E = hits2[i].E;
361 frac_en.push_back(make_pair( (my_E / e_sum2), make_pair(my_x,my_y)));
364 for(
unsigned int i = 0; i < frac_en.size(); ++i) {
365 int my_x1 = (frac_en[i].second).first ;
366 int my_y1 = (frac_en[i].second).second ;
369 m_mD[my_index1][0] += -(inv_mass * inv_mass - m_pi0mass*
m_pi0mass)*(inv_mass * inv_mass)*frac_en[i].first;
370 m_mL[my_index1][0] += (inv_mass * inv_mass)*frac_en[i].first;
372 for(
unsigned int ii = 0; ii < frac_en.size(); ++ii) {
373 int my_x2 = (frac_en[ii].second).first;
374 int my_y2 = (frac_en[ii].second).second;
377 m_mC[my_index1][my_index2] += (inv_mass*inv_mass)*(inv_mass*inv_mass)*(frac_en[i].first)*(frac_en[ii].first);
TH1F * h1D_nhits_unordered
jerror_t brun(jana::JEventLoop *locEventLoop, int32_t locRunNumber)
Called every time a new run number is detected.
DFCALGeometry * m_fcalgeom
bool GetFCALZ(double &z_fcal) const
z-location of front face of CCAL in cm
int XYtoAbsNum(int my_x, int my_y)
pair< int, int > AbsNumtoXY(int channel)
DGeometry * GetDGeometry(unsigned int run_number)
int column(int channel) const
jerror_t evnt(jana::JEventLoop *locEventLoop, uint64_t locEventNumber)
Called every event.
jerror_t init(void)
Called once at program start.
int channel(int row, int column) const
jerror_t fini(void)
Called after last event of last event source has been processed.
int row(int channel) const
DVector3 getPosition() const
bool GetTargetZ(double &z_target) const
z-location of center of target
jerror_t erun(void)
Called every time run number changes, provided brun has been called.