1 #include "AliHMPIDPreprocessor.h" //header no includes
2 #include "AliHMPIDDigit.h" //ProcPed()
3 #include "AliHMPIDRawStream.h" //ProcPed()
4 #include <Riostream.h> //ProcPed()
5 #include <AliLog.h> //all
6 #include <AliCDBMetaData.h> //ProcPed(), ProcDcs()
7 #include <AliDCSValue.h> //ProcDcs()
8 #include <TObjString.h> //ProcDcs(), ProcPed()
9 #include <TTimeStamp.h> //Initialize()
10 #include <TF1.h> //Process()
11 #include <TF2.h> //Process()
13 #include <TGraph.h> //Process()
14 #include <TMatrix.h> //ProcPed()
15 #include <TList.h> //ProcPed()
16 #include <TSystem.h> //ProcPed()
18 // HMPID Preprocessor base class
22 ClassImp(AliHMPIDPreprocessor)
24 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
25 void AliHMPIDPreprocessor::Initialize(Int_t run, UInt_t startTime,UInt_t endTime)
27 // Initialize the parameter coming from AliPreprocessor
29 // startTime -> starting time
30 // endTime -> ending time
31 AliPreprocessor::Initialize(run, startTime, endTime);
33 AliInfo(Form("HMPID started for Run %d \n\tStartTime %s \n\t EndTime %s", run,TTimeStamp(startTime).AsString(),TTimeStamp(endTime).AsString()));
36 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
37 UInt_t AliHMPIDPreprocessor::Process(TMap* pMap)
39 // Process all information from DCS and DAQ
40 // Arguments: pMap- map of DCS aliases
41 // Returns: 0 on success or 1 on error (opposite to Store!)
43 TString runType = GetRunType();
44 Log(Form(" AliHMPIDPreprocessor: RunType is %s",runType.Data()));
46 // start to check event type and procedures
48 Log("HMPID - Process in Preprocessor started");
50 Log("HMPID - ERROR - Not map of DCS aliases for HMPID - "); return kTRUE; // error in the DCS mapped aliases
52 if (runType == "CALIBRATION"){
54 Log("HMPID - ERROR - Pedestal processing failed!!"); return kTRUE; // error in pedestal processing
56 Log("HMPID - Pedestal processing successful!!"); return kFALSE; // ok for pedestals
58 } else if ( runType=="STANDALONE" || runType=="PHYSICS"){
60 Log("HMPID - ERROR - DCS processing failed!!"); return kTRUE; // error in DCS processing
62 Log("HMPID - DCS processing successful!!"); return kFALSE; // ok for DCS
65 Log("HMPID - Nothing to do with preprocessor for HMPID, bye!"); return kFALSE; // ok - nothing done
68 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
69 Bool_t AliHMPIDPreprocessor::ProcDcs(TMap* pMap)
71 // Process: 1. inlet and outlet C6F14 temperature, stores TObjArray of 21 TF1, where TF1 is Nmean=f(t), one per radiator
72 // 2. CH4 pressure and HV stores TObjArray of 7 TF1 where TF1 is thr=f(t), one per chamber
73 // Arguments: pDcsMap - map of structure "alias name" - TObjArray of AliDCSValue
74 // Assume that: HV is the same during the run for a given chamber, different chambers might have different HV
75 // P=f(t), different for different chambers
76 // Returns: kTRUE on success
78 Bool_t stDcsStore=kFALSE;
80 TF2 idx("RidxC4F14","sqrt(1+0.554*(1239.84/x)^2/((1239.84/x)^2-5769)-0.0005*(y-20))",5.5 ,8.5 ,0 ,50); //N=f(Ephot,T) [eV,grad C] DiMauro mail
82 // Qthr=f(HV,P) [V,mBar] logA0=k*HV+b is taken from p. 64 TDR plot 2.59 for PC32
83 // A0=f(P) is taken from DiMauro mail
84 // Qthr is estimated as 3*A0
85 TF2 thr("RthrCH4" ,"3*10^(3.01e-3*x-4.72)+170745848*exp(-y*0.0162012)" ,2000,3000,900,1200);
87 TObjArray arTmean(21); arTmean.SetOwner(kTRUE); //21 Tmean=f(time) one per radiator
88 TObjArray arPress(7); arPress.SetOwner(kTRUE); //7 Press=f(time) one per chamber
89 TObjArray arNmean(21); arNmean.SetOwner(kTRUE); //21 Nmean=f(time) one per radiator
90 TObjArray arQthre(42); arQthre.SetOwner(kTRUE); //42 Qthre=f(time) one per sector
92 AliDCSValue *pVal; Int_t cnt=0;
94 // evaluate environment pressure
95 TObjArray *pPenv=(TObjArray*)pMap->GetValue("HMP_DET/HMP_ENV/HMP_ENV_PENV.actual.value");TIter nextPenv(pPenv);
96 TGraph *pGrPenv=new TGraph; cnt=0;
97 while((pVal=(AliDCSValue*)nextPenv())) pGrPenv->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //P env
98 if( cnt!=0) pGrPenv->Fit(new TF1("Penv","1000+x*[0]",fStartTime,fEndTime),"Q"); //clm: if no DCS map entry don't fit
101 for(Int_t iCh=0;iCh<7;iCh++){
103 TObjArray *pP =(TObjArray*)pMap->GetValue(Form("HMP_DET/HMP_MP%i/HMP_MP%i_GAS/HMP_MP%i_GAS_PMWPC.actual.value",iCh,iCh,iCh));
105 TGraph *pGrP=new TGraph; cnt=0;
106 while((pVal=(AliDCSValue*)nextP())) pGrP->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //P
107 if( cnt!=0) pGrP->Fit(new TF1(Form("P%i",iCh),"[0] + x*[1]",fStartTime,fEndTime),"Q"); //clm: if no DCS map entry don't fit
110 for(Int_t iSec=0;iSec<6;iSec++){
111 // evaluate High Voltage
112 TObjArray *pHV=(TObjArray*)pMap->GetValue(Form("HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC%i/HMP_MP%i_SEC%i_HV.actual.vMon",iCh,iCh,iCh,iSec,iCh,iSec));TIter nextHV(pHV);
113 TGraph *pGrHV=new TGraph; cnt=0;
114 while((pVal=(AliDCSValue*)nextHV())) pGrHV->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //HV
115 if( cnt!=0) pGrHV->Fit(new TF1(Form("HV%i_%i",iCh,iSec),"[0]+x*[1]",fStartTime,fEndTime),"Q"); //clm: if no DCS map entry don't fit
118 arQthre.AddAt(new TF1(Form("HMP_QthreC%iS%i",iCh,iSec),
119 Form("3*10^(3.01e-3*HV%i_%i - 4.72)+170745848*exp(-(P%i+Penv)*0.0162012)",iCh,iSec,iCh),fStartTime,fEndTime),6*iCh+iSec);
122 // evaluate Temperatures
123 for(Int_t iRad=0;iRad<3;iRad++){
124 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
125 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
127 TGraph *pGrT1=new TGraph; cnt=0; while((pVal=(AliDCSValue*)nextT1())) pGrT1->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //T inlet
128 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
130 TGraph *pGrT2=new TGraph; cnt=0; while((pVal=(AliDCSValue*)nextT2())) pGrT2->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //T outlet
131 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
133 delete pGrT1; delete pGrT2;
136 // arTmean.Add(pRadTempF);
137 // evaluate Mean Refractive Index
138 arNmean.AddAt(new TF1(Form("HMP_Nmean%i-%i",iCh,iRad),"1.292",fStartTime,fEndTime),3*iCh+iRad); //Nmean=f(t)
142 AliCDBMetaData metaData;
143 metaData.SetBeamPeriod(0);
144 metaData.SetResponsible("AliHMPIDPreprocessor");
145 metaData.SetComment("SIMULATED");
147 stDcsStore = Store("Calib","Qthre",&arQthre,&metaData) && // from DCS
148 Store("Calib","Nmean",&arNmean,&metaData); // from DCS
150 Log("HMPID - failure to store DCS data results in OCDB");
154 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
155 Bool_t AliHMPIDPreprocessor::ProcPed()
157 // Process pedestal files and create 7 M(padx,pady)=sigma, one for each chamber
159 // Returns: kTRUE on success
161 Bool_t stPedStore=kFALSE;
163 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
165 TList *pLdc=GetFileSources(kDAQ,"pedestals"); //get list of LDC names containing id "pedestals"
168 Log("ERROR: Retrieval of sources for pedestals failed!");
171 Log(Form("HMPID - Pedestal files to be read --> %i LDCs for HMPID",pLdc->GetEntries()));
173 for(Int_t i=0;i<pLdc->GetEntries();i++) {//lists of LDCs
175 //gSystem->Exec(Form("tar xf %s",GetFile(kDAQ,"pedestals",((TObjString*)pLdc->At(i))->GetName()))); //untar pedestal files from current LDC
177 TString fileName = GetFile(kDAQ,"pedestals", ((TObjString*)pLdc->At(i))->GetName());
179 if(fileName.Length()==0) {
180 Log("ERROR retrieving pedestal file!");
183 gSystem->Exec(Form("tar xf %s",fileName.Data()));
188 AliHMPIDRawStream rs;
189 Int_t nSigCut,r,d,a,hard; Float_t mean,sigma;
190 Int_t runNumber,ldcId,timeStamp,nEv,nDdlEv,nBadEv; Char_t tName[10];
193 for(Int_t ddl=0;ddl<14;ddl++){
194 ifstream infile(Form("HmpidPedDdl%02i.txt",ddl));
195 if(!infile.is_open()) {Log("No pedestal file found for HMPID,bye!");return kFALSE;}
196 TMatrix *pM=(TMatrixF*)aDaqSig.At(ddl/2);
197 infile>>tName>>runNumber;
198 infile>>tName>>ldcId;
199 infile>>tName>>timeStamp;
201 infile>>tName>>nDdlEv;
202 infile>>tName>>nBadEv;
203 infile>>tName>>nBadEvPer;
204 infile>>nSigCut; pM->SetUniqueID(nSigCut); //n. of pedestal distribution sigmas used to create zero suppresion table
205 while(!infile.eof()){
206 infile>>dec>>r>>d>>a>>mean>>sigma>>hex>>hard;
207 AliHMPIDDigit dig(rs.GetPad(ddl,r,d,a),(Int_t)mean);
208 (*pM)(dig.PadChX(),dig.PadChY()) = sigma;
211 Log(Form("Pedestal file for DDL %i read successfully",ddl));
214 AliCDBMetaData metaData;
215 metaData.SetBeamPeriod(0);
216 metaData.SetResponsible("AliHMPIDPreprocessor");
217 metaData.SetComment("SIMULATED");
219 stPedStore = Store("Calib","DaqSig",&aDaqSig,&metaData,0,kTRUE);
222 Log("HMPID - failure to store PEDESTAL data results in OCDB");
227 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
230 // Process transparency monitoring data and calculates Emean
231 Double_t eMean=6.67786; //mean energy of photon defined by transperancy window
234 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++