]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HMPID/AliHMPIDPreprocessor.cxx
bug in Preprocessor fixed: PadPcX->PadChX
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDPreprocessor.cxx
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()
13 //.
14 // HMPID Preprocessor base class
15 //.
16 //.
17 //.
18 ClassImp(AliHMPIDPreprocessor)
19
20 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 void AliHMPIDPreprocessor::Initialize(Int_t run, UInt_t startTime,UInt_t endTime)
22 {
23   AliPreprocessor::Initialize(run, startTime, endTime);
24 }
25 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
26 UInt_t AliHMPIDPreprocessor::Process(TMap* pMap)
27 {
28 // Process all information from DCS and DAQ
29 // Arguments: pMap- map of DCS aliases
30 //   Returns: 0 on success or 1 on error    
31   if(! pMap)                     return 1; 
32   if(ProcDcs(pMap) && ProcPed()) return 0;
33   else                           return 1;     
34 }//Process()
35 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
36 Bool_t AliHMPIDPreprocessor::ProcDcs(TMap* pMap)
37 {
38 // Process: 1. inlet and outlet C6F14 temperature, stores TObjArray of 21 TF1, where TF1 is Nmean=f(t), one per radiator
39 //          2. CH4 pressure and HV                 stores TObjArray of 7 TF1 where TF1 is thr=f(t), one per chamber
40 // Arguments: pDcsMap - map of structure "alias name" - TObjArray of AliDCSValue
41 // Assume that: HV is the same during the run for a given chamber, different chambers might have different HV
42 //              P=f(t), different for different chambers
43 // Returns: kTRUE on success  
44
45   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
46   
47 // Qthr=f(HV,P) [V,mBar]  logA0=k*HV+b is taken from p. 64 TDR plot 2.59 for PC32 
48 //                           A0=f(P) is taken from DiMauro mail
49 // Qthr is estimated as 3*A0
50   TF2 thr("RthrCH4"  ,"3*10^(3.01e-3*x-4.72)+170745848*exp(-y*0.0162012)"             ,2000,3000,900,1200); 
51   
52   TObjArray arTmean(21); arTmean.SetOwner(kTRUE);     //21 Tmean=f(time) one per radiator
53   TObjArray arPress(7);  arPress.SetOwner(kTRUE);     //7  Press=f(time) one pre chamber
54   TObjArray arNmean(21); arNmean.SetOwner(kTRUE);     //21 Nmean=f(time) one per radiator
55   TObjArray arQthre(7);  arQthre.SetOwner(kTRUE);     //7  Qthre=f(time) one pre chamber
56   
57   AliDCSValue *pVal; Int_t cnt=0;
58     
59   for(Int_t iCh=0;iCh<7;iCh++){                   
60 //    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
61     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);
62     TGraph *pGrP=new TGraph; cnt=0; while((pVal=(AliDCSValue*)nextP())) pGrP->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat());            //P
63
64     pGrP->Fit(new TF1(Form("P%i",iCh),"1005",fStartTime,fEndTime),"Q"); delete pGrP;
65     arQthre.AddAt(new TF1(Form("HMP_Qthre%i",iCh),"100",fStartTime,fEndTime),iCh);    
66     
67     for(Int_t iRad=0;iRad<3;iRad++){
68       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
69       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      
70       TGraph *pGrT1=new TGraph; cnt=0;  while((pVal=(AliDCSValue*)nextT1())) pGrT1->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //T inlet
71       TGraph *pGrT2=new TGraph; cnt=0;  while((pVal=(AliDCSValue*)nextT2())) pGrT2->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //T outlet 
72       pGrT1->Fit(new TF1(Form("Tin%i%i",iCh,iRad),"[0]+[1]*x+[2]*sin([3]*x)",fStartTime,fEndTime),"Q");       //fit Tin graph 
73       pGrT2->Fit(new TF1(Form("Tou%i%i",iCh,iRad),"[0]+[1]*x+[2]*sin([3]*x)",fStartTime,fEndTime),"Q");       //fit Tout graph 
74
75       delete pGrT1;  delete pGrT2;
76             
77 //      arTmean.Add(pRadTempF);  
78       arNmean.AddAt(new TF1(Form("HMP_Nmean%i-%i",iCh,iRad),"1.292",fStartTime,fEndTime),3*iCh+iRad); //Nmean=f(t)
79     }//radiators loop
80   }//chambers loop
81   
82   AliCDBMetaData metaData; metaData.SetBeamPeriod(0); metaData.SetResponsible("AliHMPIDPreprocessor"); metaData.SetComment("SIMULATED");
83   
84 //  Store("Calib", "Press" , &arPress , &metaData)  Store("Calib", "Tmean" , &arTmean , &metaData);
85   
86   if(Store("Calib","Qthre",&arQthre,&metaData,0,kTRUE) && Store("Calib","Nmean",&arNmean,&metaData,0,kTRUE) ) return kTRUE; //all OK
87   else                                                                                                        return 1;
88 }//Process()
89 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
90 Bool_t AliHMPIDPreprocessor::ProcPed()
91 {
92 // Process pedestal files and create 7 M(padx,pady)=sigma, one for each chamber
93 // Arguments:
94 //   Returns:    
95   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
96   
97   TList *pLdc=GetFileSources(kDAQ,"pedestals"); //get list of LDC names containing id "pedestals"
98   for(Int_t i=0;i<pLdc->GetEntries();i++)//lists of LDCs
99     gSystem->Exec(Form("tar xzf %s",GetFile(kDAQ,"pedestals",((TObjString*)pLdc->At(i))->GetName()))); //untar pedestal files from current LDC
100   AliHMPIDDigit dig;
101   Int_t nSigCut,r,d,a,hard;  Float_t mean,sigma;
102   for(Int_t ddl=0;ddl<14;ddl++){  
103     ifstream infile(Form("HmpidPedDdl%02i.txt",ddl));
104     if(!infile.is_open()) return kFALSE;
105     TMatrix *pM=(TMatrixF*)aDaqSig.At(ddl/2);
106     infile>>nSigCut; pM->SetUniqueID(nSigCut); //n. of pedestal distribution sigmas used to create zero suppresion table
107     while(!infile.eof()){
108       infile>>dec>>r>>d>>a>>mean>>sigma>>hex>>hard;      
109       dig.Raw(ddl,r,d,a);
110       (*pM)(dig.PadChX(),dig.PadChY()) = sigma;
111     }
112     infile.close();
113   }
114 //  gSystem->Exec("rm -rf HmpidPed*");
115   AliCDBMetaData metaData; metaData.SetBeamPeriod(0); metaData.SetResponsible("AliHMPIDPreprocessor"); metaData.SetComment("SIMULATED");
116   return Store("Calib","DaqSig",&aDaqSig,&metaData,0,kTRUE);
117 }//ProcPed()  
118 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
119 Double_t ProcTrans()
120 {
121 // Process transparency monitoring data and calculates Emean  
122   Double_t eMean=6.67786;     //mean energy of photon defined  by transperancy window
123   return eMean;
124 }   
125 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
126