X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=HMPID%2FAliHMPIDPreprocessor.cxx;h=4a5b17e700c258b8d2b98d629da765754f95bade;hb=260a8dc4bbe3657b20df7095f26a4b92e62504d5;hp=8fbebad47fc2452d512ea0dfef18354c538d6fd5;hpb=c5d1d92197fd01dfc6f3d9def30601b6b7651257;p=u%2Fmrichter%2FAliRoot.git diff --git a/HMPID/AliHMPIDPreprocessor.cxx b/HMPID/AliHMPIDPreprocessor.cxx index 8fbebad47fc..4a5b17e700c 100644 --- a/HMPID/AliHMPIDPreprocessor.cxx +++ b/HMPID/AliHMPIDPreprocessor.cxx @@ -1,98 +1,245 @@ -#include "AliHMPIDPreprocessor.h" //header - -#include -#include -#include //Process() -#include //Process() -#include //Process() -#include //Process() - +#include "AliHMPIDPreprocessor.h" //header no includes +#include "AliHMPIDDigit.h" //ProcPed() +#include "AliHMPIDRawStream.h" //ProcPed() +#include //ProcPed() +#include //all +#include //ProcPed(), ProcDcs() +#include //ProcDcs() +#include //ProcDcs(), ProcPed() +#include //Initialize() +#include //Process() +#include //Process() +#include +#include //Process() +#include //ProcPed() +#include //ProcPed() +#include //ProcPed() +//. +// HMPID Preprocessor base class +//. +//. +//. ClassImp(AliHMPIDPreprocessor) -char *AliHMPIDPreprocessor::fP ="HMP_DET/HMP_MP%i/HMP_MP%i_GAS/HMP_MP%i_GAS_PMWC.actual.value"; -char *AliHMPIDPreprocessor::fT1="HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iIn_Temp"; -char *AliHMPIDPreprocessor::fT2="HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iOut_Temp"; -char *AliHMPIDPreprocessor::fHV="HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC0/HMP_MP%i_SEC0_HV.actual.vMon"; - - - - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void AliHMPIDPreprocessor::Initialize(Int_t run, UInt_t startTime,UInt_t endTime) { +// Initialize the parameter coming from AliPreprocessor +// run -> run number +// startTime -> starting time +// endTime -> ending time AliPreprocessor::Initialize(run, startTime, endTime); + + AliInfo(Form("HMPID started for Run %d \n\tStartTime %s \n\t EndTime %s", run,TTimeStamp(startTime).AsString(),TTimeStamp(endTime).AsString())); + } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ UInt_t AliHMPIDPreprocessor::Process(TMap* pMap) { +// Process all information from DCS and DAQ +// Arguments: pMap- map of DCS aliases +// Returns: 0 on success or 1 on error (opposite to Store!) + + TString runType = GetRunType(); + Log(Form(" AliHMPIDPreprocessor: RunType is %s",runType.Data())); + +// start to check event type and procedures + + Log("HMPID - Process in Preprocessor started"); + if(! pMap) { + Log("HMPID - ERROR - Not map of DCS aliases for HMPID - "); return kTRUE; // error in the DCS mapped aliases + } + if (runType == "CALIBRATION"){ + if (!ProcPed()){ + Log("HMPID - ERROR - Pedestal processing failed!!"); return kTRUE; // error in pedestal processing + } else { + Log("HMPID - Pedestal processing successful!!"); return kFALSE; // ok for pedestals + } + } else if ( runType=="STANDALONE" || runType=="PHYSICS"){ + if (!ProcDcs(pMap)){ + Log("HMPID - ERROR - DCS processing failed!!"); return kTRUE; // error in DCS processing + } else { + Log("HMPID - DCS processing successful!!"); return kFALSE; // ok for DCS + } + } else { + Log("HMPID - Nothing to do with preprocessor for HMPID, bye!"); return kFALSE; // ok - nothing done + } +}//Process() +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +Bool_t AliHMPIDPreprocessor::ProcDcs(TMap* pMap) +{ // Process: 1. inlet and outlet C6F14 temperature, stores TObjArray of 21 TF1, where TF1 is Nmean=f(t), one per radiator // 2. CH4 pressure and HV stores TObjArray of 7 TF1 where TF1 is thr=f(t), one per chamber // Arguments: pDcsMap - map of structure "alias name" - TObjArray of AliDCSValue // Assume that: HV is the same during the run for a given chamber, different chambers might have different HV -// P=f(t), different for different chambers - -// TList* list = GetFileSources(kDAQ, "MAP"); //first analyse a set of pedestal files -// if (list){ -// Log("The following sources produced files with the id MAP"); -// list->Print(); -// delete list; -// } +// P=f(t), different for different chambers +// Returns: kTRUE on success + Bool_t stDcsStore=kFALSE; - if(!pMap) return 0; //no DCS map provided - Double_t sor=0,eor=1500; - - 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 - TF2 thr("RthrCH4" ,"x+170745848*exp(-y*0.0162012)" ,2000,3000,900,1200); //thr=f(HV,P) [V,mBar] -// Double_t eMean=6.67786; //mean energy of photon defined by transperancy window + 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 -// TObjArray arTmean(21); arTmean.SetOwner(kTRUE); //21 Tmean=f(time) one per radiator -// TObjArray arPress(7); arPress.SetOwner(kTRUE); //7 Press=f(time) one pre chamber - TObjArray arNmean(21); arNmean.SetOwner(kTRUE); //21 Nmean=f(time) one per radiator - TObjArray arQthre(7); arQthre.SetOwner(kTRUE); //7 Qthre=f(time) one pre chamber +// Qthr=f(HV,P) [V,mBar] logA0=k*HV+b is taken from p. 64 TDR plot 2.59 for PC32 +// A0=f(P) is taken from DiMauro mail +// Qthr is estimated as 3*A0 + TF2 thr("RthrCH4" ,"3*10^(3.01e-3*x-4.72)+170745848*exp(-y*0.0162012)" ,2000,3000,900,1200); -// AliDCSValue *pVal; Int_t cnt=0; - - for(Int_t iCh=0;iCh<7;iCh++){ - // 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 -// pVal=(AliDCSValue*)pHV->At(0); Float_t hv=pVal->GetFloat();//HV + TObjArray arTmean(21); arTmean.SetOwner(kTRUE); //21 Tmean=f(time) one per radiator + TObjArray arPress(7); arPress.SetOwner(kTRUE); //7 Press=f(time) one per chamber + TObjArray arNmean(21); arNmean.SetOwner(kTRUE); //21 Nmean=f(time) one per radiator + TObjArray arQthre(42); arQthre.SetOwner(kTRUE); //42 Qthre=f(time) one per sector + TObjArray arUserCut(7); arUserCut.SetOwner(kTRUE); //7 user cut in number of sigmas + + AliDCSValue *pVal; Int_t cnt=0; -// TObjArray *pP =(TObjArray*)pMap->GetValue(Form(fP,iCh,iCh,iCh)); //P -// TGraph *pGrP; cnt=0;TIter nextp(pP); while((pVal=(AliDCSValue*)nextp())) pGrP->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //P - -// TF1 *pFuP=new TF1(Form("P%i",iCh),"1005",sor,eor); -// pGrP->Fit(pFuP,"Q"); delete pGrP; - TF1 *pFuQ=new TF1(Form("HMP_Qthre%i",iCh),"100",sor,eor); - arQthre.AddAt(pFuQ,iCh); +// evaluate environment pressure + TObjArray *pPenv=(TObjArray*)pMap->GetValue("HMP_DET/HMP_ENV/HMP_ENV_PENV.actual.value");TIter nextPenv(pPenv); + TGraph *pGrPenv=new TGraph; cnt=0; + while((pVal=(AliDCSValue*)nextPenv())) pGrPenv->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //P env + if( cnt!=0) pGrPenv->Fit(new TF1("Penv","1000+x*[0]",fStartTime,fEndTime),"Q"); //clm: if no DCS map entry don't fit + delete pGrPenv; + + for(Int_t iCh=0;iCh<7;iCh++){ +// evaluate Pressure + 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)); + TIter nextP(pP); + TGraph *pGrP=new TGraph; cnt=0; + while((pVal=(AliDCSValue*)nextP())) pGrP->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //P + 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 + delete pGrP; + + for(Int_t iSec=0;iSec<6;iSec++){ +// evaluate High Voltage + 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); + TGraph *pGrHV=new TGraph; cnt=0; + while((pVal=(AliDCSValue*)nextHV())) pGrHV->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //HV + 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 + delete pGrHV; +// evaluate Qthre + arQthre.AddAt(new TF1(Form("HMP_QthreC%iS%i",iCh,iSec), + 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); + } + +// evaluate UserCut + Int_t nSigmaUserCut = 3; + TObject *pUserCut = new TObject();pUserCut->SetUniqueID(nSigmaUserCut); + arUserCut.AddAt(pUserCut,iCh); + +// evaluate Temperatures for(Int_t iRad=0;iRad<3;iRad++){ -// TObjArray *pT1=(TObjArray*)pMap->GetValue(Form(fT1,iCh,iCh,iRad)); //Tin -// TGraph *pGrT1=new TGraph; cnt=0; TIter next1(pT1); while((pVal=(AliDCSValue*)next1())) pGrT1->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //inlet temperature -// 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 + 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 + 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 -// TObjArray *pT2=(TObjArray*)pMap->GetValue(Form(fT2,iCh,iCh,iRad));//Tout -// TGraph *pGrT2=new TGraph; cnt=0; TIter next2(pT2); while((pVal=(AliDCSValue*)next2())) pGrT2->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //outlet temperature -// TF1*pFuT1=new TF1(Form("Tout%i%i",iCh,iRad),"13",sor,eor) -// pGrT2->Fit(,"Q"); //now fit the temp graph + TGraph *pGrT1=new TGraph; cnt=0; while((pVal=(AliDCSValue*)nextT1())) pGrT1->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //T inlet + 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 + TGraph *pGrT2=new TGraph; cnt=0; while((pVal=(AliDCSValue*)nextT2())) pGrT2->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat()); //T outlet + 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 + + delete pGrT1; delete pGrT2; + + // arTmean.Add(pRadTempF); - TF1 *pFuN=new TF1(Form("HMP_Nmean%i-%i",iCh,iRad),"1.292",sor,eor); pFuN->SetLineColor(iRad+2); pFuN->SetLineWidth(1); - arNmean.AddAt(pFuN,3*iCh+iRad); -// delete pGrT1; delete pGrT2; +// evaluate Mean Refractive Index + arNmean.AddAt(new TF1(Form("HMP_Nmean%i-%i",iCh,iRad),"1.292",fStartTime,fEndTime),3*iCh+iRad); //Nmean=f(t) }//radiators loop }//chambers loop - AliCDBMetaData metaData; metaData.SetBeamPeriod(0); metaData.SetResponsible("AliHMPIDPreprocessor"); metaData.SetComment("SIMULATED"); + AliCDBMetaData metaData; + metaData.SetBeamPeriod(0); + metaData.SetResponsible("AliHMPIDPreprocessor"); + metaData.SetComment("SIMULATED"); +// stDcsStore = Store("Calib","Qthre",&arQthre,&metaData,0,kTRUE) && // from DCS +// Store("Calib","Nmean",&arNmean,&metaData,0,kTRUE) && // from DCS +// Store("Calib","UserCut",&arUserCut,&metaData,0,kTRUE); //really not from DCS...a method ProcManual maybe needed + stDcsStore = Store("Calib","Qthre",&arQthre,&metaData) && // from DCS + Store("Calib","Nmean",&arNmean,&metaData) && // from DCS + Store("Calib","UserCut",&arUserCut,&metaData); //really not from DCS...a method ProcManual maybe needed + if(!stDcsStore) { + Log("HMPID - failure to store DCS data results in OCDB"); + } + return stDcsStore; +}//Process() +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +Bool_t AliHMPIDPreprocessor::ProcPed() +{ +// Process pedestal files and create 7 M(padx,pady)=sigma, one for each chamber +// Arguments: +// Returns: kTRUE on success - arQthre.Print(); -// Store("Calib", "Press" , &arPress , &metaData); -// Store("Calib", "Tmean" , &arTmean , &metaData); + Bool_t stPedStore=kFALSE; - if( Store("Calib", "Qthre" , &arQthre , &metaData) == kTRUE && Store("Calib", "Nmean" , &arNmean , &metaData) == kTRUE ) return 0; //clm: compatibility with new Store and preprocessor requirement - else return 1; + 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 - // AliInfo("End."); + TList *pLdc=GetFileSources(kDAQ,"pedestals"); //get list of LDC names containing id "pedestals" -}//Process() -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + if(!pLdc) { + Log("ERROR: Retrieval of sources for pedestals failed!"); + return kFALSE;} + + Log(Form("HMPID - Pedestal files to be read --> %i LDCs for HMPID",pLdc->GetEntries())); + + for(Int_t i=0;iGetEntries();i++) {//lists of LDCs + + //gSystem->Exec(Form("tar xf %s",GetFile(kDAQ,"pedestals",((TObjString*)pLdc->At(i))->GetName()))); //untar pedestal files from current LDC + + TString fileName = GetFile(kDAQ,"pedestals", ((TObjString*)pLdc->At(i))->GetName()); + + if(fileName.Length()==0) { + Log("ERROR retrieving pedestal file!"); + return kFALSE; } + + gSystem->Exec(Form("tar xf %s",fileName.Data())); + + } + + AliHMPIDDigit dig; + AliHMPIDRawStream rs; + Int_t nSigCut,r,d,a,hard; Float_t mean,sigma; + Int_t runNumber,ldcId,timeStamp,nEv,nDdlEv,nBadEv; Char_t tName[10]; + Float_t nBadEvPer; + + for(Int_t ddl=0;ddl<14;ddl++){ + ifstream infile(Form("HmpidPedDdl%02i.txt",ddl)); + if(!infile.is_open()) {Log("No pedestal file found for HMPID,bye!");return kFALSE;} + TMatrix *pM=(TMatrixF*)aDaqSig.At(ddl/2); + infile>>tName>>runNumber; + infile>>tName>>ldcId; + infile>>tName>>timeStamp; + infile>>tName>>nEv; + infile>>tName>>nDdlEv; + infile>>tName>>nBadEv; + infile>>tName>>nBadEvPer; + infile>>nSigCut; pM->SetUniqueID(nSigCut); //n. of pedestal distribution sigmas used to create zero suppresion table + while(!infile.eof()){ + infile>>dec>>r>>d>>a>>mean>>sigma>>hex>>hard; + AliHMPIDDigit dig(rs.GetPad(ddl,r,d,a),(Int_t)mean); + (*pM)(dig.PadChX(),dig.PadChY()) = sigma; + } + infile.close(); + Log(Form("Pedestal file for DDL %i read successfully",ddl)); + } + + AliCDBMetaData metaData; + metaData.SetBeamPeriod(0); + metaData.SetResponsible("AliHMPIDPreprocessor"); + metaData.SetComment("SIMULATED"); + stPedStore = Store("Calib","DaqSig",&aDaqSig,&metaData,0,kTRUE); + + if(!stPedStore) { + Log("HMPID - failure to store PEDESTAL data results in OCDB"); + } + return stPedStore; + +}//ProcPed() +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +Double_t ProcTrans() +{ +// Process transparency monitoring data and calculates Emean + Double_t eMean=6.67786; //mean energy of photon defined by transperancy window + return eMean; +} +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +