FairRoot/PandaRoot
QAmacro_emc_3.C
Go to the documentation of this file.
1 #include "../auxi.C"
3 {
4  // Macro loads a file after reconstruction and plots difference between initial direction of particle and angular position of cluster
6  // The following part of macro access RunTimeDataBase and initialize PndEmcMapper from it
8  FairRunAna *fRun= new FairRunAna();
9  fRun->SetInputFile("sim_emc.root");
10  fRun->SetOutputFile("dummy_out.root");
11 
12  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
13  FairParRootFileIo* parInput1 = new FairParRootFileIo();
14  parInput1->open("simparams.root");
15 
16  TString emcAsciiPar = gSystem->Getenv("VMCWORKDIR");
17  emcAsciiPar += "/macro/params/";
18  emcAsciiPar += "emc.par";
19 
20  FairParAsciiFileIo* parInput2 = new FairParAsciiFileIo();
21  parInput2->open(emcAsciiPar.Data(),"in");
22 
23  rtdb->setFirstInput(parInput1);
24  rtdb->setSecondInput(parInput2);
25 
26  PndEmcGeoPar *geoPar = (PndEmcGeoPar*) rtdb->getContainer("PndEmcGeoPar");
27  fRun->Init();
28 
29  geoPar->InitEmcMapper();
30  std::cout<<""<<std::endl;
32 
33  TFile* f = new TFile("full_emc.root"); //file you want to analyse
34  TTree *t=(TTree *) f->Get("pndsim") ;
35 
36  TClonesArray* cluster_array=new TClonesArray("PndEmcCluster");
37  t->SetBranchAddress("EmcCluster",&cluster_array);
38  TClonesArray* digi_array=new TClonesArray("PndEmcDigi");
39  t->SetBranchAddress("EmcDigi",&digi_array);
40 
41  TFile* fsim = new TFile("sim_emc.root"); //file you want to analyse
42  TTree *tsim=(TTree *) fsim->Get("pndsim") ;
43 
44  TClonesArray* mctrack_array=new TClonesArray("PndMCTrack");
45  tsim->SetBranchAddress("MCTrack",&mctrack_array);
46 
47  TVector3 photon_momentum;
48 
49  double cluster_energy;
50  double cluster_energy_calibrated;
51  double cluster_theta, cluster_phi; //position of the cluster
52  double theta, phi; // angular position of the initial particle
53  double theta_diff, phi_diff;
54  int ndigi, npoint;
55  double max_energy=0;
56 
57  TH1F *ht=new TH1F("ht","Theta distribution",200,0.,180);
58  TH1F *h1= new TH1F("h1","Theta difference",200,-5.,5.);
59  TH1F *h2= new TH1F("h2","Phi difference",200,-5.,5.);
60  TH1F *h3= new TH1F("h3","Cluster energy",100,0.85,1.05);
61  TH2F *h2theta= new TH2F("h2theta","Theta difference",200,0.,180.,200,-5.,5.);
62  TH2F *h2phi= new TH2F("h2phi","Phi difference",200,0.,180.,200,-5.,5.);
63  TH1F *hE1= new TH1F("hE1","E1",200,0.,1.05);
64  TH1F *hE1E9= new TH1F("hE1E9","E1 / E9",200,0.,1.05);
65  TH1F *hE9E25= new TH1F("hE9E25","E9 / E25",200,0.,1.05);
66 
67  // Cluster angular position
68  // Entrance point is determined by minimal time
69 
70  // Calibrartor version 3 corresponds to non-uniformity of light collection switched on
72 
73  // Cluster energy
74  for (Int_t j=0; j< t->GetEntriesFast(); j++)
75  {
76  t->GetEntry(j);
77  for (Int_t i=0; i<cluster_array->GetEntriesFast(); i++)
78  {
79  PndEmcCluster *cluster=(PndEmcCluster*)cluster_array->At(i);
80  cluster_energy=cluster->energy();
81  cluster_energy_calibrated=calibrator1->Energy(cluster);
82  if ((cluster->NumberOfDigis()>1)&&(cluster_energy>0.02))
83  h3->Fill(cluster_energy_calibrated);
84  PndEmcClusterEnergySums esum(*cluster, digi_array);
85  hE1->Fill(esum.E1());
86  hE1E9->Fill(esum.E1E9());
87  hE9E25->Fill(esum.E9E25());
88  TVector3 cluster_pos=cluster->where();
89  ht->Fill(cluster_pos.Theta()*180./3.1415);
90  }
91  }
92 
93  for (Int_t j=0; j< t->GetEntriesFast(); j++)//t->GetEntriesFast()
94  {
95  t->GetEntry(j);
96  tsim->GetEntry(j);
97 
98  PndMCTrack *mctrack=(PndMCTrack *) mctrack_array->At(0);
99  photon_momentum=mctrack->GetMomentum();
100  theta=photon_momentum.Theta();
101  phi=photon_momentum.Phi();
102 
103 
104  // Loop over clusters
105  // If we have 1 initial particle and several cluster
106  // we can separate cluster from the first interaction by maximum energy
107 
108  max_energy=0;
109 
110  for (Int_t i=0; i<cluster_array->GetEntriesFast(); i++)
111  {
112  PndEmcCluster *cluster=(PndEmcCluster*)cluster_array->At(i);
113  cluster_energy=cluster->energy();
114  if (cluster_energy>max_energy)
115  {
116  max_energy=cluster_energy;
117  TVector3 cluster_pos=cluster->where();
118  cluster_theta=cluster_pos.Theta();
119  cluster_phi=cluster_pos.Phi();
120  }
121 
122  }
123  if (max_energy>0.6)
124  {
125  //cluster_theta-
126  theta_diff=(cluster_theta-theta)*180./TMath::Pi();
127  h1->Fill(theta_diff);
128  h2theta->Fill(theta*TMath::RadToDeg(),theta_diff);
129  //cluster_phi-
130  phi_diff=(cluster_phi-phi)*180./TMath::Pi();
131  h2->Fill(phi_diff);
132  h2phi->Fill(theta*TMath::RadToDeg(),phi_diff);
133  }
134  }
135 
136 Bool_t fTest=kTRUE;
137 
138 Double_t thetaCheckMean=h1->GetMean();
139 Double_t thetaCheckRMS=h1->GetRMS();
140 
141 if (TMath::Abs(thetaCheckMean)<0.1 && thetaCheckRMS<0.7 && thetaCheckRMS>0.1)
142 {
143  cout<<"\n Theta Diff - ACCEPTABLE "<<endl;
144 }
145 else
146 {
147  cout<<" \n Theta Diff - SOMETHING WENT WRONG "<<endl;
148  cout<<" Theta mean = " << thetaCheckMean << endl;
149  cout<<" Theta RMS = " << thetaCheckRMS << endl;
150  fTest=kFALSE;
151 }
152 
153 Double_t phiCheckMean=h2->GetMean();
154 Double_t phiCheckRMS=h2->GetRMS();
155 
156 if (TMath::Abs(phiCheckMean)<0.1 && phiCheckRMS<1.0 && phiCheckRMS>0.2)
157 {
158  cout<<"\n Phi Diff - ACCEPTABLE "<<endl;
159 }
160 else
161 {
162  cout<<" \n Phi Diff - SOMETHING WENT WRONG "<<endl;
163  cout<<" Phi mean = " << phiCheckMean << endl;
164  cout<<" Phi RMS = " << phiCheckRMS << endl;
165  fTest=kFALSE;
166 }
167 
168 Double_t energyCheckMean=h3->GetMean();
169 Double_t energyCheckRMS=h3->GetRMS();
170 
171 if (energyCheckMean<1.02 && TMath::Abs(1.0-energyCheckMean)<0.06 && energyCheckRMS<0.04 && energyCheckRMS>0.01)
172 {
173  cout<<"\n Cluster Energy - ACCEPTABLE "<<endl;
174 }
175 else
176 {
177  cout<<" \n Cluster Energy - SOMETHING WENT WRONG "<<endl;
178  cout<<" Energy mean = " << energyCheckMean << endl;
179  cout<<" Energy RMS = " << energyCheckRMS << endl;
180  fTest=kFALSE;
181 }
182 
183  if (ht->GetBinContent(15)==0)
184  {
185  fTest = kFALSE;
186  cout << "\n FW endcap absent - BAD" << endl;
187  }
188 
189 if (fTest){
190  cout << " Test passed" << endl;
191  cout << " All ok " << endl;
192 }else{
193  cout << " Test Failed" << endl;
194  cout << " Not Ok " << endl;
195 }
196  CloseGeoManager();
197  return 0;
198 }
199 
PndMCTrack * mctrack
TVector3 where() const
Int_t i
Definition: run_full.C:25
TVector3 photon_momentum
PndMvdGeoPar * geoPar
TClonesArray * digi_array
TVector3 GetMomentum() const
Definition: PndMCTrack.h:78
virtual Double_t Energy(PndEmcCluster *clust, Int_t pid=22)=0
void InitEmcMapper()
void CloseGeoManager()
Definition: QA/auxi.C:11
FairRunAna * fRun
Definition: hit_dirc.C:58
static T Abs(const T &x)
Definition: PndCAMath.h:39
virtual Double_t E1() const
Double_t cluster_theta
int npoint
TClonesArray * cluster_array
Double_t
Double_t cluster_energy
TFile * f
Definition: bump_analys.C:12
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
static PndEmcAbsClusterCalibrator * MakeEmcClusterCalibrator(Int_t method, Int_t version=1)
Double_t cluster_phi
FairParAsciiFileIo * parInput2
Definition: conMvdDigi.C:26
a cluster (group of neighboring crystals) of hit emc crystals
Definition: PndEmcCluster.h:29
TH1F * h3
FairParRootFileIo * parInput1
Definition: hit_dirc.C:67
Int_t NumberOfDigis() const
virtual Double_t E1E9() const
int QAmacro_emc_3()
Definition: QAmacro_emc_3.C:2
virtual Double_t energy() const
TTree * t
Definition: bump_analys.C:13
virtual Double_t E9E25() const
TClonesArray * mctrack_array
Double_t Pi