44 #include "AliRunLoader.h"
45 #include "AliLoader.h"
47 #include "AliTrackReference.h"
48 #include "AliTracker.h"
49 #include "AliESDEvent.h"
50 #include "AliESDMuonTrack.h"
51 #include "AliESDVertex.h"
57 #include <TLorentzVector.h>
60 #include <TParticle.h>
70 static const TString kDefaultOutFileName =
"output.txt";
71 return kDefaultOutFileName;
77 fFileName(galiceFile),
79 fesdFileName(esdFile),
81 fOutFileName(GetDefaultOutFileName()),
82 fFirstEvent(firstEvent),
90 const char* esdFile,Int_t firstEvent, Int_t lastEvent,
93 fFileName(galiceFile),
94 fFileNameSim(galiceFileSim),
95 fesdFileName(esdFile),
97 fOutFileName(GetDefaultOutFileName()),
98 fFirstEvent(firstEvent),
117 TH1F * fhMUONVertex ;
121 fhMUONVertex =
new TH1F(
"hMUONVertex",
"ITS Vertex" ,100, -25., 25.);
122 fhMUONMult =
new TH1F(
"hMUONMult" ,
"Multiplicity of ESD tracks",10, -0.5, 9.5);
124 TH1F *hY =
new TH1F(
"hY",
"Rapidity",100,-5.,-1.);
125 TH1F *hPt =
new TH1F(
"hPt",
"Pt",100, 0.,20.);
130 if (!esdFile || !esdFile->IsOpen())
132 AliError(Form(
"Error opening %s file \n",
fesdFileName.Data()));
155 Int_t fnTrackTrig=0 ;
160 Float_t muonMass = 0.105658389;
161 Double_t thetaX, thetaY, pYZ;
162 Double_t fPxRec1, fPyRec1, fPzRec1, fE1;
164 AliESDEvent* fESD =
new AliESDEvent();
165 TTree*
tree = (TTree*) esdFile->Get(
"esdTree");
168 Error(
"CheckESD",
"no ESD tree found");
169 AliError(Form(
"no ESD tree found"));
172 fESD->ReadFromTree(tree);
174 Int_t fnevents = tree->GetEntries();
181 for (ievent =
fFirstEvent; ievent < endOfLoop; ++ievent )
184 if (tree->GetEvent(ievent) <= 0)
186 Error(
"CheckESD",
"no ESD object found for event %d", ievent);
189 AliESDVertex* vertex = (AliESDVertex*) fESD->GetVertex();
191 Double_t zVertex = 0. ;
192 if (vertex) zVertex = vertex->GetZ();
194 Int_t nTracks = (Int_t)fESD->GetNumberOfMuonTracks() ;
195 ULong64_t trigword=fESD->GetTriggerMask();
197 if(pdc06TriggerResponse)
199 if (trigword & 0x01) {
203 if (trigword & 0x02){
206 if (trigword & 0x04){
209 if (trigword & 0x08){
212 if (trigword & 0x010){
215 if (trigword & 0x020){
218 if (trigword & 0x040){
221 if (trigword & 0x080){
224 if (trigword & 0x100){
227 if (trigword & 0x200){
231 if (trigword & 0x400){
234 if (trigword & 0x800){
237 if (trigword & 0x1000){
241 if (trigword & 0x2000){
245 if (trigword & 0x4000){
250 if (trigword & 0x01) {
254 if (trigword & 0x02){
257 if (trigword & 0x04){
260 if (trigword & 0x08){
263 if (trigword & 0x010){
266 if (trigword & 0x020){
273 for ( Int_t iTrack1 = 0; iTrack1<nTracks; ++iTrack1 )
275 AliESDMuonTrack* muonTrack = fESD->GetMuonTrack(iTrack1);
278 if (!muonTrack->ContainTrackerData())
continue;
282 thetaX = muonTrack->GetThetaX();
283 thetaY = muonTrack->GetThetaY();
284 pYZ = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
286 fPzRec1 = - pYZ / TMath::Sqrt(1.0 + TMath::Tan(thetaY)*TMath::Tan(thetaY));
287 fPxRec1 = fPzRec1 * TMath::Tan(thetaX);
288 fPyRec1 = fPzRec1 * TMath::Tan(thetaY);
289 fE1 = TMath::Sqrt(muonMass * muonMass + fPxRec1 * fPxRec1 + fPyRec1 * fPyRec1 + fPzRec1 * fPzRec1);
290 fV1.SetPxPyPzE(fPxRec1, fPyRec1, fPzRec1, fE1);
292 Float_t pt1 = fV1.Pt();
294 Float_t y1 = fV1.Rapidity();
296 if(muonTrack->GetMatchTrigger())
305 fhMUONVertex->Fill(zVertex) ;
306 fhMUONMult->Fill(Float_t(nTracks)) ;
310 AliInfo(Form(
"Terminate %s:", GetName())) ;
314 effMatch=100*fnTrackTrig/ftracktot;
317 if(pdc06TriggerResponse)
319 printf(
"=================================================================\n") ;
320 printf(
"================ %s ESD SUMMARY ==============\n", GetName()) ;
322 printf(
" Total number of processed events %d \n", nev) ;
326 printf(
" Global Trigger output Low pt High pt All\n") ;
327 printf(
" number of Single Plus :\t");
328 printf(
"%i\t%i\t%i\t", fSPLowpt, fSPHighpt, fSPAllpt) ;
330 printf(
" number of Single Minus :\t");
331 printf(
"%i\t%i\t%i\t", fSMLowpt, fSMHighpt, fSMAllpt) ;
333 printf(
" number of Single Undefined :\t");
334 printf(
"%i\t%i\t%i\t", fSULowpt, fSUHighpt, fSUAllpt) ;
336 printf(
" number of UnlikeSign pair :\t");
337 printf(
"%i\t%i\t%i\t", fUSLowpt, fUSHighpt, fUSAllpt) ;
339 printf(
" number of LikeSign pair :\t");
340 printf(
"%i\t%i\t%i\t", fLSLowpt, fLSHighpt, fLSAllpt) ;
342 printf(
"===================================================\n") ;
344 printf(
"matching efficiency with the trigger for single tracks = %2d %% \n", effMatch);
345 printf(
"================================================================\n") ;
printf(
"\n") ;
353 if(pdc06TriggerResponse){
354 fprintf(outtxt,
" \n");
355 fprintf(outtxt,
"===================================================\n");
356 fprintf(outtxt,
"================ ESD SUMMARY ==============\n");
357 fprintf(outtxt,
" \n");
358 fprintf(outtxt,
" Total number of processed events %d \n", nev);
359 fprintf(outtxt,
"\n");
360 fprintf(outtxt,
"\n");
361 fprintf(outtxt,
"Table 1: \n");
362 fprintf(outtxt,
" Global Trigger output Low pt High pt All\n");
363 fprintf(outtxt,
" number of Single Plus :\t");
364 fprintf(outtxt,
"%i\t%i\t%i\t",fSPLowpt,fSPHighpt,fSPAllpt);
365 fprintf(outtxt,
"\n");
366 fprintf(outtxt,
" number of Single Minus :\t");
367 fprintf(outtxt,
"%i\t%i\t%i\t",fSMLowpt,fSMHighpt,fSMAllpt);
368 fprintf(outtxt,
"\n");
369 fprintf(outtxt,
" number of Single Undefined :\t");
370 fprintf(outtxt,
"%i\t%i\t%i\t",fSULowpt,fSUHighpt,fSUAllpt);
371 fprintf(outtxt,
"\n");
372 fprintf(outtxt,
" number of UnlikeSign pair :\t");
373 fprintf(outtxt,
"%i\t%i\t%i\t",fUSLowpt,fUSHighpt,fUSAllpt);
374 fprintf(outtxt,
"\n");
375 fprintf(outtxt,
" number of LikeSign pair :\t");
376 fprintf(outtxt,
"%i\t%i\t%i\t",fLSLowpt,fLSHighpt, fLSAllpt);
377 fprintf(outtxt,
"\n");
378 fprintf(outtxt,
"===================================================\n");
379 fprintf(outtxt,
"\n");
380 fprintf(outtxt,
"matching efficiency with the trigger for single tracks = %2d %% \n", effMatch);
385 fprintf(outtxt,
" \n");
386 fprintf(outtxt,
"===================================================\n");
387 fprintf(outtxt,
"================ ESD SUMMARY ==============\n");
388 fprintf(outtxt,
" \n");
389 fprintf(outtxt,
" Total number of processed events %d \n", nev);
390 fprintf(outtxt,
"\n");
391 fprintf(outtxt,
"\n");
392 fprintf(outtxt,
"Table 1: \n");
393 fprintf(outtxt,
" Global Trigger output Low pt High pt \n");
394 fprintf(outtxt,
" number of Single :\t");
395 fprintf(outtxt,
"%i\t%i\t",fSLowpt,fSHighpt);
396 fprintf(outtxt,
"\n");
397 fprintf(outtxt,
" number of UnlikeSign pair :\t");
398 fprintf(outtxt,
"%i\t%i\t",fUSLowpt,fUSHighpt);
399 fprintf(outtxt,
"\n");
400 fprintf(outtxt,
" number of LikeSign pair :\t");
401 fprintf(outtxt,
"%i\t%i\t",fLSLowpt,fLSHighpt);
402 fprintf(outtxt,
"\n");
403 fprintf(outtxt,
"===================================================\n");
404 fprintf(outtxt,
"\n");
405 fprintf(outtxt,
"matching efficiency with the trigger for single tracks = %2d %% \n", effMatch);
409 TCanvas * c1 =
new TCanvas(
"c1",
"ESD", 400, 10, 600, 700) ;
412 fhMUONVertex->Draw() ;
415 c1->Print(
"VertexAndMul.eps") ;
416 TCanvas *c2 =
new TCanvas(
"c2",
"ESD",400,10,600,700);
422 c2->Print(
"YandPt.eps") ;
432 if (!diSim.IsValid())
return;
445 for ( Int_t ievent =
fFirstEvent; ievent < endOfLoop; ++ievent )
450 AliStack* stack = diSim.Stack(ievent);
451 Int_t npa = stack->GetNprimary();
452 Int_t npb = stack->GetNtrack();
453 printf(
"Primary particles %i \n",npa);
454 printf(
"Sec particles %i \n",npb);
455 printf(
"=================================================================\n") ;
456 printf(
"Primary particles listing: \n");
457 printf(
"=================================================================\n") ;
458 for (Int_t i=0; i<npa; ++i)
460 TParticle *p = stack->Particle(i);
462 Int_t pdg=p->GetPdgCode();
464 if (TMath::Abs(pdg) == 13)
469 printf(
"=================================================================\n") ;
470 printf(
"=================================================================\n") ;
472 printf(
"Secondaries particles listing: \n");
473 printf(
"=================================================================\n") ;
474 for (Int_t i=npa; i<npb; ++i)
476 stack->Particle(i)->Print(
"");
479 printf(
"=================================================================\n") ;
480 printf(
">>> Event %d, Number of primary particles is %d \n",ievent, npa);
481 printf(
">>> Event %d, Number of secondary articles is %d \n",ievent, npb-npa);
482 printf(
"=================================================================\n");
485 printf(
">>> Okay!!! Event %d with at least one muon on primary stack! \n",ievent);
491 printf(
">>> Warning!!! Event %d without muon on primary stack! \n",ievent);
497 printf(
">>> Okay!!! Event %d with at least two muons on primary stack! \n",ievent);
500 printf(
"=================================================================\n");
505 printf(
"=================================================================\n") ;
506 printf(
" Total number of processed events %d \n", nev) ;
511 printf(
"---> WARNING!!! <---\n");
512 printf(
" %i events without muon on primary stack \n",nmu);
517 printf(
"---> OKAY!!! <---\n");
518 printf(
" %i events generated with at least one muon on primary stack \n",nonemu);
523 printf(
"---> OKAY!!! <---\n");
524 printf(
" %i events generated with at least two muons on primary stack \n",ndimu);
528 printf(
"*** Leaving MuonKine() *** \n");
529 printf(
"**************************************************************** \n");
533 fprintf(outtxt,
" \n");
534 fprintf(outtxt,
"=================================================================\n");
535 fprintf(outtxt,
"================ MUONkine SUMMARY ================\n");
536 fprintf(outtxt,
"\n");
537 fprintf(outtxt,
"=================================================================\n");
538 fprintf(outtxt,
" Total number of processed events %d \n", nev) ;
539 fprintf(outtxt,
" \n");
543 fprintf(outtxt,
" ---> WARNING!!! <--- \n");
544 fprintf(outtxt,
" %i events without muon on primary stack \n",nmu);
549 fprintf(outtxt,
" ---> OKAY!!! <--- \n");
550 fprintf(outtxt,
" %i events generated with at least one muon on primary stack \n",nonemu);
555 fprintf(outtxt,
" ---> OKAY!!! <--- \n");
556 fprintf(outtxt,
" %i events generated with at least two muons on primary stack \n",ndimu);
559 fprintf(outtxt,
" \n") ;
560 fprintf(outtxt,
"*** Leaving MuonKine() *** \n");
561 fprintf(outtxt,
"**************************************************************** \n");
572 if ( !diSim.IsValid() )
return;
574 Int_t flag11=0,flag12=0,flag13=0,flag14=0;
576 TH1F *tof01=
new TH1F(
"tof01",
"TOF for first tracking plane",100,0.,100);
577 tof01->SetXTitle(
"tof (ns)");
578 TH1F *tof14=
new TH1F(
"tof14",
"TOF for MT22",100,0.,100);
579 tof14->SetXTitle(
"tof (ns)");
582 hitDensity[0] =
new TH1F(
"TR_dhits01",
"",30,0,300);
583 hitDensity[0]->SetFillColor(3);
584 hitDensity[0]->SetXTitle(
"R (cm)");
585 hitDensity[1] =
new TH1F(
"TR_dhits10",
"",30,0,300);
586 hitDensity[1]->SetFillColor(3);
587 hitDensity[1]->SetXTitle(
"R (cm)");
588 hitDensity[2] =
new TH1F(
"TR_dhits11",
"",30,0,300);
589 hitDensity[2]->SetFillColor(3);
590 hitDensity[2]->SetXTitle(
"R (cm)");
591 hitDensity[3] =
new TH1F(
"TR_dhits14",
"",30,0,300);
592 hitDensity[3]->SetFillColor(3);
593 hitDensity[3]->SetXTitle(
"R (cm)");
595 Int_t fnevents = diSim.NumberOfEvents();
604 for ( Int_t ievent = fFirstEvent; ievent < endOfLoop; ++ievent )
609 Int_t nentries = diSim.NumberOfTrackRefs(ievent);
611 for ( Int_t l=0; l<nentries; ++l )
613 TClonesArray* trackRefs = diSim.TrackRefs(ievent,l);
614 if (!trackRefs)
continue;
616 Int_t nnn = trackRefs->GetEntriesFast();
618 for ( Int_t k=0; k<nnn; ++k )
620 AliTrackReference *tref =
static_cast<AliTrackReference*
>(trackRefs->UncheckedAt(k));
621 Int_t label = tref->GetTrack();
622 Float_t x = tref->X();
623 Float_t y = tref->Y();
624 Float_t z = tref->Z();
626 Float_t r=TMath::Sqrt(x*x+y*y);
627 Float_t time = tref->GetTime();
629 Float_t wgt=1/(2*10*TMath::Pi()*r)/(ntot);
642 if (z<=-521&& z>=-531&&flag11==0){
644 hitDensity[0]->Fill(r,wgt);
645 tof01->Fill(1000000000*time,1);
649 if (z<=-1432&&z>=-1442&&flag12==0){
651 hitDensity[1]->Fill(r,wgt);
655 if (z<=-1598&& z>=-1608&&flag13==0){
657 hitDensity[2]->Fill(r,wgt);
661 if(z<=-1715&&z>=-1725&&flag14==0){
663 hitDensity[3]->Fill(r,wgt);
664 tof14->Fill(1000000000*time,1);
676 TCanvas *c6 =
new TCanvas(
"c6",
"TOF",400,10,600,700);
683 c6->Print(
"tof_on_trigger.ps");
685 TCanvas *c5 =
new TCanvas(
"c5",
"TRef:Hits Density",400,10,600,700);
688 hitDensity[0]->Draw();
690 hitDensity[1]->Draw();
692 hitDensity[2]->Draw();
694 hitDensity[3]->Draw();
695 c5->Print(
"TR_Hit_densities.ps");
696 printf(
"=================================================================\n") ;
697 printf(
"================ %s Tref SUMMARY ==============\n", GetName()) ;
699 printf(
" Total number of processed events %d \n", nev) ;
700 printf(
"*** Leaving TRef() *** \n");
701 printf(
"*************************************************** \n");
710 Int_t dEoccupancyBending[14][26];
711 Int_t dEoccupancyNonBending[14][26];
712 Int_t cHoccupancyBending[14];
713 Int_t cHoccupancyNonBending[14];
714 Int_t totaloccupancyBending =0;
715 Int_t totaloccupancyNonBending =0;
717 Int_t dEchannelsBending[14][26];
718 Int_t dEchannelsNonBending[14][26];
719 Int_t cHchannelsBending[14];
720 Int_t cHchannelsNonBending[14];
721 Int_t totalchannelsBending =0;
722 Int_t totalchannelsNonBending =0;
731 for (Int_t ichamber=0; ichamber<nchambers; ++ichamber)
733 cHchannelsBending[ichamber]=0;
734 cHchannelsNonBending[ichamber]=0;
735 cHoccupancyBending[ichamber]=0;
736 cHoccupancyNonBending[ichamber]=0;
738 for (Int_t idetele=0; idetele<26; idetele++)
740 Int_t detele = 100*(ichamber +1)+idetele;
754 segbend = segnonbend;
759 Int_t nchannels = segbend->
NofPads();
760 Int_t ndigits = digitStore->
GetSize(detele,cathode);
761 dEchannelsBending[ichamber][idetele] = nchannels;
762 dEoccupancyBending[ichamber][idetele] = ndigits;
763 cHchannelsBending[ichamber] += nchannels;
764 cHoccupancyBending[ichamber] += ndigits;
765 totalchannelsBending += nchannels;
766 totaloccupancyBending += ndigits;
768 nchannels = segnonbend->
NofPads();
769 ndigits = digitStore->
GetSize(detele,1-cathode);
771 dEchannelsNonBending[ichamber][idetele] = nchannels;
772 dEoccupancyNonBending[ichamber][idetele] = ndigits;
773 cHchannelsNonBending[ichamber] += nchannels;
774 cHoccupancyNonBending[ichamber] += ndigits;
775 totalchannelsNonBending += nchannels;
776 totaloccupancyNonBending += ndigits;
780 printf(
">>> Detection element %4d has %5d channels in bending and %5d channels in nonbending \n",
781 detele, dEchannelsBending[ichamber][idetele], dEchannelsNonBending[ichamber][idetele] );
784 printf(
">>> Chamber %2d has %6d channels in bending and %6d channels in nonbending \n",
785 ichamber+1, cHchannelsBending[ichamber], cHchannelsNonBending[ichamber]);
787 printf(
">>Spectrometer has %7d channels in bending and %7d channels in nonbending \n",
788 totalchannelsBending, totalchannelsNonBending);
792 for ( Int_t ichamber = 0; ichamber < nchambers; ++ichamber )
794 printf(
">>> Chamber %2d nChannels Bending %5d nChannels NonBending %5d \n",
796 cHoccupancyBending[ichamber],
797 cHoccupancyNonBending[ichamber]);
798 if ( cHchannelsBending[ichamber] != 0 && cHchannelsBending[ichamber] ) {
799 printf(
">>> Chamber %2d Occupancy Bending %5.2f %% Occupancy NonBending %5.2f %% \n",
801 100.*((Float_t) cHoccupancyBending[ichamber])/((Float_t) cHchannelsBending[ichamber]),
802 100.*((Float_t) cHoccupancyNonBending[ichamber])/((Float_t) cHchannelsBending[ichamber]));
807 for(Int_t idetele=0; idetele<26; idetele++)
809 Int_t detele = idetele + 100*(ichamber+1);
812 printf(
">>> DetEle %4d nChannels Bending %5d nChannels NonBending %5d \n",
813 idetele+100*(ichamber+1),
814 dEoccupancyBending[ichamber][idetele],
815 dEoccupancyNonBending[ichamber][idetele]);
817 if ( dEchannelsBending[ichamber][idetele] != 0 && dEchannelsNonBending[ichamber][idetele] !=0 ) {
818 printf(
">>> DetEle %4d Occupancy Bending %5.2f %% Occupancy NonBending %5.2f %% \n",
819 idetele+100*(ichamber+1),
820 100.*((Float_t) dEoccupancyBending[ichamber][idetele])/((Float_t) dEchannelsBending[ichamber][idetele]),
821 100.*((Float_t) dEoccupancyNonBending[ichamber][idetele])/((Float_t) dEchannelsNonBending[ichamber][idetele]));
828 if ( totalchannelsBending != 0 && totalchannelsNonBending != 0 ) {
829 printf(
">>> Muon Spectrometer Occupancy Bending %5.2f %% Occupancy NonBending %5.2f %% \n",
830 100.*((Float_t) totaloccupancyBending)/((Float_t) totalchannelsBending),
831 100.*((Float_t) totaloccupancyNonBending)/((Float_t) totalchannelsNonBending));
Int_t fLastEvent
! Last event to consider
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
TFile * Open(const char *filename, Long64_t &nevents)
const AliMpVSegmentation * GetMpSegmentation(Int_t detElemId, AliMp::CathodType cath, Bool_t warn=true) const
Class for data quality control.
Interface for a digit container.
static AliMpSegmentation * Instance(Bool_t warn=true)
virtual Int_t NofPads() const =0
Return the number of pads in the detection element.
An easy to use interface to MUON data.
AliMUONVDigitStore * DigitStore(Int_t event)
const char * fkOutDir
! output data directory
void CheckOccupancy(Bool_t perDetEle=kFALSE) const
virtual Int_t GetSize() const =0
Number of digits we store.
TString fesdFileName
! File (AliESDs.root) to read from
TString fFileNameSim
! File (galiceSim.root) for simulated data
AliMUONCheck(const char *galiceFile, const char *esdFile, Int_t firstEvent=0, Int_t lastEvent=-1, const char *outDir="")
static AliMp::PlaneType GetPlaneType(Int_t detElemId, AliMp::CathodType cath)
static Int_t NCh()
Return number of chambers.
void SetEventsToCheck(Int_t firstEvent, Int_t lastEvent)
Easy to use data access to MC information.
The abstract base class for the segmentation.
Int_t fFirstEvent
! First event to consider
void CheckESD(Bool_t pdc06TriggerResponse=false)
TString fOutFileName
! output file name
static Bool_t IsValidDetElemId(Int_t detElemId, Bool_t warn=false)
Int_t NumberOfEvents() const