Remove -lTable from Makefile
[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()
4#include <AliCDBMetaData.h> //ProcPed(), ProcDcs()
5#include <AliDCSValue.h> //ProcDcs()
6#include <TObjString.h> //ProcDcs(), ProcPed()
7#include <TF1.h> //Process()
8#include <TF2.h> //Process()
9#include <TGraph.h> //Process()
10#include <TMatrix.h> //ProcPed()
11#include <TList.h> //ProcPed()
12#include <TSystem.h> //ProcPed()
423554a3 13//.
14// HMPID Preprocessor base class
15//.
16//.
17//.
d3da6dc4 18ClassImp(AliHMPIDPreprocessor)
19
20//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21void AliHMPIDPreprocessor::Initialize(Int_t run, UInt_t startTime,UInt_t endTime)
22{
23 AliPreprocessor::Initialize(run, startTime, endTime);
24}
25//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
abb5f786 26UInt_t AliHMPIDPreprocessor::Process(TMap* pMap)
d3da6dc4 27{
56d2de52 28// Process all information from DCS and DAQ
29// Arguments: pMap- map of DCS aliases
9cc1a411 30// Returns: 0 on success or 1 on error
31 Printf("HMPID - Process in Preprocessor started");
32 if(! pMap) {Printf(" - Not map of DCS aliases for HMPID - ");return 1;}
33
34 TString runType = GetRunType();
35 Printf(" AliHMPIDPreprocessor: RunType is %s",runType.Data());
36 Bool_t result1,result2;
37 if (runType == "PEDESTAL_RUN"){
38 result1 = ProcPed(); return result1;
39 } else if ( runType == "PHYSICS" ){
40 result1 = ProcPed();
41 result2 = ProcDcs(pMap); return (result1&&result2);
42 } else {
43 Log("Nothing to do with preprocessor for HMPID, bye!");
44 return kFALSE;
45 }
46
56d2de52 47}//Process()
48//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
49Bool_t AliHMPIDPreprocessor::ProcDcs(TMap* pMap)
50{
abb5f786 51// Process: 1. inlet and outlet C6F14 temperature, stores TObjArray of 21 TF1, where TF1 is Nmean=f(t), one per radiator
52// 2. CH4 pressure and HV stores TObjArray of 7 TF1 where TF1 is thr=f(t), one per chamber
53// Arguments: pDcsMap - map of structure "alias name" - TObjArray of AliDCSValue
54// Assume that: HV is the same during the run for a given chamber, different chambers might have different HV
a0e5c1b9 55// P=f(t), different for different chambers
56d2de52 56// Returns: kTRUE on success
d3da6dc4 57
abb5f786 58 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 59
56d2de52 60// Qthr=f(HV,P) [V,mBar] logA0=k*HV+b is taken from p. 64 TDR plot 2.59 for PC32
61// A0=f(P) is taken from DiMauro mail
62// Qthr is estimated as 3*A0
63 TF2 thr("RthrCH4" ,"3*10^(3.01e-3*x-4.72)+170745848*exp(-y*0.0162012)" ,2000,3000,900,1200);
64
9cc1a411 65 TObjArray arTmean(21); arTmean.SetOwner(kTRUE); //21 Tmean=f(time) one per radiator
66 TObjArray arPress(7); arPress.SetOwner(kTRUE); //7 Press=f(time) one pre chamber
67 TObjArray arNmean(21); arNmean.SetOwner(kTRUE); //21 Nmean=f(time) one per radiator
68 TObjArray arQthre(7); arQthre.SetOwner(kTRUE); //7 Qthre=f(time) one pre chamber
69 TObjArray arUserCut(7); arUserCut.SetOwner(kTRUE); //7 user cut in number of sigmas
d3da6dc4 70
56d2de52 71 AliDCSValue *pVal; Int_t cnt=0;
abb5f786 72
56d2de52 73 for(Int_t iCh=0;iCh<7;iCh++){
74// 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
75 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 76 TGraph *pGrP=new TGraph; cnt=0;
77 while((pVal=(AliDCSValue*)nextP())) pGrP->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //P
78 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
79 delete pGrP;
80
9cc1a411 81 arQthre.AddAt(new TF1(Form("HMP_Qthre%i",iCh),"100",fStartTime,fEndTime),iCh);
82 TObject *pUserCut = new TObject();pUserCut->SetUniqueID(1);
83 arUserCut.AddAt(pUserCut,iCh);
56d2de52 84
d3da6dc4 85 for(Int_t iRad=0;iRad<3;iRad++){
56d2de52 86 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
87 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 88
56d2de52 89 TGraph *pGrT1=new TGraph; cnt=0; while((pVal=(AliDCSValue*)nextT1())) pGrT1->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //T inlet
43724042 90 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
91
56d2de52 92 TGraph *pGrT2=new TGraph; cnt=0; while((pVal=(AliDCSValue*)nextT2())) pGrT2->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //T outlet
43724042 93 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 94
43724042 95 delete pGrT1; delete pGrT2;
96
97
abb5f786 98// arTmean.Add(pRadTempF);
56d2de52 99 arNmean.AddAt(new TF1(Form("HMP_Nmean%i-%i",iCh,iRad),"1.292",fStartTime,fEndTime),3*iCh+iRad); //Nmean=f(t)
d3da6dc4 100 }//radiators loop
101 }//chambers loop
102
103 AliCDBMetaData metaData; metaData.SetBeamPeriod(0); metaData.SetResponsible("AliHMPIDPreprocessor"); metaData.SetComment("SIMULATED");
d3da6dc4 104
9cc1a411 105 if(Store("Calib","Qthre",&arQthre,&metaData,0,kTRUE) &&
106 Store("Calib","Nmean",&arNmean,&metaData,0,kTRUE) &&
107 Store("Calib","UserCut",&arUserCut,&metaData,0,kTRUE)) return kTRUE; //all OK
108 else return kFALSE;
d3da6dc4 109}//Process()
110//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
56d2de52 111Bool_t AliHMPIDPreprocessor::ProcPed()
112{
113// Process pedestal files and create 7 M(padx,pady)=sigma, one for each chamber
114// Arguments:
115// Returns:
116 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 117
56d2de52 118 TList *pLdc=GetFileSources(kDAQ,"pedestals"); //get list of LDC names containing id "pedestals"
4e2cd93b 119 Printf("HMPID - Pedestal files to be read --> %i LDCs for HMPID",pLdc->GetEntries());
56d2de52 120 for(Int_t i=0;i<pLdc->GetEntries();i++)//lists of LDCs
402c5589 121 gSystem->Exec(Form("tar xf %s",GetFile(kDAQ,"pedestals",((TObjString*)pLdc->At(i))->GetName()))); //untar pedestal files from current LDC
56d2de52 122 AliHMPIDDigit dig;
123 Int_t nSigCut,r,d,a,hard; Float_t mean,sigma;
124 for(Int_t ddl=0;ddl<14;ddl++){
125 ifstream infile(Form("HmpidPedDdl%02i.txt",ddl));
9cc1a411 126 if(!infile.is_open()) {Printf("No pedestal file found for HMPID,bye!");return kFALSE;}
56d2de52 127 TMatrix *pM=(TMatrixF*)aDaqSig.At(ddl/2);
128 infile>>nSigCut; pM->SetUniqueID(nSigCut); //n. of pedestal distribution sigmas used to create zero suppresion table
129 while(!infile.eof()){
130 infile>>dec>>r>>d>>a>>mean>>sigma>>hex>>hard;
131 dig.Raw(ddl,r,d,a);
ab5ca5d6 132 (*pM)(dig.PadChX(),dig.PadChY()) = sigma;
56d2de52 133 }
134 infile.close();
4e2cd93b 135 Printf("Pedestal file for DDL %i read successfully",ddl);
56d2de52 136 }
ab5ca5d6 137// gSystem->Exec("rm -rf HmpidPed*");
56d2de52 138 AliCDBMetaData metaData; metaData.SetBeamPeriod(0); metaData.SetResponsible("AliHMPIDPreprocessor"); metaData.SetComment("SIMULATED");
139 return Store("Calib","DaqSig",&aDaqSig,&metaData,0,kTRUE);
140}//ProcPed()
141//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
142Double_t ProcTrans()
143{
144// Process transparency monitoring data and calculates Emean
145 Double_t eMean=6.67786; //mean energy of photon defined by transperancy window
146 return eMean;
147}
148//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
149