10 #include <TLorentzVector.h>
34 InitJANAPlugin(locApplication);
51 int m_nElements = 768;
53 h2D_mC =
new TH2F(
"h2D_mC",
"C Matrix as TH2F ", n_channels, 0.0, n_channels, n_channels, 0.0, n_channels);
54 h1D_mD =
new TH1F(
"h1D_mD",
"D Matrix as TH1F", n_channels, 0.0, n_channels);
55 h1D_mL =
new TH1F(
"h1D_mL",
" L Matrix as TH1F", n_channels, 0.0, n_channels);
56 h1D_massbias =
new TH1F(
"h1D_massbias",
"Mass Bias Value (in bin 2)",5,0.0,5.0);
57 h1D_nhits =
new TH1F(
"h1D_nhits",
"Number of hits as function of channel number", n_channels,0,n_channels);
61 m_mD.ResizeTo(m_nElements,1);
62 m_mC.ResizeTo(m_nElements,m_nElements);
63 m_mL.ResizeTo(m_nElements,1);
64 m_nhits.ResizeTo(m_nElements,1);
150 vector<const DTrackFitter *> fitters;
151 locEventLoop->Get(fitters);
153 if(fitters.size()<1){
154 _DBG_<<
"Unable to get a DTrackFinder object!"<<endl;
155 return RESOURCE_UNAVAILABLE;
163 locEventLoop->GetSingle(locTrigger);
167 vector<const DBCALShower*> locBCALShowers;
168 vector<const DBCALCluster*> locBCALClusters;
169 vector<const DBCALPoint*> locBCALPoints;
170 vector<const DVertex*> locVertex;
171 locEventLoop->Get(locBCALShowers);
172 locEventLoop->Get(locBCALClusters);
173 locEventLoop->Get(locBCALPoints);
174 locEventLoop->Get(locVertex);
176 vector<const DTrackTimeBased*> locTrackTimeBased;
177 locEventLoop->Get(locTrackTimeBased);
182 vector <const DBCALShower *> matchedShowers;
184 for (
unsigned int i=0; i < locTrackTimeBased.size() ; ++i){
185 for (
unsigned int j=0; j< locBCALShowers.size(); ++j){
186 double x = locBCALShowers[j]->x;
187 double y = locBCALShowers[j]->y;
188 double z = locBCALShowers[j]->z;
190 double R = pos_bcal.Perp();
191 vector<DTrackFitter::Extrapolation_t>extrapolations=locTrackTimeBased[i]->extrapolations.at(
SYS_BCAL);
194 double dPhi=mypos.Phi()-pos_bcal.Phi();
195 if (dPhi<-M_PI) dPhi+=2.*M_PI;
196 if (dPhi>M_PI) dPhi-=2.*M_PI;
197 double dZ = TMath::Abs(mypos.Z() - z);
198 if(dZ < 30.0 && fabs(dPhi) < 0.18) matchedShowers.push_back(locBCALShowers[j]);
206 for (
unsigned int i = 0 ; i < locVertex.size(); i++)
208 vertexX = locVertex[i]->dSpacetimeVertex.X();
209 vertexY = locVertex[i]->dSpacetimeVertex.Y();
210 vertexZ = locVertex[i]->dSpacetimeVertex.Z();
216 japp->RootWriteLock();
218 for(
unsigned int i=0; i<locBCALShowers.size(); i++){
219 double pi0_mass = 0.1349766;
220 if (find(matchedShowers.begin(), matchedShowers.end(),locBCALShowers[i]) != matchedShowers.end())
continue;
222 vector<const DBCALPoint*> associated_points1;
223 s1->Get(associated_points1);
232 double R1 =
sqrt(dx1*dx1 + dy1*dy1 + dz1*dz1);
235 TLorentzVector sh1_p(
E1*dx1/R1,
E1*dy1/R1,
E1*dz1/R1,
E1);
238 for(
unsigned int j=i+1; j<locBCALShowers.size(); j++){
240 if (find(matchedShowers.begin(), matchedShowers.end(),s2) != matchedShowers.end())
continue;
241 vector<const DBCALPoint*> associated_points2;
242 s2->Get(associated_points2);
251 double R2 =
sqrt(dx2*dx2 + dy2*dy2 + dz2*dz2);
254 TLorentzVector sh2_p(
E2*dx2/R2,
E2*dy2/R2,
E2*dz2/R2,
E2);
256 double cospsi = (dx1*dx2+dy1*dy2+dz1*dz2)/R1/R2;
258 TLorentzVector ptot = sh1_p+sh2_p;
259 TLorentzVector ptot_raw = sh1_p_raw + sh2_p_raw ;
270 for(
unsigned int loc_k = 0; loc_k < associated_points1.size(); loc_k++){
271 int module1 = associated_points1[loc_k]->module();
272 int layer1 = associated_points1[loc_k]->layer();
273 int sector1 = associated_points1[loc_k]->sector();
274 double energy1_US = associated_points1[loc_k]->E_US();
275 double energy1_DS = associated_points1[loc_k]->E_DS();
276 int channel1 = 16*(module1-1)+4*(layer1-1)+(sector1-1);
280 for(
unsigned int loc_p = 0 ; loc_p < associated_points2.size(); loc_p++){
281 int module2 = associated_points2[loc_p]->module();
282 int layer2 = associated_points2[loc_p]->layer();
283 int sector2 = associated_points2[loc_p]->sector();
284 double energy2_US = associated_points2[loc_p]->E_US();
285 double energy2_DS = associated_points2[loc_p]->E_DS();
286 int channel2 = 16*(module2-1)+4*(layer2-1)+(sector2-1);
300 for (
unsigned int a = 0 ; a <
frac_en.size() ; ++a){
303 if(inv_mass_raw>0.12&&inv_mass_raw<.15&&E1_raw>1.&&
E2_raw>1.&&
num_tracks>0 &&frac_en[a].first > 0.0 && frac_en[a].first < 30.0 )
m_mL[frac_en[a].second][0] += (inv_mass_raw*
inv_mass_raw)*frac_en[a].first;
304 if(inv_mass_raw > 0.12 && inv_mass_raw <.15 && E1_raw>1.&&
E2_raw>1.&&
num_tracks>0 && frac_en[a].first > 0.0 && frac_en[a].first < 30.0 )
m_nhits[frac_en[a].second] += 1;
306 for(
unsigned int b = 0 ; b < frac_en.size(); ++b)
308 if(inv_mass_raw>.12&&inv_mass_raw<.15&&E1_raw>1.&&
E2_raw>1.&&
num_tracks>0 && frac_en[a].first > 0.0 && frac_en[a].first < 30.0&& frac_en[b].first > 0.0 && frac_en[b].first < 30.0 )
m_mC[frac_en[a].second][frac_en[b].second] += (inv_mass_raw*inv_mass_raw*inv_mass_raw*
inv_mass_raw)*(frac_en[a].first)*(frac_en[b].first);
335 japp->RootFillLock(
this);
337 int n_channels = 768;
339 h1D_nhits =
new TH1F(
"h1D_nhits",
"Number of hits as function of channel number", n_channels,0,767);
343 for(
int i=0; i<n_channels; i++){
349 for(
int j=0; j<n_channels; j++){
354 japp->RootFillUnLock(
this);
bool ExtrapolateToRadius(double R, const vector< Extrapolation_t > &extraps, DVector3 &pos, DVector3 &mom, double &t, double &s) const
jerror_t brun(jana::JEventLoop *locEventLoop, int32_t locRunNumber)
Called every time a new run number is detected.
vector< double > point2_channel
The DTrackFitter class is a base class for different charged track fitting algorithms. It does not actually fit the track itself, but provides the interface and some common support features most algorthims will need to implement.
const DEventWriterROOT * dEventWriterROOT
uint32_t Get_L1FrontPanelTriggerBits(void) const
jerror_t erun(void)
Called every time run number changes, provided brun has been called.
vector< double > point1_energy_calib
jerror_t init(void)
Called once at program start.
jerror_t fini(void)
Called after last event of last event source has been processed.
const DEventWriterREST * dEventWriterREST
vector< double > point1_channel
vector< double > point_energy
jerror_t evnt(jana::JEventLoop *locEventLoop, uint64_t locEventNumber)
Called every event.
vector< double > point2_energy_calib
vector< pair< double, int > > frac_en
const DTrackFitter * fitter