upgraded calibration
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDPreprocessor.cxx
CommitLineData
d3da6dc4 1#include "AliHMPIDPreprocessor.h" //header
2
a0e5c1b9 3#include <Riostream.h>
d3da6dc4 4#include <AliCDBMetaData.h>
5#include <AliDCSValue.h>
a0e5c1b9 6#include <TObjString.h> //Process()
d3da6dc4 7#include <TF1.h> //Process()
8#include <TF2.h> //Process()
9#include <TGraph.h> //Process()
a0e5c1b9 10#include <TMatrixF.h> //Process()
abb5f786 11#include <AliLog.h> //Process()
d3da6dc4 12
423554a3 13//.
14// HMPID Preprocessor base class
15//.
16//.
17//.
d3da6dc4 18ClassImp(AliHMPIDPreprocessor)
19
423554a3 20char *AliHMPIDPreprocessor::fgP ="HMP_DET/HMP_MP%i/HMP_MP%i_GAS/HMP_MP%i_GAS_PMWC.actual.value";
21char *AliHMPIDPreprocessor::fgT1="HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iIn_Temp";
22char *AliHMPIDPreprocessor::fgT2="HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iOut_Temp";
23char *AliHMPIDPreprocessor::fgHV="HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC0/HMP_MP%i_SEC0_HV.actual.vMon";
abb5f786 24
d3da6dc4 25//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
26void AliHMPIDPreprocessor::Initialize(Int_t run, UInt_t startTime,UInt_t endTime)
27{
28 AliPreprocessor::Initialize(run, startTime, endTime);
29}
30//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
abb5f786 31UInt_t AliHMPIDPreprocessor::Process(TMap* pMap)
d3da6dc4 32{
abb5f786 33// Process: 1. inlet and outlet C6F14 temperature, stores TObjArray of 21 TF1, where TF1 is Nmean=f(t), one per radiator
34// 2. CH4 pressure and HV stores TObjArray of 7 TF1 where TF1 is thr=f(t), one per chamber
35// Arguments: pDcsMap - map of structure "alias name" - TObjArray of AliDCSValue
36// Assume that: HV is the same during the run for a given chamber, different chambers might have different HV
a0e5c1b9 37// P=f(t), different for different chambers
38 TObjArray arDaqSig(14); arDaqSig.SetOwner(kTRUE);
39 for(Int_t iddl=0;iddl<14;iddl++){
40 arDaqSig.AddAt(new TObjArray(24),iddl);
41 for(Int_t row=1;row<=24;row++){
42 ((TObjArray*)arDaqSig.At(iddl))->Add(new TMatrixF(1,10,0,47));
43 }
44 }
45 TObjArray arSigCut(14); arSigCut.SetOwner(kTRUE); //14 n. of sigmas for zero suppression
46 Int_t ddl,r,d,a,hard;
47 Float_t mean,sigma;
48 Int_t sigmaCut;
49 for(Int_t iddl=0;iddl<14;iddl++){
50 TObject *sigCut= new TObject;
51 const char *name=GetFile(kDAQ,"pedestals",Form("DDL%i",iddl)); //first analyse a set of pedestal files
52 ifstream infile(name);
53 //
54 infile>>sigmaCut;
55 sigCut->SetUniqueID(sigmaCut);arSigCut.AddAt(sigCut,iddl);
56 TObjArray *pTmp = (TObjArray*)arDaqSig.At(iddl);
57 TMatrixF *pM;
58 while(!infile.eof()){
59 infile>>dec>>ddl>>r>>d>>a>>mean>>sigma>>hex>>hard;
60 pM = (TMatrixF*)pTmp->At(r-1);
61 (*pM)(d,a) = sigma;
62 }
63 //
64 infile.close();
65 Printf("file %s read successfully",name);
66 }
fefe77d6 67
abb5f786 68 if(!pMap) return 0; //no DCS map provided
69 Double_t sor=0,eor=1500;
d3da6dc4 70
abb5f786 71 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
72 TF2 thr("RthrCH4" ,"x+170745848*exp(-y*0.0162012)" ,2000,3000,900,1200); //thr=f(HV,P) [V,mBar]
73// Double_t eMean=6.67786; //mean energy of photon defined by transperancy window
d3da6dc4 74
abb5f786 75// TObjArray arTmean(21); arTmean.SetOwner(kTRUE); //21 Tmean=f(time) one per radiator
76// TObjArray arPress(7); arPress.SetOwner(kTRUE); //7 Press=f(time) one pre chamber
a0e5c1b9 77 TObjArray arNmean(21); arNmean.SetOwner (kTRUE); //21 Nmean=f(time) one per radiator
78 TObjArray arQthre(7); arQthre.SetOwner (kTRUE); //7 Qthre=f(time) one pre chamber
d3da6dc4 79
abb5f786 80// AliDCSValue *pVal; Int_t cnt=0;
81
82 for(Int_t iCh=0;iCh<7;iCh++){
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
84// pVal=(AliDCSValue*)pHV->At(0); Float_t hv=pVal->GetFloat();//HV
85
86// TObjArray *pP =(TObjArray*)pMap->GetValue(Form(fP,iCh,iCh,iCh)); //P
87// TGraph *pGrP; cnt=0;TIter nextp(pP); while((pVal=(AliDCSValue*)nextp())) pGrP->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //P
88
89// TF1 *pFuP=new TF1(Form("P%i",iCh),"1005",sor,eor);
90// pGrP->Fit(pFuP,"Q"); delete pGrP;
91 TF1 *pFuQ=new TF1(Form("HMP_Qthre%i",iCh),"100",sor,eor);
92 arQthre.AddAt(pFuQ,iCh);
d3da6dc4 93 for(Int_t iRad=0;iRad<3;iRad++){
abb5f786 94// TObjArray *pT1=(TObjArray*)pMap->GetValue(Form(fT1,iCh,iCh,iRad)); //Tin
95// TGraph *pGrT1=new TGraph; cnt=0; TIter next1(pT1); while((pVal=(AliDCSValue*)next1())) pGrT1->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //inlet temperature
96// pGrT1->Fit(new TF1(Form("Tin%i%i",iCh,iRad),"[0]+[1]*x+[2]*sin([3]*x)",sor,eor),"Q"); //now fit the temp graph
97
98// TObjArray *pT2=(TObjArray*)pMap->GetValue(Form(fT2,iCh,iCh,iRad));//Tout
99// TGraph *pGrT2=new TGraph; cnt=0; TIter next2(pT2); while((pVal=(AliDCSValue*)next2())) pGrT2->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //outlet temperature
100// TF1*pFuT1=new TF1(Form("Tout%i%i",iCh,iRad),"13",sor,eor)
101// pGrT2->Fit(,"Q"); //now fit the temp graph
102
103// arTmean.Add(pRadTempF);
104 TF1 *pFuN=new TF1(Form("HMP_Nmean%i-%i",iCh,iRad),"1.292",sor,eor); pFuN->SetLineColor(iRad+2); pFuN->SetLineWidth(1);
105 arNmean.AddAt(pFuN,3*iCh+iRad);
106// delete pGrT1; delete pGrT2;
d3da6dc4 107 }//radiators loop
108 }//chambers loop
109
110 AliCDBMetaData metaData; metaData.SetBeamPeriod(0); metaData.SetResponsible("AliHMPIDPreprocessor"); metaData.SetComment("SIMULATED");
d3da6dc4 111
a0e5c1b9 112// arQthre.Print();
abb5f786 113// Store("Calib", "Press" , &arPress , &metaData);
a0e5c1b9 114// Store("Calib", "Tmean" , &arTmean , &metaData);
115
116 if(Store("Calib","Qthre" ,&arQthre , &metaData,0,kTRUE) == kTRUE &&
117 Store("Calib","Nmean" ,&arNmean , &metaData,0,kTRUE) == kTRUE &&
118 Store("Calib","DaqSigCut",&arSigCut, &metaData,0,kTRUE) == kTRUE &&
119 Store("Calib","DaqSig" ,&arDaqSig, &metaData,0,kTRUE) == kTRUE ) return 0; //all OK
120 else
121 return 1;
fefe77d6 122
123 // AliInfo("End.");
d3da6dc4 124
125}//Process()
126//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fefe77d6 127