FairRoot/PandaRoot
analysis_digi_cluster_7gammaAnalysis_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 (7 highest energy clusters in total)",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_sumOf7clusters=0; // (set per event)
200 
201  Double_t highestenergy[7], cluster_x_7[7], cluster_y_7[7],cluster_z_7[7],cluster_dist_7[7],cluster_module_7[7];
202  for (int k=0; k<7;k++){
203  highestenergy[k]=0; // (set per event)
204  cluster_x_7[k]=cluster_y_7[k]=cluster_z_7[k]=cluster_dist_7[k]=cluster_module_7[k]=-1000; // (set per event)
205  }
206 
207  Int_t originalClusterIndex[7];
208  for (int k=0; k<7;k++)
209  originalClusterIndex[k]=-1; //stores the original indices of the 7 clusters with biggest energies (set per event)
210 
211  if (cluster_array->GetEntriesFast() > 0)
212  {
213  NumberOfClusters=cluster_array->GetEntriesFast(); //in all 5 modules
214  totClusters+=NumberOfClusters; //in all 5 modules
215  std::vector <double> clusterEnergies;
216  std::vector <double> clusterEnergies_original;
217 
218  for (Int_t i=0; i<NumberOfClusters; i++) //loop over all clusters of the present event under analysis (ndigi>=1)
219  {
220  PndEmcCluster *cluster=(PndEmcCluster*)cluster_array->At(i);
221  if (cluster->GetModule()!=5)
222  {
223  NumberOfClusters_noModule5++; //in all modules except for module 5
224  if (cluster->GetModule()==3 || cluster->GetModule()==4 || cluster->GetModule()==1 || cluster->GetModule()==2)//Full Emc except for shashlyk
225  {
226  moduleDistribution->Fill(cluster->GetModule());
227 
228  Double_t cluster_energy=cluster->GetEnergyCorrected();//energy();
229  clusterEnergies.push_back(cluster_energy); //first, push all the cluster energies into the vector; no sorting yet
230  clusterEnergies_original.push_back(cluster_energy); //make another one, in order to keep track of indices
231 
232  Int_t ndigi=cluster->NumberOfDigis(); // number of fired detectors inside the cluster
233  totdigis_fromClusterAnalysis += ndigi;
234  if (ndigi >= 1 && cluster_energy >= clusterThresholdEnergy) //by this definition for a cluster, ndigi is considered to be >= 1
235  ClustNo++;
236 
237  /* if (cluster_energy > highestEnergy) //finding the cluster with highest deposited energy
238  {
239  idClusterSatisfiedThresholdEnergy = i;
240  highestEnergy = cluster_energy;
241  ndigisOfHighestEnergyCluster = ndigi;
242  }*/
243  }
244  }
245  }
246 
247  /*
248  // Per-event analysis of the cluster with highest deposited energy
249  if (idClusterSatisfiedThresholdEnergy != -1) {
250  PndEmcCluster *cluster=(PndEmcCluster*)cluster_array->At(idClusterSatisfiedThresholdEnergy);
251  TVector3 cluster_pos=cluster->where();
252  Double_t cluster_theta=cluster->theta()*(180./TMath::Pi()); //cluster_theta=cluster_pos.Theta()*(180./TMath::Pi());
253  Double_t cluster_phi=cluster->phi()*(180./TMath::Pi()); //cluster_phi=cluster_pos.Phi()*(180./TMath::Pi());
254  Double_t cluster_x=cluster->x();
255  Double_t cluster_y=cluster->y();
256  Double_t cluster_z=cluster->z();
257  Double_t cluster_energy=cluster->GetEnergyCorrected();//energy();
258  //sum_clus_ene+=cluster_energy; //sum up the highest deposited cluster energy of all events
259  HISTmax_cluster_energy->Fill(cluster_energy); //fill the highest deposited cluster energy per event
260  HISTmax_cluster_theta->Fill(cluster_theta); // reconstructed
261  HISTmax_cluster_theta_diff->Fill(cluster_theta-theta_mc);
262  //if (cluster_theta>10)
263  // {
264  HISTmax_cluster_phi->Fill(cluster_phi); // reconstructed
265  HISTmax_cluster_phi_diff->Fill(cluster_phi-phi_mc);
266  HISTmax_cluster_x->Fill(cluster_x); // reconstructed
267  HISTmax_cluster_y->Fill(cluster_y); // reconstructed
268  HISTmax_cluster_y_x->Fill(cluster_x,cluster_y);
269  HISTmax_cluster_z->Fill(cluster_z); // reconstructed
270  Double_t x_mc = cluster_z*TMath::Tan(theta_mc/180.*TMath::Pi())*TMath::Cos(phi_mc/180.*TMath::Pi());
271  Double_t y_mc = cluster_z*TMath::Tan(theta_mc/180.*TMath::Pi())*TMath::Sin(phi_mc/180.*TMath::Pi());
272  HISTmax_cluster_x_diff->Fill(cluster_x-x_mc);
273  HISTmax_cluster_y_diff->Fill(cluster_y-y_mc);
274  //}
275  HISTtheta_MonteCarlo->Fill(theta_mc);
276  HISTphi_MonteCarlo->Fill(phi_mc);
277  HISTtheta_MonteCarlo_cluster->Fill(cluster_theta,theta_mc);
278  HISTphi_MonteCarlo_cluster->Fill(cluster_phi,phi_mc);
279  HISTclusterSize_clusterPhi->Fill(cluster_phi,ndigisOfHighestEnergyCluster);
280  HISTclusterEnergy_clusterPhi->Fill(cluster_phi,cluster_energy);
281  HISTnumberOfclusters_clusterPhi->Fill(cluster_phi,NumberOfClusters);
282  HISTtotdigis_clusterPhi->Fill(cluster_phi,totdigis_fromClusterAnalysis);
283  }*/
284 
285  // Per-event analysis of the 7 clusters with highest deposited energy
286  std::sort(clusterEnergies.begin(), clusterEnergies.end()); //now sort all the recognized clusters in the 4 modules
287 
288  if (NumberOfClusters_noModule5>=7) //finding at least 7 clusters on modules 1,2,3,4 in total
289  {
290  for (int k=0; k<7; k++) //finding the first 7 biggest cluster energies (k=0 corresponds to the cluster with biggest energy)
291  {
292  highestenergy[k] = clusterEnergies[(NumberOfClusters_noModule5-1)-k];
293  //cout << "decsendingly sorted energy of cluster # " << k+1 << " = " << highestenergy[k] << '\n';
297 
298  for (int i=0; i<NumberOfClusters_noModule5; i++) //finding the original cluster indices of the 7 biggest energy clusters
299  if (!(clusterEnergies_original[i]>highestenergy[k]) && !(clusterEnergies_original[i]<highestenergy[k]))//practically the equality sign
300  {
301  originalClusterIndex[k]=i;
302  //cout<<"originalClusterIndex["<<k<<"] = "<<i<<endl;
303  }
304 
305  PndEmcCluster *cluster=(PndEmcCluster*)cluster_array->At(originalClusterIndex[k]);
306  TVector3 cluster_pos=cluster->where();
307  cluster_x_7[k]=cluster->x();
308  cluster_y_7[k]=cluster->y();
309  cluster_z_7[k]=cluster->z();
310  cluster_dist_7[k]=cluster_pos.Mag();//distance of the center of the cluster to the target point
311  cluster_module_7[k]=cluster->GetModule();
312  }
313 
314  for (int k0=1; k0<7; k0++)
315  {
316  //if (cluster_module_7[0] != cluster_module_7[k0])
317  {
318  Double_t cosTheta = (1./cluster_dist_7[0]/cluster_dist_7[k0])*(cluster_x_7[0]*cluster_x_7[k0]+cluster_y_7[0]*cluster_y_7[k0]+cluster_z_7[0]*cluster_z_7[k0]);
319  Double_t invMass = sqrt(2*highestenergy[0]*highestenergy[k0]*(1-cosTheta));
320  HISTinvariantMass->Fill(invMass);
321  HISTinvariantMass_openingAngle->Fill(invMass,acos(cosTheta)*180/3.1415926535);
322  HIST_Egamma1Egamma2->Fill(highestenergy[0]*highestenergy[k0]);// (E_gamma1)(E_gamma2)
323  HIST_Egamma1vsEgamma2->Fill(highestenergy[0],highestenergy[k0]);// E_gamma1 versus E_gamma2
324  HIST_Egamma1Egamma2_openingAngle->Fill(highestenergy[0]*highestenergy[k0],acos(cosTheta)*180/3.1415926535);
325  HISTinvariantMass_Egamma1Egamma2->Fill(invMass,highestenergy[0]*highestenergy[k0]);
326  HIST_Egamma1_Egamma1Egamma2->Fill(highestenergy[0],highestenergy[0]*highestenergy[k0]);
327  HIST_Egamma1_openingAngle->Fill(highestenergy[0],acos(cosTheta)*180/3.1415926535);
328  HISTinvariantMass_openingAngle_Egamma1Egamma2->Fill(invMass,acos(cosTheta)*180/3.1415926535,highestenergy[0]*highestenergy[k0]);
329  }
330  }
331  for (int k1=2; k1<7; k1++)
332  {
333  //if (cluster_module_7[1] != cluster_module_7[k1])
334  {
335  Double_t cosTheta = (1./cluster_dist_7[1]/cluster_dist_7[k1])*(cluster_x_7[1]*cluster_x_7[k1]+cluster_y_7[1]*cluster_y_7[k1]+cluster_z_7[1]*cluster_z_7[k1]);
336  Double_t invMass = sqrt(2*highestenergy[1]*highestenergy[k1]*(1-cosTheta));
337  HISTinvariantMass->Fill(invMass);
338  HISTinvariantMass_openingAngle->Fill(invMass,acos(cosTheta)*180/3.1415926535);
339  HIST_Egamma1Egamma2->Fill(highestenergy[1]*highestenergy[k1]);// (E_gamma1)(E_gamma2)
340  HIST_Egamma1vsEgamma2->Fill(highestenergy[1],highestenergy[k1]);// E_gamma1 versus E_gamma2
341  HIST_Egamma1Egamma2_openingAngle->Fill(highestenergy[1]*highestenergy[k1],acos(cosTheta)*180/3.1415926535);
342  HISTinvariantMass_Egamma1Egamma2->Fill(invMass,highestenergy[1]*highestenergy[k1]);
343  HIST_Egamma1_Egamma1Egamma2->Fill(highestenergy[1],highestenergy[1]*highestenergy[k1]);
344  HIST_Egamma1_openingAngle->Fill(highestenergy[1],acos(cosTheta)*180/3.1415926535);
345  HISTinvariantMass_openingAngle_Egamma1Egamma2->Fill(invMass,acos(cosTheta)*180/3.1415926535,highestenergy[1]*highestenergy[k1]);
346  }
347  }
348  for (int k2=3; k2<7; k2++)
349  {
350  //if (cluster_module_7[2] != cluster_module_7[k2])
351  {
352  Double_t cosTheta = (1./cluster_dist_7[2]/cluster_dist_7[k2])*(cluster_x_7[2]*cluster_x_7[k2]+cluster_y_7[2]*cluster_y_7[k2]+cluster_z_7[2]*cluster_z_7[k2]);
353  Double_t invMass = sqrt(2*highestenergy[2]*highestenergy[k2]*(1-cosTheta));
354  HISTinvariantMass->Fill(invMass);
355  HISTinvariantMass_openingAngle->Fill(invMass,acos(cosTheta)*180/3.1415926535);
356  HIST_Egamma1Egamma2->Fill(highestenergy[2]*highestenergy[k2]);// (E_gamma1)(E_gamma2)
357  HIST_Egamma1vsEgamma2->Fill(highestenergy[2],highestenergy[k2]);// E_gamma1 versus E_gamma2
358  HIST_Egamma1Egamma2_openingAngle->Fill(highestenergy[2]*highestenergy[k2],acos(cosTheta)*180/3.1415926535);
359  HISTinvariantMass_Egamma1Egamma2->Fill(invMass,highestenergy[2]*highestenergy[k2]);
360  HIST_Egamma1_Egamma1Egamma2->Fill(highestenergy[2],highestenergy[2]*highestenergy[k2]);
361  HIST_Egamma1_openingAngle->Fill(highestenergy[2],acos(cosTheta)*180/3.1415926535);
362  HISTinvariantMass_openingAngle_Egamma1Egamma2->Fill(invMass,acos(cosTheta)*180/3.1415926535,highestenergy[2]*highestenergy[k2]);
363  }
364  }
365  for (int k3=4; k3<7; k3++)
366  {
367  //if (cluster_module_7[3] != cluster_module_7[k3])
368  {
369  Double_t cosTheta = (1./cluster_dist_7[3]/cluster_dist_7[k3])*(cluster_x_7[3]*cluster_x_7[k3]+cluster_y_7[3]*cluster_y_7[k3]+cluster_z_7[3]*cluster_z_7[k3]);
370  Double_t invMass = sqrt(2*highestenergy[3]*highestenergy[k3]*(1-cosTheta));
371  HISTinvariantMass->Fill(invMass);
372  HISTinvariantMass_openingAngle->Fill(invMass,acos(cosTheta)*180/3.1415926535);
373  HIST_Egamma1Egamma2->Fill(highestenergy[3]*highestenergy[k3]);// (E_gamma1)(E_gamma2)
374  HIST_Egamma1vsEgamma2->Fill(highestenergy[3],highestenergy[k3]);// E_gamma1 versus E_gamma2
375  HIST_Egamma1Egamma2_openingAngle->Fill(highestenergy[3]*highestenergy[k3],acos(cosTheta)*180/3.1415926535);
376  HISTinvariantMass_Egamma1Egamma2->Fill(invMass,highestenergy[3]*highestenergy[k3]);
377  HIST_Egamma1_Egamma1Egamma2->Fill(highestenergy[3],highestenergy[3]*highestenergy[k3]);
378  HIST_Egamma1_openingAngle->Fill(highestenergy[3],acos(cosTheta)*180/3.1415926535);
379  HISTinvariantMass_openingAngle_Egamma1Egamma2->Fill(invMass,acos(cosTheta)*180/3.1415926535,highestenergy[3]*highestenergy[k3]);
380  }
381  }
382  for (int k4=5; k4<7; k4++)
383  {
384  //if (cluster_module_7[4] != cluster_module_7[k4])
385  {
386  Double_t cosTheta = (1./cluster_dist_7[4]/cluster_dist_7[k4])*(cluster_x_7[4]*cluster_x_7[k4]+cluster_y_7[4]*cluster_y_7[k4]+cluster_z_7[4]*cluster_z_7[k4]);
387  Double_t invMass = sqrt(2*highestenergy[4]*highestenergy[k4]*(1-cosTheta));
388  HISTinvariantMass->Fill(invMass);
389  HISTinvariantMass_openingAngle->Fill(invMass,acos(cosTheta)*180/3.1415926535);
390  HIST_Egamma1Egamma2->Fill(highestenergy[4]*highestenergy[k4]);// (E_gamma1)(E_gamma2)
391  HIST_Egamma1vsEgamma2->Fill(highestenergy[4],highestenergy[k4]);// E_gamma1 versus E_gamma2
392  HIST_Egamma1Egamma2_openingAngle->Fill(highestenergy[4]*highestenergy[k4],acos(cosTheta)*180/3.1415926535);
393  HISTinvariantMass_Egamma1Egamma2->Fill(invMass,highestenergy[4]*highestenergy[k4]);
394  HIST_Egamma1_Egamma1Egamma2->Fill(highestenergy[4],highestenergy[4]*highestenergy[k4]);
395  HIST_Egamma1_openingAngle->Fill(highestenergy[4],acos(cosTheta)*180/3.1415926535);
396  HISTinvariantMass_openingAngle_Egamma1Egamma2->Fill(invMass,acos(cosTheta)*180/3.1415926535,highestenergy[4]*highestenergy[k4]);
397  }
398  }
399  for (int k5=6; k5<7; k5++)
400  {
401  //if (cluster_module_7[5] != cluster_module_7[k5])
402  {
403  Double_t cosTheta = (1./cluster_dist_7[5]/cluster_dist_7[k5])*(cluster_x_7[5]*cluster_x_7[k5]+cluster_y_7[5]*cluster_y_7[k5]+cluster_z_7[5]*cluster_z_7[k5]);
404  Double_t invMass = sqrt(2*highestenergy[5]*highestenergy[k5]*(1-cosTheta));
405  HISTinvariantMass->Fill(invMass);
406  HISTinvariantMass_openingAngle->Fill(invMass,acos(cosTheta)*180/3.1415926535);
407  HIST_Egamma1Egamma2->Fill(highestenergy[5]*highestenergy[k5]);// (E_gamma1)(E_gamma2)
408  HIST_Egamma1vsEgamma2->Fill(highestenergy[5],highestenergy[k5]);// E_gamma1 versus E_gamma2
409  HIST_Egamma1Egamma2_openingAngle->Fill(highestenergy[5]*highestenergy[k5],acos(cosTheta)*180/3.1415926535);
410  HISTinvariantMass_Egamma1Egamma2->Fill(invMass,highestenergy[5]*highestenergy[k5]);
411  HIST_Egamma1_Egamma1Egamma2->Fill(highestenergy[5],highestenergy[5]*highestenergy[k5]);
412  HIST_Egamma1_openingAngle->Fill(highestenergy[5],acos(cosTheta)*180/3.1415926535);
413  HISTinvariantMass_openingAngle_Egamma1Egamma2->Fill(invMass,acos(cosTheta)*180/3.1415926535,highestenergy[5]*highestenergy[k5]);
414  }
415  }
416  }
417  }
418 
419  //hz_clust->Fill(cluster->z());
420 
421  if (NumberOfClusters>0)
422  HISTnumberOfClusters->Fill(NumberOfClusters); //number of clusters per event, having more than or equal to one digi per cluster
423  if (ClustNo>0)
424  HISTclustNo->Fill(ClustNo); //number of clusters per event, having more than one digi per cluster and satisfying the cluster threshold energy
425  if (ndigisOfHighestEnergyCluster>0)
426  HISTndigisOfHighestEnergyCluster->Fill(ndigisOfHighestEnergyCluster); //number of digis per event for clusters with highest energy deposition
427 
428  HISTtotdigis_fromClusterAnalysis->Fill(totdigis_fromClusterAnalysis);
429 
430  if (j%1000 ==0)
431  cout<<"Evt. No. "<< j<<endl;
432  }
433  //cout<<"totaldigis = "<<totaldigis<<"\n";
434  //cout<<"efficiencyCounter_d = "<<efficiencyCounter_d<<" , atLeastOneHitPerEventCounter_d = "<<atLeastOneHitPerEventCounter_d<<"\n";
435  //cout<<"FwEndCap efficiency (more than 10 MeV deposition in at least one crystal) = "<< (double)efficiencyCounter_d/atLeastOneHitPerEventCounter_d<<"\n";
436  cout<<"totClusters = "<<totClusters<<endl;
438  gStyle->SetPalette(1);
439 
440 
441 
442 /*
443  TCanvas* c3 = new TCanvas("c3","", 100, 100, 800, 800);
444  c3->Divide(3,2);
445  c3->cd(1);
446  HISTOdigi_ene11_12->Draw();
447  c3->cd(2);
448  HISTOdigi_ene12_12->Draw();
449  c3->cd(3);
450  HISTOdigi_ene13_12->Draw();
451  c3->cd(4);
452  HISTOdigi_ene14_12->Draw();
453  c3->cd(5);
454  HISTene_d->Draw();
455  HISTene_d->GetXaxis()->SetTitle("FwEndCap Deposited Energy per digi (digi analysis)");
456  c3->cd(6);
457  HISTdigi_ene->SetLineColor(1);
458  HISTdigi_ene->Draw();
459  HISTdigi_ene->GetXaxis()->SetTitle("FwEndCap Deposited Energy per event (digi analysis)");
460  */
461 
462  /*
463  TCanvas* c4 = new TCanvas("c4","", 100, 100, 800, 800);
464  c4->Divide(3,2);
465  c4->cd(1);
466  HISTy_x_d->Draw("colz");
467  c4->cd(2);
468  HISTrow_crystal_d->Draw("colz");
469  c4->cd(3);
470  HISTxpad_x_d->Draw("colz");
471  c4->cd(4);
472  HISTypad_y_d->Draw("colz");
473  c4->cd(5);
474  HISTrow_x_d->Draw("colz");
475  */
476 
477  /*
478  TCanvas* c5 = new TCanvas("c5","", 100, 100, 800, 800);
479  c5->Divide(4,4);
480  c5->cd(1);
481  HISTnumberOfClusters->Draw("");
482  c5->cd(2);
483  HISTclustNo->Draw("");
484  c5->cd(3);
485  HISTndigisOfHighestEnergyCluster->Draw("");
486  c5->cd(4);
487  HISTmax_cluster_energy->Draw("");
488  c5->cd(5);
489  HISTtheta_MonteCarlo->Draw("");
490  c5->cd(6);
491  HISTphi_MonteCarlo->Draw("");
492  c5->cd(7);
493  HISTtheta_MonteCarlo_cluster->Draw("colz");
494  c5->cd(8);
495  HISTphi_MonteCarlo_cluster->Draw("colz");
496  c5->cd(9);
497  HISTmax_cluster_theta->Draw("");
498  c5->cd(10);
499  HISTmax_cluster_phi->Draw("");
500  c5->cd(11);
501  HISTmax_cluster_theta_diff->Draw("");
502  c5->cd(12);
503  HISTmax_cluster_phi_diff->Draw("");
504  c5->cd(13);
505  HISTmax_cluster_x->Draw("");
506  c5->cd(14);
507  HISTmax_cluster_y->Draw("");
508  c5->cd(15);
509  //HISTmax_cluster_z->Draw("");
510  HISTmax_cluster_x_diff->Draw("");
511  c5->cd(16);
512  HISTmax_cluster_y_diff->Draw("");
513 
514  TCanvas* c55 = new TCanvas("c55","", 100, 100, 800, 800);
515  HISTmax_cluster_y_x->Draw("colz");
516  */
517 
518  /* TCanvas* c6 = new TCanvas("c6","", 100, 100, 800, 800);
519  c6->Divide(2,2);
520  c6->cd(1);
521  HISTclusterSize_clusterPhi->Draw("colz");
522  c6->cd(2);
523  HISTclusterEnergy_clusterPhi->Draw("colz");
524  c6->cd(3);
525  HISTnumberOfclusters_clusterPhi->Draw("colz");
526  c6->cd(4);
527  HISTtotdigis_clusterPhi->Draw("colz");
528  //HISTtotdigis_fromClusterAnalysis->Draw();
529  */
530 
531  /*
532  TCanvas* c8 = new TCanvas("c8","", 100, 100, 1200, 800);
533  c8->Divide(2,2);
534  c8->cd(1);
535  HISTmultiplicity_5MeVtrigThresh_d->Draw();
536  c8->cd(2);
537  HISTmultiplicity_10MeVtrigThresh_d->Draw();
538 */
539 
540  TCanvas* c10 = new TCanvas("c10","", 100, 100, 1200, 800);
541  c10->Divide(2,4);
542  c10->cd(1)->SetLogy();
543  HISTinvariantMass->Draw();
544  c10->cd(2)->SetLogy();
545  HIST_Egamma1Egamma2->Draw();
546  c10->cd(3)->SetLogz();
547  HIST_Egamma1vsEgamma2->Draw("colz");
548  c10->cd(4)->SetLogz();
549  HISTinvariantMass_openingAngle->Draw("colz");
550  c10->cd(5)->SetLogz();
551  HIST_Egamma1Egamma2_openingAngle->Draw("colz");
552  c10->cd(6)->SetLogz();
553  HIST_Egamma1_openingAngle->Draw("colz");
554  c10->cd(7)->SetLogz();
555  HIST_Egamma1_Egamma1Egamma2->Draw("colz");
556  c10->cd(8)->SetLogz();
557  HISTinvariantMass_Egamma1Egamma2->Draw("colz");
558 
559  TCanvas* c100 = new TCanvas("c100","", 100, 100, 1200, 800);
560  HISTinvariantMass_openingAngle_Egamma1Egamma2->Draw("Box");
561  HISTinvariantMass_openingAngle_Egamma1Egamma2->GetXaxis()->SetTitle("m_{#gamma#gamma}");
562  HISTinvariantMass_openingAngle_Egamma1Egamma2->GetXaxis()->SetTitleOffset(1.5);
563  HISTinvariantMass_openingAngle_Egamma1Egamma2->GetYaxis()->SetTitle("opening angle");
564  HISTinvariantMass_openingAngle_Egamma1Egamma2->GetYaxis()->SetTitleOffset(1.5);
565  HISTinvariantMass_openingAngle_Egamma1Egamma2->GetZaxis()->SetTitle("E_{#gamma1} #times E_{#gamma2}");
566  HISTinvariantMass_openingAngle_Egamma1Egamma2->GetZaxis()->SetTitleOffset(1.1);
567 
568 
569  TCanvas* c11 = new TCanvas("c11","", 100, 100, 1200, 800);
570  c11->SetLogy();
571  moduleDistribution->Draw();
572 
574  TString outfile= "./invMass_histo_7gammaAnalysis_FullEmcIncluded.root";
575  TFile* file_out = new TFile(outfile,"RECREATE");
576 
577  HISTinvariantMass->Write();
578  HISTinvariantMass_openingAngle->Write();
579  HIST_Egamma1Egamma2->Write();
580  HIST_Egamma1vsEgamma2->Write();
581  HIST_Egamma1Egamma2_openingAngle->Write();
582  HISTinvariantMass_Egamma1Egamma2->Write();
583  HIST_Egamma1_Egamma1Egamma2->Write();
584  HIST_Egamma1_openingAngle->Write();
585  HISTinvariantMass_openingAngle_Egamma1Egamma2->Write();
586  moduleDistribution->Write();
587 
588  file_out->Close();
589 
590  timer.Stop();
591  Double_t rtime = timer.RealTime();
592  Double_t ctime = timer.CpuTime();
593  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
594  return 0;
595 }
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
int analysis_digi_cluster_7gammaAnalysis_FullEmc()
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