1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 #include "AliMUONDigitizerV3.h"
22 #include "AliMUONCalibrationData.h"
23 #include "AliMUONConstants.h"
24 #include "AliMUONDigit.h"
25 #include "AliMUONLogger.h"
26 #include "AliMUONTriggerElectronics.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"
32 #include "AliMUONTriggerChamberEfficiency.h"
33 #include "AliMUONTriggerUtilities.h"
36 #include "AliMpSegmentation.h"
37 #include "AliMpCathodType.h"
38 #include "AliMpConstants.h"
39 #include "AliMpDEIterator.h"
40 #include "AliMpDEManager.h"
42 #include "AliMpStationType.h"
43 #include "AliMpVSegmentation.h"
44 #include "AliMpDDLStore.h"
46 #include "AliCDBManager.h"
47 #include "AliCodeTimer.h"
50 #include "AliRunDigitizer.h"
51 #include "AliLoader.h"
52 #include "AliRunLoader.h"
54 #include <Riostream.h>
63 //-----------------------------------------------------------------------------
64 /// \class AliMUONDigitizerV3
66 /// The digitizer is performing the transformation to go from SDigits (digits
67 /// w/o any electronic noise) to Digits (w/ electronic noise, and decalibration)
69 /// The decalibration is performed by doing the reverse operation of the
70 /// calibration, that is we do (Signal+pedestal)/gain -> ADC
72 /// Note also that the digitizer takes care of merging sdigits that belongs
73 /// to the same pad, either because we're merging several input sdigit files
74 /// or with a single file because the sdigitizer does not merge sdigits itself
75 /// (for performance reason mainly, and because anyway we know we have to do it
76 /// here, at the digitization level).
78 /// August 2011. In order to remove the need for specific MC OCDB storages,
79 /// we're introducing a dependence of simulation on AliMUONRecoParam (stored
80 /// in MUON/Calib/RecoParam in OCDB), which is normally (or conceptually, if
81 /// you will) only a reconstruction object. That's not a pretty solution, but,
82 /// well, we have to do it...
83 /// This dependence comes from the fact that we must know how to decalibrate
84 /// the digits, so that the decalibration (done here) - calibration (done during
85 /// reco) process is (as much as possible) neutral.
88 /// \author Laurent Aphecetche
90 //-----------------------------------------------------------------------------
96 return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
99 //ADDED for trigger noise
100 const AliMUONGeometryTransformer* GetTransformer()
102 return muon()->GetGeometryTransformer();
106 Double_t AliMUONDigitizerV3::fgNSigmas = 4.0;
109 ClassImp(AliMUONDigitizerV3)
112 //_____________________________________________________________________________
113 AliMUONDigitizerV3::AliMUONDigitizerV3(AliRunDigitizer* manager,
114 Int_t generateNoisyDigits)
115 : AliDigitizer(manager),
116 fIsInitialized(kFALSE),
117 fCalibrationData(0x0),
118 fTriggerProcessor(0x0),
119 fNoiseFunctionTrig(0x0),
120 fGenerateNoisyDigits(generateNoisyDigits),
121 fLogger(new AliMUONLogger(1000)),
122 fTriggerStore(new AliMUONTriggerStoreV1),
124 fOutputDigitStore(0x0),
125 fInputDigitStores(0x0),
127 fTriggerEfficiency(0x0),
128 fTriggerUtilities(0x0),
129 fEfficiencyResponse(2*AliMUONConstants::NTriggerCh()*AliMUONConstants::NTriggerCircuit())
133 AliDebug(1,Form("AliRunDigitizer=%p",fManager));
137 //_____________________________________________________________________________
138 AliMUONDigitizerV3::~AliMUONDigitizerV3()
140 /// Dtor. Note we're the owner of some pointers.
144 // delete fCalibrationData;
145 delete fTriggerProcessor;
146 delete fNoiseFunctionTrig;
147 delete fTriggerStore;
149 delete fOutputDigitStore;
150 delete fInputDigitStores;
151 delete fTriggerUtilities;
153 AliInfo("Summary of messages");
159 //_____________________________________________________________________________
161 AliMUONDigitizerV3::ApplyResponseToTrackerDigit(AliMUONVDigit& digit, Bool_t addNoise)
163 /// For tracking digits, starting from an ideal digit's charge, we :
165 /// - "divide" by a gain (thus decalibrating the digit)
166 /// - add a pedestal (thus decalibrating the digit)
167 /// - add some electronics noise (thus leading to a realistic adc), if requested to do so
168 /// - sets the signal to zero if below 3*sigma of the noise
170 Float_t charge = digit.Charge();
172 if (!digit.IsChargeInFC())
174 charge *= AliMUONConstants::DefaultADC2MV()*AliMUONConstants::DefaultA0()*AliMUONConstants::DefaultCapa();
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 ? ");
179 // We set the charge to 0, as the only relevant piece of information
180 // after Digitization is the ADC value.
183 Int_t detElemId = digit.DetElemId();
184 Int_t manuId = digit.ManuId();
186 AliMUONVCalibParam* pedestal = fCalibrationData->Pedestals(detElemId,manuId);
189 fLogger->Log(Form("%s:%d:Could not get pedestal for DE=%4d manuId=%4d. Disabling.",
196 Int_t manuChannel = digit.ManuChannel();
198 if ( pedestal->ValueAsFloat(manuChannel,0) == AliMUONVCalibParam::InvalidFloatValue() ||
199 pedestal->ValueAsFloat(manuChannel,1) == AliMUONVCalibParam::InvalidFloatValue() )
201 // protection against invalid pedestal value
206 AliMUONVCalibParam* gain = fCalibrationData->Gains(detElemId,manuId);
209 fLogger->Log(Form("%s:%d:Could not get gain for DE=%4d manuId=%4d. Disabling.",
216 Int_t adc = DecalibrateTrackerDigit(*pedestal,*gain,manuChannel,charge,addNoise,
218 fRecoParam->GetCalibrationMode());
224 //_____________________________________________________________________________
226 AliMUONDigitizerV3::ApplyResponseToTriggerDigit(AliMUONVDigit& digit)
228 /// For trigger digits, starting from an ideal digit, we :
230 /// - apply efficiency (on demand)
231 /// - apply trigger masks
233 Int_t detElemId = digit.DetElemId();
234 Int_t localCircuit = digit.ManuId();
235 Int_t strip = digit.ManuChannel();
236 Int_t cathode = digit.Cathode();
237 Int_t trigCh = detElemId/100 - 11;
239 Int_t arrayIndex = GetArrayIndex(cathode, trigCh, localCircuit);
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];
251 AliDebug(1,Form("ch %i cath %i board %i strip %i efficiency %i\n", trigCh, cathode, localCircuit, strip, fEfficiencyResponse[arrayIndex]));
252 if ( fEfficiencyResponse[arrayIndex] == 0 ) {
255 //AliDebug(1,Form("ch %i cath %i board %i strip %i NOT efficient\n", trigCh, cathode, localCircuit, strip));
261 Bool_t isMasked = fTriggerUtilities->IsMasked(digit);
262 AliDebug(1,Form("ch %i cath %i board %i strip %i mask %i\n", trigCh, cathode, localCircuit, strip, !isMasked));
266 //AliDebug(1,Form("ch %i cath %i board %i strip %i masked\n", trigCh, cathode, localCircuit, strip));
273 //_____________________________________________________________________________
275 AliMUONDigitizerV3::ApplyResponse(const AliMUONVDigitStore& store,
276 AliMUONVDigitStore& filteredStore)
278 /// Loop over all chamber digits, and apply the response to them
279 /// Note that this method may remove digits.
281 filteredStore.Clear();
283 const Bool_t kAddNoise = kTRUE;
285 TIter next(store.CreateIterator());
286 AliMUONVDigit* digit;
288 if ( fTriggerEfficiency ) fEfficiencyResponse.Reset(-1);
290 while ( ( digit = static_cast<AliMUONVDigit*>(next()) ) )
292 AliMp::StationType stationType = AliMpDEManager::GetStationType(digit->DetElemId());
294 if ( stationType != AliMp::kStationTrigger )
296 Bool_t addNoise = kAddNoise;
297 if (digit->IsConverted()) addNoise = kFALSE; // No need to add extra noise to a converted real digit
298 ApplyResponseToTrackerDigit(*digit,addNoise);
301 ApplyResponseToTriggerDigit(*digit);
304 if ( digit->ADC() > 0 || digit->Charge() > 0 )
306 filteredStore.Add(*digit,AliMUONVDigitStore::kIgnore);
311 //_____________________________________________________________________________
313 AliMUONDigitizerV3::DecalibrateTrackerDigit(const AliMUONVCalibParam& pedestals,
314 const AliMUONVCalibParam& gains,
319 const TString& calibrationMode)
321 /// Decalibrate (i.e. go from charge to adc) a tracker digit, given its
322 /// pedestal and gain parameters.
323 /// Must insure before calling that channel is valid (i.e. between 0 and
324 /// pedestals or gains->GetSize()-1, but also corresponding to a valid channel
325 /// otherwise results are not predictible...)
327 /// This method is completely tied to what happens in its sister method :
328 /// AliMUONDigitCalibrator::CalibrateDigit, which is doing the reverse work...
331 static const Int_t kMaxADC = (1<<12)-1; // We code the charge on a 12 bits ADC.
333 Bool_t nogain = calibrationMode.Contains("NOGAIN");
338 Float_t capa(AliMUONConstants::DefaultCapa()); // capa = 0.2 and a0 = 1.25
339 Float_t a0(AliMUONConstants::DefaultA0()); // is equivalent to gain = 4 mV/fC
340 Float_t adc2mv(AliMUONConstants::DefaultADC2MV()); // 1 ADC channel = 0.61 mV
344 a0 = gains.ValueAsFloat(channel,0);
345 a1 = gains.ValueAsFloat(channel,1);
346 thres = gains.ValueAsInt(channel,2);
347 qual = gains.ValueAsInt(channel,3);
350 Float_t pedestalMean = pedestals.ValueAsFloat(channel,0);
351 Float_t pedestalSigma = pedestals.ValueAsFloat(channel,1);
353 AliDebugClass(1,Form("DE %04d MANU %04d CH %02d PEDMEAN %7.2f PEDSIGMA %7.2f",
354 pedestals.ID0(),pedestals.ID1(),channel,pedestalMean,pedestalSigma));
356 if ( qual <= 0 ) return 0;
358 Float_t chargeThres = a0*thres;
360 Float_t padc(0); // (adc - ped) value
362 if ( nogain || charge <= chargeThres || TMath::Abs(a1) < 1E-12 )
366 if ( TMath::Abs(a0) > 1E-12 )
373 // FIXME: when we'll use capacitances and real gains, revise this part
374 // to take capa properly into account...
376 AliWarningClass("YOU PROBABLY NEED TO REVISE THIS PART OF CODE !!!");
378 // linear + parabolic part
379 Double_t qt = chargeThres - charge;
380 Double_t delta = a0*a0-4*a1*qt;
383 AliErrorClass(Form("delta=%e DE %d Manu %d Channel %d "
384 " charge %e a0 %e a1 %e thres %d ped %e pedsig %e",
385 delta,pedestals.ID0(),pedestals.ID1(),
386 channel, charge, a0, a1, thres, pedestalMean,
391 delta = TMath::Sqrt(delta);
393 padc = ( ( -a0 + delta ) > 0 ? ( -a0 + delta ) : ( -a0 - delta ) );
399 if ( TMath::Abs(padc) > 1E-3)
401 // this is more than a precision problem : let's signal it !
402 AliErrorClass(Form("padc=%e DE %d Manu %d Channel %d "
403 " charge %e a0 %e a1 %e thres %d ped %e pedsig %e delta %e",
404 padc,pedestals.ID0(),pedestals.ID1(),
405 channel, charge, a0, a1, thres, pedestalMean,
406 pedestalSigma,delta));
409 // ok. consider we're just at thres, let it be zero.
422 Float_t adcNoise = 0.0;
428 adcNoise = NoiseFunction()->GetRandom()*pedestalSigma;
432 adcNoise = gRandom->Gaus(0.0,pedestalSigma);
436 adc = TMath::Nint(padc + pedestalMean + adcNoise + 0.5);
438 if ( adc < TMath::Nint(pedestalMean + fgNSigmas*pedestalSigma + 0.5) )
440 // this is an error only in specific cases
441 if ( !addNoise || (addNoise && noiseOnly) )
443 AliErrorClass(Form(" DE %04d Manu %04d Channel %02d "
444 " a0 %7.2f a1 %7.2f thres %04d ped %7.2f pedsig %7.2f adcNoise %7.2f "
445 " charge=%7.2f padc=%7.2f adc=%04d ZS=%04d fgNSigmas=%e addNoise %d noiseOnly %d ",
446 pedestals.ID0(),pedestals.ID1(),channel,
447 a0, a1, thres, pedestalMean, pedestalSigma, adcNoise,
449 TMath::Nint(pedestalMean + fgNSigmas*pedestalSigma + 0.5),
450 fgNSigmas,addNoise,noiseOnly));
456 // be sure we stick to 12 bits.
465 //_____________________________________________________________________________
467 AliMUONDigitizerV3::CreateInputDigitStores()
469 /// Create input digit stores
472 if (fInputDigitStores)
474 AliFatal("Should be called only once !");
477 fInputDigitStores = new TObjArray;
479 fInputDigitStores->SetOwner(kTRUE);
481 for ( Int_t iFile = 0; iFile < fManager->GetNinputs(); ++iFile )
483 AliLoader* inputLoader = GetLoader(fManager->GetInputFolderName(iFile));
485 inputLoader->LoadSDigits("READ");
487 TTree* iTreeS = inputLoader->TreeS();
490 AliFatal(Form("Could not get access to input file #%d",iFile));
493 fInputDigitStores->AddAt(AliMUONVDigitStore::Create(*iTreeS),iFile);
497 //_____________________________________________________________________________
499 AliMUONDigitizerV3::Exec(Option_t*)
502 /// We first loop over input files, and merge the sdigits we found there.
503 /// Second, we digitize all the resulting sdigits
504 /// Then we generate noise-only digits (for tracker only)
505 /// And we finally generate the trigger outputs.
507 AliCodeTimerAuto("",0)
509 if ( fManager->GetNinputs() == 0 )
511 AliWarning("No input set. Nothing to do.");
515 if ( !fIsInitialized )
517 AliError("Not initialized. Cannot perform the work. Sorry");
521 Int_t nInputFiles = fManager->GetNinputs();
523 AliLoader* outputLoader = GetLoader(fManager->GetOutputFolderName());
525 outputLoader->MakeDigitsContainer();
527 TTree* oTreeD = outputLoader->TreeD();
531 AliFatal("Cannot create output TreeD");
534 // Loop over all the input files, and merge the sdigits found in those
537 for ( Int_t iFile = 0; iFile < nInputFiles; ++iFile )
539 AliLoader* inputLoader = GetLoader(fManager->GetInputFolderName(iFile));
541 inputLoader->LoadSDigits("READ");
543 TTree* iTreeS = inputLoader->TreeS();
546 AliFatal(Form("Could not get access to input file #%d",iFile));
549 if (!fInputDigitStores)
551 CreateInputDigitStores();
554 AliMUONVDigitStore* dstore = static_cast<AliMUONVDigitStore*>(fInputDigitStores->At(iFile));
556 dstore->Connect(*iTreeS);
560 MergeWithSDigits(fDigitStore,*dstore,fManager->GetMask(iFile));
562 inputLoader->UnloadSDigits();
568 // At this point, we do have digit arrays (one per chamber) which contains
569 // the merging of all the sdigits of the input file(s).
570 // We now massage them to apply the detector response, i.e. this
571 // is here that we do the "digitization" work.
573 if (!fOutputDigitStore)
575 fOutputDigitStore = fDigitStore->Create();
578 if ( fGenerateNoisyDigits>=2 )
580 // Generate noise-only digits for trigger.
581 GenerateNoisyDigitsForTrigger(*fDigitStore);
583 ApplyResponse(*fDigitStore,*fOutputDigitStore);
585 if ( fGenerateNoisyDigits )
587 // Generate noise-only digits for tracker.
588 GenerateNoisyDigits(*fOutputDigitStore);
591 // We generate the global and local trigger decisions.
592 fTriggerProcessor->Digits2Trigger(*fOutputDigitStore,*fTriggerStore);
594 // Prepare output tree
595 Bool_t okD = fOutputDigitStore->Connect(*oTreeD,kFALSE);
596 Bool_t okT = fTriggerStore->Connect(*oTreeD,kFALSE);
599 AliError(Form("Could not make branch : Digit %d Trigger %d",okD,okT));
603 // Fill the output treeD
606 // Write to the output tree(D).
607 // Please note that as GlobalTrigger, LocalTrigger and Digits are in the same
608 // tree (=TreeD) in different branches, this WriteDigits in fact writes all of
610 outputLoader->WriteDigits("OVERWRITE");
612 outputLoader->UnloadDigits();
614 // Finally, we clean up after ourselves.
615 fTriggerStore->Clear();
616 fDigitStore->Clear();
617 fOutputDigitStore->Clear();
621 //_____________________________________________________________________________
623 AliMUONDigitizerV3::GenerateNoisyDigits(AliMUONVDigitStore& digitStore)
625 /// According to a given probability, generate digits that
626 /// have a signal above the noise cut (ped+n*sigma_ped), i.e. digits
627 /// that are "only noise".
629 AliCodeTimerAuto("",0)
631 for ( Int_t i = 0; i < AliMUONConstants::NTrackingCh(); ++i )
637 while ( !it.IsDone() )
639 for ( Int_t cathode = 0; cathode < 2; ++cathode )
641 GenerateNoisyDigitsForOneCathode(digitStore,it.CurrentDEId(),cathode);
648 //_____________________________________________________________________________
650 AliMUONDigitizerV3::GenerateNoisyDigitsForOneCathode(AliMUONVDigitStore& digitStore,
651 Int_t detElemId, Int_t cathode)
653 /// Generate noise-only digits for one cathode of one detection element.
654 /// Called by GenerateNoisyDigits()
656 const AliMpVSegmentation* seg
657 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode));
658 Int_t nofPads = seg->NofPads();
660 Int_t maxIx = seg->MaxPadIndexX();
661 Int_t maxIy = seg->MaxPadIndexY();
663 static const Double_t kProbToBeOutsideNsigmas = TMath::Erfc(fgNSigmas/TMath::Sqrt(2.0)) / 2. ;
665 Int_t nofNoisyPads = TMath::Nint(kProbToBeOutsideNsigmas*nofPads);
666 if ( !nofNoisyPads ) return;
669 TMath::Nint(gRandom->Gaus(nofNoisyPads,
670 nofNoisyPads/TMath::Sqrt(nofNoisyPads)));
672 AliDebug(3,Form("DE %d cath %d nofNoisyPads %d",detElemId,cathode,nofNoisyPads));
674 for ( Int_t i = 0; i < nofNoisyPads; ++i )
681 ix = gRandom->Integer(maxIx+1);
682 iy = gRandom->Integer(maxIy+1);
683 pad = seg->PadByIndices(ix,iy,kFALSE);
684 } while ( !pad.IsValid() );
686 Int_t manuId = pad.GetManuId();
687 Int_t manuChannel = pad.GetManuChannel();
689 AliMUONVCalibParam* pedestals = fCalibrationData->Pedestals(detElemId,manuId);
693 // no pedestal available for this channel, simply give up
697 AliMUONVDigit* d = digitStore.CreateDigit(detElemId,manuId,manuChannel,cathode);
701 d->SetCharge(0.0); // charge is zero, the ApplyResponseToTrackerDigit will add the noise
703 ApplyResponseToTrackerDigit(*d,kTRUE);
706 Bool_t ok = digitStore.Add(*d,AliMUONVDigitStore::kDeny);
707 // this can happen (that we randomly chose a digit that is
708 // already there). We simply ignore this, but log the occurence
709 // to cross-check that it's not too frequent.
712 fLogger->Log("Collision while adding noiseOnly digit");
716 fLogger->Log("Added noiseOnly digit");
724 //_____________________________________________________________________________
726 AliMUONDigitizerV3::GenerateNoisyDigitsForTrigger(AliMUONVDigitStore& digitStore)
728 /// Generate noise-only digits for one cathode of one detection element.
729 /// Called by GenerateNoisyDigits()
731 if ( !fNoiseFunctionTrig )
733 fNoiseFunctionTrig = new TF1("AliMUONDigitizerV3::fNoiseFunctionTrig","landau",
736 fNoiseFunctionTrig->SetParameters(3.91070e+02, 9.85026, 9.35881e-02);
740 AliMUONVDigit *d[2]={0x0};
742 for ( Int_t chamberId = AliMUONConstants::NTrackingCh(); chamberId < AliMUONConstants::NCh(); ++chamberId )
745 Int_t nofNoisyPads = 50;
747 Float_t r=-1, fi = 0., gx, gy, x, y, z, xg01, yg01, zg, xg02, yg02;
750 AliDebug(3,Form("Chamber %d nofNoisyPads %d",chamberId,nofNoisyPads));
752 for ( Int_t i = 0; i < nofNoisyPads; ++i )
754 //printf("Generating noise %i\n",i);
757 Bool_t isOk = kFALSE;
758 Int_t detElemId = -1;
760 //r = gRandom->Landau(9.85026, 9.35881e-02);
761 r = fNoiseFunctionTrig->GetRandom();
762 fi = 2. * TMath::Pi() * gRandom->Rndm();
763 //printf("r = %f\tfi = %f\n", r, fi);
764 gx = r * TMath::Cos(fi);
765 gy = r * TMath::Sin(fi);
767 for ( it.First(chamberId); ! it.IsDone(); it.Next() ){
768 Int_t currDetElemId = it.CurrentDEId();
769 const AliMpVSegmentation* seg
770 = AliMpSegmentation::Instance()->GetMpSegmentation(currDetElemId,AliMp::GetCathodType(0));
772 Float_t deltax = seg->GetDimensionX();
773 Float_t deltay = seg->GetDimensionY();
774 GetTransformer()->Local2Global(currDetElemId, -deltax, -deltay, 0, xg01, yg01, zg);
775 GetTransformer()->Local2Global(currDetElemId, deltax, deltay, 0, xg02, yg02, zg);
776 Float_t xg1 = xg01, xg2 = xg02, yg1 = yg01, yg2 = yg02;
785 if(gx>=xg1 && gx<=xg2 && gy>=yg1 && gy<=yg2){
786 detElemId = currDetElemId;
787 GetTransformer()->Global2Local(detElemId, gx, gy, 0, x, y, z);
788 pad[0] = seg->PadByPosition(x,y,kFALSE);
789 if(!pad[0].IsValid()) continue;
796 const AliMpVSegmentation* seg1
797 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(1));
798 pad[1] = seg1->PadByPosition(x,y,kFALSE);
800 for ( Int_t cathode = 0; cathode < 2; ++cathode ){
801 Int_t manuId = pad[cathode].GetLocalBoardId(0);
802 Int_t manuChannel = pad[cathode].GetLocalBoardChannel(0);
803 d[cathode] = digitStore.CreateDigit(detElemId,manuId,manuChannel,cathode);
804 ix = pad[cathode].GetIx();
805 iy = pad[cathode].GetIy();
806 d[cathode]->SetPadXY(ix,iy);
807 //d[cathode].SetSignal(1);
808 //d[cathode].SetPhysicsSignal(0);
809 d[cathode]->SetCharge(1);
810 d[cathode]->NoiseOnly(kTRUE);
811 AliDebug(3,Form("Adding a pure noise digit :"));
813 Bool_t ok = digitStore.Add(*d[cathode],AliMUONVDigitStore::kDeny);
816 fLogger->Log("Collision while adding TriggerNoise digit");
820 fLogger->Log("Added triggerNoise digit");
823 } // loop on noisy pads
824 } // loop on chambers
828 //_____________________________________________________________________________
830 AliMUONDigitizerV3::GetLoader(const TString& folderName)
832 /// Get a MUON loader
834 AliDebug(2,Form("Getting access to folder %s",folderName.Data()));
835 AliLoader* loader = AliRunLoader::GetDetectorLoader("MUON",folderName.Data());
838 AliError(Form("Could not get MuonLoader from folder %s",folderName.Data()));
844 //_____________________________________________________________________________
846 AliMUONDigitizerV3::Init()
848 /// Initialization of the TTask :
849 /// a) create the calibrationData, according to run number
850 /// b) create the trigger processing task
854 if ( fIsInitialized )
856 AliError("Object already initialized.");
862 AliError("fManager is null !");
867 if ( ! AliMpCDB::LoadDDLStore() ) {
868 AliFatal("Could not access mapping from OCDB !");
871 if (!fCalibrationData)
872 AliFatal("Calibration data object not defined");
874 if ( !fCalibrationData->Pedestals() )
876 AliFatal("Could not access pedestals from OCDB !");
878 if ( !fCalibrationData->Gains() )
880 AliFatal("Could not access gains from OCDB !");
884 AliInfo("Using trigger configuration from CDB");
886 fTriggerProcessor = new AliMUONTriggerElectronics(fCalibrationData);
888 AliDebug(1, Form("Will %s generate noise-only digits for tracker",
889 (fGenerateNoisyDigits ? "":"NOT")));
891 fTriggerUtilities = new AliMUONTriggerUtilities(fCalibrationData);
893 if ( muon()->GetTriggerEffCells() ) {
894 // Apply trigger efficiency
895 AliDebug(1, "Will apply trigger efficiency");
896 fTriggerEfficiency = new AliMUONTriggerChamberEfficiency(fCalibrationData->TriggerEfficiency());
899 fIsInitialized = kTRUE;
904 //_____________________________________________________________________________
905 Int_t AliMUONDigitizerV3::GetArrayIndex(Int_t cathode, Int_t trigCh, Int_t localCircuit)
907 /// Get index of array with trigger status map or efficiency
909 AliMUONConstants::NTriggerCircuit() * AliMUONConstants::NTriggerCh() * cathode +
910 AliMUONConstants::NTriggerCircuit() * trigCh + localCircuit-1;
914 //_____________________________________________________________________________
916 AliMUONDigitizerV3::MergeWithSDigits(AliMUONVDigitStore*& outputStore,
917 const AliMUONVDigitStore& input,
920 /// Merge the sdigits in inputData with the digits already present in outputData
922 if ( !outputStore ) outputStore = input.Create();
924 TIter next(input.CreateIterator());
925 AliMUONVDigit* sdigit;
927 while ( ( sdigit = static_cast<AliMUONVDigit*>(next()) ) )
929 // Update the track references using the mask.
930 // FIXME: this is dirty, for backward compatibility only.
931 // Should re-design all this way of keeping track of MC information...
932 if ( mask ) sdigit->PatchTracks(mask);
933 // Then add or update the digit to the output.
934 AliMUONVDigit* added = outputStore->Add(*sdigit,AliMUONVDigitStore::kMerge);
937 AliError("Could not add digit in merge mode");
942 //_____________________________________________________________________________
944 AliMUONDigitizerV3::NoiseFunction()
946 /// Return noise function
950 f = new TF1("AliMUONDigitizerV3::NoiseFunction","gaus",fgNSigmas,fgNSigmas*10);
951 f->SetParameters(1,0,1);
956 //_____________________________________________________________________________
957 void AliMUONDigitizerV3::SetCalibrationData(AliMUONCalibrationData* calibrationData,
958 AliMUONRecoParam* recoParam)
960 fCalibrationData = calibrationData;
961 fRecoParam = recoParam;
964 AliError("Cannot work (e.g. decalibrate) without recoparams !");