]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONRecoParam.cxx
Coverity fix for uninitialized variables and check for returned null value
[u/mrichter/AliRoot.git] / MUON / AliMUONRecoParam.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-2007, 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 /// \class AliMUONRecoParam
20 ///
21 /// Class with MUON reconstruction parameters
22 ///
23 ///  \author Philippe Pillot
24 //-----------------------------------------------------------------------------
25
26
27
28 #include "AliMUONRecoParam.h"
29 #include "AliMUONPadStatusMaker.h"
30
31 #include "AliRecoParam.h"
32 #include "AliLog.h"
33
34 #include "AliCDBManager.h"
35 #include "AliCDBEntry.h"
36
37 #include <Riostream.h>
38
39 using std::cout;
40 using std::endl;
41 ClassImp(AliMUONRecoParam)
42
43
44 //_____________________________________________________________________________
45 AliMUONRecoParam::AliMUONRecoParam()
46 : AliDetectorRecoParam(),
47   fClusteringMode("MLEM"),
48   fTrackingMode("KALMAN"),
49   fMinBendingMomentum(0.),
50   fMaxBendingMomentum(0.),
51   fMaxNonBendingSlope(0.),
52   fMaxBendingSlope(0.),
53   fNonBendingVertexDispersion(0.),
54   fBendingVertexDispersion(0.),
55   fMaxNonBendingDistanceToTrack(0.),
56   fMaxBendingDistanceToTrack(0.),
57   fSigmaCutForTracking(0.),
58   fSigmaCutForImprovement(0.),
59   fSigmaCutForTrigger(0.),
60   fStripCutForTrigger(0.),
61   fMaxStripAreaForTrigger(0.),
62   fMaxNormChi2MatchTrigger(0.),
63   fPercentOfFullClusterInESD(10.),
64   fCombinedClusterTrackReco(kFALSE),
65   fTrackAllTracks(kFALSE),
66   fRecoverTracks(kFALSE),
67   fMakeTrackCandidatesFast(kFALSE),
68   fMakeMoreTrackCandidates(kFALSE),
69   fComplementTracks(kFALSE),
70   fImproveTracks(kFALSE),
71   fUseSmoother(kFALSE),
72   fSaveFullClusterInESD(kTRUE),
73   fCalibrationMode("NOGAIN"),
74   fBypassSt45(0),
75   fPadGoodnessMask(0),
76   fChargeSigmaCut(4.0),
77   fRemoveConnectedTracksInSt12(kFALSE),
78   fMaxTriggerTracks(0),
79   fMaxTrackCandidates(0),
80   fSelectTrackOnSlope(kFALSE),
81   fMissingPadFractionLimit(-1),
82   fFractionOfBuspatchOutsideOccupancyLimit(0),
83   fAverageNoisePadCharge(0.22875),
84   fClusterChargeCut(2.0),
85   fEventSizeSoftLimit(35.0),
86   fEventSizeHardLimit(45.0),
87   fTokenLostLimit(0.0),
88   fTryRecover(kFALSE)
89 {  
90   /// Constructor
91   
92   SetNameTitle("Dummy","Dummy");
93   for (Int_t iCh = 0; iCh < 10; iCh++) {
94     fUseChamber[iCh] = kTRUE;
95     fDefaultNonBendingReso[iCh] = 0.;
96     fDefaultBendingReso[iCh] = 0.;
97   }
98   for (Int_t iSt = 0; iSt < 5; iSt++) fRequestStation[iSt] = kTRUE;
99   SetDefaultLimits();
100 }
101
102 //_____________________________________________________________________________
103 AliMUONRecoParam::~AliMUONRecoParam() 
104 {
105   /// Destructor
106 }
107
108 //_____________________________________________________________________________
109 void
110 AliMUONRecoParam::BypassSt45(Bool_t st4, Bool_t st5)
111 {
112         /// Set the bypass status
113         
114         if ( st4 && st5 ) fBypassSt45 = 45;
115         else if ( st4 ) fBypassSt45 = 4;
116         else if ( st5 ) fBypassSt45 = 5;
117         else fBypassSt45 = 0;
118 }
119
120 //_____________________________________________________________________________
121 Option_t*
122 AliMUONRecoParam::GetCalibrationMode() const
123 {
124   /// Return the calibration mode. Can be : 
125   /// NOGAIN : only do pedestal subtraction
126   /// GAIN : do pedestal subtraction, and apply gain correction, but with a
127   ///        single capacitance value for all channels
128   /// INJECTIONGAIN : as GAIN, but with gain values taken as EMELEC factory values
129   /// GAINCONSTANTCAPA : as GAIN, but with a channel-dependent capacitance value
130   
131   return fCalibrationMode.Data();
132 }
133
134 //_____________________________________________________________________________
135 AliMUONRecoParam *AliMUONRecoParam::GetLowFluxParam() 
136 {
137   /// Return default reconstruction parameters for low flux environment
138   
139   AliMUONRecoParam *param = new AliMUONRecoParam();
140   param->SetLowFluxParam();
141   
142   return param;
143 }
144
145 //_____________________________________________________________________________
146 AliMUONRecoParam *AliMUONRecoParam::GetHighFluxParam() 
147 {
148   /// Return default reconstruction parameters for high flux environment
149   
150   AliMUONRecoParam *param = new AliMUONRecoParam();
151   param->SetHighFluxParam();
152  
153   return param;
154 }
155
156 //_____________________________________________________________________________
157 AliMUONRecoParam *AliMUONRecoParam::GetCosmicParam() 
158 {
159   /// Return default reconstruction parameters for high flux environment
160   
161   AliMUONRecoParam *param = new AliMUONRecoParam();
162   param->SetCosmicParam();
163   
164   return param;
165 }
166
167 //_____________________________________________________________________________
168 AliMUONRecoParam *AliMUONRecoParam::GetCalibrationParam() 
169 {
170   /// Return default (dummy) reconstruction parameters for calibration environment
171   
172   AliMUONRecoParam *param = new AliMUONRecoParam();
173   param->SetCalibrationParam();
174   
175   return param;
176 }
177
178
179 //_____________________________________________________________________________
180 void AliMUONRecoParam::SetLowFluxParam() 
181 {
182   /// Set reconstruction parameters for low flux environment
183   
184   SetNameTitle("Low Flux","Low Flux");
185   SetEventSpecie(AliRecoParam::kLowMult);
186   fMinBendingMomentum = 0.8;
187   fMaxBendingMomentum = 1.e10;
188   fMaxNonBendingSlope = 0.3;
189   fMaxBendingSlope = 0.4;
190   fSelectTrackOnSlope = kFALSE;
191   fNonBendingVertexDispersion = 70.;
192   fBendingVertexDispersion = 70.;
193   fMaxNonBendingDistanceToTrack = 1.;
194   fMaxBendingDistanceToTrack = 1.;
195   fSigmaCutForTracking = 6.;
196   fSigmaCutForImprovement = 5.;
197   fSigmaCutForTrigger = 4.;
198   fStripCutForTrigger = 1.;
199   fMaxStripAreaForTrigger = 3.;
200   fMaxNormChi2MatchTrigger = fSigmaCutForTrigger * fSigmaCutForTrigger;
201   fCombinedClusterTrackReco = kFALSE;
202   fTrackAllTracks = kTRUE;
203   fRecoverTracks = kTRUE;
204   fMakeTrackCandidatesFast = kFALSE;
205   fMakeMoreTrackCandidates = kFALSE;
206   fComplementTracks = kTRUE;
207   fImproveTracks = kTRUE;
208   fRemoveConnectedTracksInSt12 = kFALSE;
209   fUseSmoother = kTRUE;
210   for (Int_t iCh = 0; iCh < 10; iCh++) {
211     fUseChamber[iCh] = kTRUE;
212     fDefaultNonBendingReso[iCh] = 0.144;
213     fDefaultBendingReso[iCh] = 0.01;
214   }
215   for (Int_t iSt = 0; iSt < 5; iSt++) fRequestStation[iSt] = kTRUE;
216   fBypassSt45 = 0;
217   fMaxTriggerTracks = 100;
218   fMaxTrackCandidates = 10000;  
219 }
220
221 //_____________________________________________________________________________
222 void AliMUONRecoParam::SetHighFluxParam() 
223 {
224   /// Set reconstruction parameters for high flux environment
225   
226   SetNameTitle("High Flux","High Flux");
227   SetEventSpecie(AliRecoParam::kHighMult);
228   fMinBendingMomentum = 0.8;
229   fMaxBendingMomentum = 1.e10;
230   fMaxNonBendingSlope = 0.3;
231   fMaxBendingSlope = 0.4;
232   fSelectTrackOnSlope = kFALSE;
233   fNonBendingVertexDispersion = 70.;
234   fBendingVertexDispersion = 70.;
235   fMaxNonBendingDistanceToTrack = 1.;
236   fMaxBendingDistanceToTrack = 1.;
237   fSigmaCutForTracking = 6.;
238   fSigmaCutForImprovement = 5.;
239   fSigmaCutForTrigger = 4.;
240   fStripCutForTrigger = 1.;
241   fMaxStripAreaForTrigger = 3.;
242   fMaxNormChi2MatchTrigger = fSigmaCutForTrigger * fSigmaCutForTrigger;
243   fCombinedClusterTrackReco = kFALSE;
244   fTrackAllTracks = kTRUE;
245   fRecoverTracks = kTRUE;
246   fMakeTrackCandidatesFast = kFALSE;
247   fMakeMoreTrackCandidates = kFALSE;
248   fComplementTracks = kTRUE;
249   fImproveTracks = kTRUE;
250   fRemoveConnectedTracksInSt12 = kFALSE;
251   fUseSmoother = kTRUE;
252   for (Int_t iCh = 0; iCh < 10; iCh++) {
253     fUseChamber[iCh] = kTRUE;
254     fDefaultNonBendingReso[iCh] = 0.144;
255     fDefaultBendingReso[iCh] = 0.01;
256   }
257   for (Int_t iSt = 0; iSt < 5; iSt++) fRequestStation[iSt] = kTRUE;
258   fBypassSt45 = 0;
259   fMaxTriggerTracks = 100;
260   fMaxTrackCandidates = 10000;
261 }
262
263 //_____________________________________________________________________________
264 void AliMUONRecoParam::SetCosmicParam() 
265 {
266   /// Set reconstruction parameters for high flux environment
267   
268   SetNameTitle("Cosmic","Cosmic");
269   SetEventSpecie(AliRecoParam::kCosmic);
270   fMinBendingMomentum = 0.8;
271   fMaxBendingMomentum = 1.e10;
272   fMaxNonBendingSlope = 0.3;
273   fMaxBendingSlope = 0.4;
274   fSelectTrackOnSlope = kTRUE;
275   fNonBendingVertexDispersion = 170.;
276   fBendingVertexDispersion = 170.;
277   fMaxNonBendingDistanceToTrack = 1.;
278   fMaxBendingDistanceToTrack = 1.;
279   fSigmaCutForTracking = 7.;
280   fSigmaCutForImprovement = 6.;
281   fSigmaCutForTrigger = 4.;
282   fStripCutForTrigger = 1.5;
283   fMaxStripAreaForTrigger = 3.;
284   fMaxNormChi2MatchTrigger = fSigmaCutForTrigger * fSigmaCutForTrigger;
285   fPercentOfFullClusterInESD = 100.;
286   fCombinedClusterTrackReco = kFALSE;
287   fTrackAllTracks = kTRUE;
288   fRecoverTracks = kTRUE;
289   fMakeTrackCandidatesFast = kFALSE;
290   fMakeMoreTrackCandidates = kFALSE;
291   fComplementTracks = kTRUE;
292   fImproveTracks = kTRUE;
293   fRemoveConnectedTracksInSt12 = kTRUE;
294   fUseSmoother = kTRUE;
295   fSaveFullClusterInESD = kTRUE;
296   for (Int_t iCh = 0; iCh < 10; iCh++) {
297     fUseChamber[iCh] = kTRUE;
298     fDefaultNonBendingReso[iCh] = 0.4;
299     fDefaultBendingReso[iCh] = 0.4;
300   }
301   fRequestStation[0] = kTRUE;
302   fRequestStation[1] = kTRUE;
303   fRequestStation[2] = kTRUE;
304   fRequestStation[3] = kTRUE;
305   fRequestStation[4] = kTRUE;
306   fBypassSt45 = 0;
307   fPadGoodnessMask = 0x400BE80; // Ped Mean is Zero | Ped Mean Too Low | Ped Mean Too High | Ped Sigma Too Low | Ped Sigma Too High | Ped is missing | HV is missing | manu occupancy too high
308   fMaxTriggerTracks = 100;
309   fMaxTrackCandidates = 10000;
310   
311   SetPedMeanLimits(20, 700);
312   SetManuOccupancyLimits(-1.,0.01); // reject manu above occ=1%
313
314   SetBuspatchOccupancyLimits(-1,0.05);  
315   SetFractionOfBuspatchOutsideOccupancyLimit(0.10); // 10 %
316 }
317
318
319 //_____________________________________________________________________________
320 void AliMUONRecoParam::SetCalibrationParam() 
321 {
322   /// Set (dummy) reconstruction parameters for calibration environment
323   
324   SetNameTitle("Calibration","Calibration");
325   SetEventSpecie(AliRecoParam::kCalib);
326
327   fPedMeanLimits[0] = 5000;
328   fPedMeanLimits[1] = 0;
329
330   fPadGoodnessMask = 0x8C00; // Pedestal is missing | is too low | too high
331
332 }
333
334 //_____________________________________________________________________________
335 UInt_t
336 AliMUONRecoParam::RequestedStationMask() const
337 {
338   /// Get the mask of the requested station, i.e. an integer where 
339   /// bit n is set to one if the station n was requested
340   
341   UInt_t m(0);
342   
343   for ( Int_t i = 0; i < 5; ++i ) 
344   {
345     if ( RequestStation(i) ) m |= ( 1 << i );
346   }
347   return m;
348 }
349
350 //_____________________________________________________________________________
351 void AliMUONRecoParam::Print(Option_t *option) const
352 {
353   /// print reconstruction parameters
354   /// if option = FULL then print also unused parameters
355   
356   cout<<endl<<"\t------MUON Reconstruction parameters ("<<GetName()<<")------"<<endl;
357   
358   if (IsDefault()) cout<<"\t\t*** Parameters used by default ***"<<endl;
359   
360   cout << "Event Specie=" << GetEventSpecie() << endl;
361   
362   cout<<Form("Calibration mode = %s",fCalibrationMode.Data())<<endl;
363   cout<<Form("Clustering mode = %s",fClusteringMode.Data())<<endl;
364   cout<<Form("Tracking mode = %s",fTrackingMode.Data())<<endl;
365
366         TString bypass;
367         
368         if ( BypassSt45() )
369         {
370                 bypass = "stations 4 and 5";
371         }
372         else if ( BypassSt4() ) 
373         {
374                 bypass = "station 4";
375         }
376         else if ( BypassSt5() ) 
377         {
378                 bypass = "station 5";
379         }
380         
381   if (bypass.Length()) cout << "Will bypass " << bypass.Data() << " (replacing real clusters by generated ones from trigger tracks)" << endl;
382   
383   if (fCombinedClusterTrackReco) cout<<"Combined cluster/track reconstruction: ON"<<endl;
384   else cout<<"Combined cluster/track reconstruction: OFF"<<endl;
385   
386   if (fSaveFullClusterInESD) cout<<Form("Save all cluster info in ESD for %5.2f %% of events",fPercentOfFullClusterInESD)<<endl;
387   else cout<<"Save partial cluster info in ESD"<<endl;
388     
389   cout<<"Selection of track candidates:"<<endl;
390   if (fSelectTrackOnSlope) cout<<Form("\t- Non-bending slope < %5.2f",fMaxNonBendingSlope)<<endl;
391   else cout<<"\t- Impact parameter < 3 * vertex dispersion in the non-bending direction"<<endl;
392   cout<<Form("\t- if B!=0: Bending momentum > %5.2f",fMinBendingMomentum)<<endl;
393   if (fSelectTrackOnSlope) cout<<Form("\t  if B==0: Bending slope < %5.2f",fMaxBendingSlope)<<endl;
394   else cout<<"\t  if B==0: Impact parameter < 3 * vertex dispersion in the bending direction"<<endl;
395   
396   cout<<Form("Vertex dispersion (used to estimate initial bending momentum resolution) = (%5.2f,%5.2f)",fNonBendingVertexDispersion,fBendingVertexDispersion)<<endl;
397   
398   cout<<Form("Maximum distance to track = (%5.2f,%5.2f)",fMaxNonBendingDistanceToTrack,fMaxBendingDistanceToTrack)<<endl;
399   
400   cout<<Form("Sigma cut for tracking = %5.2f",fSigmaCutForTracking)<<endl;
401
402   cout<<Form("Sigma cut for trigger hit pattern = %5.2f",fSigmaCutForTrigger)<<endl;
403
404   cout<<Form("Cut in strips for trigger chamber efficiency = %5.2f",fStripCutForTrigger)<<endl;
405
406   cout<<Form("Max search area in strips for trigger chamber efficiency = %5.2f",fMaxStripAreaForTrigger)<<endl;
407
408   if (fTrackAllTracks) cout<<"Track all the possible candidates"<<endl;
409   else cout<<"Track only the best candidates"<<endl;
410   
411   if (strstr(option,"FULL")) {
412     cout<<"Make track candidates assuming linear propagation between stations 4 and 5: ";
413     if (fMakeTrackCandidatesFast) cout<<"ON"<<endl;
414     else cout<<"OFF"<<endl;
415   } else if (fMakeTrackCandidatesFast)
416     cout<<"Make track candidates assuming linear propagation between stations 4 and 5"<<endl;
417   
418   if (strstr(option,"FULL")) {
419     cout<<"Make track candidates starting from 1 cluster in each of the stations 4 and 5: ";
420     if (fMakeMoreTrackCandidates) cout<<"ON"<<endl;
421     else cout<<"OFF"<<endl;
422   } else if (fMakeMoreTrackCandidates)
423     cout<<"Make track candidates starting from 1 cluster in each of the stations 4 and 5"<<endl;
424   
425   if (strstr(option,"FULL")) {
426     cout<<"Try to recover tracks getting lost during tracking: ";
427     if (fRecoverTracks) cout<<"ON"<<endl;
428     else cout<<"OFF"<<endl;
429   } else if (fRecoverTracks)
430     cout<<"Try to recover tracks getting lost during tracking"<<endl;
431   
432   if (strstr(option,"FULL")) {
433     cout<<"Try to complete the reconstructed tracks by adding missing clusters: ";
434     if (fComplementTracks) cout<<"ON"<<endl;
435     else cout<<"OFF"<<endl;
436   } else if (fComplementTracks)
437     cout<<"Try to complete the reconstructed tracks by adding missing clusters"<<endl;
438   
439   if (strstr(option,"FULL")) {
440     cout<<"Try to improve the reconstructed tracks by removing bad clusters: ";
441     if (fImproveTracks) cout<<Form("ON (sigma cut = %5.2f)",fSigmaCutForImprovement)<<endl;
442     else cout<<"OFF"<<endl;
443   } else if (fImproveTracks)
444     cout<<Form("Try to improve the reconstructed tracks by removing bad clusters (sigma cut = %5.2f)",fSigmaCutForImprovement)<<endl;
445   
446   if (fRemoveConnectedTracksInSt12) cout<<"Remove tracks sharing one cluster or more in any station"<<endl;
447   else cout<<"Remove tracks sharing one cluster or more in stations 3, 4 and 5"<<endl;
448   
449   if (strstr(option,"FULL")) {
450     cout<<"Use smoother to compute final track parameters, etc, at each cluster (used for Kalman tracking only): ";
451     if (fUseSmoother) cout<<"ON"<<endl;
452     else cout<<"OFF"<<endl;
453   } else if (fUseSmoother)
454     cout<<"Use smoother to compute final track parameters, etc, at each cluster"<<endl;
455   
456   cout<<Form("Maximum normalized chi2 of tracking/trigger track matching = %5.2f",fMaxNormChi2MatchTrigger)<<endl;
457   
458   Bool_t discardedCh = kFALSE;
459   Int_t ch = 0;
460   do {
461     if (!UseChamber(ch)) {
462       if (!discardedCh) {
463         cout<<"Discarded chambers(1..): "<<ch+1;
464         discardedCh = kTRUE;
465       }
466       else cout<<" "<<ch+1;
467     }
468   } while (++ch < 10);
469   if (discardedCh) cout<<endl;
470   
471   Bool_t discardedSt = kFALSE;
472   Int_t st = 0;
473   do {
474     if (!RequestStation(st)) {
475       if (!discardedSt) {
476         cout<<"Not requested stations(1..): "<<st+1;
477         discardedSt = kTRUE;
478       }
479       else cout<<" "<<st+1;
480     }
481   } while (++st < 5);
482   if (discardedSt) cout<<endl;
483   
484   cout << Form("Pad goodness policy mask is 0x%x",PadGoodnessMask()) << endl;
485   cout << "Which means we reject pads having the condition = " <<
486   AliMUONPadStatusMaker::AsCondition(PadGoodnessMask()).Data() << endl;
487   
488   cout << "The pad limits we are using are :" << endl;
489   
490   for ( int ichamber = 0; ichamber < 10; ++ichamber ) 
491   {
492     cout << Form("HV Ch %d must be >= %5.2f",ichamber,HVLimit(ichamber)) << endl;
493   }
494
495   cout << Form("%7.2f <= Pedestal mean <= %7.2f",PedMeanLowLimit(),PedMeanHighLimit()) << endl;
496   cout << Form("%7.2f <= Pedestal sigma <= %7.2f",PedSigmaLowLimit(),PedSigmaHighLimit()) << endl;
497   cout << Form("%e <= Gain linear term <= %e",GainA1LowLimit(),GainA1HighLimit()) << endl;
498   cout << Form("%e <= Gain quadratic term <= %e",GainA2LowLimit(),GainA2HighLimit()) << endl;
499   cout << Form("%5.0f <= Gain threshold term <= %5.0f",GainThresLowLimit(),GainThresHighLimit()) << endl;
500     
501   cout << Form("And we cut on charge >= %7.2f x ( pedestal sigma ) ",ChargeSigmaCut()) << endl;
502   
503   cout << "Occupancy limits are :" << endl;
504   
505   cout << Form("%e <= Manu occupancy < %7.3f",ManuOccupancyLowLimit(),ManuOccupancyHighLimit()) << endl;
506   cout << Form("%e <= Buspatch occupancy < %7.3f",BuspatchOccupancyLowLimit(),BuspatchOccupancyHighLimit()) << endl;
507   cout << Form("%e <= DE occupancy < %7.3f",DEOccupancyLowLimit(),DEOccupancyHighLimit()) << endl;
508   
509   cout << "'QAChecker' limits" << endl;  
510   cout << Form("FractionOfBuspatchOutsideOccupancyLimit = %5.2f %%",FractionOfBuspatchOutsideOccupancyLimit()*100.0) << endl;
511   cout << Form("Event size limit = %5.2f KB/event (soft) and %5.2f KB/event (hard)",fEventSizeSoftLimit,fEventSizeHardLimit) << endl;
512   if ( fTokenLostLimit > 0 )
513   {
514     cout << Form("We tolerate up to %5.2f %% token lost errors per event",fTokenLostLimit) << endl;
515   }
516   else
517   {
518     cout << "We dot not tolerate any token lost error !" << endl;
519   }
520   
521   cout << "chamber non bending resolution = |";
522   for (Int_t iCh = 0; iCh < 10; iCh++) cout << Form(" %6.3f |",fDefaultNonBendingReso[iCh]);
523   cout << endl;
524   cout << "chamber bending resolution = |";
525   for (Int_t iCh = 0; iCh < 10; iCh++) cout << Form(" %6.3f |",fDefaultBendingReso[iCh]);
526   cout << endl;
527   cout<<Form("maximum number of trigger tracks above which the tracking is cancelled = %d",fMaxTriggerTracks)<<endl;
528   cout<<Form("maximum number of track candidates above which the tracking is abandonned = %d",fMaxTrackCandidates)<<endl;
529
530   cout << Form("The average noise pad charge is assumed to be %7.2f fC",AverageNoisePadCharge()) << endl;
531   cout << Form("and clusters below %5.2f times this noise charge (i.e. %7.2f fC) are discarded",
532                ClusterChargeCut(),ClusterChargeCut()*AverageNoisePadCharge()) << endl;
533   cout << Form("Note that LowestPadCharge is then %7.2f fC",LowestPadCharge()) << endl;
534   
535   if (TryRecover())
536   {
537     cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
538     cout << "!!! WILL TRY TO RECOVER CORRUPTED RAW DATA !!!" << endl;
539     cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;    
540   }
541   cout<<"\t-----------------------------------------------------"<<endl<<endl;
542   
543 }
544
545 //_____________________________________________________________________________
546 void
547 AliMUONRecoParam::SetHVLimit(Int_t chamberId, Double_t value)
548 {
549   /// Set the HV limit for a given chamber (or all chambers 
550   /// if chamberId==-1
551   
552   if ( chamberId == -1 ) 
553   {
554     for ( Int_t i = 0; i < 10; ++i ) 
555     {
556       fHVLimit[i] = value;
557     }
558   }
559   else if ( chamberId >= 0 && chamberId < 10 ) 
560   {
561     fHVLimit[chamberId]=value;
562   }
563   else
564   {
565     AliError(Form("chamberId = %d is not a valid chamberId",chamberId));
566   }
567 }
568
569 //_____________________________________________________________________________
570 Double_t AliMUONRecoParam::HVLimit(Int_t chamberId) const
571 {
572   /// Get the HV limit for a given chamber
573   if ( chamberId >= 0 && chamberId < 10 )
574   {
575     return fHVLimit[chamberId];
576   }
577   AliError(Form("chamberId = %d is not a valid chamberId",chamberId));
578
579   return 0.0;
580 }
581
582 //_____________________________________________________________________________
583 void
584 AliMUONRecoParam::SetDefaultLimits()
585 {
586         /// Set the default limits and pad goodness policy
587
588   fHVSt12Limits[0]=1500; // kept for backward compatibility only
589         fHVSt12Limits[1]=2000; // kept for backward compatibility only
590         fHVSt345Limits[0]=1500; // kept for backward compatibility only
591         fHVSt345Limits[1]=2000; // kept for backward compatibility only
592   
593   SetHVLimit(-1,1590); // this one is the real HV limit used now
594   
595         fPedMeanLimits[0] = 20;
596         fPedMeanLimits[1] = 1024;
597         
598         fPedSigmaLimits[0] = 0.6;
599         fPedSigmaLimits[1] = 100;
600
601         fGainA1Limits[0] = 0.1;
602         fGainA1Limits[1] = 10;
603
604         fGainA2Limits[0] = -1E30;
605         fGainA2Limits[1] = 1E30;
606         
607         fGainThresLimits[0] = 0;
608         fGainThresLimits[1] = 4095;
609         
610         fPadGoodnessMask = 0x8080; // Ped is missing | HV is missing
611
612   fManuOccupancyLimits[0] = -1.0; 
613   fManuOccupancyLimits[1] = 1.0;
614
615   fBuspatchOccupancyLimits[0] = 1E-6; 
616   fBuspatchOccupancyLimits[1] = 1.0;
617
618   fDEOccupancyLimits[0] = -1.0; 
619   fDEOccupancyLimits[1] = 1.0;
620
621   fMissingPadFractionLimit = -1; // DEPRECATED
622   fFractionOfBuspatchOutsideOccupancyLimit = 0.05; // 5 % 
623
624   ChargeSigmaCut(4.0); // pad with charge < 4.0 x sigma will be removed (where sigma is the actual noise of that very pad, i.e. not the average)
625   
626   AverageNoisePadCharge(0.22875); // 0.22875 coulombs ~ 1.5 ADC channels
627
628   ClusterChargeCut(2.0); // will cut cluster below 2.0 x LowestPadCharge()
629   
630   SetEventSizeLimits(35.0,45.0);
631   
632   SetTokenLostLimit(0.0);
633   
634   fTryRecover = kFALSE;
635 }
636
637
638 //-----------------------------------------------------------------------
639 TObjArray* 
640 AliMUONRecoParam::Create(const char* settings)
641 {
642   /// Create pre-defined recoparam array, according to settings.
643   /// settings is case-insensitive.
644   ///
645   /// Currently defined are :
646   ///
647   /// "cosmics" :
648   ///      Cosmic (default)
649   ///      Calibration
650   /// "ppideal"
651   ///      LowFlux (default)
652   ///      Calibration
653   /// "ppreal"
654   ///      LowFlux (modified to reconstruct real p-p data)
655   ///      Calibration
656   /// "pprealsim"
657   ///      LowFlux (modified to reconstruct realistic p-p simulation)
658   ///      Calibration
659   /// "pbpbreal"
660   ///      HighFlux (modified to reconstruct real Pb-Pb data)
661   ///      Calibration
662   
663   AliMUONRecoParam* param(0x0);
664   
665   AliRecoParam::EventSpecie_t defaultParam = AliRecoParam::kLowMult;
666   
667   TString stype(settings);
668   stype.ToLower();
669   
670   if ( stype == "cosmics" )
671   {
672     // set parameters for cosmic runs
673     param = AliMUONRecoParam::GetCosmicParam();
674     defaultParam = AliRecoParam::kCosmic;
675   }
676   else if ( stype == "ppideal" ) 
677   {
678     // set default lowFlux parameters
679     param = AliMUONRecoParam::GetLowFluxParam();
680   }
681   else if ( stype == "ppreal" || stype == "pprealsim" || stype == "pprealnofield" ) 
682   {      
683     // common parameters for p-p data and realistic p-p simu
684     param = AliMUONRecoParam::GetLowFluxParam();
685     param->SaveFullClusterInESD(kTRUE, 100.);
686     for (Int_t iCh=0; iCh<10; iCh++) 
687     {
688       param->SetDefaultNonBendingReso(iCh,0.4);
689       param->SetDefaultBendingReso(iCh,0.4);
690     }
691     param->SetSigmaCutForTracking(7.);
692     param->SetStripCutForTrigger(1.5);
693     param->SetSigmaCutForTrigger(6.);
694     param->ImproveTracks(kTRUE, 6.);
695     param->SetPedMeanLimits(20, 700);
696     param->SetManuOccupancyLimits(-1.,0.015);
697     param->SetBuspatchOccupancyLimits(-1.,0.05);  
698     param->SetFractionOfBuspatchOutsideOccupancyLimit(0.05); // 5 %
699     param->SetEventSizeLimits(45., 65.);
700     param->SetHVLimit(0,1550);
701     param->SetHVLimit(1,1550);
702     param->SetHVLimit(2,1550);
703     param->SetHVLimit(3,1550);
704     
705     // specific parameters for p-p data or realistic p-p simu
706     if ( stype == "ppreal" || stype == "pprealnofield" )
707     {
708       param->SetPadGoodnessMask(0x400BE9B);
709     }
710     else
711     {
712       param->SetPadGoodnessMask(0x8080);      
713     }
714     
715     if ( stype == "pprealnofield" )
716     {
717       param->TryRecover(kTRUE);
718     }
719   }
720   else if ( stype == "pbpbreal" || stype == "pbpbrealsim" ) 
721   {      
722     // common parameters for Pb-Pb data and realistic Pb-Pb simu
723     param = AliMUONRecoParam::GetHighFluxParam();
724     defaultParam = AliRecoParam::kHighMult;
725     param->SaveFullClusterInESD(kTRUE, 100.);
726     for (Int_t iCh=0; iCh<10; iCh++) 
727     {
728       param->SetDefaultNonBendingReso(iCh,0.2);
729       param->SetDefaultBendingReso(iCh,0.2);
730     }
731     param->SetSigmaCutForTracking(5.);
732     param->SetStripCutForTrigger(1.5);
733     param->SetSigmaCutForTrigger(4.);
734     param->ImproveTracks(kTRUE, 4.);
735     param->SetPedMeanLimits(20, 700);
736     param->SetManuOccupancyLimits(-1.,0.03);
737     param->SetBuspatchOccupancyLimits(-1.,0.1); // 10 % (this cut not used for the reco anyway)
738     param->SetFractionOfBuspatchOutsideOccupancyLimit(0.05); // 5 %
739     param->SetEventSizeLimits(100., 150.);
740     
741     // specific parameters for Pb-Pb data or realistic Pb-Pb simu
742     if ( stype == "pbpbreal" )
743     {
744       param->SetPadGoodnessMask(0x400BE9B);
745     }
746     else
747     {
748       param->SetPadGoodnessMask(0x8080);      
749     }
750   }
751   else
752   {
753     AliErrorClass("Unknown settings !");
754     return 0x0;
755   }
756
757   TObjArray* recoParams = new TObjArray;
758
759   recoParams->AddLast(param);
760   
761   // set (dummy) parameters for calibration runs
762   param = AliMUONRecoParam::GetCalibrationParam();
763   recoParams->AddLast(param);
764   
765   // set parameters for Pb-Pb runs
766   // param = AliMUONRecoParam::GetHighFluxParam();
767   // recoParams.AddLast(param);
768   
769   // identify default parameters (exit if identification failed)
770   Bool_t defaultIsSet = kFALSE;
771   TIter next(recoParams);
772   while ( (param = static_cast<AliMUONRecoParam*>(next())) ) 
773   {
774     if (param->GetEventSpecie() == defaultParam) 
775     {
776       param->SetAsDefault();
777       defaultIsSet = kTRUE;
778     }
779     param->Print("FULL");
780   }
781   
782   if (!defaultIsSet) 
783   {
784     AliErrorClass("The default reconstruction parameters are not set! Exiting...");
785     return 0x0;
786   }  
787   
788   return recoParams;
789 }
790
791 //______________________________________________________________________________
792 void 
793 AliMUONRecoParam::Show(Int_t runNumber, const char* ocdb)
794 {
795   /// Show what we have in the designated OCDB for that run, as far as RecoParams are concerned
796   
797   AliCDBManager::Instance()->SetDefaultStorage(ocdb);
798   AliCDBManager::Instance()->SetRun(runNumber);
799   
800   AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam");
801   
802   if (!entry) return;
803   
804   TObject* o = entry->GetObject();
805   
806   if ( o->IsA() == TObjArray::Class() ) 
807   {
808     TObjArray* array = static_cast<TObjArray*>(o);
809     for ( Int_t i = 0; i <= array->GetLast(); ++i ) 
810     {
811       AliDetectorRecoParam* p = static_cast<AliDetectorRecoParam*>(array->At(i));
812       cout << Form("array[%d]=%s %s %s",i,
813                    p ? p->ClassName() : "",
814                    p ? AliRecoParam::GetEventSpecieName(AliRecoParam::Convert(p->GetEventSpecie())) :"",
815                    p ? ( p->IsDefault() ? "default" : "") : "" ) << endl;
816     }
817     cout << "=========== dumps below ====== " << endl;
818     
819     for ( Int_t i = 0; i <= array->GetLast(); ++i ) 
820     {
821       AliDetectorRecoParam* p = static_cast<AliDetectorRecoParam*>(array->At(i));
822       if ( p ) p->Print("");
823     }
824   }
825   else
826   {
827     o->Print();
828   }
829 }