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