]>
Commit | Line | Data |
---|---|---|
92d9f317 | 1 | /************************************************************************** |
2 | * This file is property of and copyright by * | |
3 | * the Relativistic Heavy Ion Group (RHIG), Yale University, US, 2009 * | |
4 | * * | |
5 | * Primary Author: Per Thomas Hille <p.t.hille@fys.uio.no> * | |
6 | * * | |
7 | * Contributors are mentioned in the code where appropriate. * | |
8 | * Please report bugs to p.t.hille@fys.uio.no * | |
9 | * * | |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
18 | ||
19 | // Extraction of amplitude and peak position | |
20 | // FRom CALO raw data using | |
21 | // least square fit for the | |
22 | // Moment assuming identical and | |
23 | // independent errors (equivalent with chi square) | |
24 | // | |
25 | ||
26 | #include "AliCaloRawAnalyzerLMSOffline.h" | |
27 | #include "AliCaloBunchInfo.h" | |
28 | #include "AliCaloFitResults.h" | |
29 | #include "AliLog.h" | |
30 | #include "TMath.h" | |
31 | #include <stdexcept> | |
32 | #include <iostream> | |
33 | #include "TF1.h" | |
34 | #include "TGraph.h" | |
35 | #include "AliEMCALRawUtils.h" | |
36 | #include <TRandom.h> | |
37 | ||
38 | //#include "AliCaloRawAnalyzerLMS.h" | |
39 | ||
40 | #include "AliCaloRawAnalyzerFactory.h" | |
41 | ||
42 | using namespace std; | |
43 | ||
44 | ||
45 | //#define BAD 4 //CRAP PTH | |
46 | ||
47 | ClassImp( AliCaloRawAnalyzerLMSOffline ) | |
48 | ||
49 | ||
50 | AliCaloRawAnalyzerLMSOffline::AliCaloRawAnalyzerLMSOffline() : AliCaloRawAnalyzer("Chi Square Fit OFFLINE", "LMSOffline"), | |
51 | fNoiseThreshold(0), | |
52 | fRawAnalyzer(0), fSmearFactor() | |
53 | { | |
54 | fRawAnalyzer = AliCaloRawAnalyzerFactory::CreateAnalyzer(kLMS); | |
55 | fAlgo = Algo::kLMSOffline; | |
56 | } | |
57 | ||
58 | ||
59 | AliCaloRawAnalyzerLMSOffline::~AliCaloRawAnalyzerLMSOffline() | |
60 | { | |
61 | // delete fTf1; | |
62 | } | |
63 | ||
64 | ||
65 | AliCaloFitResults | |
66 | AliCaloRawAnalyzerLMSOffline::Evaluate( const vector<AliCaloBunchInfo> &bunchlist, const UInt_t altrocfg1, const UInt_t altrocfg2 ) | |
67 | { | |
68 | // fRawAnalyzer setup | |
69 | fRawAnalyzer->SetNsampleCut(5); // requirement for fits to be done, for the new methods | |
70 | fRawAnalyzer->SetOverflowCut(OVERFLOWCUT); | |
71 | fRawAnalyzer->SetAmpCut(fNoiseThreshold); | |
72 | fRawAnalyzer->SetFitArrayCut(fNoiseThreshold); | |
73 | ||
74 | // fRawAnalyzer->SetIsZeroSuppressed(true); // TMP - should use stream->IsZeroSuppressed(), or altro cfg registers later | |
75 | ||
76 | fRawAnalyzer->SetIsZeroSuppressed(fIsZerosupressed); // TMP - should use stream->IsZeroSuppressed(), or altro cfg registers later | |
77 | ||
78 | ||
79 | AliCaloFitResults fitResults; | |
80 | Float_t time = 0; | |
81 | Float_t amp = 0; | |
82 | short timeEstimate = 0; | |
83 | Float_t ampEstimate = 0; | |
84 | Bool_t fitDone = kFALSE; | |
85 | fitResults = fRawAnalyzer->Evaluate( bunchlist, altrocfg1, altrocfg2 ); | |
86 | amp = fitResults.GetAmp(); | |
87 | time = fitResults.GetTime(); | |
88 | timeEstimate = fitResults.GetMaxTimebin(); | |
89 | ampEstimate = fitResults.GetMaxSig(); | |
90 | ||
91 | if (fitResults.GetStatus() == Ret::kFitPar) | |
92 | { | |
93 | fitDone = kTRUE; | |
94 | } | |
95 | ||
96 | if ( fitDone ) | |
97 | { // brief sanity check of fit results | |
98 | Float_t ampAsymm = (amp - ampEstimate)/(amp + ampEstimate); | |
99 | Float_t timeDiff = time - timeEstimate; | |
100 | ||
101 | if ( (TMath::Abs(ampAsymm) > 0.1) || (TMath::Abs(timeDiff) > 2) ) | |
102 | { | |
103 | amp = ampEstimate; | |
104 | time = timeEstimate; | |
105 | fitDone = kFALSE; | |
106 | } | |
107 | } // fitDone | |
108 | ||
109 | if (amp >= fNoiseThreshold) | |
110 | { // something to be stored | |
111 | if ( ! fitDone) | |
112 | { // smear ADC with +- 0.5 uniform (avoid discrete effects) | |
113 | fSmearFactor = (0.5 - gRandom->Rndm() ); | |
114 | amp += fSmearFactor; // Rndm generates a number in ]0,1] | |
115 | } | |
116 | // go from time-bin units to physical time fgtimetrigger | |
117 | time = time *TIMEBINWITH; // skip subtraction of fgTimeTrigger? | |
118 | // subtract RCU L1 phase (L1Phase is in seconds) w.r.t. L0: | |
119 | // time -= in.GetL1Phase(); | |
120 | time -= fL1Phase; | |
121 | time = time/ TIMEBINWITH; | |
122 | } | |
123 | fitResults.SetTime(time); | |
124 | fitResults.SetAmp(amp); | |
125 | return fitResults ; | |
126 | } | |
127 |