]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONCheck.cxx
Initial classes for Lee Yang Zeroes from Naomi van der Kolk
[u/mrichter/AliRoot.git] / MUON / AliMUONCheck.cxx
CommitLineData
70b4a8d6 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
7* Permission to use, copy, modify and distribute this software and its *
8* documentation strictly for non-commercial purposes is hereby granted *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
15
16// $Id$
17
3d1463c8 18//-----------------------------------------------------------------------------
9780bd43 19/// \class AliMUONCheck
20///
21/// This class check the ESD tree, providing the matching with the trigger
22/// response and designing useful plots (Pt, Y, ITS vertex, multiplicity).
23/// Note that there is a special flag to turn on for pdc06 production.
24/// It also checks the TR tree giving hit densities on the two first and
25/// last planes of the spectrometer as well as the time of flight on these planes.
26/// MUONkine() provides event stack and check if the event are generated with
27/// at least one muon and two muons (for PDC06).
28/// DumpDigit() as a replacement of the function from MUONCheck.C macro.
29///
30/// \author Frederic Yermia, INFN Torino
3d1463c8 31//-----------------------------------------------------------------------------
9780bd43 32
70b4a8d6 33#include "AliMUONCheck.h"
9780bd43 34#include "AliMUONConstants.h"
35#include "AliMUONTrack.h"
36#include "AliMUONTrackParam.h"
37#include "AliMUONTrackExtrap.h"
2e6ca202 38#include "AliMUONMCDataInterface.h"
39#include "AliMUONDataInterface.h"
9780bd43 40#include "AliMpSegmentation.h"
41#include "AliMpVSegmentation.h"
42#include "AliMpDEManager.h"
88544f7e 43#include "AliMpCDB.h"
2e6ca202 44#include "AliMUONVDigitStore.h"
70b4a8d6 45
9780bd43 46#include "AliRunLoader.h"
70b4a8d6 47#include "AliLoader.h"
9780bd43 48#include "AliStack.h"
49#include "AliTrackReference.h"
50#include "AliTracker.h"
af885e0f 51#include "AliESDEvent.h"
9780bd43 52#include "AliESDMuonTrack.h"
aad72f45 53#include "AliESDVertex.h"
9780bd43 54#include "AliMagFMaps.h"
70b4a8d6 55#include "AliLog.h"
70b4a8d6 56
9780bd43 57#include <TSystem.h>
58#include <TCanvas.h>
59#include <TLorentzVector.h>
60#include <TFile.h>
61#include <TH1.h>
62#include <TParticle.h>
70b4a8d6 63
5398f946 64/// \cond CLASSIMP
70b4a8d6 65ClassImp(AliMUONCheck)
5398f946 66/// \endcond
6b092dfc 67
5a560b6a 68AliMUONCheck::AliMUONCheck(const char* galiceFile, const char* esdFile,Int_t firstEvent, Int_t lastEvent,const char* outDir)
69: TObject(),
2e6ca202 70fFileName(galiceFile),
71fFileNameSim(),
72fesdFileName(esdFile),
73foutDir(outDir),
74fFirstEvent(firstEvent),
75fLastEvent(lastEvent)
5a560b6a 76{
77 /// ctor
5a560b6a 78}
2e6ca202 79
70b4a8d6 80//_____________________________________________________________________________
2e6ca202 81AliMUONCheck::AliMUONCheck(const char* galiceFile, const char* galiceFileSim,
82 const char* esdFile,Int_t firstEvent, Int_t lastEvent,
83 const char* outDir)
70b4a8d6 84: TObject(),
2e6ca202 85fFileName(galiceFile),
86fFileNameSim(galiceFileSim),
87fesdFileName(esdFile),
88foutDir(outDir),
89fFirstEvent(firstEvent),
90fLastEvent(lastEvent)
70b4a8d6 91{
71a2d3aa 92 /// ctor
9780bd43 93}
94
70b4a8d6 95//_____________________________________________________________________________
96AliMUONCheck::~AliMUONCheck()
97{
2e6ca202 98 /// Destructor
70b4a8d6 99}
100
101//_____________________________________________________________________________
102void
9780bd43 103AliMUONCheck::CheckESD(Bool_t pdc06TriggerResponse)
70b4a8d6 104{
71a2d3aa 105 /// Check ESD files
70b4a8d6 106
9780bd43 107 // Histograms
108 TH1F * fhMUONVertex ; //!
109 TH1F * fhMUONMult ; //!
110
111 // create histograms
112 fhMUONVertex = new TH1F("hMUONVertex","ITS Vertex" ,100, -25., 25.);
113 fhMUONMult = new TH1F("hMUONMult" ,"Multiplicity of ESD tracks",10, -0.5, 9.5);
70b4a8d6 114
9780bd43 115 TH1F *hY = new TH1F("hY","Rapidity",100,-5.,-1.);
116 TH1F *hPt = new TH1F("hPt","Pt",100, 0.,20.);
70b4a8d6 117
9780bd43 118 // ------------->open the ESD file
119 TFile* esdFile = TFile::Open(fesdFileName.Data());
120
2e6ca202 121 if (!esdFile || !esdFile->IsOpen())
122 {
9780bd43 123 AliError(Form("Error opening %s file \n",fesdFileName.Data()));
2e6ca202 124 return;
125 }
126
9780bd43 127 Int_t fSPLowpt=0 ; //!
128 Int_t fSPHighpt=0 ; //!
129 Int_t fSPAllpt=0 ; //!
130 Int_t fSMLowpt=0 ; //!
131 Int_t fSMHighpt =0 ; //!
132 Int_t fSMAllpt=0 ; //!
133 Int_t fSULowpt=0 ; //!
134 Int_t fSUHighpt=0 ; //!
135 Int_t fSUAllpt=0 ; //!
136 Int_t fUSLowpt=0 ; //!
137 Int_t fUSHighpt=0 ; //!
138 Int_t fUSAllpt=0 ; //!
139 Int_t fLSLowpt=0 ; //!
140 Int_t fLSHighpt=0 ; //!
141 Int_t fLSAllpt=0 ; //!
2e6ca202 142
9780bd43 143 Int_t fSLowpt=0 ; //!
144 Int_t fSHighpt=0 ; //!
2e6ca202 145
9780bd43 146 Int_t fnTrackTrig=0 ; //!
147 Int_t ftracktot=0 ; //!
148 Int_t effMatch=0 ; //!
149
150 TLorentzVector fV1;
151 Float_t muonMass = 0.105658389;
152 Double_t thetaX, thetaY, pYZ;
153 Double_t fPxRec1, fPyRec1, fPzRec1, fE1;
154 Int_t fZ1;
155
af885e0f 156 AliESDEvent* fESD = new AliESDEvent();
2e6ca202 157 TTree* tree = (TTree*) esdFile->Get("esdTree");
158 if (!tree)
159 {
9780bd43 160 Error("CheckESD", "no ESD tree found");
161 AliError(Form("CheckESD", "no ESD tree found"));
162 return ;
163 }
2e6ca202 164 fESD->ReadFromTree(tree);
9780bd43 165
2e6ca202 166 Int_t fnevents = tree->GetEntries();
9780bd43 167 Int_t endOfLoop = fLastEvent+1;
2e6ca202 168
9780bd43 169 if ( fLastEvent == -1 ) endOfLoop = fnevents;
170 Int_t ievent=0;
171 Int_t nev=0;
2e6ca202 172
9780bd43 173 for (ievent = fFirstEvent; ievent < endOfLoop; ++ievent )
70b4a8d6 174 {
2e6ca202 175 nev++;
176 tree->GetEvent(ievent);
177 if (!fESD)
178 {
9780bd43 179 Error("CheckESD", "no ESD object found for event %d", ievent);
180 return ;
181 }
2e6ca202 182 AliESDVertex* vertex = (AliESDVertex*) fESD->GetVertex();
9780bd43 183
184 Double_t zVertex = 0. ;
185 if (vertex) zVertex = vertex->GetZv();
2e6ca202 186
9780bd43 187 Int_t nTracks = (Int_t)fESD->GetNumberOfMuonTracks() ;
188 ULong64_t trigword=fESD->GetTriggerMask();
2e6ca202 189
190 if(pdc06TriggerResponse)
191 {
9780bd43 192 if (trigword & 0x01) {
193 fSPLowpt++;
194 }
2e6ca202 195
9780bd43 196 if (trigword & 0x02){
197 fSPHighpt++;
198 }
199 if (trigword & 0x04){
200 fSPAllpt++;
201 }
202 if (trigword & 0x08){
203 fSMLowpt++;
204 }
205 if (trigword & 0x010){
206 fSMHighpt++;
207 }
208 if (trigword & 0x020){
209 fSMAllpt++;
210 }
211 if (trigword & 0x040){
212 fSULowpt++;
213 }
214 if (trigword & 0x080){
215 fSUHighpt++;
216 }
217 if (trigword & 0x100){
218 fSUAllpt++;
219 }
220 if (trigword & 0x200){
221 fUSLowpt++;
222 }
2e6ca202 223
9780bd43 224 if (trigword & 0x400){
225 fUSHighpt++;
226 }
227 if (trigword & 0x800){
228 fUSAllpt++;
229 }
230 if (trigword & 0x1000){
231 fLSLowpt++;
232 }
2e6ca202 233
9780bd43 234 if (trigword & 0x2000){
235 fLSHighpt++;
236 }
2e6ca202 237
9780bd43 238 if (trigword & 0x4000){
239 fLSAllpt++;
240 }
241 }// if pdc06TriggerResponse
242 else {
243 if (trigword & 0x01) {
244 fSLowpt++;
245 }
2e6ca202 246
9780bd43 247 if (trigword & 0x02){
248 fSHighpt++;
249 }
250 if (trigword & 0x04){
251 fLSLowpt++;
252 }
253 if (trigword & 0x08){
254 fLSHighpt++;
255 }
256 if (trigword & 0x010){
257 fUSLowpt++;
258 }
259 if (trigword & 0x020){
260 fUSHighpt++;
261 }
262 }
263
264 Int_t tracktrig=0;
2e6ca202 265
266 for ( Int_t iTrack1 = 0; iTrack1<nTracks; ++iTrack1 )
267 { //1st loop
9780bd43 268 AliESDMuonTrack* muonTrack = fESD->GetMuonTrack(iTrack1);
269 ftracktot++;
270
271 thetaX = muonTrack->GetThetaX();
272 thetaY = muonTrack->GetThetaY();
273 pYZ = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
2e6ca202 274
9780bd43 275 fPzRec1 = - pYZ / TMath::Sqrt(1.0 + TMath::Tan(thetaY)*TMath::Tan(thetaY));
276 fPxRec1 = fPzRec1 * TMath::Tan(thetaX);
277 fPyRec1 = fPzRec1 * TMath::Tan(thetaY);
278 fZ1 = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
279 fE1 = TMath::Sqrt(muonMass * muonMass + fPxRec1 * fPxRec1 + fPyRec1 * fPyRec1 + fPzRec1 * fPzRec1);
280 fV1.SetPxPyPzE(fPxRec1, fPyRec1, fPzRec1, fE1);
281 // -----------> transverse momentum
282 Float_t pt1 = fV1.Pt();
283 // ----------->Rapidity
284 Float_t y1 = fV1.Rapidity();
2e6ca202 285
286 if(muonTrack->GetMatchTrigger())
287 {
9780bd43 288 fnTrackTrig++;
289 tracktrig++;
290 }
291 hY->Fill(y1);
292 hPt->Fill(pt1);
2e6ca202 293 } // loop on track
294
9780bd43 295 fhMUONVertex->Fill(zVertex) ;
296 fhMUONMult->Fill(Float_t(nTracks)) ;
2e6ca202 297
9780bd43 298 } // loop over events
299
300 AliInfo(Form("Terminate %s:", GetName())) ;
301
302 effMatch=100*fnTrackTrig/ftracktot;
2e6ca202 303
304 if(pdc06TriggerResponse)
305 {
9780bd43 306 printf("=================================================================\n") ;
307 printf("================ %s ESD SUMMARY ==============\n", GetName()) ;
308 printf(" \n") ;
309 printf(" Total number of processed events %d \n", nev) ;
310 printf("\n") ;
311 printf("\n") ;
312 printf("Table 1: \n") ;
313 printf(" Global Trigger output Low pt High pt All\n") ;
314 printf(" number of Single Plus :\t");
315 printf("%i\t%i\t%i\t", fSPLowpt, fSPHighpt, fSPAllpt) ;
316 printf("\n");
317 printf(" number of Single Minus :\t");
318 printf("%i\t%i\t%i\t", fSMLowpt, fSMHighpt, fSMAllpt) ;
319 printf("\n");
320 printf(" number of Single Undefined :\t");
321 printf("%i\t%i\t%i\t", fSULowpt, fSUHighpt, fSUAllpt) ;
322 printf("\n");
323 printf(" number of UnlikeSign pair :\t");
324 printf("%i\t%i\t%i\t", fUSLowpt, fUSHighpt, fUSAllpt) ;
325 printf("\n");
326 printf(" number of LikeSign pair :\t");
327 printf("%i\t%i\t%i\t", fLSLowpt, fLSHighpt, fLSAllpt) ;
328 printf("\n");
329 printf("===================================================\n") ;
330 printf("\n") ;
331 printf("matching efficiency with the trigger for single tracks = %2d %% \n", effMatch);
332 printf("================================================================\n") ; printf("\n") ;
2e6ca202 333
9780bd43 334 }//if(pdc06TriggerResponse)
335
336 gSystem->cd(foutDir);
337
338 FILE *outtxt=fopen("output.txt","a");
339 freopen("output.txt","a",outtxt);
2e6ca202 340
9780bd43 341 if(pdc06TriggerResponse){
342 fprintf(outtxt," \n");
343 fprintf(outtxt,"===================================================\n");
344 fprintf(outtxt,"================ ESD SUMMARY ==============\n");
345 fprintf(outtxt," \n");
346 fprintf(outtxt," Total number of processed events %d \n", nev);
347 fprintf(outtxt,"\n");
348 fprintf(outtxt,"\n");
349 fprintf(outtxt,"Table 1: \n");
350 fprintf(outtxt," Global Trigger output Low pt High pt All\n");
351 fprintf(outtxt," number of Single Plus :\t");
352 fprintf(outtxt,"%i\t%i\t%i\t",fSPLowpt,fSPHighpt,fSPAllpt);
353 fprintf(outtxt,"\n");
354 fprintf(outtxt," number of Single Minus :\t");
355 fprintf(outtxt,"%i\t%i\t%i\t",fSMLowpt,fSMHighpt,fSMAllpt);
356 fprintf(outtxt,"\n");
357 fprintf(outtxt," number of Single Undefined :\t");
358 fprintf(outtxt,"%i\t%i\t%i\t",fSULowpt,fSUHighpt,fSUAllpt);
359 fprintf(outtxt,"\n");
360 fprintf(outtxt," number of UnlikeSign pair :\t");
361 fprintf(outtxt,"%i\t%i\t%i\t",fUSLowpt,fUSHighpt,fUSAllpt);
362 fprintf(outtxt,"\n");
363 fprintf(outtxt," number of LikeSign pair :\t");
364 fprintf(outtxt,"%i\t%i\t%i\t",fLSLowpt,fLSHighpt, fLSAllpt);
365 fprintf(outtxt,"\n");
366 fprintf(outtxt,"===================================================\n");
367 fprintf(outtxt,"\n");
368 fprintf(outtxt,"matching efficiency with the trigger for single tracks = %2d %% \n", effMatch);
369 }//if(pdc06TriggerResponse)
9780bd43 370
2e6ca202 371 else {
372
9780bd43 373 fprintf(outtxt," \n");
374 fprintf(outtxt,"===================================================\n");
375 fprintf(outtxt,"================ ESD SUMMARY ==============\n");
376 fprintf(outtxt," \n");
377 fprintf(outtxt," Total number of processed events %d \n", nev);
378 fprintf(outtxt,"\n");
379 fprintf(outtxt,"\n");
380 fprintf(outtxt,"Table 1: \n");
381 fprintf(outtxt," Global Trigger output Low pt High pt \n");
382 fprintf(outtxt," number of Single :\t");
383 fprintf(outtxt,"%i\t%i\t",fSLowpt,fSHighpt);
384 fprintf(outtxt,"\n");
385 fprintf(outtxt," number of UnlikeSign pair :\t");
386 fprintf(outtxt,"%i\t%i\t",fUSLowpt,fUSHighpt);
387 fprintf(outtxt,"\n");
388 fprintf(outtxt," number of LikeSign pair :\t");
389 fprintf(outtxt,"%i\t%i\t",fLSLowpt,fLSHighpt);
390 fprintf(outtxt,"\n");
391 fprintf(outtxt,"===================================================\n");
392 fprintf(outtxt,"\n");
393 fprintf(outtxt,"matching efficiency with the trigger for single tracks = %2d %% \n", effMatch);
394 }//else
395 fclose(outtxt);
396
397 TCanvas * c1 = new TCanvas("c1", "ESD", 400, 10, 600, 700) ;
398 c1->Divide(1,2) ;
399 c1->cd(1) ;
400 fhMUONVertex->Draw() ;
401 c1->cd(2) ;
402 fhMUONMult->Draw() ;
403 c1->Print("VertexAndMul.eps") ;
404 TCanvas *c2 = new TCanvas("c2","ESD",400,10,600,700);
405 c2->Divide(1,2);
406 c2->cd(1);
407 hY->Draw();
408 c2->cd(2);
409 hPt->Draw();
410 c2->Print("YandPt.eps") ;
70b4a8d6 411}
9780bd43 412
413//_____________________________________________________________________________
414void
415AliMUONCheck::CheckKine()
416{
71a2d3aa 417 /// Check Stack
9780bd43 418
2e6ca202 419 AliMUONMCDataInterface diSim(fFileNameSim.Data());
420 if (!diSim.IsValid()) return;
421
422 Int_t fnevents = diSim.NumberOfEvents();
9780bd43 423
9780bd43 424 Int_t endOfLoop = fLastEvent+1;
425
426 if ( fLastEvent == -1 ) endOfLoop = fnevents;
427
9780bd43 428 Int_t nev=0;
429 Int_t nmu=0;
430 Int_t nonemu=0;
431 Int_t ndimu=0;
9780bd43 432
2e6ca202 433 for ( Int_t ievent = fFirstEvent; ievent < endOfLoop; ++ievent )
434 {
9780bd43 435 Int_t nmu2=0;
2e6ca202 436 ++nev;
9780bd43 437
2e6ca202 438 AliStack* stack = diSim.Stack(ievent);
439 Int_t npa = stack->GetNprimary();
440 Int_t npb = stack->GetNtrack();
9780bd43 441 printf("Primary particles %i \n",npa);
442 printf("Sec particles %i \n",npb);
443 printf("=================================================================\n") ;
444 printf("Primary particles listing: \n");
445 printf("=================================================================\n") ;
2e6ca202 446 for (Int_t i=0; i<npa; ++i)
447 {
9780bd43 448 TParticle *p = stack->Particle(i);
449 p->Print("");
450 Int_t pdg=p->GetPdgCode();
451
2e6ca202 452 if (abs(pdg) == 13)
453 {
454 ++nmu2;
9780bd43 455 }
456 }
457 printf("=================================================================\n") ;
458 printf("=================================================================\n") ;
459
460 printf("Secondaries particles listing: \n");
461 printf("=================================================================\n") ;
2e6ca202 462 for (Int_t i=npa; i<npb; ++i)
463 {
9780bd43 464 stack->Particle(i)->Print("");
465 }
2e6ca202 466
9780bd43 467 printf("=================================================================\n") ;
468 printf(">>> Event %d, Number of primary particles is %d \n",ievent, npa);
469 printf(">>> Event %d, Number of secondary articles is %d \n",ievent, npb-npa);
470 printf("=================================================================\n");
2e6ca202 471 if(nmu2>0)
472 {
9780bd43 473 printf(">>> Okay!!! Event %d with at least one muon on primary stack! \n",ievent);
2e6ca202 474 ++nonemu;
9780bd43 475 }
476
2e6ca202 477 if(nmu2==0)
478 {
9780bd43 479 printf(">>> Warning!!! Event %d without muon on primary stack! \n",ievent);
2e6ca202 480 ++nmu;
9780bd43 481 }
2e6ca202 482
483 if(nmu2>1)
484 {
9780bd43 485 printf(">>> Okay!!! Event %d with at least two muons on primary stack! \n",ievent);
2e6ca202 486 ++ndimu;
9780bd43 487 }
488 printf("=================================================================\n");
489 printf(" \n");
490 printf(" \n") ;
491 }//ievent
492
9780bd43 493 printf("=================================================================\n") ;
494 printf(" Total number of processed events %d \n", nev) ;
495 printf(" \n") ;
496
2e6ca202 497 if(nmu>0)
498 {
9780bd43 499 printf("---> WARNING!!! <---\n");
500 printf(" %i events without muon on primary stack \n",nmu);
501 }
502
2e6ca202 503 if(nmu==0)
504 {
9780bd43 505 printf("---> OKAY!!! <---\n");
506 printf(" %i events generated with at least one muon on primary stack \n",nonemu);
507 }
2e6ca202 508
509 if(ndimu>0)
510 {
9780bd43 511 printf("---> OKAY!!! <---\n");
512 printf(" %i events generated with at least two muons on primary stack \n",ndimu);
513 }
2e6ca202 514
9780bd43 515 printf(" \n") ;
516 printf("*** Leaving MuonKine() *** \n");
517 printf("**************************************************************** \n");
518
519 gSystem->cd(foutDir);
520 FILE *outtxt=fopen("output.txt","a");
521 freopen("output.txt","a",outtxt);
522 fprintf(outtxt," \n");
523 fprintf(outtxt,"=================================================================\n");
524 fprintf(outtxt,"================ MUONkine SUMMARY ================\n");
525 fprintf(outtxt,"\n");
526 fprintf(outtxt,"=================================================================\n");
527 fprintf(outtxt," Total number of processed events %d \n", nev) ;
528 fprintf(outtxt," \n");
529
2e6ca202 530 if(nmu>0)
531 {
9780bd43 532 fprintf(outtxt," ---> WARNING!!! <--- \n");
533 fprintf(outtxt," %i events without muon on primary stack \n",nmu);
534 }
2e6ca202 535
536 if(nmu==0)
537 {
9780bd43 538 fprintf(outtxt," ---> OKAY!!! <--- \n");
539 fprintf(outtxt," %i events generated with at least one muon on primary stack \n",nonemu);
540 }
2e6ca202 541
542 if(ndimu>0)
543 {
9780bd43 544 fprintf(outtxt," ---> OKAY!!! <--- \n");
545 fprintf(outtxt," %i events generated with at least two muons on primary stack \n",ndimu);
546 }
2e6ca202 547
9780bd43 548 fprintf(outtxt," \n") ;
549 fprintf(outtxt,"*** Leaving MuonKine() *** \n");
550 fprintf(outtxt,"**************************************************************** \n");
551 fclose(outtxt);
9780bd43 552}
553
554//_____________________________________________________________________________
555void
556AliMUONCheck::CheckTrackRef()
557{
2e6ca202 558 /// Check TrackRef files
559
560 AliMUONMCDataInterface diSim(fFileNameSim.Data());
561 if ( !diSim.IsValid() ) return;
9780bd43 562
9780bd43 563 Int_t flag11=0,flag12=0,flag13=0,flag14=0;
2e6ca202 564
9780bd43 565 TH1F *tof01= new TH1F("tof01","TOF for first tracking plane",100,0.,100);
566 tof01->SetXTitle("tof (ns)");
567 TH1F *tof14= new TH1F("tof14","TOF for MT22",100,0.,100);
568 tof14->SetXTitle("tof (ns)");
569
570 TH1F *hitDensity[4];
571 hitDensity[0] = new TH1F("TR_dhits01","",30,0,300);
572 hitDensity[0]->SetFillColor(3);
573 hitDensity[0]->SetXTitle("R (cm)");
574 hitDensity[1] = new TH1F("TR_dhits10","",30,0,300);
575 hitDensity[1]->SetFillColor(3);
576 hitDensity[1]->SetXTitle("R (cm)");
577 hitDensity[2] = new TH1F("TR_dhits11","",30,0,300);
578 hitDensity[2]->SetFillColor(3);
579 hitDensity[2]->SetXTitle("R (cm)");
580 hitDensity[3] = new TH1F("TR_dhits14","",30,0,300);
581 hitDensity[3]->SetFillColor(3);
582 hitDensity[3]->SetXTitle("R (cm)");
9780bd43 583
2e6ca202 584 Int_t fnevents = diSim.NumberOfEvents();
585
9780bd43 586 Int_t endOfLoop = fLastEvent+1;
587
588 if ( fLastEvent == -1 ) endOfLoop = fnevents;
589
9780bd43 590 Int_t nev=0;
591 Int_t ntot=fLastEvent+1-fFirstEvent;
2e6ca202 592
593 for ( Int_t ievent = fFirstEvent; ievent < endOfLoop; ++ievent )
594 {
9780bd43 595 Int_t save=-99;
2e6ca202 596 ++nev;
597
598 Int_t nentries = diSim.NumberOfTrackRefs(ievent);
9780bd43 599
2e6ca202 600 for ( Int_t l=0; l<nentries; ++l )
9780bd43 601 {
2e6ca202 602 TClonesArray* trackRefs = diSim.TrackRefs(ievent,l);
603 if (!trackRefs) continue;
604
605 Int_t nnn = trackRefs->GetEntriesFast();
606
607 for ( Int_t k=0; k<nnn; ++k )
9780bd43 608 {
2e6ca202 609 AliTrackReference *tref = static_cast<AliTrackReference*>(trackRefs->UncheckedAt(k));
9780bd43 610 Int_t label = tref->GetTrack();
611 Float_t x = tref->X(); // x-pos of hit
612 Float_t y = tref->Y(); // y-pos
613 Float_t z = tref->Z();
614
615 Float_t r=TMath::Sqrt(x*x+y*y);
616 Float_t time = tref->GetTime();
617
618 Float_t wgt=1/(2*10*TMath::Pi()*r)/(ntot);
619
620 if (save!=label){
621 save=label;
622 flag11=0;
623 flag12=0;
624 flag13=0;
625 flag14=0;
626 }
2e6ca202 627
9780bd43 628 if (save==label){
629
630 //Ch 1, z=-526.16
631 if (z<=-521&& z>=-531&&flag11==0){
632 flag11=1;
633 hitDensity[0]->Fill(r,wgt);
634 tof01->Fill(1000000000*time,1);
635 };
636
637 //Ch 10, z=-1437.6
638 if (z<=-1432&&z>=-1442&&flag12==0){
639 flag12=1;
640 hitDensity[1]->Fill(r,wgt);
641 }
2e6ca202 642
9780bd43 643 //Ch 11, z=-1603.5
644 if (z<=-1598&& z>=-1608&&flag13==0){
645 flag13=1;
646 hitDensity[2]->Fill(r,wgt);
647 };
648
649 //ch 14 z=-1720.5
650 if(z<=-1715&&z>=-1725&&flag14==0){
651 flag14=1;
652 hitDensity[3]->Fill(r,wgt);
653 tof14->Fill(1000000000*time,1);
654 };
655
656 }//if save==label
2e6ca202 657
9780bd43 658 }//hits de tTR
2e6ca202 659
9780bd43 660 }//entree de tTR
2e6ca202 661
9780bd43 662 }//evt loop
2e6ca202 663
9780bd43 664 gSystem->cd(foutDir);
665 TCanvas *c6 = new TCanvas("c6","TOF",400,10,600,700);
666 c6->Divide(1,2);
667 c6->cd(1);
668
669 tof01->Draw();
670 c6->cd(2);
671 tof14->Draw();
672 c6->Print("tof_on_trigger.ps");
2e6ca202 673
9780bd43 674 TCanvas *c5 = new TCanvas("c5","TRef:Hits Density",400,10,600,700);
675 c5->Divide(2,2);
676 c5->cd(1);
677 hitDensity[0]->Draw();
678 c5->cd(2);
679 hitDensity[1]->Draw();
680 c5->cd(3);
681 hitDensity[2]->Draw();
682 c5->cd(4);
683 hitDensity[3]->Draw();
684 c5->Print("TR_Hit_densities.ps");
685 printf("=================================================================\n") ;
686 printf("================ %s Tref SUMMARY ==============\n", GetName()) ;
687 printf(" \n") ;
688 printf(" Total number of processed events %d \n", nev) ;
689 printf("*** Leaving TRef() *** \n");
690 printf("*************************************************** \n");
9780bd43 691}
692
693//_____________________________________________________________________________
694void
695AliMUONCheck::CheckOccupancy(Bool_t perDetEle) const
696{
2e6ca202 697 /// Check occupancy for the first event selected
698
9780bd43 699 Int_t dEoccupancyBending[14][26];
700 Int_t dEoccupancyNonBending[14][26];
701 Int_t cHoccupancyBending[14];
702 Int_t cHoccupancyNonBending[14];
703 Int_t totaloccupancyBending =0;
704 Int_t totaloccupancyNonBending =0;
2e6ca202 705
9780bd43 706 Int_t dEchannelsBending[14][26];
707 Int_t dEchannelsNonBending[14][26];
708 Int_t cHchannelsBending[14];
709 Int_t cHchannelsNonBending[14];
710 Int_t totalchannelsBending =0;
711 Int_t totalchannelsNonBending =0;
2e6ca202 712
713 Int_t nchambers = AliMUONConstants::NCh();
714
715 AliMUONDataInterface di(fFileNameSim);
716
717 AliMUONVDigitStore* digitStore = di.DigitStore(fFirstEvent);
718
88544f7e 719 if ( ! AliMpCDB::LoadMpSegmentation() )
720 AliFatal("Could not access mapping from OCDB !");
721
2e6ca202 722 // Compute values
723 for (Int_t ichamber=0; ichamber<nchambers; ++ichamber)
724 {
9780bd43 725 cHchannelsBending[ichamber]=0;
726 cHchannelsNonBending[ichamber]=0;
2e6ca202 727 cHoccupancyBending[ichamber]=0;
728 cHoccupancyNonBending[ichamber]=0;
729
730 for (Int_t idetele=0; idetele<26; idetele++)
731 {
9780bd43 732 Int_t detele = 100*(ichamber +1)+idetele;
2e6ca202 733
734 if ( AliMpDEManager::IsValidDetElemId(detele) )
735 {
736 Int_t cathode(0);
737
738 const AliMpVSegmentation* segbend = AliMpSegmentation::Instance()
739 ->GetMpSegmentation(detele, AliMp::kCath0);
740 const AliMpVSegmentation* segnonbend = AliMpSegmentation::Instance()
741 ->GetMpSegmentation(detele, AliMp::kCath1);
742
743 if (AliMpDEManager::GetPlaneType(detele, AliMp::kCath0) != AliMp::kBendingPlane )
744 {
745 const AliMpVSegmentation* tmp = segbend;
746 segbend = segnonbend;
747 segnonbend = tmp;
748 cathode = 1;
749 }
750
751 Int_t nchannels = segbend->NofPads();
752 Int_t ndigits = digitStore->GetSize(detele,cathode);
753 dEchannelsBending[ichamber][idetele] = nchannels;
754 dEoccupancyBending[ichamber][idetele] = ndigits;
755 cHchannelsBending[ichamber] += nchannels;
756 cHoccupancyBending[ichamber] += ndigits;
757 totalchannelsBending += nchannels;
758 totaloccupancyBending += ndigits;
759
760 nchannels = segnonbend->NofPads();
761 ndigits = digitStore->GetSize(detele,1-cathode);
762
763 dEchannelsNonBending[ichamber][idetele] = nchannels;
764 dEoccupancyBending[ichamber][idetele] = ndigits;
765 cHchannelsNonBending[ichamber] += nchannels;
766 cHoccupancyNonBending[ichamber] += ndigits;
767 totalchannelsNonBending += nchannels;
768 totaloccupancyNonBending += ndigits;
9780bd43 769 }
2e6ca202 770 if (perDetEle)
771 {
772 printf(">>> Detection element %4d has %5d channels in bending and %5d channels in nonbending \n",
773 detele, dEchannelsBending[ichamber][idetele], dEchannelsNonBending[ichamber][idetele] );
9780bd43 774 }
775 }
776 printf(">>> Chamber %2d has %6d channels in bending and %6d channels in nonbending \n",
2e6ca202 777 ichamber+1, cHchannelsBending[ichamber], cHchannelsNonBending[ichamber]);
9780bd43 778 }
779 printf(">>Spectrometer has %7d channels in bending and %7d channels in nonbending \n",
2e6ca202 780 totalchannelsBending, totalchannelsNonBending);
781
782 // Output values
783
784 for ( Int_t ichamber = 0; ichamber < 14; ++ichamber )
785 {
9780bd43 786 printf(">>> Chamber %2d nChannels Bending %5d nChannels NonBending %5d \n",
2e6ca202 787 ichamber+1,
788 cHoccupancyBending[ichamber],
789 cHoccupancyNonBending[ichamber]);
9780bd43 790 printf(">>> Chamber %2d Occupancy Bending %5.2f %% Occupancy NonBending %5.2f %% \n",
2e6ca202 791 ichamber+1,
792 100.*((Float_t) cHoccupancyBending[ichamber])/((Float_t) cHchannelsBending[ichamber]),
793 100.*((Float_t) cHoccupancyNonBending[ichamber])/((Float_t) cHchannelsBending[ichamber]) );
794
795 if ( perDetEle )
796 {
797 for(Int_t idetele=0; idetele<26; idetele++)
798 {
799 Int_t detele = idetele + 100*(ichamber+1);
800 if ( AliMpDEManager::IsValidDetElemId(detele) )
801 {
802 printf(">>> DetEle %4d nChannels Bending %5d nChannels NonBending %5d \n",
803 idetele+100*(ichamber+1),
804 dEoccupancyBending[ichamber][idetele],
805 dEoccupancyNonBending[ichamber][idetele]);
806 printf(">>> DetEle %4d Occupancy Bending %5.2f %% Occupancy NonBending %5.2f %% \n",
807 idetele+100*(ichamber+1),
808 100.*((Float_t) dEoccupancyBending[ichamber][idetele])/((Float_t) dEchannelsBending[ichamber][idetele]),
809 100.*((Float_t) dEoccupancyNonBending[ichamber][idetele])/((Float_t) dEchannelsBending[ichamber][idetele]));
810 }
9780bd43 811 }
812 }
2e6ca202 813 }
814
9780bd43 815 printf(">>> Muon Spectrometer Occupancy Bending %5.2f %% Occupancy NonBending %5.2f %% \n",
2e6ca202 816 100.*((Float_t) totaloccupancyBending)/((Float_t) totalchannelsBending),
817 100.*((Float_t) totaloccupancyNonBending)/((Float_t) totalchannelsNonBending) );
818
9780bd43 819}
820
821//_____________________________________________________________________________
822void
823AliMUONCheck::CheckRecTracks () const
824{
2e6ca202 825 /// Reads and dumps rec tracks objects
826
827 AliWarning("Reimplement me ? or use AliMUONDumper simply ?");
828
829 // // waiting for mag field in CDB
830 // AliInfoStream() << "Loading field map...\n";
831 // if (!AliTracker::GetFieldMap()) {
832 // AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 1, 1., 10., AliMagFMaps::k5kG);
833 // AliTracker::SetFieldMap(field, kFALSE);
834 // }
835 //
836 // // Loading data
837 // fLoader->LoadTracks("READ");
838 //
839 // Int_t endOfLoop = fLastEvent+1;
840 // if ( fLastEvent == -1 ) endOfLoop = fRunLoader->GetNumberOfEvents();
841 //
842 // for (Int_t ievent=fFirstEvent; ievent<endOfLoop; ievent++) {
843 // fRunLoader->GetEvent(ievent);
844 //
845 // fRecData->SetTreeAddress("RT");
846 // fRecData->GetRecTracks();
847 // TClonesArray* recTracks = fRecData->RecTracks();
848 //
849 // Int_t nrectracks = (Int_t) recTracks->GetEntriesFast(); //
850 // printf(">>> Event %d, Number of Recconstructed tracks %d \n",ievent, nrectracks);
851 //
852 // // Set the magnetic field for track extrapolations
853 // AliMUONTrackExtrap::SetField(AliTracker::GetFieldMap());
854 //
855 // // Loop over tracks
856 // for (Int_t iRecTracks = 0; iRecTracks < nrectracks; iRecTracks++) {
857 // AliMUONTrack* recTrack = (AliMUONTrack*) recTracks->At(iRecTracks);
858 // AliMUONTrackParam* trackParam = (AliMUONTrackParam*) (recTrack->GetTrackParamAtHit())->First();
859 // AliMUONTrackExtrap::ExtrapToZ(trackParam,0.);
860 // recTrack->Print("full");
861 // }
862 // fRecData->ResetRecTracks();
863 // }
864 // fLoader->UnloadTracks();
9780bd43 865}
866
867//_____________________________________________________________________________
868void AliMUONCheck::SetEventsToCheck(Int_t firstEvent, Int_t lastEvent)
869{
2e6ca202 870 /// Set first and last event number to check
871
9780bd43 872 fFirstEvent = firstEvent;
873 fLastEvent = lastEvent;
874}