13 fPtEl = new TH1F("PtEl", "Transverse momentum e+/e-", 100, 0, 2.);
14 fPtMu = new TH1F("PtMu", "Transverse momentum mu+/mu-", 100, 0, 2.);
15 fPtPi = new TH1F("PtPi", "Transverse momentum pi+/pi-", 100, 0, 2.);
17 fRapEl = new TH1F("RapEl", "Rapidity e+/e-", 200, -10, 10);
18 fRapMu = new TH1F("RapMu", "Rapidity mu+/mu-", 200, -10, 10);
19 fRapPi = new TH1F("RapPi", "Rapidity pi+/pi-", 200, -10, 10);
21 fInvMassEl = new TH1F("InvMassEl", "Invariant mass", 100, 0, 5);
22 fInvMassMu = new TH1F("InvMassMu", "Invariant mass", 100, 0, 5);
23 fInvMassPi = new TH1F("InvMassPi", "Invariant mass", 100, 0, 5);
25 fPt1 = new TH1F("fPt1", "Transverse momentum track 1", 100, 0, 2.);
26 fPt2 = new TH1F("fPt2", "Transverse momentum track 2", 100, 0, 2.);
29 Analyse::Analyse(char* infile, Int_t nEvents) :
36 fPtEl = new TH1F("PtEl", "Transverse momentum e+/e-", 100, 0, 2.);
37 fPtMu = new TH1F("PtMu", "Transverse momentum mu+/mu-", 100, 0, 2.);
38 fPtPi = new TH1F("PtPi", "Transverse momentum pi+/pi-", 100, 0, 2.);
40 fRapEl = new TH1F("RapEl", "Rapidity e+/e-", 200, -10, 10);
41 fRapMu = new TH1F("RapMu", "Rapidity mu+/mu-", 200, -10, 10);
42 fRapPi = new TH1F("RapPi", "Rapidity pi+/pi-", 200, -10., 10.);
44 fInvMassEl = new TH1F("InvMassEl", "Invariant mass", 100, 0, 5);
45 fInvMassMu = new TH1F("InvMassMu", "Invariant mass", 100, 0, 5);
46 fInvMassPi = new TH1F("InvMassPi", "Invariant mass", 100, 0., 5.);
49 fPt1 = new TH1F("fPt1", "Transverse momentum track 1", 100, 0, 2.);
50 fPt2 = new TH1F("fPt2", "Transverse momentum track 2", 100, 0, 2.);
78 cout << "Opening textfile " << fInfile << endl;
79 if( !(filelist=fopen(fInfile,"r")) ){
80 cout<<"Couldn't open input file: "<<fInfile<<endl;
83 cout << "Done opening textfile" << endl;
87 Int_t Analyse::NextEvent()
100 fscanf(filelist,"%s %d %d %d ",linelabel,&i1,&ntrk,&i2);
102 cout<<linelabel<<" "<<i1<<" "<<ntrk<<" "<<i2<<" "<<fNParticles<<endl;
104 fscanf(filelist,"%s %lf %lf %lf %lf %d %d %d %d",
105 linelabel,&x1,&x2,&x3,&x4,&i1,&i2,&i3,&nvtx);
106 cout<<linelabel<<" "<<x1<<" "<<x2<<" "<<x3<<" "<<x4<<" "<<i1<<" "<<i2<<" "<<i3<<" "<<nvtx<<endl;
107 if(ntrk != nvtx)cout<<"ERROR: ntrk = "<<ntrk<<" nvtx = "<<nvtx<<endl;
112 TParticle* Analyse::NextParticle()
125 cout<<"In NextParticle: fNparticles = "<<fNParticles<<endl;
127 // for ( int itk=0; itk < fNParticles; itk++){
130 fscanf(filelist,"%s %d %le %le %le %d %d %d %d",
131 tracklabel,&i1,&px,&py,&pz,&i2,&i3,&i4,&idpart);
132 cout<<" "<<tracklabel<<" "<<i1<<" "<<px<<" "<<py<<" "<<pz<<" "<<i2<<" "<<i3<<" "<<i4<<" "<<idpart<<endl;
134 TParticle *particle =
135 new TParticle(idpart, 0, -1, -1, -1, -1, px, py, pz, ep, 0., 0., 0., 0.);
142 void Analyse::doAnalysis()
145 Int_t check = Init();
146 if(check < 0) return;
148 for(Int_t ev = 0; ev < fNEvents; ev++){
150 const Int_t ntracks = NextEvent();
151 //Array of TLorentzVectors. One vector for each tracks
152 TLorentzVector* vecArr[ntracks];
153 TParticle* partArr[ntracks];
154 //Looping over the tracks of the event
155 for(Int_t tr = 0; tr < ntracks; tr++){
156 //Getting a TParticle from the TClonesArray
157 TParticle *part = NextParticle();
158 Double_t mpi = 0.13957018;
159 Double_t energy = TMath::Sqrt(mpi*mpi+part->Px()*part->Px()+part->Py()*part->Py()+part->Pz()*part->Pz());
160 //Creating a new TLorentzVector and setting px, py, pz and E.
161 vecArr[tr] = new TLorentzVector;
162 vecArr[tr]->SetPxPyPzE(part->Px(), part->Py(), part->Pz(), energy);
163 cout << "particle " << tr << ": px: " << part->Px() << " py: " << part->Py() << " pz: " << part->Pz() << " Energy: " << energy << endl;
167 fPt1->Fill(vecArr[0]->Pt());
168 fPt2->Fill(vecArr[1]->Pt());
170 //Creating a new TLorentzVector, which is the sum of the elements in vecArr
172 for(Int_t i = 0; i < ntracks; i++){
175 //Filling the histograms depending on particle type
177 if(partArr[0]->GetPdgCode() == 11 || partArr[0]->GetPdgCode() == -11){
178 fPtEl->Fill(sum.Pt());
179 fRapEl->Fill(sum.Rapidity());
180 fInvMassEl->Fill(sum.M());
182 else if(partArr[0]->GetPdgCode() == 13 || partArr[0]->GetPdgCode() == -13){
183 fPtMu->Fill(sum.Pt());
184 fRapMu->Fill(sum.Rapidity());
185 fInvMassMu->Fill(sum.M());
187 else if(partArr[0]->GetPdgCode() == 211 || partArr[0]->GetPdgCode() == -211){
188 fPtPi->Fill(sum.Pt());
189 cout << "sum.Rapidity: " << sum.Rapidity() << endl;
190 cout << "sum.M(): " << sum.M() << endl;
191 fRapPi->Fill(sum.Rapidity());
192 fInvMassPi->Fill(sum.M());
196 //Writing the histograms to file
197 TFile file("histograms.root", "RECREATE");