10 #include <TLorentzVector.h>
100 InitJANAPlugin(locApplication);
121 TDirectory *
main = gDirectory;
122 gDirectory->mkdir(
"bcal_eff")->cd();
128 h1_Num_matched_showers =
new TH1I(
"h1_Num_matched_showers",
"Number of matched showers per event", 20,0,20);
169 h1trk_FOM =
new TH1I(
"h1trk_FOM",
"FOM for matched tracks", nbins,0,1);
172 h1trk_pmag =
new TH1I(
"h1trk_mag",
"pmag for matched tracks", nbins,0,4);
175 h1trk_px =
new TH1I(
"h1trk_px",
"px for matched tracks", nbins,0,2);
178 h1trk_py =
new TH1I(
"h1trk_py",
"py for matched tracks", nbins,0,2);
179 h1trk_py->SetXTitle(
"Number of tracks");
181 h1trk_pz =
new TH1I(
"h1trk_pz",
"pz for matched tracks", nbins,0,4);
184 h1trk_energy =
new TH1I(
"h1trk_energy",
"energy for matched tracks", nbins,0,4);
188 h2_Evsenergy =
new TH2I(
"h2_Evsenergy",
"E vs energy matched tracks", nbins,0,4,nbins,0,4);
191 h2_pmagvsenergy =
new TH2I(
"h2_pmagvsenergy",
"pmag vs energy matched tracks", nbins,0,4,nbins,0,4);
196 h1pt_Num_points =
new TH1I(
"h1pt_Num_points",
"pt points per Shower",20,0,20);
199 h1pt_module =
new TH1I(
"h1pt_module",
"pt module number",50,0,50);
202 h1pt_layer =
new TH1I(
"h1pt_layer",
"pt layer number",5,0,5);
205 h1pt_sector =
new TH1I(
"h1pt_sector",
"pt sector number",5,0,5);
208 h1pt_cell_id =
new TH1I(
"h1pt_cell_id",
"pt cell id number",800,0,800);
211 h1pt_energy =
new TH1I(
"h1pt_energy",
"pt energy",nbins,0,1);
214 h1pt_energy_US =
new TH1I(
"h1pt_energy_US",
"pt energy US",nbins,0,1);
217 h1pt_energy_DS =
new TH1I(
"h1pt_energy_DS",
"pt energy DS",nbins,0,1);
221 h1eff_layertot =
new TH1I(
"h1eff_layertot",
"eff layertot",5,0,5);
225 h1eff_layer =
new TH1I(
"h1eff_layer",
"eff layer hit",5,0,5);
229 h1eff_eff =
new TH1F(
"h1eff_eff",
"efficiency",5,0,5);
234 h1eff_cellidtot =
new TH1I(
"h1eff_cellidtot",
"eff cellidtot",200,0,200);
238 h1eff_cellid =
new TH1I(
"h1eff_cellid",
"eff cellid hit",200,0,200);
251 h1eff2_layer =
new TH1I(
"h1eff2_layer",
"eff2 layer hit",5,0,5);
255 h1eff2_eff2 =
new TH1F(
"h1eff2_eff2",
"eff2 efficiency",5,0,5);
260 h1eff2_cellidtot =
new TH1I(
"h1eff2_cellidtot",
"eff2 cellidtot",200,0,200);
264 h1eff2_cellid =
new TH1I(
"h1eff2_cellid",
"eff2 cellid hit",200,0,200);
273 h1E_US_layer1 =
new TH1I(
"h1E_US_layer1",
"E US layer1",nbins,0,1);
276 h1E_DS_layer1 =
new TH1I(
"h1E_DS_layer1",
"E DS layer1",nbins,0,1);
279 h2E_USvsDS_layer1 =
new TH2I(
"h2E_USvsDS_layer1",
"E US vs DS ",nbins,0,1,nbins,0,1);
358 locEventLoop->GetSingle(locTrigger);
362 vector<const DTrackFitter *> fitters;
363 locEventLoop->Get(fitters);
365 if(fitters.size()<1){
366 _DBG_<<
"Unable to get a DTrackFinder object!"<<endl;
367 return RESOURCE_UNAVAILABLE;
372 vector<const DBCALShower*> locBCALShowers;
373 vector<const DBCALHit*> bcalhits;
374 vector<const DBCALPoint*> locBCALPoints;
375 vector<const DVertex*> kinfitVertex;
378 locEventLoop->Get(locBCALShowers);
379 locEventLoop->Get(bcalhits);
380 locEventLoop->Get(locBCALPoints);
381 locEventLoop->Get(kinfitVertex);
383 vector<const DTrackTimeBased*> locTrackTimeBased;
384 locEventLoop->Get(locTrackTimeBased);
386 vector <const DBCALShower *> matchedShowers;
387 vector < const DBCALShower *> matchedShowersneg;
388 vector < const DBCALShower *> matchedShowerspos;
389 vector <const DTrackTimeBased* > matchedTracks;
392 for (
unsigned int i=0; i < locTrackTimeBased.size() ; ++i){
393 vector<DTrackFitter::Extrapolation_t>extrapolations=locTrackTimeBased[i]->extrapolations.at(
SYS_BCAL);
394 if (extrapolations.size()>0){
395 for (
unsigned int j=0; j< locBCALShowers.size(); ++j){
396 double x = locBCALShowers[j]->x;
397 double y = locBCALShowers[j]->y;
398 double z = locBCALShowers[j]->z;
401 double R = pos_bcal.Perp();
402 double phi = pos_bcal.Phi();
406 locTrackTimeBased[i]->momentum().Mag();
407 double trkmass = locTrackTimeBased[i]->mass();
409 double dPhi = mypos.Phi()-phi;
410 if (dPhi<-M_PI) dPhi+=2.*M_PI;
411 if (dPhi>M_PI) dPhi-=2.*M_PI;
412 double dZ = TMath::Abs(mypos.Z() - z);
418 if(dZ < 30.0 && fabs(dPhi) < 0.18 && trkmass < 0.15) {
419 matchedShowers.push_back(locBCALShowers[j]);
420 matchedTracks.push_back(locTrackTimeBased[i]);
430 japp->RootFillLock(
this);
438 #if 0 // disabling since it doesn't do anything other than cause compiler warnings 10/15/2015 DL
439 double kinfitVertexX, kinfitVertexY, kinfitVertexZ, kinfitVertexT;
440 for (
unsigned int i = 0 ; i < kinfitVertex.size(); i++)
442 kinfitVertexX = kinfitVertex[i]->dSpacetimeVertex.X();
443 kinfitVertexY = kinfitVertex[i]->dSpacetimeVertex.Y();
444 kinfitVertexZ = kinfitVertex[i]->dSpacetimeVertex.Z();
445 kinfitVertexT = kinfitVertex[i]->dSpacetimeVertex.T();
452 Int_t numshowers_per_event = matchedShowers.size();
454 Int_t numtracks_per_event = matchedTracks.size();
458 for(
int i=0; i<numshowers_per_event; i++){
461 Float_t E = matchedShowers[i]->E;
487 double FOM = matchedTracks[i]->FOM;
488 double pmag = matchedTracks[i]->pmag();
489 double px = matchedTracks[i]->px();
490 double py = matchedTracks[i]->py();
491 double pz = matchedTracks[i]->pz();
492 double energy = matchedTracks[i]->energy();
504 vector <int> matchedShowers_modules;
509 vector<const DBCALPoint*> points;
510 matchedShowers[i]->Get(points);
511 matchedShowers_modules.clear();
514 Int_t numpoints_per_shower = points.size();
523 for (
int jj=0; jj<numpoints_per_shower; jj++) {
525 int module = points[jj]->module();
526 int layer = points[jj]->layer();
527 int sector = points[jj]->sector();
529 int cell_id = (module-1)*16 + (layer-1)*4 + sector;
531 double energy = points[jj]->E();
532 double energy_US = points[jj]->E_US();
533 double energy_DS = points[jj]->E_DS();
544 if (layer == 1) pointlayer1 = 1;
545 if (layer == 2) pointlayer2 = 2;
546 if (layer == 3) pointlayer3 = 3;
547 if (layer == 4) pointlayer4 = 4;
551 bool module_in_list =
false;
552 for (
unsigned int jjj=0; jjj<matchedShowers_modules.size(); jjj++) {
553 if (module == matchedShowers_modules[jjj]) module_in_list =
true;
555 if (!module_in_list) matchedShowers_modules.push_back(module);
562 if (pointlayer2 + pointlayer3 + pointlayer4 > 0) {
565 int cellid = (module_ndx-1)*4 + 1;
570 if (pointlayer3 + pointlayer4 > 0) {
573 int cellid = (module_ndx-1)*4 + 2;
577 if (pointlayer4 > 0) {
580 int cellid = (module_ndx-1)*4 + 3;
585 if (pointlayer1 + pointlayer2 + pointlayer3 > 3) {
588 int cellid = (module_ndx-1)*4 + 4;
599 Int_t hitmodule_ndx=0;
601 for (
unsigned int jjj=0; jjj<bcalhits.size(); jjj++) {
602 int module = bcalhits[jjj]->module;
606 if (bcalhits[jjj]->end == 0)
h1E_US_layer1->Fill(bcalhits[jjj]->E);
607 if (bcalhits[jjj]->end == 1)
h1E_DS_layer1->Fill(bcalhits[jjj]->E);
610 bool module_in_list =
false;
611 for (
unsigned int k=0; k<matchedShowers_modules.size(); k++) {
612 if (module == matchedShowers_modules[k]) module_in_list =
true;
614 if (!module_in_list)
continue;
616 int layer = bcalhits[jjj]->layer;
621 if (layer == 1) hitlayer1 = 1;
622 if (layer == 2) hitlayer2 = 2;
623 if (layer == 3) hitlayer3 = 3;
624 if (layer == 4) hitlayer4 = 4;
625 hitmodule_ndx = module;
631 if (hitlayer2 + hitlayer3 + hitlayer4 > 0) {
634 int cellid = (hitmodule_ndx-1)*4 + 1;
639 if (hitlayer3 + hitlayer4 > 0) {
642 int cellid = (hitmodule_ndx-1)*4 + 2;
649 int cellid = (hitmodule_ndx-1)*4 + 3;
654 if (hitlayer1 + hitlayer2 + hitlayer3 > 3) {
657 int cellid = (hitmodule_ndx-1)*4 + 4;
666 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, int locRunNumber)
Called every time a new run number is detected.
jerror_t evnt(jana::JEventLoop *locEventLoop, uint64_t locEventNumber)
Called every event.
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.
jerror_t init(void)
Called once at program start.
static TH2I * h2_pmagvsenergy
uint32_t Get_L1FrontPanelTriggerBits(void) const
jerror_t fini(void)
Called after last event of last event source has been processed.
static TH1I * h1trk_energy
static TH1I * h1pt_energy_DS
static TH1I * h1pt_energy_US
static TH1I * h1E_US_layer1
static TH1I * h1pt_module
static TH1I * h1pt_energy
static TH1I * h1pt_sector
static TH2I * h2_Evsenergy
static TH1I * h1_Num_matched_showers
const DTrackFitter * fitter
jerror_t erun(void)
Called every time run number changes, provided brun has been called.
static TH1I * h1pt_cell_id
static TH1I * h1trk_Num_matched_tracks
static TH1I * h1pt_Num_points
static TH1I * h1E_DS_layer1
int main(int argc, char *argv[])
static TH2I * h2E_USvsDS_layer1