15 #include "FairRunAna.h"
16 #include "FairRootManager.h"
17 #include "FairEventHeader.h"
19 #include "TClonesArray.h"
367 double E0[3] = {134.976, 493.677, 938.272};
373 return 1/
sqrt(2*
TMath::Pi()*rms*rms)*
exp(-0.5*((x-mean_value)/rms)*((x-mean_value)/rms));
382 for(
size_t i = 0;
i < values.size();
i++)
384 average += values[
i];
387 return average/double(values.size());
397 for(
size_t i = 0;
i < values.size();
i++)
399 average += (values[
i]-mean_value)*(values[
i]-mean_value);
402 average =
sqrt(1/(
double(values.size())-1)*average);
428 LOG(INFO) <<
"DiscDircTaskReconstruction::ReInit()";
437 LOG(INFO) <<
"PndDiscTaskReconstruction::Init()";
440 FairRootManager* io_manager = FairRootManager::Instance();
443 LOG(FATAL) <<
"FairRootManager instance is NULL !!!";
451 LOG(ERROR) <<
"Branch " <<
branch_name_digits.Data() <<
" is not accessible through FairRootManager.";
455 tclarr_particles = (TClonesArray*) io_manager->GetObject(
"DiscMCTruthTracks");
458 LOG(ERROR) <<
"No DiscDIRC_ParticleMCPoint collection registered with FairRootManager";
473 static bool recon_initialized =
false;
474 if(recon_initialized)
return kSUCCESS;
498 std::vector<double>
x0,
y0,px,py,
pz,
p;
500 std::vector<double>
t;
502 std::vector<std::vector<double > > mean_time;
503 std::vector<std::vector<double > > deviation_time;
513 for(
int i = 0;
i < particles;
i++)
517 x0.push_back(particle_mc_point->GetX());
518 y0.push_back(particle_mc_point->GetY());
520 px.push_back(particle_mc_point->GetPx());
521 py.push_back(particle_mc_point->GetPy());
522 pz.push_back(particle_mc_point->GetPz());
524 p.push_back(
sqrt(px[
i]*px[
i]+py[
i]*py[
i]+pz[
i]*pz[
i]));
526 t.push_back(particle_mc_point->GetTime());
528 theta.push_back(
acos(pz[i]/
sqrt(px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i])));
530 std::cout <<
"Primary particles:" << std::endl;
531 std::cout <<
"Particle pos: x = "<< x0[
i] << std::endl;
532 std::cout <<
"Particle pos: y = "<< y0[
i] << std::endl;
533 std::cout <<
"Particle mom: px = "<< px[
i] << std::endl;
534 std::cout <<
"Particle mom: py = "<< py[
i] << std::endl;
535 std::cout <<
"Particle mom: pz = "<< pz[
i] << std::endl;
536 std::cout <<
"Particle abs mom: p = "<< p[
i] << std::endl;
537 std::cout <<
"Particle time: t = "<< t[
i] << std::endl;
538 std::cout <<
"Particle angle: theta[deg] = " << theta[
i]*180/
TMath::Pi() << std::endl;
539 std::cout << std::endl;
548 for(
int i = 0;
i < particles;
i++)
550 for(
int j = 0; j < 3; j++)
552 std::cout <<
"Particle: " << j << std::endl;
553 for(
int k = 0; k < 108; k++)
555 double E =
sqrt(p[
i]*1000*p[
i]*1000 +
E0[j]*
E0[j]);
556 double gamma = E/
E0[j];
557 double beta =
sqrt(1-1/(gamma*gamma));
559 double cherenkov =
acos(1/(n*beta));
564 double phirel =
acos((dx*px[
i]+dy*py[
i])/(
sqrt(dx*dx+dy*dy)*
sqrt(px[i]*px[i]+py[i]*py[i])));
568 if(div(k,27).quot == 0 || div(k,27).quot == 3)
572 if(div(k,27).quot == 1 || div(k,27).quot == 2)
579 double delta =
sin(theta[i])*
cos(phirel);
580 double lambda = delta*delta+
cos(theta[i])*
cos(theta[i]);
581 double varphi =
acos(delta*
cos(cherenkov)/lambda+
sqrt((
cos(theta[i])*
cos(theta[i])-
cos(cherenkov)*
cos(cherenkov))/lambda+(delta*
cos(cherenkov)/lambda)*(delta*
cos(cherenkov)/lambda)));
582 double varphidash = atan(tan(varphi)/
cos(alpha));
584 int pixel = (
TMath::Pi()/2 - varphidash-0.8530931655)/0.0035321867;
586 double time = (
sqrt(dx*dx+dy*dy))/100/3e8*n/
cos(varphidash)*1e9;
589 if(pixel >= 0 && pixel <= 100)
592 std::cout <<
"Sensor: " << k <<
" Pixel: " << pixel <<
" Time: " << time << std::endl;
596 recon_result->
pixel = pixel;
597 recon_result->
time = time;
608 recon_result->
pixel = -1;
609 recon_result->
time = time;
615 std::cout << std::endl;
625 for(
int i = 0;
i < entries;
i++)
631 for(
int i = 0;
i < particles;
i++)
640 for(
int i = 0;
i < entries;
i++)
645 int sensor_id = 27*detector_id + sensor_mc_point->
GetReadoutID();
672 std::cout <<
"Hit informations:" << std::endl;
673 std::cout <<
"TDC Time [ns]: " << time << std::endl;
674 std::cout <<
"Detector ID: " << detector_id << std::endl;
675 std::cout <<
"Sensor ID: " << sensor_id << std::endl;
676 std::cout <<
"Sensor coor: x = " <<
pos_fel_x[sensor_id] <<
", y = " <<
pos_fel_y[sensor_id] << std::endl;
677 std::cout <<
"Pixel no: " << pixel << std::endl;
678 std::cout << std::endl;
682 std::cout <<
"DiscDIRC_TaskReconstruction::Exec\n";
friend F32vec4 acos(const F32vec4 &a)
TClonesArray * tclarr_particles_out
friend F32vec4 cos(const F32vec4 &a)
double gauss(int x, double mean, double rms)
friend F32vec4 exp(const F32vec4 &a)
const Int_t & GetReadoutID() const
Double_t lambda(Double_t x, Double_t y, Double_t z)
friend F32vec4 sqrt(const F32vec4 &a)
friend F32vec4 sin(const F32vec4 &a)
TString branch_name_digits
Branch name where digitized hits are stored.
virtual void Exec(Option_t *opt)
TString folder_name_digits
Folder name for digits.
const Double_t & GetTdcTime() const
virtual ~PndDiscTaskReconstruction()
PndDiscTaskReconstruction()
double mean(std::vector< double > values)
TClonesArray * tclarr_digits_out
TClonesArray * tclarr_digits
TClonesArray * tclarr_particles
to cache the pointer to particle MC TClonesArray returned by IO manager.
const Int_t & GetDetectorID() const
virtual InitStatus Init()
virtual void FinishTask()
virtual InitStatus ReInit()
const Int_t & GetPixelNumber() const
double deviation(double mean, std::vector< double > values)
TClonesArray * tclarr_recon_results
results of reconstruction (pattern matching)
virtual void FinishEvent()