FairRoot/PandaRoot
analysis_digi_cluster_allGammasAnalysis_fwendcap.C
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <vector>
4 #include "TF1.h"
5 
6 
8 {
9  TStopwatch timer;
10  timer.Start();
11 
12  gROOT->LoadMacro("$VMCWORKDIR/macro/mvd/Tools.C");
13  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
14 
15  TFile* fsim = new TFile("/home/moini/myPandaRoot/myCodes/ROOTfiles/h_c_channel/emc_complete_onlyFwEndCap.root");
16 
17  TTree *tsim=(TTree *) fsim->Get("pndsim") ;
18  TClonesArray* mctrack_array=new TClonesArray("PndMCTrack");
19  tsim->SetBranchAddress("MCTrack",&mctrack_array);
20 
21  TClonesArray* digi_array=new TClonesArray("PndEmcDigi");
22  tsim->SetBranchAddress("EmcDigi",&digi_array);
23 
24  TClonesArray* cluster_array=new TClonesArray("PndEmcCluster");
25  tsim->SetBranchAddress("EmcCluster",&cluster_array);
26 
27  TClonesArray* bump_array=new TClonesArray("PndEmcBump");
28  tsim->SetBranchAddress("EmcBump",&bump_array);
29 
32  TVector3 photon_momentum;
33  TLorentzVector p4mom;
34  Double_t clusterThresholdEnergy=0;
35 
36  TH1F *hene_mc= new TH1F("hene_mc","MC energy (GeV)",100,0.0,1.05);
37  TH1F *h10= new TH1F("h10"," Theta (MC)",180,0.,180.);
38  TH1F *h20= new TH1F("h20"," Phi (MC)",360,0.,360.);
39  TH1F *h10d= new TH1F("h10d"," Theta (data)",180,0.,180.);
40  TH1F *h20d= new TH1F("h20d"," Phi (data)",360,0.,360.);
41  TH1F *h1= new TH1F("h1"," Theta difference",100,-2.,2.);
42  TH1F *h2= new TH1F("h2"," Phi difference",100,-2.,2.);
43 
44  Int_t ncounts = tsim->GetEntriesFast();
45  cout << "Number of events = " << ncounts<< endl;
46  //ncounts=100; //in case you want to analyse specific number of events
47 
49  TH1F *HISTdigi_ene= new TH1F("HISTdigi_ene","FwEndCap energy (digi)",2000,0.0,2.05); // deposited energy per event in the whole FwEndCap
50  TH1F *HISTene_d= new TH1F("HISTene_d","energy (digi)",1000,0.0001,1.01); // deposited energy per digi in the whole FwEndCap
51  TH2F *HISTxpad_x_d = new TH2F("HISTxpad_x_d","xpad vs x (digi)",200,200,300,2*38.5,-38.5,38.5); // here x means: map of the x-position of the hit crystal
52  TH2F *HISTypad_y_d = new TH2F("HISTypad_y_d","ypad vs y (digi)",200,200,300,2*38.5,-38.5,38.5); // here y means: map of the y-position of the hit crystal
53  TH2F *HISTrow_x_d = new TH2F("HISTrow_x_d","row vs x (digi)",200,200,300,2*38.5,-38.5,38.5); // here x means: map of the x-position of the hit crystal
54  TH2F *HISTrow_crystal_d = new TH2F("HISTrow_crystal_d","row vs column (digi)",2*38.5,-38.5,38.5,2*38.5,-38.5,38.5);
55  TH2F *HISTy_x_d = new TH2F("HISTy_x_d","y vs x (digi map)",200,200,300,200,200,300); // here x and y mean: map of the y- and x-position of the hit crystal
56  TH1F *HISTOdigi_ene11_12= new TH1F("HISTOdigi_ene11_12","crystal [11,12] dep. energy (GeV)",100,0.0001,1.01);
57  TH1F *HISTOdigi_ene12_12= new TH1F("HISTOdigi_ene12_12","crystal [12,12] dep. energy (GeV)",100,0.0001,1.01);
58  TH1F *HISTOdigi_ene13_12= new TH1F("HISTOdigi_ene13_12","crystal [13,12] dep. energy (GeV)",100,0.0001,1.01);
59  TH1F *HISTOdigi_ene14_12= new TH1F("HISTOdigi_ene14_12","crystal [14,12] dep. energy (GeV)",100,0.0001,1.01);
60  TH1F *HISTtotdigis_fromClusterAnalysis = new TH1F("HISTtotdigis_fromClusterAnalysis","total number of digis per event",100,0,25);
61  TH1I *HISTmultiplicity_5MeVtrigThresh_d = new TH1I("HISTmultiplicity_5MeVtrigThresh_d","Crystal digi multiplicity per event (3 MeV detection threshold and considering 5 MeV trigger threshold)",40,0.5,40.5);
62  TH1I *HISTmultiplicity_10MeVtrigThresh_d = new TH1I("HISTmultiplicity_10MeVtrigThresh_d","Crystal digi multiplicity per event (3 MeV detection threshold and considering 10 MeV trigger threshold)",40,0.5,40.5);
63 
64  TH1I *HISTnumberOfClusters = new TH1I("HISTnumberOfClusters","Total number of clusters per event, having more than or equal to one digi per cluster",100,0,20);
65  TH1I *HISTclustNo = new TH1I("HISTclustNo","Total number of clusters per event, having more than one digi per cluster and satisfying the cluster threshold energy",1000,0,20);
66  TH1I *HISTndigisOfHighestEnergyCluster = new TH1I("HISTndigisOfHighestEnergyCluster","Number of digis per event for clusters with highest energy deposition",1000,0,30);
67  TH1F *HISTmax_cluster_energy= new TH1F("HISTOmax_cluster_energy","Maximum cluster energy deposition per event",500,0.,1.05);
68  TH1F *HISTmax_cluster_theta = new TH1F("HISTmax_cluster_theta","#theta per event of the cluster with maximum deposition energy",100,0,30);
69  TH1F *HISTmax_cluster_phi = new TH1F("HISTmax_cluster_phi","#phi per event of the cluster with maximum deposition energy",370,-185,185);
70  TH1F *HISTmax_cluster_x = new TH1F("HISTmax_cluster_x","x per event of the cluster with maximum deposition energy",220,-110,110);
71  TH1F *HISTmax_cluster_y = new TH1F("HISTmax_cluster_y","y per event of the cluster with maximum deposition energy",220,-110,110);
72  TH1F *HISTmax_cluster_z = new TH1F("HISTmax_cluster_z","z per event of the cluster with maximum deposition energy",80,208,216);
73  TH2F *HISTmax_cluster_y_x = new TH2F("HISTmax_cluster_y_x","y vs x per event of the cluster with maximum deposition energy",220,-110,110,220,-110,110);
74  TH1F *HISTtheta_MonteCarlo = new TH1F("HISTtheta_MonteCarlo","Monte Carlo #theta per event of the cluster with maximum deposition energy",100,0,30);
75  TH1F *HISTphi_MonteCarlo = new TH1F("HISTphi_MonteCarlo","Monte Carlo #phi per event of the cluster with maximum deposition energy",370,-185,185);
76  TH1F *HISTmax_cluster_theta_diff = new TH1F("HISTmax_cluster_theta_diff","Difference between Monte Carlo and reconstructed #theta per event of the cluster with maximum deposition energy",100,-5,5);
77  TH1F *HISTmax_cluster_phi_diff = new TH1F("HISTmax_cluster_phi_diff","Difference between Monte Carlo and reconstructed #phi per event of the cluster with maximum deposition energy",360,-5,5);
78  TH2F *HISTtheta_MonteCarlo_cluster = new TH2F("HISTtheta_MonteCarlo_cluster","Monte Carlo versus cluster #theta of the cluster with maximum deposition energy",100,0,30,100,0,30);
79  TH2F *HISTphi_MonteCarlo_cluster = new TH2F("HISTphi_MonteCarlo_cluster","Monte Carlo versus cluster #phi of the cluster with maximum deposition energy",370,-185,185,370,-185,185);
80  TH1F *HISTmax_cluster_x_diff = new TH1F("HISTmax_cluster_x_diff","Difference between Monte Carlo and reconstructed x per event of the cluster with maximum deposition energy",100,-5,5);
81  TH1F *HISTmax_cluster_y_diff = new TH1F("HISTmax_cluster_y_diff","Difference between Monte Carlo and reconstructed y per event of the cluster with maximum deposition energy",100,-5,5);
82  TH2F *HISTclusterSize_clusterPhi = new TH2F("HISTclusterSize_clusterPhi","number of digis vs cluster #phi for clusters with highest energy deposition",370,-185,185,100,0,25);
83  TH2F *HISTclusterEnergy_clusterPhi = new TH2F("HISTclusterEnergy_clusterPhi","cluster energy deposition vs cluster #phi for clusters with highest energy deposition",370,-185,185,500,0.,1.05);
84  TH2F *HISTnumberOfclusters_clusterPhi = new TH2F("HISTnumberOfclusters_clusterPhi","number of clusters vs cluster #phi for clusters with highest energy deposition",370,-185,185,100,0,20);
85  TH2F *HISTtotdigis_clusterPhi = new TH2F("HISTtotdigis_clusterPhi","total number of digis vs cluster #phi (#phi of clusters with highest energy deposition)",370,-185,185,100,0,25);
86 
87  TH1F *HISTinvariantMass = new TH1F("HISTinvariantMass","invariant mass of every two clusters (7 highest energy clusters in total)",3200,0,3.2);
88  TH2F *HISTinvariantMass_openingAngle = new TH2F("HISTinvariantMass_openingAngle","opening angle of the two clusters versus the invariant mass of the assumed two gammas that make the two clusters",3200,0,3.2,140,0,50);
89  TH1F *HIST_Egamma1Egamma2 = new TH1F("HIST_Egamma1Egamma2","E_{#gamma1} #times E_{#gamma2}",8000,0,8.);
90  TH2F *HIST_Egamma1vsEgamma2 = new TH2F("HIST_Egamma1vsEgamma2","E_{#gamma2} versus E_{#gamma1}",8000,0,8.,3200,0,3.2);
91  TH2F *HIST_Egamma1Egamma2_openingAngle = new TH2F("HIST_Egamma1Egamma2_openingAngle","opening angle of the two clusters versus E_{#gamma1} #times E_{#gamma2}",8000,0,8.,140,0,50);
92  TH2F *HISTinvariantMass_Egamma1Egamma2 = new TH2F("HISTinvariantMass_Egamma1Egamma2","E_{#gamma1} #times E_{#gamma2} versus the invariant mass of the two gammas",3200,0,3.2,8000,0,8.);
93  TH2F *HIST_Egamma1_Egamma1Egamma2 = new TH2F("HIST_Egamma1_Egamma1Egamma2","E_{#gamma1} #times E_{#gamma2} versus E_{#gamma1}",6400,0,6.4,8000,0,8.);
94  TH2F *HIST_Egamma1_openingAngle = new TH2F("HIST_Egamma1_openingAngle","opening angle of the two clusters versus E_{#gamma1}",6400,0,6.4,140,0,50);
95  TH3F *HISTinvariantMass_openingAngle_Egamma1Egamma2 = new TH3F("HISTinvariantMass_openingAngle_Egamma1Egamma2","",150,0,1.5,140,0,50,400,0,4.);
96 
97 
98  Int_t totaldigis=0; //counter on the total number of digis (fired detectors) in all events
99  Int_t efficiencyCounter_d=0;
100  Int_t atLeastOneHitPerEventCounter_d=0;
101 
102  for (int j = 0; j < ncounts; j++) {
103 
104  Int_t efficiencyFlag10MeV_d=0;
105  Int_t efficiencyFlag5MeV_d=0;
106  Int_t atLeastOneHitPerEventFlag_d=0;
107  Double_t sum_digi_ene=0;
108 
109  tsim->GetEntry(j);
110 
111  PndMCTrack *mctrack=(PndMCTrack *) mctrack_array->At(0);
112  photon_momentum=mctrack->GetMomentum();
113  theta_mc=photon_momentum.Theta()*(180./TMath::Pi());
114  phi_mc=photon_momentum.Phi()*(180./TMath::Pi());
115  //p4mom=mctrack->Get4Momentum();
116 /*
118  Int_t ndigis = digi_array->GetEntries();
119  totaldigis+=ndigis;
120  if (ndigis!=0)
121  atLeastOneHitPerEventFlag_d = 1;
122 
123  for (Int_t i=0; i<ndigis; i++)
124  {
125  PndEmcDigi *digi=(PndEmcDigi*)digi_array->At(i);
126  TVector3 digi_pos=digi->where();
127  module_d = digi->GetModule();
128  if (module_d==3){
129  //dene_mc->Fill(p4mom.E());
130 
131  digi_ene=digi->GetEnergy();
132  HISTene_d->Fill(digi_ene);
133  if (digi_ene >= 0.010) // 10 MeV trigger threshold used (here only) to calculate the efficiency of the FwEndCap geometry
134  efficiencyFlag10MeV_d = 1;
135  if (digi_ene >= 0.005) // 5 MeV trigger threshold used (here only) to calculate the efficiency of the FwEndCap geometry
136  efficiencyFlag5MeV_d = 1;
137 
138  //filling some histograms for a few crystals
139  if (digi->GetXPad()==11 && digi->GetYPad()==12)
140  HISTOdigi_ene11_12->Fill(digi_ene);
141  else if (digi->GetXPad()==12 && digi->GetYPad()==12)
142  HISTOdigi_ene12_12->Fill(digi_ene);
143  else if (digi->GetXPad()==13 && digi->GetYPad()==12)
144  HISTOdigi_ene13_12->Fill(digi_ene);
145  else if (digi->GetXPad()==14 && digi->GetYPad()==12)
146  HISTOdigi_ene14_12->Fill(digi_ene);
147 
148  if (digi_ene >= 0.010)
149  sum_digi_ene+=digi_ene;
150 
151  //Double_t digi_z=digi_pos.Z();
152  //hz_d->Fill(digi_z);
153 
154  digi_theta=(digi->GetTheta())*(180./TMath::Pi());
155  digi_phi=(digi->GetPhi())*(180./TMath::Pi());
156  //h10digi->Fill(theta_mc);
157  //h20digi->Fill(phi_mc);
158  //h10ddigi->Fill(digi_theta);
159  //h20ddigi->Fill(digi_phi);
160  //h1d->Fill(digi_theta-theta_mc);
161  //h2d->Fill(digi_phi-phi_mc);
162 
163  id_d = digi->GetDetectorId();
164  crystal_did = -(id_d%10000 - 36); //crystal column number (the same as GetXPad())
165  row_did = (id_d/1000000)%100 - 37; //crystal row number (the same as GetYPad())
166 
167  HISTxpad_x_d->Fill(digi->GetThetaInt(),digi->GetXPad());
168  HISTypad_y_d->Fill(digi->GetPhiInt(),digi->GetYPad());
169  HISTrow_x_d->Fill(digi->GetThetaInt(),digi->GetYPad());
170 
171  //hid_d->Fill(id_d);
172  //hmodule_d->Fill(module_d);
173  HISTrow_crystal_d->Fill(digi->GetXPad(),digi->GetYPad());
174  HISTy_x_d->Fill(digi->GetThetaInt(),digi->GetPhiInt());
175  }
176  }
177 
178  if (efficiencyFlag10MeV_d==1) //if the trigger threshold is satisfied
179  HISTdigi_ene->Fill(sum_digi_ene); // deposited energy per event in all digis (whole FwEndCap)
180 
181  if (efficiencyFlag10MeV_d==1)
182  {
183  efficiencyCounter_d+=1;
184  HISTmultiplicity_10MeVtrigThresh_d->Fill(ndigis); //10 MEV trigger threshold and 3 MeV detection threshold (in the level of digi this 3 MeV is already implemented)
185  }
186  if (efficiencyFlag5MeV_d==1)
187  HISTmultiplicity_5MeVtrigThresh_d->Fill(ndigis); //5 MEV trigger threshold and 3 MeV detection threshold (in the level of digi this 3 MeV is already implemented)
188 
189  if (atLeastOneHitPerEventFlag_d==1)
190  atLeastOneHitPerEventCounter_d+=1;
191 */
192 
194  Int_t NumberOfClusters, ClustNo, totdigis_fromClusterAnalysis, ndigisOfHighestEnergyCluster;
195  NumberOfClusters=ClustNo=totdigis_fromClusterAnalysis=ndigisOfHighestEnergyCluster=0; //set per event
196  Int_t idClusterSatisfiedThresholdEnergy=-1;
197  Double_t highestEnergy=0; // (set per event)
198  Double_t highestenergy_sumOfclusters=0; // (set per event)
199 
200  std::vector <double> highestenergy;
201  std::vector <double> cluster_x;
202  std::vector <double> cluster_y;
203  std::vector <double> cluster_z;
204  std::vector <double> cluster_dist;
205  std::vector <double> cluster_module;
206  std::vector <double> originalClusterIndex;
207 
208  if (cluster_array->GetEntriesFast() > 0)
209  {
210  NumberOfClusters=cluster_array->GetEntriesFast();
211  std::vector <double> clusterEnergies;
212  std::vector <double> clusterEnergies_original;
213 
214  for (Int_t i=0; i<NumberOfClusters; i++) //loop over all clusters of the present event under analysis (ndigi>=1)
215  {
216  PndEmcCluster *cluster=(PndEmcCluster*)cluster_array->At(i);
217  if (cluster->GetModule()==3)
218  {
219  Double_t cluster_energy=cluster->GetEnergyCorrected();//energy();
220  clusterEnergies.push_back(cluster_energy); //first push all the cluster energies into the vector; no sorting yet
221  clusterEnergies_original.push_back(cluster_energy); //make another one, in order to keep track of indices
222 
223  Int_t ndigi=cluster->NumberOfDigis(); // number of fired detectors inside the cluster
224  totdigis_fromClusterAnalysis += ndigi;
225  if (ndigi >= 1 && cluster_energy >= clusterThresholdEnergy) //by this definition for a cluster, ndigi should be more than 1
226  ClustNo++;
227 
228  /*if (cluster_energy > highestEnergy) //finding the cluster with highest deposited energy
229  {
230  idClusterSatisfiedThresholdEnergy = i;
231  highestEnergy = cluster_energy;
232  ndigisOfHighestEnergyCluster = ndigi;
233  }*/
234  }
235  }
236 
237  /*
238  // Per-event analysis of the cluster with highest deposited energy
239  if (idClusterSatisfiedThresholdEnergy != -1) {
240  PndEmcCluster *cluster=(PndEmcCluster*)cluster_array->At(idClusterSatisfiedThresholdEnergy);
241  TVector3 cluster_pos=cluster->where();
242  Double_t cluster_theta=cluster->theta()*(180./TMath::Pi()); //cluster_theta=cluster_pos.Theta()*(180./TMath::Pi());
243  Double_t cluster_phi=cluster->phi()*(180./TMath::Pi()); //cluster_phi=cluster_pos.Phi()*(180./TMath::Pi());
244  Double_t cluster_x=cluster->x();
245  Double_t cluster_y=cluster->y();
246  Double_t cluster_z=cluster->z();
247  Double_t cluster_energy=cluster->GetEnergyCorrected();//energy();
248  //sum_clus_ene+=cluster_energy; //sum up the highest deposited cluster energy of all events
249  HISTmax_cluster_energy->Fill(cluster_energy); //fill the highest deposited cluster energy per event
250  HISTmax_cluster_theta->Fill(cluster_theta); // reconstructed
251  HISTmax_cluster_theta_diff->Fill(cluster_theta-theta_mc);
252  //if (cluster_theta>10)
253  // {
254  HISTmax_cluster_phi->Fill(cluster_phi); // reconstructed
255  HISTmax_cluster_phi_diff->Fill(cluster_phi-phi_mc);
256  HISTmax_cluster_x->Fill(cluster_x); // reconstructed
257  HISTmax_cluster_y->Fill(cluster_y); // reconstructed
258  HISTmax_cluster_y_x->Fill(cluster_x,cluster_y);
259  HISTmax_cluster_z->Fill(cluster_z); // reconstructed
260  Double_t x_mc = cluster_z*TMath::Tan(theta_mc/180.*TMath::Pi())*TMath::Cos(phi_mc/180.*TMath::Pi());
261  Double_t y_mc = cluster_z*TMath::Tan(theta_mc/180.*TMath::Pi())*TMath::Sin(phi_mc/180.*TMath::Pi());
262  HISTmax_cluster_x_diff->Fill(cluster_x-x_mc);
263  HISTmax_cluster_y_diff->Fill(cluster_y-y_mc);
264  //}
265  HISTtheta_MonteCarlo->Fill(theta_mc);
266  HISTphi_MonteCarlo->Fill(phi_mc);
267  HISTtheta_MonteCarlo_cluster->Fill(cluster_theta,theta_mc);
268  HISTphi_MonteCarlo_cluster->Fill(cluster_phi,phi_mc);
269  HISTclusterSize_clusterPhi->Fill(cluster_phi,ndigisOfHighestEnergyCluster);
270  HISTclusterEnergy_clusterPhi->Fill(cluster_phi,cluster_energy);
271  HISTnumberOfclusters_clusterPhi->Fill(cluster_phi,NumberOfClusters);
272  HISTtotdigis_clusterPhi->Fill(cluster_phi,totdigis_fromClusterAnalysis);
273  }*/
274 
275  // Per-event analysis of all the clusters
276  std::sort(clusterEnergies.begin(), clusterEnergies.end()); //now sort it
277 
278  if (NumberOfClusters>=7) //finding at least 7 clusters
279  {
280  for (int k=0; k<NumberOfClusters; k++) //(k=0 corresponds to the cluster with biggest energy)
281  {
282  highestenergy.push_back(clusterEnergies[(NumberOfClusters-1)-k]);
283  //cout << "decsendingly sorted energy of cluster # " << k+1 << " = " << highestenergy[k] << '\n';
287 
288  for (int i=0; i<NumberOfClusters; i++)//finding the original cluster indices of the clusters
289  if (!(clusterEnergies_original[i]>highestenergy[k]) && !(clusterEnergies_original[i]<highestenergy[k]))//practically the equality sign
290  originalClusterIndex.push_back(i);
291 
292  PndEmcCluster *cluster=(PndEmcCluster*)cluster_array->At(originalClusterIndex[k]);
293  TVector3 cluster_pos=cluster->where();
294  cluster_x.push_back(cluster->x());
295  cluster_y.push_back(cluster->y());
296  cluster_z.push_back(cluster->z());
297  cluster_dist.push_back(cluster_pos.Mag());//distance of the center of the cluster to the target point
298 
299  }
300 
301  for (int k0=1; k0<NumberOfClusters; k0++)
302  {
303  Double_t cosTheta = (1./cluster_dist[0]/cluster_dist[k0])*(cluster_x[0]*cluster_x[k0]+cluster_y[0]*cluster_y[k0]+cluster_z[0]*cluster_z[k0]);
304  Double_t invMass = sqrt(2*highestenergy[0]*highestenergy[k0]*(1-cosTheta));
305  HISTinvariantMass->Fill(invMass);
306  HISTinvariantMass_openingAngle->Fill(invMass,acos(cosTheta)*180/3.1415926535);
307  HIST_Egamma1Egamma2->Fill(highestenergy[0]*highestenergy[k0]);// (E_gamma1)(E_gamma2)
308  HIST_Egamma1vsEgamma2->Fill(highestenergy[0],highestenergy[k0]);// E_gamma1 versus E_gamma2
309  HIST_Egamma1Egamma2_openingAngle->Fill(highestenergy[0]*highestenergy[k0],acos(cosTheta)*180/3.1415926535);
310  HISTinvariantMass_Egamma1Egamma2->Fill(invMass,highestenergy[0]*highestenergy[k0]);
311  HIST_Egamma1_Egamma1Egamma2->Fill(highestenergy[0],highestenergy[0]*highestenergy[k0]);
312  HIST_Egamma1_openingAngle->Fill(highestenergy[0],acos(cosTheta)*180/3.1415926535);
313  HISTinvariantMass_openingAngle_Egamma1Egamma2->Fill(invMass,acos(cosTheta)*180/3.1415926535,highestenergy[0]*highestenergy[k0]);
314  }
315  for (int k1=2; k1<NumberOfClusters; k1++)
316  {
317  Double_t cosTheta = (1./cluster_dist[1]/cluster_dist[k1])*(cluster_x[1]*cluster_x[k1]+cluster_y[1]*cluster_y[k1]+cluster_z[1]*cluster_z[k1]);
318  Double_t invMass = sqrt(2*highestenergy[1]*highestenergy[k1]*(1-cosTheta));
319  HISTinvariantMass->Fill(invMass);
320  HISTinvariantMass_openingAngle->Fill(invMass,acos(cosTheta)*180/3.1415926535);
321  HIST_Egamma1Egamma2->Fill(highestenergy[1]*highestenergy[k1]);// (E_gamma1)(E_gamma2)
322  HIST_Egamma1vsEgamma2->Fill(highestenergy[1],highestenergy[k1]);// E_gamma1 versus E_gamma2
323  HIST_Egamma1Egamma2_openingAngle->Fill(highestenergy[1]*highestenergy[k1],acos(cosTheta)*180/3.1415926535);
324  HISTinvariantMass_Egamma1Egamma2->Fill(invMass,highestenergy[1]*highestenergy[k1]);
325  HIST_Egamma1_Egamma1Egamma2->Fill(highestenergy[1],highestenergy[1]*highestenergy[k1]);
326  HIST_Egamma1_openingAngle->Fill(highestenergy[1],acos(cosTheta)*180/3.1415926535);
327  HISTinvariantMass_openingAngle_Egamma1Egamma2->Fill(invMass,acos(cosTheta)*180/3.1415926535,highestenergy[1]*highestenergy[k1]);
328  }
329  for (int k2=3; k2<NumberOfClusters; k2++)
330  {
331  Double_t cosTheta = (1./cluster_dist[2]/cluster_dist[k2])*(cluster_x[2]*cluster_x[k2]+cluster_y[2]*cluster_y[k2]+cluster_z[2]*cluster_z[k2]);
332  Double_t invMass = sqrt(2*highestenergy[2]*highestenergy[k2]*(1-cosTheta));
333  HISTinvariantMass->Fill(invMass);
334  HISTinvariantMass_openingAngle->Fill(invMass,acos(cosTheta)*180/3.1415926535);
335  HIST_Egamma1Egamma2->Fill(highestenergy[2]*highestenergy[k2]);// (E_gamma1)(E_gamma2)
336  HIST_Egamma1vsEgamma2->Fill(highestenergy[2],highestenergy[k2]);// E_gamma1 versus E_gamma2
337  HIST_Egamma1Egamma2_openingAngle->Fill(highestenergy[2]*highestenergy[k2],acos(cosTheta)*180/3.1415926535);
338  HISTinvariantMass_Egamma1Egamma2->Fill(invMass,highestenergy[2]*highestenergy[k2]);
339  HIST_Egamma1_Egamma1Egamma2->Fill(highestenergy[2],highestenergy[2]*highestenergy[k2]);
340  HIST_Egamma1_openingAngle->Fill(highestenergy[2],acos(cosTheta)*180/3.1415926535);
341  HISTinvariantMass_openingAngle_Egamma1Egamma2->Fill(invMass,acos(cosTheta)*180/3.1415926535,highestenergy[2]*highestenergy[k2]);
342  }
343  for (int k3=4; k3<NumberOfClusters; k3++)
344  {
345  Double_t cosTheta = (1./cluster_dist[3]/cluster_dist[k3])*(cluster_x[3]*cluster_x[k3]+cluster_y[3]*cluster_y[k3]+cluster_z[3]*cluster_z[k3]);
346  Double_t invMass = sqrt(2*highestenergy[3]*highestenergy[k3]*(1-cosTheta));
347  HISTinvariantMass->Fill(invMass);
348  HISTinvariantMass_openingAngle->Fill(invMass,acos(cosTheta)*180/3.1415926535);
349  HIST_Egamma1Egamma2->Fill(highestenergy[3]*highestenergy[k3]);// (E_gamma1)(E_gamma2)
350  HIST_Egamma1vsEgamma2->Fill(highestenergy[3],highestenergy[k3]);// E_gamma1 versus E_gamma2
351  HIST_Egamma1Egamma2_openingAngle->Fill(highestenergy[3]*highestenergy[k3],acos(cosTheta)*180/3.1415926535);
352  HISTinvariantMass_Egamma1Egamma2->Fill(invMass,highestenergy[3]*highestenergy[k3]);
353  HIST_Egamma1_Egamma1Egamma2->Fill(highestenergy[3],highestenergy[3]*highestenergy[k3]);
354  HIST_Egamma1_openingAngle->Fill(highestenergy[3],acos(cosTheta)*180/3.1415926535);
355  HISTinvariantMass_openingAngle_Egamma1Egamma2->Fill(invMass,acos(cosTheta)*180/3.1415926535,highestenergy[3]*highestenergy[k3]);
356  }
357  for (int k4=5; k4<NumberOfClusters; k4++)
358  {
359  Double_t cosTheta = (1./cluster_dist[4]/cluster_dist[k4])*(cluster_x[4]*cluster_x[k4]+cluster_y[4]*cluster_y[k4]+cluster_z[4]*cluster_z[k4]);
360  Double_t invMass = sqrt(2*highestenergy[4]*highestenergy[k4]*(1-cosTheta));
361  HISTinvariantMass->Fill(invMass);
362  HISTinvariantMass_openingAngle->Fill(invMass,acos(cosTheta)*180/3.1415926535);
363  HIST_Egamma1Egamma2->Fill(highestenergy[4]*highestenergy[k4]);// (E_gamma1)(E_gamma2)
364  HIST_Egamma1vsEgamma2->Fill(highestenergy[4],highestenergy[k4]);// E_gamma1 versus E_gamma2
365  HIST_Egamma1Egamma2_openingAngle->Fill(highestenergy[4]*highestenergy[k4],acos(cosTheta)*180/3.1415926535);
366  HISTinvariantMass_Egamma1Egamma2->Fill(invMass,highestenergy[4]*highestenergy[k4]);
367  HIST_Egamma1_Egamma1Egamma2->Fill(highestenergy[4],highestenergy[4]*highestenergy[k4]);
368  HIST_Egamma1_openingAngle->Fill(highestenergy[4],acos(cosTheta)*180/3.1415926535);
369  HISTinvariantMass_openingAngle_Egamma1Egamma2->Fill(invMass,acos(cosTheta)*180/3.1415926535,highestenergy[4]*highestenergy[k4]);
370  }
371  for (int k5=6; k5<NumberOfClusters; k5++)
372  {
373  Double_t cosTheta = (1./cluster_dist[5]/cluster_dist[k5])*(cluster_x[5]*cluster_x[k5]+cluster_y[5]*cluster_y[k5]+cluster_z[5]*cluster_z[k5]);
374  Double_t invMass = sqrt(2*highestenergy[5]*highestenergy[k5]*(1-cosTheta));
375  HISTinvariantMass->Fill(invMass);
376  HISTinvariantMass_openingAngle->Fill(invMass,acos(cosTheta)*180/3.1415926535);
377  HIST_Egamma1Egamma2->Fill(highestenergy[5]*highestenergy[k5]);// (E_gamma1)(E_gamma2)
378  HIST_Egamma1vsEgamma2->Fill(highestenergy[5],highestenergy[k5]);// E_gamma1 versus E_gamma2
379  HIST_Egamma1Egamma2_openingAngle->Fill(highestenergy[5]*highestenergy[k5],acos(cosTheta)*180/3.1415926535);
380  HISTinvariantMass_Egamma1Egamma2->Fill(invMass,highestenergy[5]*highestenergy[k5]);
381  HIST_Egamma1_Egamma1Egamma2->Fill(highestenergy[5],highestenergy[5]*highestenergy[k5]);
382  HIST_Egamma1_openingAngle->Fill(highestenergy[5],acos(cosTheta)*180/3.1415926535);
383  HISTinvariantMass_openingAngle_Egamma1Egamma2->Fill(invMass,acos(cosTheta)*180/3.1415926535,highestenergy[5]*highestenergy[k5]);
384  }
385  }
386  }
387 
388  //hz_clust->Fill(cluster->z());
389 
390  if (NumberOfClusters>0)
391  HISTnumberOfClusters->Fill(NumberOfClusters); //number of clusters per event, having more than or equal to one digi per cluster
392  if (ClustNo>0)
393  HISTclustNo->Fill(ClustNo); //number of clusters per event, having more than one digi per cluster and satisfying the cluster threshold energy
394  if (ndigisOfHighestEnergyCluster>0)
395  HISTndigisOfHighestEnergyCluster->Fill(ndigisOfHighestEnergyCluster); //number of digis per event for clusters with highest energy deposition
396 
397  HISTtotdigis_fromClusterAnalysis->Fill(totdigis_fromClusterAnalysis);
398 
399  if (j%1000 ==0)
400  cout<<"Evt. No. "<< j<<endl;
401  }
402  //cout<<"totaldigis = "<<totaldigis<<"\n";
403  //cout<<"efficiencyCounter_d = "<<efficiencyCounter_d<<" , atLeastOneHitPerEventCounter_d = "<<atLeastOneHitPerEventCounter_d<<"\n";
404  //cout<<"FwEndCap efficiency (more than 10 MeV deposition in at least one crystal) = "<< (double)efficiencyCounter_d/atLeastOneHitPerEventCounter_d<<"\n";
405 
406 
408  gStyle->SetPalette(1);
409 
410 
411 
412 /*
413  TCanvas* c3 = new TCanvas("c3","", 100, 100, 800, 800);
414  c3->Divide(3,2);
415  c3->cd(1);
416  HISTOdigi_ene11_12->Draw();
417  c3->cd(2);
418  HISTOdigi_ene12_12->Draw();
419  c3->cd(3);
420  HISTOdigi_ene13_12->Draw();
421  c3->cd(4);
422  HISTOdigi_ene14_12->Draw();
423  c3->cd(5);
424  HISTene_d->Draw();
425  HISTene_d->GetXaxis()->SetTitle("FwEndCap Deposited Energy per digi (digi analysis)");
426  c3->cd(6);
427  HISTdigi_ene->SetLineColor(1);
428  HISTdigi_ene->Draw();
429  HISTdigi_ene->GetXaxis()->SetTitle("FwEndCap Deposited Energy per event (digi analysis)");
430  */
431 
432  /*
433  TCanvas* c4 = new TCanvas("c4","", 100, 100, 800, 800);
434  c4->Divide(3,2);
435  c4->cd(1);
436  HISTy_x_d->Draw("colz");
437  c4->cd(2);
438  HISTrow_crystal_d->Draw("colz");
439  c4->cd(3);
440  HISTxpad_x_d->Draw("colz");
441  c4->cd(4);
442  HISTypad_y_d->Draw("colz");
443  c4->cd(5);
444  HISTrow_x_d->Draw("colz");
445  */
446 
447  /*
448  TCanvas* c5 = new TCanvas("c5","", 100, 100, 800, 800);
449  c5->Divide(4,4);
450  c5->cd(1);
451  HISTnumberOfClusters->Draw("");
452  c5->cd(2);
453  HISTclustNo->Draw("");
454  c5->cd(3);
455  HISTndigisOfHighestEnergyCluster->Draw("");
456  c5->cd(4);
457  HISTmax_cluster_energy->Draw("");
458  c5->cd(5);
459  HISTtheta_MonteCarlo->Draw("");
460  c5->cd(6);
461  HISTphi_MonteCarlo->Draw("");
462  c5->cd(7);
463  HISTtheta_MonteCarlo_cluster->Draw("colz");
464  c5->cd(8);
465  HISTphi_MonteCarlo_cluster->Draw("colz");
466  c5->cd(9);
467  HISTmax_cluster_theta->Draw("");
468  c5->cd(10);
469  HISTmax_cluster_phi->Draw("");
470  c5->cd(11);
471  HISTmax_cluster_theta_diff->Draw("");
472  c5->cd(12);
473  HISTmax_cluster_phi_diff->Draw("");
474  c5->cd(13);
475  HISTmax_cluster_x->Draw("");
476  c5->cd(14);
477  HISTmax_cluster_y->Draw("");
478  c5->cd(15);
479  //HISTmax_cluster_z->Draw("");
480  HISTmax_cluster_x_diff->Draw("");
481  c5->cd(16);
482  HISTmax_cluster_y_diff->Draw("");
483 
484  TCanvas* c55 = new TCanvas("c55","", 100, 100, 800, 800);
485  HISTmax_cluster_y_x->Draw("colz");
486  */
487 
488  /* TCanvas* c6 = new TCanvas("c6","", 100, 100, 800, 800);
489  c6->Divide(2,2);
490  c6->cd(1);
491  HISTclusterSize_clusterPhi->Draw("colz");
492  c6->cd(2);
493  HISTclusterEnergy_clusterPhi->Draw("colz");
494  c6->cd(3);
495  HISTnumberOfclusters_clusterPhi->Draw("colz");
496  c6->cd(4);
497  HISTtotdigis_clusterPhi->Draw("colz");
498  //HISTtotdigis_fromClusterAnalysis->Draw();
499  */
500 
501  /*
502  TCanvas* c8 = new TCanvas("c8","", 100, 100, 1200, 800);
503  c8->Divide(2,2);
504  c8->cd(1);
505  HISTmultiplicity_5MeVtrigThresh_d->Draw();
506  c8->cd(2);
507  HISTmultiplicity_10MeVtrigThresh_d->Draw();
508 */
509 
510 
511  TCanvas* c10 = new TCanvas("c10","", 100, 100, 1200, 800);
512  c10->Divide(2,4);
513  c10->cd(1)->SetLogy();
514  HISTinvariantMass->Draw();
515  c10->cd(2)->SetLogy();
516  HIST_Egamma1Egamma2->Draw();
517  c10->cd(3)->SetLogz();
518  HIST_Egamma1vsEgamma2->Draw("colz");
519  c10->cd(4)->SetLogz();
520  HISTinvariantMass_openingAngle->Draw("colz");
521  c10->cd(5)->SetLogz();
522  HIST_Egamma1Egamma2_openingAngle->Draw("colz");
523  c10->cd(6)->SetLogz();
524  HIST_Egamma1_openingAngle->Draw("colz");
525  c10->cd(7)->SetLogz();
526  HIST_Egamma1_Egamma1Egamma2->Draw("colz");
527  c10->cd(8)->SetLogz();
528  HISTinvariantMass_Egamma1Egamma2->Draw("colz");
529 
530  TCanvas* c100 = new TCanvas("c100","", 100, 100, 1200, 800);
531  HISTinvariantMass_openingAngle_Egamma1Egamma2->Draw("Box");
532  HISTinvariantMass_openingAngle_Egamma1Egamma2->GetXaxis()->SetTitle("m_{#gamma#gamma}");
533  HISTinvariantMass_openingAngle_Egamma1Egamma2->GetXaxis()->SetTitleOffset(1.5);
534  HISTinvariantMass_openingAngle_Egamma1Egamma2->GetYaxis()->SetTitle("opening angle");
535  HISTinvariantMass_openingAngle_Egamma1Egamma2->GetYaxis()->SetTitleOffset(1.5);
536  HISTinvariantMass_openingAngle_Egamma1Egamma2->GetZaxis()->SetTitle("E_{#gamma1} #times E_{#gamma2}");
537  HISTinvariantMass_openingAngle_Egamma1Egamma2->GetZaxis()->SetTitleOffset(1.1);
538 
540  TString outfile= "./invMass_histo_allGammasAnalysis_onlyFwEndCapIncluded_GetEnergyCorrected.root";
541  TFile* file_out = new TFile(outfile,"RECREATE");
542 
543  HISTinvariantMass->Write();
544  HISTinvariantMass_openingAngle->Write();
545  HIST_Egamma1Egamma2->Write();
546  HIST_Egamma1vsEgamma2->Write();
547  HIST_Egamma1Egamma2_openingAngle->Write();
548  HISTinvariantMass_Egamma1Egamma2->Write();
549  HIST_Egamma1_Egamma1Egamma2->Write();
550  HIST_Egamma1_openingAngle->Write();
551  HISTinvariantMass_openingAngle_Egamma1Egamma2->Write();
552 
553  file_out->Close();
554 
555  timer.Stop();
556  Double_t rtime = timer.RealTime();
557  Double_t ctime = timer.CpuTime();
558  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
559  return 0;
560 }
561 
PndMCTrack * mctrack
friend F32vec4 acos(const F32vec4 &a)
Definition: P4_F32vec4.h:113
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
Double_t theta_mc
Double_t crystal_did
TVector3 where() const
Int_t i
Definition: run_full.C:25
TVector3 photon_momentum
Short_t GetModule() const
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
TClonesArray * digi_array
TCanvas * c10
TVector3 GetMomentum() const
Definition: PndMCTrack.h:78
Double_t z() const
Double_t digi_ene
TClonesArray * cluster_array
Double_t
TStopwatch timer
Definition: hit_dirc.C:51
Double_t cluster_energy
Double_t x() const
Double_t row_did
a cluster (group of neighboring crystals) of hit emc crystals
Definition: PndEmcCluster.h:29
Double_t ctime
Definition: hit_dirc.C:114
Double_t digi_theta
Int_t NumberOfDigis() const
Double_t GetEnergyCorrected() const
TClonesArray * bump_array
Definition: bump_analys.C:14
TClonesArray * mctrack_array
TLorentzVector p4mom
Double_t rtime
Definition: hit_dirc.C:113
Double_t Pi
Double_t module_d
Double_t digi_phi
Double_t y() const
TString outfile