]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONDigitCalibrator.cxx
- Reordering includes from most specific to more general ones
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitCalibrator.cxx
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 #include "AliMUONDigitCalibrator.h"
19
20 #include "AliCDBEntry.h"
21 #include "AliCDBManager.h"
22 #include "AliCDBStorage.h"
23 #include "AliLog.h"
24 #include "AliMUONCalibrationData.h"
25 #include "AliMUONConstants.h"
26 #include "AliMUONData.h"
27 #include "AliMUONDigit.h"
28 #include "AliMUONVCalibParam.h"
29 #include "AliMpDEManager.h"
30 #include "AliMpPad.h"
31 #include "AliMpPlaneType.h"
32 #include "AliMpStationType.h"
33 #include "AliMpVSegmentation.h"
34 #include "Riostream.h"
35 #include "TClonesArray.h"
36
37 ClassImp(AliMUONDigitCalibrator)
38
39 //_____________________________________________________________________________
40 AliMUONDigitCalibrator::AliMUONDigitCalibrator(AliMUONData* muonData,
41                                               AliMUONCalibrationData* calib)
42 : TTask("AliMUONDigitCalibrator","Subtract pedestal from digit charge"),
43   fData(muonData),
44   fCalibrationData(calib)
45 {
46     //
47     // ctor. This class need the muonData to get access to the digit,
48     // and the calibrationData to get access to calibration parameters.
49     //
50 }
51
52 //______________________________________________________________________________
53 AliMUONDigitCalibrator::AliMUONDigitCalibrator(const AliMUONDigitCalibrator& right) 
54   : TTask(right) 
55 {  
56 /// Protected copy constructor (not implemented)
57
58   AliFatal("Copy constructor not provided.");
59 }
60
61 //_____________________________________________________________________________
62 AliMUONDigitCalibrator::~AliMUONDigitCalibrator()
63 {
64   //
65   // empty dtor.
66   //
67 }
68
69 //______________________________________________________________________________
70 AliMUONDigitCalibrator& 
71 AliMUONDigitCalibrator::operator=(const AliMUONDigitCalibrator& right)
72 {
73 /// Protected assignement operator (not implemented)
74
75   // check assignement to self
76   if (this == &right) return *this;
77
78   AliFatal("Assignement operator not provided.");
79     
80   return *this;  
81 }    
82
83 //_____________________________________________________________________________
84 void
85 AliMUONDigitCalibrator::Exec(Option_t*)
86 {
87   //
88   // Main method.
89   // We loop on tracking chambers (i.e. we do nothing for trigger)
90   // and for each digit in that chamber, we calibrate it :
91   // a) if the corresponding channel is known to be bad, we set the signal to 0
92   //    (so that digit can be suppressed later on)
93   // b) we then apply pedestal and gain corrections.
94   
95   for ( Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ++ch )
96   {
97     TClonesArray* digitArray = fData->Digits(ch);
98     Int_t nDigits = digitArray->GetEntriesFast();
99     for ( Int_t d = 0; d < nDigits; ++d )
100     {
101       AliMUONDigit* digit = 
102         static_cast<AliMUONDigit*>(digitArray->UncheckedAt(d));
103  
104       // Very first check is whether this channel is known to be bad,
105       // in which case we set the signal to zero.
106       AliMUONVCalibParam* dead = static_cast<AliMUONVCalibParam*>
107         (fCalibrationData->DeadChannel(digit->DetElemId(),digit->ManuId()));
108       if ( dead && dead->ValueAsInt(digit->ManuChannel()) )
109       {
110         AliDebug(10,Form("Removing dead channel detElemId %d manuId %d "
111                         "manuChannel %d",digit->DetElemId(),digit->ManuId(),
112                         digit->ManuChannel()));
113         digit->SetSignal(0);
114         continue;
115       }
116           
117       // If the channel is good, go on with the calibration itself.
118       
119       AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
120         (fCalibrationData->Pedestal(digit->DetElemId(),digit->ManuId()));
121       
122       AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
123         (fCalibrationData->Gain(digit->DetElemId(),digit->ManuId()));
124       
125       if (!pedestal)
126       {
127         AliFatal(Form("Got a null ped object for DE,manu=%d,%d",
128                       digit->DetElemId(),digit->ManuId()));
129         
130       }
131       if (!gain)
132       {
133         AliFatal(Form("Got a null gain object for DE,manu=%d,%d",
134                       digit->DetElemId(),digit->ManuId()));        
135       }
136       
137       Int_t manuChannel = digit->ManuChannel();
138       Int_t adc = digit->Signal();
139       Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0);
140       if ( padc < 3.0*pedestal->ValueAsFloat(manuChannel,1) ) 
141       {
142         padc = 0.0;
143       }
144       Float_t charge = padc*gain->ValueAsFloat(manuChannel,0);
145       Int_t signal = TMath::Nint(charge);
146       digit->SetSignal(signal);
147       Int_t saturation = gain->ValueAsInt(manuChannel,1);
148       if ( signal >= saturation )
149       {
150         digit->Saturated(kTRUE);
151       }
152     }
153   }
154 }