Further fixes to the par file generation
[u/mrichter/AliRoot.git] / HMPID / Hshuttle.C
CommitLineData
b7c14c1c 1void Hshuttle(Int_t runTime=1500)
56d2de52 2{// this macro is to simulate the functionality of SHUTTLE.
9cc1a411 3 gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
4// AliTestShuttle::SetMainCDB(TString("local://$HOME/CDB"));
5 AliTestShuttle::SetMainCDB(TString("local://$HOME"));
abb5f786 6
56d2de52 7 TMap *pDcsMap = new TMap; pDcsMap->SetOwner(1); //DCS archive map
8
9 AliTestShuttle* pShuttle = new AliTestShuttle(0,0,1000000);
b7c14c1c 10 // pShuttle->SetInputRunType("PHYSICS");
11 pShuttle->SetInputRunType("CALIBRATION");
12 SimPed();
13 for(Int_t ldc=51;ldc<=52;ldc++)
14 {
15 if(ldc==51) {for(Int_t iddl=0;iddl<=7;iddl++) pShuttle->AddInputFile(AliTestShuttle::kDAQ,"HMP",Form("HmpidPedDdl%02i.txt",iddl),Form("LDC%i",ldc),Form("HmpidPedDdl%02i.txt",iddl));}
16 if(ldc==52) {for(Int_t iddl=8;iddl<=13;iddl++) pShuttle->AddInputFile(AliTestShuttle::kDAQ,"HMP",Form("HmpidPedDdl%02i.txt",iddl),Form("LDC%i",ldc),Form("HmpidPedDdl%02i.txt",iddl));}
17 }
56d2de52 18 SimMap(pDcsMap,runTime); pShuttle->SetDCSInput(pDcsMap); //DCS map
19
20 AliPreprocessor* pp = new AliHMPIDPreprocessor(pShuttle); pShuttle->Process(); delete pp; //here goes preprocessor
abb5f786 21
ab5ca5d6 22 DrawInput(pDcsMap); DrawOutput();
9cc1a411 23 gSystem->Exec("rm -rf HmpidPedDdl*.txt");
b7c14c1c 24
abb5f786 25}//Hshuttle()
26//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a0e5c1b9 27void SimPed()
28{
4e2cd93b 29 Int_t iDDLmin=0,iDDLmax=13;
b7c14c1c 30 Int_t nSigmas = 3; // value stored in the ddl files of pedestals
a0e5c1b9 31 ofstream out;
4e2cd93b 32 for(Int_t ddl=iDDLmin;ddl<=iDDLmax;ddl++){
56d2de52 33 out.open(Form("HmpidPedDdl%02i.txt",ddl));
b7c14c1c 34 out << Form("%8s %2d\n","RunNumber", 999); //read run number
35 out << Form("%8s %2d\n","LdcId" , 999); //read LDC Id
36 out << Form("%8s %2d\n","TimeStamp", 999); //read time stamp
37 out << Form("%8s %2d\n","TotNumEvt", 999); //read number of total events processed
38 out << Form("%8s %2d\n","TotDDLEvt", 999); //read number of bad events for DDL # nDDL processed
39 out << Form("%8s %2d\n","NumBadEvt", 999); //read number of bad events for DDL # nDDL processed
40 out << Form("%8s %2f\n","NBadE(%)", 999.9); //read number of bad events (in %) for DDL # nDDL processed
41 out << Form("%8s %2.2d\n","SigCut", nSigmas); //# of sigma cuts
a0e5c1b9 42 for(Int_t row=1;row<=24;row++)
43 for(Int_t dil=1;dil<=10;dil++)
44 for(Int_t adr=0;adr<=47;adr++){
45 Float_t mean = 150+200*gRandom->Rndm();
9cc1a411 46 Float_t sigma = 1+0.3*gRandom->Gaus();
b7c14c1c 47 Int_t inhard=((Int_t(mean+nSigmas*sigma))<<9)+Int_t(mean); //right calculation, xchecked with Paolo 8/4/2008
48 out << Form("%2i %2i %2i %5.3f %5.3f %4.4x \n",row,dil,adr,mean,sigma,inhard);
a0e5c1b9 49 }
50
a0e5c1b9 51 out.close();
52 }
4e2cd93b 53 Printf("HMPID - All %i DDL pedestal files created successfully",iDDLmax-iDDLmin+1);
a0e5c1b9 54}
55//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
abb5f786 56void SimMap(TMap *pDcsMap,Int_t runTime=1500)
57{
ad712d2e 58 Int_t stepTime=100; //time interval between measurements
abb5f786 59 Int_t startTime=0;
60
49881df7 61 TObjArray *pHV[7];
43480497 62 for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
49881df7 63 TObjArray *pPCH4=new TObjArray; pPCH4->SetOwner(1);
64 TObjArray *pPenv=new TObjArray; pPenv->SetOwner(1);
65 pHV[iCh]=new TObjArray; pHV[iCh]->SetOwner(1);
9cc1a411 66 for(Int_t time=0;time<runTime;time+=stepTime) {
49881df7 67 pPCH4->Add(new AliDCSValue((Float_t)4.0,time)); //sample CH4 pressure [mBar] differential respect to atm
68 pPenv->Add(new AliDCSValue((Float_t)1000.0 ,time)); //also atm. pressure set to the same value
3f84bc66 69// pHV[iCh]->Add(new AliDCSValue((Float_t)(1930+iCh*20),time)); //sample chamber HV [V]
70 pHV[iCh]->Add(new AliDCSValue((Float_t)(2050),time)); //sample chamber HV [V]
9cc1a411 71 }
49881df7 72 pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_GAS/HMP_MP%i_GAS_PMWPC.actual.value" ,iCh,iCh,iCh )),pPCH4); //CH4 pressure wrt atm
73 pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_ENV/HMP_ENV_PENV.actual.value" )),pPenv); //atm pressure
74 pDcsMap->Add(new TObjString(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)),pHV[iCh]); //HV SEC0
75 pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC1/HMP_MP%i_SEC1_HV.actual.vMon",iCh,iCh,iCh,iCh)),pHV[iCh]); //HV SEC1
76 pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC2/HMP_MP%i_SEC2_HV.actual.vMon",iCh,iCh,iCh,iCh)),pHV[iCh]); //HV SEC2
77 pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC3/HMP_MP%i_SEC3_HV.actual.vMon",iCh,iCh,iCh,iCh)),pHV[iCh]); //HV SEC3
78 pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC4/HMP_MP%i_SEC4_HV.actual.vMon",iCh,iCh,iCh,iCh)),pHV[iCh]); //HV SEC4
79 pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC5/HMP_MP%i_SEC5_HV.actual.vMon",iCh,iCh,iCh,iCh)),pHV[iCh]); //HV SEC5
9cc1a411 80
43480497 81 for(Int_t iRad=0;iRad<3;iRad++){//radiators loop
d15caf65 82 TObjArray *pT1=new TObjArray; pT1->SetOwner(1);
83 TObjArray *pT2=new TObjArray; pT2->SetOwner(1);
49881df7 84 for (Int_t time=0;time<runTime;time+=stepTime) pT1->Add(new AliDCSValue(13,time)); //sample inlet temperature Nmean=1.292 @ 13 degrees
ab5ca5d6 85 for (Int_t time=0;time<runTime;time+=stepTime) pT2->Add(new AliDCSValue(14,time)); //sample outlet temperature
49881df7 86 pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iIn_Temp",iCh,iCh,iRad)) ,pT1); //Temperature in Rad
87 pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iOut_Temp",iCh,iCh,iRad)),pT2); //Temperature out Rad
d15caf65 88 }//radiators loop
43480497 89 }//chambers loop
abb5f786 90}//SimMap()
91//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ab5ca5d6 92void DrawInput(TMap *pDcsMap)
abb5f786 93{
ab5ca5d6 94 TCanvas *c=new TCanvas("cc","Input data",600,600); c->Divide(3,3);
43480497 95
ab5ca5d6 96 AliDCSValue *pVal; Int_t cnt;
abb5f786 97
98 for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
99 if(iCh==6) c->cd(1); if(iCh==5) c->cd(2);
100 if(iCh==4) c->cd(4); if(iCh==3) c->cd(5); if(iCh==2) c->cd(6);
101 if(iCh==1) c->cd(8); if(iCh==0) c->cd(9);
102
56d2de52 103 TObjArray *pHV=(TObjArray*)pDcsMap->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
104 TObjArray *pP =(TObjArray*)pDcsMap->GetValue(Form("HMP_DET/HMP_MP%i/HMP_MP%i_GAS/HMP_MP%i_GAS_PMWC.actual.value",iCh,iCh,iCh)); //P
ab5ca5d6 105 TGraph *pGrHV=new TGraph; pGrHV->SetMarkerStyle(5); TIter nextHV(pHV);
106 TGraph *pGrP =new TGraph; pGrP ->SetMarkerStyle(5); TIter nextP (pP );
43480497 107
ab5ca5d6 108 for(Int_t iRad=0;iRad<3;iRad++){
109 TObjArray *pT1=(TObjArray*)pDcsMap->GetValue(Form("HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iIn_Temp",iCh,iCh,iRad)); TIter nextT1(pT1);
110 TObjArray *pT2=(TObjArray*)pDcsMap->GetValue(Form("HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iOut_Temp",iCh,iCh,iRad)); TIter nextT2(pT2);
111 TGraph *pGrT1=new TGraph; pGrT1->SetMarkerStyle(5);
112 TGraph *pGrT2=new TGraph; pGrT2->SetMarkerStyle(5);
113 cnt=0; while((pVal=(AliDCSValue*)nextT1())) pGrT1->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat());
114 cnt=0; while((pVal=(AliDCSValue*)nextT2())) pGrT2->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat());
115 pGrT1->Draw("AP"); pGrT2->Draw("same");
116 }//radiators loop
117 }//chambers loop
118}//DrawInput()
abb5f786 119//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
120void DrawOutput()
121{
9cc1a411 122// AliCDBManager::Instance()->SetDefaultStorage("local://$HOME/CDB"); AliCDBManager::Instance()->SetRun(0);
123 AliCDBManager::Instance()->SetDefaultStorage("local://$HOME"); AliCDBManager::Instance()->SetRun(0);
56d2de52 124 AliCDBEntry *pQthreEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Qthre");
125 AliCDBEntry *pNmeanEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Nmean");
126 AliCDBEntry *pDaqSigEnt=AliCDBManager::Instance()->Get("HMPID/Calib/DaqSig");
abb5f786 127
56d2de52 128 if(!pQthreEnt || !pNmeanEnt || !pDaqSigEnt) return;
abb5f786 129
a0e5c1b9 130 TObjArray *pNmean =(TObjArray*)pNmeanEnt ->GetObject();
131 TObjArray *pQthre =(TObjArray*)pQthreEnt ->GetObject();
a0e5c1b9 132 TObjArray *pDaqSig=(TObjArray*)pDaqSigEnt->GetObject();
133
abb5f786 134 TF1 *pRad0,*pRad1,*pRad2;
ab5ca5d6 135 TCanvas *c2=new TCanvas("c2","Output"); c2->Divide(3,3);
abb5f786 136
ab5ca5d6 137 TH1F *pSig[7];
43480497 138
43480497 139 for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
ab5ca5d6 140 TMatrix *pM=(TMatrix*)pDaqSig->At(iCh);
141
142 pSig[iCh]=new TH1F(Form("sig%i",iCh),"Sigma;[QDC]",100,-5,20); //pSig[iCh]->SetLineColor(iCh+kRed);
143 for(Int_t padx=0;padx<160;padx++) for(Int_t pady=0;pady<144;pady++) pSig[iCh]->Fill((*pM)(padx,pady));
144
145 c2->cd(7); if(iCh==0) pSig[iCh]->Draw(); else pSig[iCh]->Draw("same");
146
abb5f786 147 if(iCh==6) c2->cd(1); if(iCh==5) c2->cd(2);
148 if(iCh==4) c2->cd(4); if(iCh==3) c2->cd(5); if(iCh==2) c2->cd(6);
149 if(iCh==1) c2->cd(8); if(iCh==0) c2->cd(9);
150
151 TF1 *pRad0=(TF1*)pNmean->At(iCh*3+0); pRad0->Draw(); pRad0->GetXaxis()->SetTimeDisplay(kTRUE); pRad0->GetYaxis()->SetRangeUser(1.28,1.3);
152 TF1 *pRad1=(TF1*)pNmean->At(iCh*3+1); pRad1->Draw("same");
153 TF1 *pRad2=(TF1*)pNmean->At(iCh*3+2); pRad2->Draw("same");
ab5ca5d6 154 }//chambers loop
155}//DrawOutput()
56d2de52 156//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++