compilation warnings fixed
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDPreprocessor.cxx
CommitLineData
56d2de52 1#include "AliHMPIDPreprocessor.h" //header no includes
2#include "AliHMPIDDigit.h" //ProcPed()
3#include <Riostream.h> //ProcPed()
ad712d2e 4#include <AliLog.h> //all
56d2de52 5#include <AliCDBMetaData.h> //ProcPed(), ProcDcs()
6#include <AliDCSValue.h> //ProcDcs()
7#include <TObjString.h> //ProcDcs(), ProcPed()
ad712d2e 8#include <TTimeStamp.h> //Initialize()
56d2de52 9#include <TF1.h> //Process()
10#include <TF2.h> //Process()
11#include <TGraph.h> //Process()
12#include <TMatrix.h> //ProcPed()
13#include <TList.h> //ProcPed()
14#include <TSystem.h> //ProcPed()
423554a3 15//.
16// HMPID Preprocessor base class
17//.
18//.
19//.
d3da6dc4 20ClassImp(AliHMPIDPreprocessor)
21
22//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23void AliHMPIDPreprocessor::Initialize(Int_t run, UInt_t startTime,UInt_t endTime)
24{
25 AliPreprocessor::Initialize(run, startTime, endTime);
ad712d2e 26
27 AliInfo(Form("HMPID started for Run %d \n\tStartTime %s \n\t EndTime %s", run,TTimeStamp(startTime).AsString(),TTimeStamp(endTime).AsString()));
28
d3da6dc4 29}
30//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
abb5f786 31UInt_t AliHMPIDPreprocessor::Process(TMap* pMap)
d3da6dc4 32{
56d2de52 33// Process all information from DCS and DAQ
34// Arguments: pMap- map of DCS aliases
ad712d2e 35// Returns: 0 on success or 1 on error (opposite to Store!)
36
37 Log("HMPID - Process in Preprocessor started");
38 if(! pMap) {Log(" - Not map of DCS aliases for HMPID - ");return 1;}
9cc1a411 39
40 TString runType = GetRunType();
ad712d2e 41 Log(Form(" AliHMPIDPreprocessor: RunType is %s",runType.Data()));
9cc1a411 42 Bool_t result1,result2;
43 if (runType == "PEDESTAL_RUN"){
ad712d2e 44 result1 = ProcPed(); return !result1;
9cc1a411 45 } else if ( runType == "PHYSICS" ){
46 result1 = ProcPed();
ad712d2e 47 result2 = ProcDcs(pMap); return !(result1&&result2);
9cc1a411 48 } else {
ad712d2e 49 Log("HMPID - Nothing to do with preprocessor for HMPID, bye!");
9cc1a411 50 return kFALSE;
51 }
52
56d2de52 53}//Process()
54//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
55Bool_t AliHMPIDPreprocessor::ProcDcs(TMap* pMap)
56{
abb5f786 57// Process: 1. inlet and outlet C6F14 temperature, stores TObjArray of 21 TF1, where TF1 is Nmean=f(t), one per radiator
58// 2. CH4 pressure and HV stores TObjArray of 7 TF1 where TF1 is thr=f(t), one per chamber
59// Arguments: pDcsMap - map of structure "alias name" - TObjArray of AliDCSValue
60// Assume that: HV is the same during the run for a given chamber, different chambers might have different HV
a0e5c1b9 61// P=f(t), different for different chambers
56d2de52 62// Returns: kTRUE on success
d3da6dc4 63
ad712d2e 64 Bool_t stDcsStore=kFALSE;
65
abb5f786 66 TF2 idx("RidxC4F14","sqrt(1+0.554*(1239.84/x)^2/((1239.84/x)^2-5796)-0.0005*(y-20))",5.5 ,8.5 ,0 ,50); //N=f(Ephot,T) [eV,grad C] DiMauro mail
d3da6dc4 67
56d2de52 68// Qthr=f(HV,P) [V,mBar] logA0=k*HV+b is taken from p. 64 TDR plot 2.59 for PC32
69// A0=f(P) is taken from DiMauro mail
70// Qthr is estimated as 3*A0
71 TF2 thr("RthrCH4" ,"3*10^(3.01e-3*x-4.72)+170745848*exp(-y*0.0162012)" ,2000,3000,900,1200);
72
9cc1a411 73 TObjArray arTmean(21); arTmean.SetOwner(kTRUE); //21 Tmean=f(time) one per radiator
74 TObjArray arPress(7); arPress.SetOwner(kTRUE); //7 Press=f(time) one pre chamber
75 TObjArray arNmean(21); arNmean.SetOwner(kTRUE); //21 Nmean=f(time) one per radiator
76 TObjArray arQthre(7); arQthre.SetOwner(kTRUE); //7 Qthre=f(time) one pre chamber
77 TObjArray arUserCut(7); arUserCut.SetOwner(kTRUE); //7 user cut in number of sigmas
d3da6dc4 78
56d2de52 79 AliDCSValue *pVal; Int_t cnt=0;
abb5f786 80
56d2de52 81 for(Int_t iCh=0;iCh<7;iCh++){
ad712d2e 82// evaluate High Voltage
56d2de52 83// TObjArray *pHV=(TObjArray*)pMap->GetValue(Form("HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC0/HMP_MP%i_SEC0_HV.actual.vMon",iCh,iCh,iCh,iCh)); //HV
ad712d2e 84// evaluate Pressure
56d2de52 85 TObjArray *pP =(TObjArray*)pMap->GetValue(Form("HMP_DET/HMP_MP%i/HMP_MP%i_GAS/HMP_MP%i_GAS_PMWC.actual.value" ,iCh,iCh,iCh)); TIter nextP(pP);
43724042 86 TGraph *pGrP=new TGraph; cnt=0;
87 while((pVal=(AliDCSValue*)nextP())) pGrP->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //P
88 if( cnt!=0) pGrP->Fit(new TF1(Form("P%i",iCh),"1005+x*[0]",fStartTime,fEndTime),"Q"); //clm: if no DCS map entry don't fit
89 delete pGrP;
ad712d2e 90// evaluate Qthre
9cc1a411 91 arQthre.AddAt(new TF1(Form("HMP_Qthre%i",iCh),"100",fStartTime,fEndTime),iCh);
ad712d2e 92// evaluate UserCut
d15caf65 93 Int_t nSigmaUserCut = 3;
94 TObject *pUserCut = new TObject();pUserCut->SetUniqueID(nSigmaUserCut);
9cc1a411 95 arUserCut.AddAt(pUserCut,iCh);
ad712d2e 96// evaluate Temperatures
d3da6dc4 97 for(Int_t iRad=0;iRad<3;iRad++){
56d2de52 98 TObjArray *pT1=(TObjArray*)pMap->GetValue(Form("HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iIn_Temp",iCh,iCh,iRad)); TIter nextT1(pT1);//Tin
99 TObjArray *pT2=(TObjArray*)pMap->GetValue(Form("HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iOut_Temp",iCh,iCh,iRad)); TIter nextT2(pT2);//Tout
43724042 100
56d2de52 101 TGraph *pGrT1=new TGraph; cnt=0; while((pVal=(AliDCSValue*)nextT1())) pGrT1->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //T inlet
43724042 102 if(cnt!=0) pGrT1->Fit(new TF1(Form("Tin%i%i",iCh,iRad),"[0]+[1]*x+[2]*sin([3]*x)",fStartTime,fEndTime),"Q"); //fit Tin graph -- clm: if DCS entry
103
56d2de52 104 TGraph *pGrT2=new TGraph; cnt=0; while((pVal=(AliDCSValue*)nextT2())) pGrT2->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //T outlet
43724042 105 if(cnt!=0) pGrT2->Fit(new TF1(Form("Tou%i%i",iCh,iRad),"[0]+[1]*x+[2]*sin([3]*x)",fStartTime,fEndTime),"Q"); //fit Tout graph -- clm: if DCS entry
56d2de52 106
43724042 107 delete pGrT1; delete pGrT2;
108
109
abb5f786 110// arTmean.Add(pRadTempF);
ad712d2e 111// evaluate Mean Refractive Index
56d2de52 112 arNmean.AddAt(new TF1(Form("HMP_Nmean%i-%i",iCh,iRad),"1.292",fStartTime,fEndTime),3*iCh+iRad); //Nmean=f(t)
d3da6dc4 113 }//radiators loop
114 }//chambers loop
115
ad712d2e 116 AliCDBMetaData metaData;
117 metaData.SetBeamPeriod(0);
118 metaData.SetResponsible("AliHMPIDPreprocessor");
119 metaData.SetComment("SIMULATED");
120
76fd1a96 121 stDcsStore = Store("Calib","Qthre",&arQthre,&metaData,0,kTRUE) && // from DCS
122 Store("Calib","Nmean",&arNmean,&metaData,0,kTRUE) && // from DCS
123 Store("Calib","UserCut",&arUserCut,&metaData,0,kTRUE); //really not from DCS...a method ProcManual maybe needed
ad712d2e 124 if(!stDcsStore) {
125 Log("HMPID - failure to store DCS data results in OCDB");
126 }
127 return stDcsStore;
d3da6dc4 128}//Process()
129//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
56d2de52 130Bool_t AliHMPIDPreprocessor::ProcPed()
131{
132// Process pedestal files and create 7 M(padx,pady)=sigma, one for each chamber
133// Arguments:
ad712d2e 134// Returns: kTRUE on success
135
136 Bool_t stPedStore=kFALSE;
137
56d2de52 138 TObjArray aDaqSig(7); aDaqSig.SetOwner(kTRUE); for(Int_t i=0;i<7;i++) aDaqSig.AddAt(new TMatrix(160,144),i); //TObjArray of 7 TMatrixF, m(padx,pady)=sigma
fefe77d6 139
56d2de52 140 TList *pLdc=GetFileSources(kDAQ,"pedestals"); //get list of LDC names containing id "pedestals"
ad712d2e 141 Log(Form("HMPID - Pedestal files to be read --> %i LDCs for HMPID",pLdc->GetEntries()));
142
56d2de52 143 for(Int_t i=0;i<pLdc->GetEntries();i++)//lists of LDCs
402c5589 144 gSystem->Exec(Form("tar xf %s",GetFile(kDAQ,"pedestals",((TObjString*)pLdc->At(i))->GetName()))); //untar pedestal files from current LDC
ad712d2e 145
56d2de52 146 AliHMPIDDigit dig;
147 Int_t nSigCut,r,d,a,hard; Float_t mean,sigma;
ad712d2e 148
56d2de52 149 for(Int_t ddl=0;ddl<14;ddl++){
150 ifstream infile(Form("HmpidPedDdl%02i.txt",ddl));
ad712d2e 151 if(!infile.is_open()) {Log("No pedestal file found for HMPID,bye!");return kFALSE;}
56d2de52 152 TMatrix *pM=(TMatrixF*)aDaqSig.At(ddl/2);
153 infile>>nSigCut; pM->SetUniqueID(nSigCut); //n. of pedestal distribution sigmas used to create zero suppresion table
154 while(!infile.eof()){
155 infile>>dec>>r>>d>>a>>mean>>sigma>>hex>>hard;
156 dig.Raw(ddl,r,d,a);
ab5ca5d6 157 (*pM)(dig.PadChX(),dig.PadChY()) = sigma;
56d2de52 158 }
159 infile.close();
ad712d2e 160 Log(Form("Pedestal file for DDL %i read successfully",ddl));
56d2de52 161 }
ad712d2e 162
163 AliCDBMetaData metaData;
164 metaData.SetBeamPeriod(0);
165 metaData.SetResponsible("AliHMPIDPreprocessor");
166 metaData.SetComment("SIMULATED");
167
168 stPedStore = Store("Calib","DaqSig",&aDaqSig,&metaData,0,kTRUE);
169
170 if(!stPedStore) {
171 Log("HMPID - failure to store PEDESTAL data results in OCDB");
172 }
173 return stPedStore;
174
56d2de52 175}//ProcPed()
176//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
177Double_t ProcTrans()
178{
179// Process transparency monitoring data and calculates Emean
180 Double_t eMean=6.67786; //mean energy of photon defined by transperancy window
181 return eMean;
182}
183//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
184