Adding small protection
[u/mrichter/AliRoot.git] / MUON / MUONevaluation / 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"
2e6ca202 35#include "AliMUONMCDataInterface.h"
36#include "AliMUONDataInterface.h"
a55f49a0 37#include "AliMpCDB.h"
9780bd43 38#include "AliMpSegmentation.h"
39#include "AliMpVSegmentation.h"
40#include "AliMpDEManager.h"
88544f7e 41#include "AliMpCDB.h"
2e6ca202 42#include "AliMUONVDigitStore.h"
70b4a8d6 43
9780bd43 44#include "AliRunLoader.h"
70b4a8d6 45#include "AliLoader.h"
9780bd43 46#include "AliStack.h"
47#include "AliTrackReference.h"
48#include "AliTracker.h"
af885e0f 49#include "AliESDEvent.h"
9780bd43 50#include "AliESDMuonTrack.h"
aad72f45 51#include "AliESDVertex.h"
f7a1cc68 52#include "AliMagF.h"
70b4a8d6 53#include "AliLog.h"
70b4a8d6 54
9780bd43 55#include <TSystem.h>
56#include <TCanvas.h>
57#include <TLorentzVector.h>
58#include <TFile.h>
59#include <TH1.h>
60#include <TParticle.h>
70b4a8d6 61
5398f946 62/// \cond CLASSIMP
70b4a8d6 63ClassImp(AliMUONCheck)
5398f946 64/// \endcond
6b092dfc 65
31edb2d7 66//_____________________________________________________________________________
67const TString& AliMUONCheck::GetDefaultOutFileName()
68{
69 /// Default output file name
70 static const TString kDefaultOutFileName = "output.txt";
71 return kDefaultOutFileName;
72}
de62e2bd 73
31edb2d7 74//_____________________________________________________________________________
5a560b6a 75AliMUONCheck::AliMUONCheck(const char* galiceFile, const char* esdFile,Int_t firstEvent, Int_t lastEvent,const char* outDir)
76: TObject(),
2e6ca202 77fFileName(galiceFile),
78fFileNameSim(),
79fesdFileName(esdFile),
7d5d0cc5 80fkOutDir(outDir),
31edb2d7 81fOutFileName(GetDefaultOutFileName()),
2e6ca202 82fFirstEvent(firstEvent),
83fLastEvent(lastEvent)
5a560b6a 84{
cab86c08 85 /// ctor
5a560b6a 86}
2e6ca202 87
70b4a8d6 88//_____________________________________________________________________________
2e6ca202 89AliMUONCheck::AliMUONCheck(const char* galiceFile, const char* galiceFileSim,
90 const char* esdFile,Int_t firstEvent, Int_t lastEvent,
91 const char* outDir)
70b4a8d6 92: TObject(),
2e6ca202 93fFileName(galiceFile),
94fFileNameSim(galiceFileSim),
95fesdFileName(esdFile),
7d5d0cc5 96fkOutDir(outDir),
31edb2d7 97fOutFileName(GetDefaultOutFileName()),
2e6ca202 98fFirstEvent(firstEvent),
99fLastEvent(lastEvent)
70b4a8d6 100{
71a2d3aa 101 /// ctor
9780bd43 102}
103
104//_____________________________________________________________________________
70b4a8d6 105AliMUONCheck::~AliMUONCheck()
106{
2e6ca202 107 /// Destructor
70b4a8d6 108}
109
110//_____________________________________________________________________________
111void
9780bd43 112AliMUONCheck::CheckESD(Bool_t pdc06TriggerResponse)
70b4a8d6 113{
71a2d3aa 114 /// Check ESD files
70b4a8d6 115
9780bd43 116 // Histograms
117 TH1F * fhMUONVertex ; //!
118 TH1F * fhMUONMult ; //!
119
120 // create histograms
121 fhMUONVertex = new TH1F("hMUONVertex","ITS Vertex" ,100, -25., 25.);
122 fhMUONMult = new TH1F("hMUONMult" ,"Multiplicity of ESD tracks",10, -0.5, 9.5);
70b4a8d6 123
9780bd43 124 TH1F *hY = new TH1F("hY","Rapidity",100,-5.,-1.);
125 TH1F *hPt = new TH1F("hPt","Pt",100, 0.,20.);
70b4a8d6 126
9780bd43 127 // ------------->open the ESD file
128 TFile* esdFile = TFile::Open(fesdFileName.Data());
129
2e6ca202 130 if (!esdFile || !esdFile->IsOpen())
131 {
9780bd43 132 AliError(Form("Error opening %s file \n",fesdFileName.Data()));
2e6ca202 133 return;
134 }
135
9780bd43 136 Int_t fSPLowpt=0 ; //!
137 Int_t fSPHighpt=0 ; //!
138 Int_t fSPAllpt=0 ; //!
139 Int_t fSMLowpt=0 ; //!
140 Int_t fSMHighpt =0 ; //!
141 Int_t fSMAllpt=0 ; //!
142 Int_t fSULowpt=0 ; //!
143 Int_t fSUHighpt=0 ; //!
144 Int_t fSUAllpt=0 ; //!
145 Int_t fUSLowpt=0 ; //!
146 Int_t fUSHighpt=0 ; //!
147 Int_t fUSAllpt=0 ; //!
148 Int_t fLSLowpt=0 ; //!
149 Int_t fLSHighpt=0 ; //!
150 Int_t fLSAllpt=0 ; //!
2e6ca202 151
9780bd43 152 Int_t fSLowpt=0 ; //!
153 Int_t fSHighpt=0 ; //!
2e6ca202 154
9780bd43 155 Int_t fnTrackTrig=0 ; //!
156 Int_t ftracktot=0 ; //!
157 Int_t effMatch=0 ; //!
158
159 TLorentzVector fV1;
160 Float_t muonMass = 0.105658389;
161 Double_t thetaX, thetaY, pYZ;
162 Double_t fPxRec1, fPyRec1, fPzRec1, fE1;
9780bd43 163
af885e0f 164 AliESDEvent* fESD = new AliESDEvent();
2e6ca202 165 TTree* tree = (TTree*) esdFile->Get("esdTree");
166 if (!tree)
167 {
9780bd43 168 Error("CheckESD", "no ESD tree found");
1130977f 169 AliError(Form("no ESD tree found"));
9780bd43 170 return ;
171 }
2e6ca202 172 fESD->ReadFromTree(tree);
9780bd43 173
2e6ca202 174 Int_t fnevents = tree->GetEntries();
9780bd43 175 Int_t endOfLoop = fLastEvent+1;
2e6ca202 176
9780bd43 177 if ( fLastEvent == -1 ) endOfLoop = fnevents;
178 Int_t ievent=0;
179 Int_t nev=0;
2e6ca202 180
9780bd43 181 for (ievent = fFirstEvent; ievent < endOfLoop; ++ievent )
70b4a8d6 182 {
2e6ca202 183 nev++;
a99c3449 184 if (tree->GetEvent(ievent) <= 0)
2e6ca202 185 {
9780bd43 186 Error("CheckESD", "no ESD object found for event %d", ievent);
187 return ;
188 }
2e6ca202 189 AliESDVertex* vertex = (AliESDVertex*) fESD->GetVertex();
9780bd43 190
191 Double_t zVertex = 0. ;
e690d4d0 192 if (vertex) zVertex = vertex->GetZ();
2e6ca202 193
9780bd43 194 Int_t nTracks = (Int_t)fESD->GetNumberOfMuonTracks() ;
195 ULong64_t trigword=fESD->GetTriggerMask();
2e6ca202 196
197 if(pdc06TriggerResponse)
198 {
9780bd43 199 if (trigword & 0x01) {
200 fSPLowpt++;
201 }
2e6ca202 202
9780bd43 203 if (trigword & 0x02){
204 fSPHighpt++;
205 }
206 if (trigword & 0x04){
207 fSPAllpt++;
208 }
209 if (trigword & 0x08){
210 fSMLowpt++;
211 }
212 if (trigword & 0x010){
213 fSMHighpt++;
214 }
215 if (trigword & 0x020){
216 fSMAllpt++;
217 }
218 if (trigword & 0x040){
219 fSULowpt++;
220 }
221 if (trigword & 0x080){
222 fSUHighpt++;
223 }
224 if (trigword & 0x100){
225 fSUAllpt++;
226 }
227 if (trigword & 0x200){
228 fUSLowpt++;
229 }
2e6ca202 230
9780bd43 231 if (trigword & 0x400){
232 fUSHighpt++;
233 }
234 if (trigword & 0x800){
235 fUSAllpt++;
236 }
237 if (trigword & 0x1000){
238 fLSLowpt++;
239 }
2e6ca202 240
9780bd43 241 if (trigword & 0x2000){
242 fLSHighpt++;
243 }
2e6ca202 244
9780bd43 245 if (trigword & 0x4000){
246 fLSAllpt++;
247 }
248 }// if pdc06TriggerResponse
249 else {
250 if (trigword & 0x01) {
251 fSLowpt++;
252 }
2e6ca202 253
9780bd43 254 if (trigword & 0x02){
255 fSHighpt++;
256 }
257 if (trigword & 0x04){
258 fLSLowpt++;
259 }
260 if (trigword & 0x08){
261 fLSHighpt++;
262 }
263 if (trigword & 0x010){
264 fUSLowpt++;
265 }
266 if (trigword & 0x020){
267 fUSHighpt++;
268 }
269 }
270
271 Int_t tracktrig=0;
2e6ca202 272
273 for ( Int_t iTrack1 = 0; iTrack1<nTracks; ++iTrack1 )
274 { //1st loop
9780bd43 275 AliESDMuonTrack* muonTrack = fESD->GetMuonTrack(iTrack1);
b1fea02e 276
277 // skip fake tracks (ghosts)
278 if (!muonTrack->ContainTrackerData()) continue;
279
9780bd43 280 ftracktot++;
281
282 thetaX = muonTrack->GetThetaX();
283 thetaY = muonTrack->GetThetaY();
284 pYZ = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
2e6ca202 285
9780bd43 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);
9780bd43 289 fE1 = TMath::Sqrt(muonMass * muonMass + fPxRec1 * fPxRec1 + fPyRec1 * fPyRec1 + fPzRec1 * fPzRec1);
290 fV1.SetPxPyPzE(fPxRec1, fPyRec1, fPzRec1, fE1);
291 // -----------> transverse momentum
292 Float_t pt1 = fV1.Pt();
293 // ----------->Rapidity
294 Float_t y1 = fV1.Rapidity();
2e6ca202 295
296 if(muonTrack->GetMatchTrigger())
297 {
9780bd43 298 fnTrackTrig++;
299 tracktrig++;
300 }
301 hY->Fill(y1);
302 hPt->Fill(pt1);
2e6ca202 303 } // loop on track
304
9780bd43 305 fhMUONVertex->Fill(zVertex) ;
306 fhMUONMult->Fill(Float_t(nTracks)) ;
2e6ca202 307
9780bd43 308 } // loop over events
309
310 AliInfo(Form("Terminate %s:", GetName())) ;
311
4fa6297a 312 if ( ftracktot > 0 )
313 {
314 effMatch=100*fnTrackTrig/ftracktot;
315 }
2e6ca202 316
317 if(pdc06TriggerResponse)
318 {
9780bd43 319 printf("=================================================================\n") ;
320 printf("================ %s ESD SUMMARY ==============\n", GetName()) ;
321 printf(" \n") ;
322 printf(" Total number of processed events %d \n", nev) ;
323 printf("\n") ;
324 printf("\n") ;
325 printf("Table 1: \n") ;
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) ;
329 printf("\n");
330 printf(" number of Single Minus :\t");
331 printf("%i\t%i\t%i\t", fSMLowpt, fSMHighpt, fSMAllpt) ;
332 printf("\n");
333 printf(" number of Single Undefined :\t");
334 printf("%i\t%i\t%i\t", fSULowpt, fSUHighpt, fSUAllpt) ;
335 printf("\n");
336 printf(" number of UnlikeSign pair :\t");
337 printf("%i\t%i\t%i\t", fUSLowpt, fUSHighpt, fUSAllpt) ;
338 printf("\n");
339 printf(" number of LikeSign pair :\t");
340 printf("%i\t%i\t%i\t", fLSLowpt, fLSHighpt, fLSAllpt) ;
341 printf("\n");
342 printf("===================================================\n") ;
343 printf("\n") ;
344 printf("matching efficiency with the trigger for single tracks = %2d %% \n", effMatch);
345 printf("================================================================\n") ; printf("\n") ;
2e6ca202 346
9780bd43 347 }//if(pdc06TriggerResponse)
348
7d5d0cc5 349 gSystem->cd(fkOutDir);
9780bd43 350
de62e2bd 351 FILE *outtxt=fopen(fOutFileName.Data(),"a");
2e6ca202 352
9780bd43 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);
381 }//if(pdc06TriggerResponse)
9780bd43 382
2e6ca202 383 else {
384
9780bd43 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);
406 }//else
407 fclose(outtxt);
408
409 TCanvas * c1 = new TCanvas("c1", "ESD", 400, 10, 600, 700) ;
410 c1->Divide(1,2) ;
411 c1->cd(1) ;
412 fhMUONVertex->Draw() ;
413 c1->cd(2) ;
414 fhMUONMult->Draw() ;
415 c1->Print("VertexAndMul.eps") ;
416 TCanvas *c2 = new TCanvas("c2","ESD",400,10,600,700);
417 c2->Divide(1,2);
418 c2->cd(1);
419 hY->Draw();
420 c2->cd(2);
421 hPt->Draw();
422 c2->Print("YandPt.eps") ;
70b4a8d6 423}
9780bd43 424
425//_____________________________________________________________________________
426void
427AliMUONCheck::CheckKine()
428{
71a2d3aa 429 /// Check Stack
9780bd43 430
2e6ca202 431 AliMUONMCDataInterface diSim(fFileNameSim.Data());
432 if (!diSim.IsValid()) return;
433
434 Int_t fnevents = diSim.NumberOfEvents();
9780bd43 435
9780bd43 436 Int_t endOfLoop = fLastEvent+1;
437
438 if ( fLastEvent == -1 ) endOfLoop = fnevents;
439
9780bd43 440 Int_t nev=0;
441 Int_t nmu=0;
442 Int_t nonemu=0;
443 Int_t ndimu=0;
9780bd43 444
2e6ca202 445 for ( Int_t ievent = fFirstEvent; ievent < endOfLoop; ++ievent )
446 {
9780bd43 447 Int_t nmu2=0;
2e6ca202 448 ++nev;
9780bd43 449
2e6ca202 450 AliStack* stack = diSim.Stack(ievent);
451 Int_t npa = stack->GetNprimary();
452 Int_t npb = stack->GetNtrack();
9780bd43 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") ;
2e6ca202 458 for (Int_t i=0; i<npa; ++i)
459 {
9780bd43 460 TParticle *p = stack->Particle(i);
461 p->Print("");
462 Int_t pdg=p->GetPdgCode();
463
b8bec44f 464 if (TMath::Abs(pdg) == 13)
2e6ca202 465 {
466 ++nmu2;
9780bd43 467 }
468 }
469 printf("=================================================================\n") ;
470 printf("=================================================================\n") ;
471
472 printf("Secondaries particles listing: \n");
473 printf("=================================================================\n") ;
2e6ca202 474 for (Int_t i=npa; i<npb; ++i)
475 {
9780bd43 476 stack->Particle(i)->Print("");
477 }
2e6ca202 478
9780bd43 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");
2e6ca202 483 if(nmu2>0)
484 {
9780bd43 485 printf(">>> Okay!!! Event %d with at least one muon on primary stack! \n",ievent);
2e6ca202 486 ++nonemu;
9780bd43 487 }
488
2e6ca202 489 if(nmu2==0)
490 {
9780bd43 491 printf(">>> Warning!!! Event %d without muon on primary stack! \n",ievent);
2e6ca202 492 ++nmu;
9780bd43 493 }
2e6ca202 494
495 if(nmu2>1)
496 {
9780bd43 497 printf(">>> Okay!!! Event %d with at least two muons on primary stack! \n",ievent);
2e6ca202 498 ++ndimu;
9780bd43 499 }
500 printf("=================================================================\n");
501 printf(" \n");
502 printf(" \n") ;
503 }//ievent
504
9780bd43 505 printf("=================================================================\n") ;
506 printf(" Total number of processed events %d \n", nev) ;
507 printf(" \n") ;
508
2e6ca202 509 if(nmu>0)
510 {
9780bd43 511 printf("---> WARNING!!! <---\n");
512 printf(" %i events without muon on primary stack \n",nmu);
513 }
514
2e6ca202 515 if(nmu==0)
516 {
9780bd43 517 printf("---> OKAY!!! <---\n");
518 printf(" %i events generated with at least one muon on primary stack \n",nonemu);
519 }
2e6ca202 520
521 if(ndimu>0)
522 {
9780bd43 523 printf("---> OKAY!!! <---\n");
524 printf(" %i events generated with at least two muons on primary stack \n",ndimu);
525 }
2e6ca202 526
9780bd43 527 printf(" \n") ;
528 printf("*** Leaving MuonKine() *** \n");
529 printf("**************************************************************** \n");
530
7d5d0cc5 531 gSystem->cd(fkOutDir);
de62e2bd 532 FILE *outtxt=fopen(fOutFileName.Data(),"a");
9780bd43 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");
540
2e6ca202 541 if(nmu>0)
542 {
9780bd43 543 fprintf(outtxt," ---> WARNING!!! <--- \n");
544 fprintf(outtxt," %i events without muon on primary stack \n",nmu);
545 }
2e6ca202 546
547 if(nmu==0)
548 {
9780bd43 549 fprintf(outtxt," ---> OKAY!!! <--- \n");
550 fprintf(outtxt," %i events generated with at least one muon on primary stack \n",nonemu);
551 }
2e6ca202 552
553 if(ndimu>0)
554 {
9780bd43 555 fprintf(outtxt," ---> OKAY!!! <--- \n");
556 fprintf(outtxt," %i events generated with at least two muons on primary stack \n",ndimu);
557 }
2e6ca202 558
9780bd43 559 fprintf(outtxt," \n") ;
560 fprintf(outtxt,"*** Leaving MuonKine() *** \n");
561 fprintf(outtxt,"**************************************************************** \n");
562 fclose(outtxt);
9780bd43 563}
564
565//_____________________________________________________________________________
566void
567AliMUONCheck::CheckTrackRef()
568{
2e6ca202 569 /// Check TrackRef files
570
571 AliMUONMCDataInterface diSim(fFileNameSim.Data());
572 if ( !diSim.IsValid() ) return;
9780bd43 573
9780bd43 574 Int_t flag11=0,flag12=0,flag13=0,flag14=0;
2e6ca202 575
9780bd43 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)");
580
581 TH1F *hitDensity[4];
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)");
9780bd43 594
2e6ca202 595 Int_t fnevents = diSim.NumberOfEvents();
596
9780bd43 597 Int_t endOfLoop = fLastEvent+1;
598
599 if ( fLastEvent == -1 ) endOfLoop = fnevents;
600
9780bd43 601 Int_t nev=0;
602 Int_t ntot=fLastEvent+1-fFirstEvent;
2e6ca202 603
604 for ( Int_t ievent = fFirstEvent; ievent < endOfLoop; ++ievent )
605 {
9780bd43 606 Int_t save=-99;
2e6ca202 607 ++nev;
608
609 Int_t nentries = diSim.NumberOfTrackRefs(ievent);
9780bd43 610
2e6ca202 611 for ( Int_t l=0; l<nentries; ++l )
9780bd43 612 {
2e6ca202 613 TClonesArray* trackRefs = diSim.TrackRefs(ievent,l);
614 if (!trackRefs) continue;
615
616 Int_t nnn = trackRefs->GetEntriesFast();
617
618 for ( Int_t k=0; k<nnn; ++k )
9780bd43 619 {
2e6ca202 620 AliTrackReference *tref = static_cast<AliTrackReference*>(trackRefs->UncheckedAt(k));
9780bd43 621 Int_t label = tref->GetTrack();
622 Float_t x = tref->X(); // x-pos of hit
623 Float_t y = tref->Y(); // y-pos
624 Float_t z = tref->Z();
625
626 Float_t r=TMath::Sqrt(x*x+y*y);
627 Float_t time = tref->GetTime();
628
629 Float_t wgt=1/(2*10*TMath::Pi()*r)/(ntot);
630
631 if (save!=label){
632 save=label;
633 flag11=0;
634 flag12=0;
635 flag13=0;
636 flag14=0;
637 }
2e6ca202 638
9780bd43 639 if (save==label){
640
641 //Ch 1, z=-526.16
642 if (z<=-521&& z>=-531&&flag11==0){
643 flag11=1;
644 hitDensity[0]->Fill(r,wgt);
645 tof01->Fill(1000000000*time,1);
646 };
647
648 //Ch 10, z=-1437.6
649 if (z<=-1432&&z>=-1442&&flag12==0){
650 flag12=1;
651 hitDensity[1]->Fill(r,wgt);
652 }
2e6ca202 653
9780bd43 654 //Ch 11, z=-1603.5
655 if (z<=-1598&& z>=-1608&&flag13==0){
656 flag13=1;
657 hitDensity[2]->Fill(r,wgt);
658 };
659
660 //ch 14 z=-1720.5
661 if(z<=-1715&&z>=-1725&&flag14==0){
662 flag14=1;
663 hitDensity[3]->Fill(r,wgt);
664 tof14->Fill(1000000000*time,1);
665 };
666
667 }//if save==label
2e6ca202 668
9780bd43 669 }//hits de tTR
2e6ca202 670
9780bd43 671 }//entree de tTR
2e6ca202 672
9780bd43 673 }//evt loop
2e6ca202 674
7d5d0cc5 675 gSystem->cd(fkOutDir);
9780bd43 676 TCanvas *c6 = new TCanvas("c6","TOF",400,10,600,700);
677 c6->Divide(1,2);
678 c6->cd(1);
679
680 tof01->Draw();
681 c6->cd(2);
682 tof14->Draw();
683 c6->Print("tof_on_trigger.ps");
2e6ca202 684
9780bd43 685 TCanvas *c5 = new TCanvas("c5","TRef:Hits Density",400,10,600,700);
686 c5->Divide(2,2);
687 c5->cd(1);
688 hitDensity[0]->Draw();
689 c5->cd(2);
690 hitDensity[1]->Draw();
691 c5->cd(3);
692 hitDensity[2]->Draw();
693 c5->cd(4);
694 hitDensity[3]->Draw();
695 c5->Print("TR_Hit_densities.ps");
696 printf("=================================================================\n") ;
697 printf("================ %s Tref SUMMARY ==============\n", GetName()) ;
698 printf(" \n") ;
699 printf(" Total number of processed events %d \n", nev) ;
700 printf("*** Leaving TRef() *** \n");
701 printf("*************************************************** \n");
9780bd43 702}
703
704//_____________________________________________________________________________
705void
706AliMUONCheck::CheckOccupancy(Bool_t perDetEle) const
707{
2e6ca202 708 /// Check occupancy for the first event selected
709
9780bd43 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;
2e6ca202 716
9780bd43 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;
2e6ca202 723
724 Int_t nchambers = AliMUONConstants::NCh();
725
726 AliMUONDataInterface di(fFileNameSim);
727
728 AliMUONVDigitStore* digitStore = di.DigitStore(fFirstEvent);
729
730 // Compute values
731 for (Int_t ichamber=0; ichamber<nchambers; ++ichamber)
732 {
9780bd43 733 cHchannelsBending[ichamber]=0;
734 cHchannelsNonBending[ichamber]=0;
2e6ca202 735 cHoccupancyBending[ichamber]=0;
736 cHoccupancyNonBending[ichamber]=0;
737
738 for (Int_t idetele=0; idetele<26; idetele++)
739 {
9780bd43 740 Int_t detele = 100*(ichamber +1)+idetele;
2e6ca202 741
742 if ( AliMpDEManager::IsValidDetElemId(detele) )
743 {
744 Int_t cathode(0);
745
746 const AliMpVSegmentation* segbend = AliMpSegmentation::Instance()
747 ->GetMpSegmentation(detele, AliMp::kCath0);
748 const AliMpVSegmentation* segnonbend = AliMpSegmentation::Instance()
749 ->GetMpSegmentation(detele, AliMp::kCath1);
750
751 if (AliMpDEManager::GetPlaneType(detele, AliMp::kCath0) != AliMp::kBendingPlane )
752 {
753 const AliMpVSegmentation* tmp = segbend;
754 segbend = segnonbend;
755 segnonbend = tmp;
756 cathode = 1;
757 }
758
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;
767
768 nchannels = segnonbend->NofPads();
769 ndigits = digitStore->GetSize(detele,1-cathode);
770
771 dEchannelsNonBending[ichamber][idetele] = nchannels;
92b90935 772 dEoccupancyNonBending[ichamber][idetele] = ndigits;
2e6ca202 773 cHchannelsNonBending[ichamber] += nchannels;
774 cHoccupancyNonBending[ichamber] += ndigits;
775 totalchannelsNonBending += nchannels;
776 totaloccupancyNonBending += ndigits;
9780bd43 777 }
2e6ca202 778 if (perDetEle)
779 {
780 printf(">>> Detection element %4d has %5d channels in bending and %5d channels in nonbending \n",
781 detele, dEchannelsBending[ichamber][idetele], dEchannelsNonBending[ichamber][idetele] );
9780bd43 782 }
783 }
784 printf(">>> Chamber %2d has %6d channels in bending and %6d channels in nonbending \n",
2e6ca202 785 ichamber+1, cHchannelsBending[ichamber], cHchannelsNonBending[ichamber]);
9780bd43 786 }
787 printf(">>Spectrometer has %7d channels in bending and %7d channels in nonbending \n",
2e6ca202 788 totalchannelsBending, totalchannelsNonBending);
789
790 // Output values
791
5213784e 792 for ( Int_t ichamber = 0; ichamber < nchambers; ++ichamber )
2e6ca202 793 {
9780bd43 794 printf(">>> Chamber %2d nChannels Bending %5d nChannels NonBending %5d \n",
2e6ca202 795 ichamber+1,
796 cHoccupancyBending[ichamber],
c8218bec 797 cHoccupancyNonBending[ichamber]);
798 if ( cHchannelsBending[ichamber] != 0 && cHchannelsBending[ichamber] ) {
799 printf(">>> Chamber %2d Occupancy Bending %5.2f %% Occupancy NonBending %5.2f %% \n",
800 ichamber+1,
801 100.*((Float_t) cHoccupancyBending[ichamber])/((Float_t) cHchannelsBending[ichamber]),
802 100.*((Float_t) cHoccupancyNonBending[ichamber])/((Float_t) cHchannelsBending[ichamber]));
803 }
2e6ca202 804
805 if ( perDetEle )
806 {
807 for(Int_t idetele=0; idetele<26; idetele++)
808 {
809 Int_t detele = idetele + 100*(ichamber+1);
810 if ( AliMpDEManager::IsValidDetElemId(detele) )
811 {
812 printf(">>> DetEle %4d nChannels Bending %5d nChannels NonBending %5d \n",
813 idetele+100*(ichamber+1),
814 dEoccupancyBending[ichamber][idetele],
815 dEoccupancyNonBending[ichamber][idetele]);
c8218bec 816
4adf1b4c 817 if ( dEchannelsBending[ichamber][idetele] != 0 && dEchannelsNonBending[ichamber][idetele] !=0 ) {
c8218bec 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]),
4adf1b4c 821 100.*((Float_t) dEoccupancyNonBending[ichamber][idetele])/((Float_t) dEchannelsNonBending[ichamber][idetele]));
c8218bec 822 }
2e6ca202 823 }
9780bd43 824 }
825 }
2e6ca202 826 }
827
c8218bec 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));
832 }
9780bd43 833}
834
835//_____________________________________________________________________________
9780bd43 836void AliMUONCheck::SetEventsToCheck(Int_t firstEvent, Int_t lastEvent)
837{
2e6ca202 838 /// Set first and last event number to check
839
9780bd43 840 fFirstEvent = firstEvent;
841 fLastEvent = lastEvent;
842}