AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONDigitizerV3.cxx
Go to the documentation of this file.
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 
18 
19 #include "AliMUONDigitizerV3.h"
20 
21 #include "AliMUON.h"
22 #include "AliMUONCalibrationData.h"
23 #include "AliMUONConstants.h"
24 #include "AliMUONDigit.h"
25 #include "AliMUONLogger.h"
27 #include "AliMUONTriggerStoreV1.h"
28 #include "AliMUONVCalibParam.h"
29 #include "AliMUONVDigitStore.h"
30 #include "AliMUONGeometryTransformer.h" //ADDED for trigger noise
31 #include "AliMUONRecoParam.h"
34 
35 #include "AliMpCDB.h"
36 #include "AliMpSegmentation.h"
37 #include "AliMpCathodType.h"
38 #include "AliMpConstants.h"
39 #include "AliMpDEIterator.h"
40 #include "AliMpDEManager.h"
41 #include "AliMpPad.h"
42 #include "AliMpStationType.h"
43 #include "AliMpVSegmentation.h"
44 #include "AliMpDDLStore.h"
45 
46 #include "AliCDBManager.h"
47 #include "AliCodeTimer.h"
48 #include "AliLog.h"
49 #include "AliRun.h"
50 #include "AliDigitizationInput.h"
51 #include "AliLoader.h"
52 #include "AliRunLoader.h"
53 
54 #include <Riostream.h>
55 #include <TF1.h>
56 #include <TFile.h>
57 #include <TMath.h>
58 #include <TRandom.h>
59 #include <TString.h>
60 #include <TSystem.h>
61 #include <TTree.h>
62 
63 //-----------------------------------------------------------------------------
90 //-----------------------------------------------------------------------------
91 
92 namespace
93 {
94  AliMUON* muon()
95  {
96  return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
97  }
98 
99  //ADDED for trigger noise
100  const AliMUONGeometryTransformer* GetTransformer()
101  {
102  return muon()->GetGeometryTransformer();
103  }
104 }
105 
106 Double_t AliMUONDigitizerV3::fgNSigmas = 4.0;
107 
111 
112 //_____________________________________________________________________________
113 AliMUONDigitizerV3::AliMUONDigitizerV3(AliDigitizationInput* digInput,
114  Int_t generateNoisyDigits)
115 : AliDigitizer(digInput),
116 fIsInitialized(kFALSE),
117 fCalibrationData(0x0),
118 fTriggerProcessor(0x0),
119 fNoiseFunctionTrig(0x0),
120 fGenerateNoisyDigits(generateNoisyDigits),
121 fLogger(new AliMUONLogger(4207)), /* 4207 = 25% of the 16828 MCH manus */
122 fTriggerStore(new AliMUONTriggerStoreV1),
123 fDigitStore(0x0),
124 fOutputDigitStore(0x0),
125 fInputDigitStores(0x0),
126 fRecoParam(0x0),
127 fTriggerEfficiency(0x0),
128 fTriggerUtilities(0x0),
129 fEfficiencyResponse(2*AliMUONConstants::NTriggerCh()*AliMUONConstants::NTriggerCircuit())
130 {
132 
133  AliDebug(1,Form("AliDigitizationInput=%p",fDigInput));
134 
135 }
136 
137 //_____________________________________________________________________________
139 {
141 
142  AliDebug(1,"dtor");
143 
144  // delete fCalibrationData;
145  delete fTriggerProcessor;
146  delete fNoiseFunctionTrig;
147  delete fTriggerStore;
148  delete fDigitStore;
149  delete fOutputDigitStore;
150  delete fInputDigitStores;
151  delete fTriggerUtilities;
152 
153  AliInfo("Summary of messages");
154  fLogger->Print();
155 
156  delete fLogger;
157 }
158 
159 //_____________________________________________________________________________
160 void
162 {
169 
170  Float_t charge = digit.Charge();
171 
172  if (!digit.IsChargeInFC())
173  {
175  fLogger->Log("CHECK ME ! WAS NOT SUPPOSED TO BE HERE !!! ARE YOU RECONSTRUCTING OLD SIMULATIONS ? ");
176  AliError("CHECK ME ! WAS NOT SUPPOSED TO BE HERE !!! ARE YOU RECONSTRUCTING OLD SIMULATIONS ? ");
177  }
178 
179  // We set the charge to 0, as the only relevant piece of information
180  // after Digitization is the ADC value.
181  digit.SetCharge(0);
182 
183  Int_t detElemId = digit.DetElemId();
184  Int_t manuId = digit.ManuId();
185 
186  AliMUONVCalibParam* pedestal = fCalibrationData->Pedestals(detElemId,manuId);
187  if (!pedestal)
188  {
189  fLogger->Log(Form("%s:%d:Could not get pedestal for DE=%4d manuId=%4d. Disabling.",
190  __FILE__,__LINE__,
191  detElemId,manuId));
192  digit.SetADC(0);
193  return;
194  }
195 
196  Int_t manuChannel = digit.ManuChannel();
197 
198  if ( pedestal->ValueAsFloat(manuChannel,0) == AliMUONVCalibParam::InvalidFloatValue() ||
199  pedestal->ValueAsFloat(manuChannel,1) == AliMUONVCalibParam::InvalidFloatValue() )
200  {
201  // protection against invalid pedestal value
202  digit.SetADC(0);
203  return;
204  }
205 
206  Int_t adc = DecalibrateTrackerDigit(*pedestal,manuChannel,charge,addNoise,
207  digit.IsNoiseOnly());
208 
209  digit.SetADC(adc);
210 }
211 
212 
213 //_____________________________________________________________________________
214 void
216 {
221 
222  Int_t detElemId = digit.DetElemId();
223  Int_t localCircuit = digit.ManuId();
224  Int_t strip = digit.ManuChannel();
225  Int_t cathode = digit.Cathode();
226  Int_t trigCh = detElemId/100 - 11;
227 
228  // Masked channels
229  Bool_t isMasked = fTriggerUtilities->IsMasked(digit);
230  AliDebug(1,Form("detElemId %i cath %i board %i strip %i is masked %i\n", detElemId, cathode, localCircuit, strip, isMasked));
231  if ( isMasked ) {
232  digit.SetCharge(0);
233  digit.SetADC(0);
234  //AliDebug(1,Form("ch %i cath %i board %i strip %i masked\n", trigCh, cathode, localCircuit, strip));
235  return;
236  }
237 
238 
239  Int_t arrayIndex = GetArrayIndex(cathode, trigCh, localCircuit);
240 
241  // Trigger chamber efficiency
242  if ( fTriggerEfficiency ) {
243  if ( fEfficiencyResponse[arrayIndex] < 0 ) {
244  Bool_t isTrig[2] = {kTRUE, kTRUE};
245  fTriggerEfficiency->IsTriggered(detElemId, localCircuit, isTrig[0], isTrig[1]);
246  Int_t arrayIndexBend = GetArrayIndex(0, trigCh, localCircuit);
247  Int_t arrayIndexNonBend = GetArrayIndex(1, trigCh, localCircuit);
248  fEfficiencyResponse[arrayIndexBend] = isTrig[0];
249  fEfficiencyResponse[arrayIndexNonBend] = isTrig[1];
250  }
251  AliDebug(1,Form("detElemId %i cath %i board %i strip %i efficiency %i\n", detElemId, cathode, localCircuit, strip, fEfficiencyResponse[arrayIndex]));
252  if ( fEfficiencyResponse[arrayIndex] == 0 ) {
253  digit.SetCharge(0);
254  digit.SetADC(0);
255  //AliDebug(1,Form("ch %i cath %i board %i strip %i NOT efficient\n", trigCh, cathode, localCircuit, strip));
256  return;
257  }
258  }
259 }
260 
261 
262 
263 //_____________________________________________________________________________
264 void
266  AliMUONVDigitStore& filteredStore)
267 {
270 
271  filteredStore.Clear();
272 
273  const Bool_t kAddNoise = kTRUE;
274 
275  TIter next(store.CreateIterator());
276  AliMUONVDigit* digit;
277 
278  if ( fTriggerEfficiency ) fEfficiencyResponse.Reset(-1);
279 
280  while ( ( digit = static_cast<AliMUONVDigit*>(next()) ) )
281  {
282  AliMp::StationType stationType = AliMpDEManager::GetStationType(digit->DetElemId());
283 
284  if ( stationType != AliMp::kStationTrigger )
285  {
286  Bool_t addNoise = kAddNoise;
287  if (digit->IsConverted()) addNoise = kFALSE; // No need to add extra noise to a converted real digit
288  ApplyResponseToTrackerDigit(*digit,addNoise);
289  }
290  else {
292  }
293 
294  if ( digit->ADC() > 0 || digit->Charge() > 0 )
295  {
296  filteredStore.Add(*digit,AliMUONVDigitStore::kIgnore);
297  }
298  }
299 }
300 
301 //_____________________________________________________________________________
302 Int_t
304  Int_t channel,
305  Float_t charge,
306  Bool_t addNoise,
307  Bool_t noiseOnly)
308 {
318 
319  static const Int_t kMaxADC = (1<<12)-1; // We code the charge on a 12 bits ADC.
320 
321  Int_t thres(4095);
322  Int_t qual(0xF);
323  Float_t capa(AliMUONConstants::DefaultCapa()); // capa = 0.2 and a0 = 1.25
324  Float_t a0(AliMUONConstants::DefaultA0()); // is equivalent to gain = 4 mV/fC
325  Float_t adc2mv(AliMUONConstants::DefaultADC2MV()); // 1 ADC channel = 0.61 mV
326 
327  Float_t pedestalMean = pedestals.ValueAsFloat(channel,0);
328  Float_t pedestalSigma = pedestals.ValueAsFloat(channel,1);
329 
330  AliDebugClass(2,Form("DE %04d MANU %04d CH %02d PEDMEAN %7.2f PEDSIGMA %7.2f",
331  pedestals.ID0(),pedestals.ID1(),channel,pedestalMean,pedestalSigma));
332 
333  if ( qual <= 0 ) return 0;
334 
335  Float_t chargeThres = a0*thres;
336 
337  Float_t padc = charge/a0; // (adc - ped) value
338 
339  padc /= capa*adc2mv;
340 
341  Int_t adc(0);
342 
343  Float_t adcNoise = 0.0;
344 
345  if ( addNoise )
346  {
347  if ( noiseOnly )
348  {
349  adcNoise = NoiseFunction()->GetRandom()*pedestalSigma;
350  }
351  else
352  {
353  adcNoise = gRandom->Gaus(0.0,pedestalSigma);
354  }
355  }
356 
357  adc = TMath::Nint(padc + pedestalMean + adcNoise + 0.5);
358 
359  if ( adc < TMath::Nint(pedestalMean + fgNSigmas*pedestalSigma + 0.5) )
360  {
361  // this is an error only in specific cases
362  if ( !addNoise || (addNoise && noiseOnly) )
363  {
364  AliDebugClass(1,Form(" DE %04d Manu %04d Channel %02d "
365  " a0 %7.2f thres %04d ped %7.2f pedsig %7.2f adcNoise %7.2f "
366  " charge=%7.2f padc=%7.2f adc=%04d ZS=%04d fgNSigmas=%e addNoise %d noiseOnly %d ",
367  pedestals.ID0(),pedestals.ID1(),channel,
368  a0, thres, pedestalMean, pedestalSigma, adcNoise,
369  charge, padc, adc,
370  TMath::Nint(pedestalMean + fgNSigmas*pedestalSigma + 0.5),
371  fgNSigmas,addNoise,noiseOnly));
372  }
373 
374  adc = 0;
375  }
376 
377  // be sure we stick to 12 bits.
378  if ( adc > kMaxADC )
379  {
380  adc = kMaxADC;
381  }
382 
383  return adc;
384 }
385 
386 //_____________________________________________________________________________
387 void
389 {
392 
393  if (fInputDigitStores)
394  {
395  AliFatal("Should be called only once !");
396  }
397 
399 
400  fInputDigitStores->SetOwner(kTRUE);
401 
402  for ( Int_t iFile = 0; iFile < fDigInput->GetNinputs(); ++iFile )
403  {
404  AliLoader* inputLoader = GetLoader(fDigInput->GetInputFolderName(iFile));
405 
406  inputLoader->LoadSDigits("READ");
407 
408  TTree* iTreeS = inputLoader->TreeS();
409  if (!iTreeS)
410  {
411  AliFatal(Form("Could not get access to input file #%d",iFile));
412  }
413 
414  fInputDigitStores->AddAt(AliMUONVDigitStore::Create(*iTreeS),iFile);
415  }
416 }
417 
418 //_____________________________________________________________________________
419 void
421 {
427 
428  AliCodeTimerAuto("",0)
429 
430  if ( fDigInput->GetNinputs() == 0 )
431  {
432  AliWarning("No input set. Nothing to do.");
433  return;
434  }
435 
436  if ( !fIsInitialized )
437  {
438  AliError("Not initialized. Cannot perform the work. Sorry");
439  return;
440  }
441 
442  Int_t nInputFiles = fDigInput->GetNinputs();
443 
444  AliLoader* outputLoader = GetLoader(fDigInput->GetOutputFolderName());
445 
446  outputLoader->MakeDigitsContainer();
447 
448  TTree* oTreeD = outputLoader->TreeD();
449 
450  if (!oTreeD)
451  {
452  AliFatal("Cannot create output TreeD");
453  }
454 
455  // Loop over all the input files, and merge the sdigits found in those
456  // files.
457 
458  for ( Int_t iFile = 0; iFile < nInputFiles; ++iFile )
459  {
460  AliLoader* inputLoader = GetLoader(fDigInput->GetInputFolderName(iFile));
461 
462  inputLoader->LoadSDigits("READ");
463 
464  TTree* iTreeS = inputLoader->TreeS();
465  if (!iTreeS)
466  {
467  AliFatal(Form("Could not get access to input file #%d",iFile));
468  }
469 
470  if (!fInputDigitStores)
471  {
473  }
474 
475  AliMUONVDigitStore* dstore = static_cast<AliMUONVDigitStore*>(fInputDigitStores->At(iFile));
476 
477  dstore->Connect(*iTreeS);
478 
479  iTreeS->GetEvent(0);
480 
481  MergeWithSDigits(fDigitStore,*dstore,fDigInput->GetMask(iFile));
482 
483  inputLoader->UnloadSDigits();
484 
485  dstore->Clear();
486  }
487 
488 
489  // At this point, we do have digit arrays (one per chamber) which contains
490  // the merging of all the sdigits of the input file(s).
491  // We now massage them to apply the detector response, i.e. this
492  // is here that we do the "digitization" work.
493 
494  if (!fOutputDigitStore)
495  {
497  }
498 
499  if ( fGenerateNoisyDigits>=2 )
500  {
501  // Generate noise-only digits for trigger.
503  }
505 
506  if ( fGenerateNoisyDigits )
507  {
508  // Generate noise-only digits for tracker.
510  }
511 
512  // We generate the global and local trigger decisions.
514 
515  // Prepare output tree
516  Bool_t okD = fOutputDigitStore->Connect(*oTreeD,kFALSE);
517  Bool_t okT = fTriggerStore->Connect(*oTreeD,kFALSE);
518  if (!okD || !okT)
519  {
520  AliError(Form("Could not make branch : Digit %d Trigger %d",okD,okT));
521  return;
522  }
523 
524  // Fill the output treeD
525  oTreeD->Fill();
526 
527  // Write to the output tree(D).
528  // Please note that as GlobalTrigger, LocalTrigger and Digits are in the same
529  // tree (=TreeD) in different branches, this WriteDigits in fact writes all of
530  // the 3 branches.
531  outputLoader->WriteDigits("OVERWRITE");
532 
533  outputLoader->UnloadDigits();
534 
535  // Finally, we clean up after ourselves.
536  fTriggerStore->Clear();
537  fDigitStore->Clear();
539 }
540 
541 
542 //_____________________________________________________________________________
543 void
545 {
549 
550  AliCodeTimerAuto("",0)
551 
552  for ( Int_t i = 0; i < AliMUONConstants::NTrackingCh(); ++i )
553  {
554  AliMpDEIterator it;
555 
556  it.First(i);
557 
558  while ( !it.IsDone() )
559  {
560  for ( Int_t cathode = 0; cathode < 2; ++cathode )
561  {
562  GenerateNoisyDigitsForOneCathode(digitStore,it.CurrentDEId(),cathode);
563  }
564  it.Next();
565  }
566  }
567 }
568 
569 //_____________________________________________________________________________
570 void
572  Int_t detElemId, Int_t cathode)
573 {
576 
577  const AliMpVSegmentation* seg
579  Int_t nofPads = seg->NofPads();
580 
581  Int_t maxIx = seg->MaxPadIndexX();
582  Int_t maxIy = seg->MaxPadIndexY();
583 
584  static const Double_t kProbToBeOutsideNsigmas = TMath::Erfc(fgNSigmas/TMath::Sqrt(2.0)) / 2. ;
585 
586  Int_t nofNoisyPads = TMath::Nint(kProbToBeOutsideNsigmas*nofPads);
587  if ( !nofNoisyPads ) return;
588 
589  nofNoisyPads =
590  TMath::Nint(gRandom->Gaus(nofNoisyPads,
591  nofNoisyPads/TMath::Sqrt(nofNoisyPads)));
592 
593  AliDebug(3,Form("DE %d cath %d nofNoisyPads %d",detElemId,cathode,nofNoisyPads));
594 
595  for ( Int_t i = 0; i < nofNoisyPads; ++i )
596  {
597  Int_t ix(-1);
598  Int_t iy(-1);
599  AliMpPad pad;
600 
601  do {
602  ix = gRandom->Integer(maxIx+1);
603  iy = gRandom->Integer(maxIy+1);
604  pad = seg->PadByIndices(ix,iy,kFALSE);
605  } while ( !pad.IsValid() );
606 
607  Int_t manuId = pad.GetManuId();
608  Int_t manuChannel = pad.GetManuChannel();
609 
610  AliMUONVCalibParam* pedestals = fCalibrationData->Pedestals(detElemId,manuId);
611 
612  if (!pedestals)
613  {
614  // no pedestal available for this channel, simply give up
615  continue;
616  }
617 
618  AliMUONVDigit* d = digitStore.CreateDigit(detElemId,manuId,manuChannel,cathode);
619 
620  d->SetPadXY(ix,iy);
621 
622  d->SetCharge(0.0); // charge is zero, the ApplyResponseToTrackerDigit will add the noise
623  d->NoiseOnly(kTRUE);
624  ApplyResponseToTrackerDigit(*d,kTRUE);
625  if ( d->ADC() > 0 )
626  {
627  Bool_t ok = digitStore.Add(*d,AliMUONVDigitStore::kDeny);
628  // this can happen (that we randomly chose a digit that is
629  // already there). We simply ignore this, but log the occurence
630  // to cross-check that it's not too frequent.
631  if (!ok)
632  {
633  fLogger->Log("Collision while adding noiseOnly digit");
634  }
635  else
636  {
637  fLogger->Log("Added noiseOnly digit");
638  }
639  }
640  delete d;
641  }
642 }
643 
644 
645 //_____________________________________________________________________________
646 void
648 {
651 
652  if ( !fNoiseFunctionTrig )
653  {
654  fNoiseFunctionTrig = new TF1("AliMUONDigitizerV3::fNoiseFunctionTrig","landau",
655  50.,270.);
656 
657  fNoiseFunctionTrig->SetParameters(3.91070e+02, 9.85026, 9.35881e-02);
658  }
659 
660  AliMpPad pad[2];
661  AliMUONVDigit *d[2]={0x0};
662 
663  for ( Int_t chamberId = AliMUONConstants::NTrackingCh(); chamberId < AliMUONConstants::NCh(); ++chamberId )
664  {
665 
666  Int_t nofNoisyPads = 50;
667 
668  Float_t r=-1, fi = 0., gx, gy, x, y, z, xg01, yg01, zg, xg02, yg02;
669  AliMpDEIterator it;
670 
671  AliDebug(3,Form("Chamber %d nofNoisyPads %d",chamberId,nofNoisyPads));
672 
673  for ( Int_t i = 0; i < nofNoisyPads; ++i )
674  {
675  //printf("Generating noise %i\n",i);
676  Int_t ix(-1);
677  Int_t iy(-1);
678  Bool_t isOk = kFALSE;
679  Int_t detElemId = -1;
680  do {
681  //r = gRandom->Landau(9.85026, 9.35881e-02);
682  r = fNoiseFunctionTrig->GetRandom();
683  fi = 2. * TMath::Pi() * gRandom->Rndm();
684  //printf("r = %f\tfi = %f\n", r, fi);
685  gx = r * TMath::Cos(fi);
686  gy = r * TMath::Sin(fi);
687 
688  for ( it.First(chamberId); ! it.IsDone(); it.Next() ){
689  Int_t currDetElemId = it.CurrentDEId();
690  const AliMpVSegmentation* seg
692  if (!seg) continue;
693  Float_t deltax = seg->GetDimensionX();
694  Float_t deltay = seg->GetDimensionY();
695  GetTransformer()->Local2Global(currDetElemId, -deltax, -deltay, 0, xg01, yg01, zg);
696  GetTransformer()->Local2Global(currDetElemId, deltax, deltay, 0, xg02, yg02, zg);
697  Float_t xg1 = xg01, xg2 = xg02, yg1 = yg01, yg2 = yg02;
698  if(xg01>xg02){
699  xg1 = xg02;
700  xg2 = xg01;
701  }
702  if(yg01>yg02){
703  yg1 = yg02;
704  yg2 = yg01;
705  }
706  if(gx>=xg1 && gx<=xg2 && gy>=yg1 && gy<=yg2){
707  detElemId = currDetElemId;
708  GetTransformer()->Global2Local(detElemId, gx, gy, 0, x, y, z);
709  pad[0] = seg->PadByPosition(x,y,kFALSE);
710  if(!pad[0].IsValid()) continue;
711  isOk = kTRUE;
712  break;
713  }
714  } // loop on slats
715  } while ( !isOk );
716 
717  const AliMpVSegmentation* seg1
719  pad[1] = seg1->PadByPosition(x,y,kFALSE);
720 
721  for ( Int_t cathode = 0; cathode < 2; ++cathode ){
722  Int_t manuId = pad[cathode].GetLocalBoardId(0);
723  Int_t manuChannel = pad[cathode].GetLocalBoardChannel(0);
724  d[cathode] = digitStore.CreateDigit(detElemId,manuId,manuChannel,cathode);
725  ix = pad[cathode].GetIx();
726  iy = pad[cathode].GetIy();
727  d[cathode]->SetPadXY(ix,iy);
728  //d[cathode].SetSignal(1);
729  //d[cathode].SetPhysicsSignal(0);
730  d[cathode]->SetCharge(1);
731  d[cathode]->NoiseOnly(kTRUE);
732  AliDebug(3,Form("Adding a pure noise digit :"));
733 
734  Bool_t ok = digitStore.Add(*d[cathode],AliMUONVDigitStore::kDeny);
735  if (!ok)
736  {
737  fLogger->Log("Collision while adding TriggerNoise digit");
738  }
739  else
740  {
741  fLogger->Log("Added triggerNoise digit");
742  }
743  } //loop on cathodes
744  } // loop on noisy pads
745  } // loop on chambers
746 }
747 
748 
749 //_____________________________________________________________________________
750 AliLoader*
751 AliMUONDigitizerV3::GetLoader(const TString& folderName)
752 {
754 
755  AliDebug(2,Form("Getting access to folder %s",folderName.Data()));
756  AliLoader* loader = AliRunLoader::GetDetectorLoader("MUON",folderName.Data());
757  if (!loader)
758  {
759  AliError(Form("Could not get MuonLoader from folder %s",folderName.Data()));
760  return 0x0;
761  }
762  return loader;
763 }
764 
765 //_____________________________________________________________________________
766 Bool_t
768 {
772 
773  AliDebug(2,"");
774 
775  if ( fIsInitialized )
776  {
777  AliError("Object already initialized.");
778  return kFALSE;
779  }
780 
781  if (!fDigInput)
782  {
783  AliError("fDigInput is null !");
784  return kFALSE;
785  }
786 
787  // Load mapping
788  if ( ! AliMpCDB::LoadDDLStore() ) {
789  AliFatal("Could not access mapping from OCDB !");
790  }
791 
792  if (!fCalibrationData)
793  AliFatal("Calibration data object not defined");
794 
795  if ( !fCalibrationData->Pedestals() )
796  {
797  AliFatal("Could not access pedestals from OCDB !");
798  }
799 
800  AliInfo("Using trigger configuration from CDB");
801 
803 
804  AliDebug(1, Form("Will %s generate noise-only digits for tracker",
805  (fGenerateNoisyDigits ? "":"NOT")));
806 
808 
809  if ( muon()->GetTriggerEffCells() ) {
810  // Apply trigger efficiency
811  AliDebug(1, "Will apply trigger efficiency");
813  }
814 
815  fIsInitialized = kTRUE;
816  return kTRUE;
817 }
818 
819 
820 //_____________________________________________________________________________
821 Int_t AliMUONDigitizerV3::GetArrayIndex(Int_t cathode, Int_t trigCh, Int_t localCircuit)
822 {
824  return
826  AliMUONConstants::NTriggerCircuit() * trigCh + localCircuit-1;
827 }
828 
829 
830 //_____________________________________________________________________________
831 void
833  const AliMUONVDigitStore& input,
834  Int_t mask)
835 {
837 
838  if ( !outputStore ) outputStore = input.Create();
839 
840  TIter next(input.CreateIterator());
841  AliMUONVDigit* sdigit;
842 
843  while ( ( sdigit = static_cast<AliMUONVDigit*>(next()) ) )
844  {
845  // Update the track references using the mask.
846  // FIXME: this is dirty, for backward compatibility only.
847  // Should re-design all this way of keeping track of MC information...
848  if ( mask ) sdigit->PatchTracks(mask);
849  // Then add or update the digit to the output.
850  AliMUONVDigit* added = outputStore->Add(*sdigit,AliMUONVDigitStore::kMerge);
851  if (!added)
852  {
853  AliError("Could not add digit in merge mode");
854  }
855  }
856 }
857 
858 //_____________________________________________________________________________
859 TF1*
861 {
863  static TF1* f = 0x0;
864  if (!f)
865  {
866  f = new TF1("AliMUONDigitizerV3::NoiseFunction","gaus",fgNSigmas,fgNSigmas*10);
867  f->SetParameters(1,0,1);
868  }
869  return f;
870 }
871 
872 //_____________________________________________________________________________
874  AliMUONRecoParam* recoParam)
875 {
876  fCalibrationData = calibrationData;
877  fRecoParam = recoParam;
878  if (!fRecoParam)
879  {
880  AliError("Cannot work (e.g. decalibrate) without recoparams !");
881  }
882 }
883 
virtual Int_t ManuChannel() const =0
The channel within ManuId() this digit belongs to (manuChannel for tracker, localBoardChannel for tri...
The iterator over detection elements.
static Float_t InvalidFloatValue()
Return 1E38 as invalid float value.
TF1 * fNoiseFunctionTrig
! function to get noise disribution on trig. chambers
const AliMpVSegmentation * GetMpSegmentation(Int_t detElemId, AliMp::CathodType cath, Bool_t warn=true) const
Interface for a digit container.
void Print(Option_t *opt="") const
Implementation of AliMUONVTriggerStore.
static AliMpSegmentation * Instance(Bool_t warn=true)
virtual Float_t ValueAsFloat(Int_t i, Int_t j=0) const =0
#define TObjArray
static Int_t NTrackingCh()
Return number of tracking chambers.
Int_t GetIy() const
Definition: AliMpPad.cxx:280
virtual Int_t NofPads() const =0
Return the number of pads in the detection element.
Int_t fGenerateNoisyDigits
! whether or not we should generate noise-only digits for tracker (1) and trigger (2) ...
Top container class for geometry transformations.
Int_t GetManuId() const
Definition: AliMpPad.cxx:256
Bool_t IsDone() const
TFile f("CalibObjects.root")
virtual Int_t ADC() const =0
Raw ADC value of this digit.
Int_t Log(const char *message)
AliMUONRecoParam * fRecoParam
! reco params (to know how to decalibrate) (not owner)
virtual void Digitize(Option_t *opt="")
Bool_t fIsInitialized
are we initialized ?
AliMUONLogger * fLogger
for noise-only digit generation and zero-suppression
static Bool_t LoadDDLStore(Bool_t warn=false)
Definition: AliMpCDB.cxx:149
Int_t CurrentDEId() const
AliDetector class for MUON subsystem providing simulation data management.
Definition: AliMUON.h:37
Int_t GetArrayIndex(Int_t cathode, Int_t trigCh, Int_t localCircuit)
Class with MUON reconstruction parameters.
Utilities for trigger (check if pad is masked)
void ApplyResponseToTriggerDigit(AliMUONVDigit &digit)
virtual Bool_t IsChargeInFC() const
Whether this digit has charge in femto coulomb (see note 1 in AliMUONVDigit.cxx)
Definition: AliMUONVDigit.h:73
virtual void SetCharge(Float_t q)=0
Set the charge of this digit.
virtual Float_t Charge() const =0
The charge of this digit, calibrated or not depending on IsCalibrated()
static Float_t DefaultA0()
virtual AliMpPad PadByIndices(Int_t ix, Int_t iy, Bool_t warning=true) const =0
Find pad by indices.
virtual Int_t DetElemId() const =0
The detection element this digit belongs to.
virtual Double_t GetDimensionY() const =0
Return the y half-sizes of the detection element.
virtual void NoiseOnly(Bool_t=kTRUE)
Set the noiseOnly status.
Definition: AliMUONVDigit.h:60
virtual TIterator * CreateIterator() const =0
Create an iterator to loop over all our digits.
AliMUONVDigitStore * fDigitStore
! temporary digits
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
AliMUONTriggerChamberEfficiency * fTriggerEfficiency
! trigger efficiency map
Int_t GetManuChannel() const
Definition: AliMpPad.cxx:264
Manager class for muon trigger electronics.
A logger that keeps track of the number of times a message appeared.
Definition: AliMUONLogger.h:24
Container of calibration values for a given number of channels.
static Int_t DecalibrateTrackerDigit(const AliMUONVCalibParam &pedestals, Int_t channel, Float_t charge, Bool_t addNoise=kFALSE, Bool_t noiseOnly=kFALSE)
void ApplyResponse(const AliMUONVDigitStore &store, AliMUONVDigitStore &filteredStore)
void IsTriggered(Int_t detElemId, Int_t localBoard, Bool_t &trigBend, Bool_t &trigNonBend) const
virtual AliMUONVDigitStore * Create() const =0
Create an (empty) object of the same concrete class as *this.
virtual void SetADC(Int_t adc)=0
Set the ADC value.
void MergeWithSDigits(AliMUONVDigitStore *&digitStore, const AliMUONVDigitStore &input, Int_t mask)
virtual Int_t MaxPadIndexY() const =0
Return maximum pad index in Y direction.
virtual Int_t Cathode() const =0
Cathode number this digit is on (0 or 1)
Bool_t IsMasked(const AliMUONVDigit &digit) const
MUON global constants.
virtual Int_t ID0() const
First id of this object.
virtual Int_t ID1() const
Second id of this object (might not be required)
AliMUONTriggerUtilities * fTriggerUtilities
! Trigger utilities for masks
static Float_t DefaultCapa()
static AliMp::StationType GetStationType(Int_t detElemId)
void GenerateNoisyDigitsForTrigger(AliMUONVDigitStore &digitStore)
const AliMUONGeometryTransformer * GetGeometryTransformer() const
Definition: AliMUON.cxx:243
static Float_t DefaultADC2MV()
virtual Double_t GetDimensionX() const =0
Return the x half-sizes of the detection element.
virtual void SetPadXY(Int_t padx, Int_t pady)=0
Set the ix and iy of this digit.
AliMp::CathodType GetCathodType(Int_t cathodNumber)
Convert integer number in enum;.
static Int_t NTriggerCh()
Return number of trigger chambers.
AliRun * gAlice
Int_t GetLocalBoardId(Int_t i) const
Definition: AliMpPad.cxx:347
AliMUONVStore * Pedestals() const
Get the pedestal store.
AliMUONTriggerEfficiencyCells * TriggerEfficiency() const
Get the trigger efficiency map.
virtual Bool_t IsNoiseOnly() const =0
Whether this (simulated) digit is purely noise.
TObjArray * fInputDigitStores
! input digit stores (one per input file
static Int_t NCh()
Return number of chambers.
Bool_t IsValid() const
Return validity.
Definition: AliMpPad.h:89
void GenerateNoisyDigits(AliMUONVDigitStore &digitStore)
static Double_t fgNSigmas
number of sigmas above ped to use
virtual AliMpPad PadByPosition(Double_t x, Double_t y, Bool_t warning=true) const =0
Find pad by position.
Single entry point to access MUON calibration data.
Int_t GetIx() const
Definition: AliMpPad.cxx:272
AliMUON * muon()
AliMUONCalibrationData * fCalibrationData
! pointer to access calib parameters
The abstract base class for the segmentation.
trigger stations (slats)
AliMUONVTriggerStore * fTriggerStore
! trigger objects
virtual Int_t MaxPadIndexX() const =0
Return maximum pad index in X direction.
AliLoader * GetLoader(const TString &foldername)
virtual Int_t ManuId() const =0
The electronic card id this digit belongs to (manuId for tracker, localboardId for trigger) ...
ABC of a MUON digit.
Definition: AliMUONVDigit.h:18
TArrayI fEfficiencyResponse
! Local board efficiency response
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
Calculate, apply and possibly draw trigger chamber efficiency.
virtual void Clear(Option_t *opt="")=0
Clear ourselves (i.e. Reset)
virtual void Digits2Trigger(const AliMUONVDigitStore &digitStore, AliMUONVTriggerStore &triggerStore)
virtual AliMUONVDigit * CreateDigit(Int_t detElemId, Int_t manuId, Int_t manuChannel, Int_t cathode) const =0
Create a digit.
Digitizer (from SDigit to Digit), performing digit de-calibration.
static TF1 * NoiseFunction()
static Int_t NTriggerCircuit()
Return number of trigger circuits.
Int_t GetLocalBoardChannel(Int_t i) const
Definition: AliMpPad.cxx:358
virtual Bool_t Connect(TTree &tree, Bool_t alone=kTRUE) const
Connect us to a TTree (only valid if CanConnect()==kTRUE)
void SetCalibrationData(AliMUONCalibrationData *calibrationData, AliMUONRecoParam *recoParam)
Set calibration (and recoparam) data.
void GenerateNoisyDigitsForOneCathode(AliMUONVDigitStore &digitStore, Int_t detElemId, Int_t cathode)
virtual Bool_t Add(TObject *object)
Add an object, if it is of the right class.
void ApplyResponseToTrackerDigit(AliMUONVDigit &digit, Bool_t addNoise)
AliMUONTriggerElectronics * fTriggerProcessor
pointer to the trigger part of the job
virtual void PatchTracks(Int_t)
Patch track with a mask.
AliMUONVDigitStore * fOutputDigitStore
! digits we'll output to disk