Remove -lTable from Makefile
[u/mrichter/AliRoot.git] / HMPID / Hshuttle.C
CommitLineData
9cc1a411 1 void 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);
9cc1a411 10 pShuttle->SetInputRunType("PHYSICS");
4e2cd93b 11// pShuttle->SetInputRunType("PEDESTAL_RUN");
12 SimPed(); for(Int_t ldc=1;ldc<=2;ldc++) pShuttle->AddInputFile(AliTestShuttle::kDAQ,"HMP","pedestals",Form("LDC%i",ldc),Form("HmpidPeds%i.tar",ldc));
56d2de52 13 SimMap(pDcsMap,runTime); pShuttle->SetDCSInput(pDcsMap); //DCS map
14
15 AliPreprocessor* pp = new AliHMPIDPreprocessor(pShuttle); pShuttle->Process(); delete pp; //here goes preprocessor
abb5f786 16
ab5ca5d6 17 DrawInput(pDcsMap); DrawOutput();
9cc1a411 18 gSystem->Exec("rm -rf HmpidPedDdl*.txt");
19 gSystem->Exec("rm -rf HmpidPeds*.tar");
abb5f786 20}//Hshuttle()
21//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a0e5c1b9 22void SimPed()
23{
4e2cd93b 24 Int_t iDDLmin=0,iDDLmax=13;
b3727018 25 Int_t nSigmas = 3; // value stored in the ddl files of pedestals
a0e5c1b9 26 ofstream out;
4e2cd93b 27 for(Int_t ddl=iDDLmin;ddl<=iDDLmax;ddl++){
56d2de52 28 out.open(Form("HmpidPedDdl%02i.txt",ddl));
9cc1a411 29 out << nSigmas <<endl;
a0e5c1b9 30 for(Int_t row=1;row<=24;row++)
31 for(Int_t dil=1;dil<=10;dil++)
32 for(Int_t adr=0;adr<=47;adr++){
33 Float_t mean = 150+200*gRandom->Rndm();
9cc1a411 34 Float_t sigma = 1+0.3*gRandom->Gaus();
35 Int_t inhard=((Int_t(mean))<<9)+Int_t(mean+nSigmas*sigma);
56d2de52 36 out << Form("%2i %2i %2i %5.2f %5.2f %x\n",row,dil,adr,mean,sigma,inhard);
a0e5c1b9 37 }
38
a0e5c1b9 39 out.close();
40 }
4e2cd93b 41 Printf("HMPID - All %i DDL pedestal files created successfully",iDDLmax-iDDLmin+1);
42 gSystem->Exec("tar cf HmpidPeds1.tar HmpidPedDdl00.txt HmpidPedDdl01.txt HmpidPedDdl02.txt HmpidPedDdl03.txt HmpidPedDdl04.txt HmpidPedDdl05.txt HmpidPedDdl06.txt");
43 gSystem->Exec("tar cf HmpidPeds2.tar HmpidPedDdl07.txt HmpidPedDdl08.txt HmpidPedDdl09.txt HmpidPedDdl10.txt HmpidPedDdl11.txt HmpidPedDdl12.txt HmpidPedDdl13.txt");
44 Printf("HMPID - 2 tar files (HmpidPeds1-2) created (size 2273280 bytes)");
a0e5c1b9 45}
46//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
abb5f786 47void SimMap(TMap *pDcsMap,Int_t runTime=1500)
48{
49 Int_t stepTime=100; //time interval between mesuraments
50 Int_t startTime=0;
51
43480497 52
53 for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
abb5f786 54 TObjArray *pP=new TObjArray; pP->SetOwner(1);
55 TObjArray *pHV=new TObjArray; pHV->SetOwner(1);
9cc1a411 56 TObjArray *pUserCut=new TObjArray; pUserCut->SetOwner(1);
57 TObjArray *pDaqSigCut=new TObjArray; pDaqSigCut->SetOwner(1);
58 for(Int_t time=0;time<runTime;time+=stepTime) {
59 pP->Add(new AliDCSValue((Float_t)1005.0 ,time)); //sample CH4 pressure [mBar]
4e2cd93b 60 pHV->Add(new AliDCSValue((Float_t)2050.0,time)); //sample chamber HV [V]
9cc1a411 61 pUserCut->Add(new AliDCSValue(3,time)); //User Cut in number of sigmas
62 pDaqSigCut->Add(new AliDCSValue(1,time)); //Cut in sigmas applied to electronics
63 }
56d2de52 64 pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_GAS/HMP_MP%i_GAS_PMWC.actual.value" ,iCh,iCh,iCh)),pP);
65 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)),pHV);
9cc1a411 66 pDcsMap->Add(new TObjString(Form("HMP_%i.UserCut",iCh)),pUserCut);
4e2cd93b 67 pDcsMap->Add(new TObjString(Form("HMP_%i.DaqSigCut",iCh)),pDaqSigCut);
9cc1a411 68
43480497 69 for(Int_t iRad=0;iRad<3;iRad++){//radiators loop
abb5f786 70 TObjArray *pT1=new TObjArray; pT1->SetOwner(1);
71 TObjArray *pT2=new TObjArray; pT2->SetOwner(1);
72 for (Int_t time=0;time<runTime;time+=stepTime) pT1->Add(new AliDCSValue(13,time)); //sample inlet temperature Nmean=1.292 @ 13 degrees
ab5ca5d6 73 for (Int_t time=0;time<runTime;time+=stepTime) pT2->Add(new AliDCSValue(14,time)); //sample outlet temperature
56d2de52 74 pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iIn_Temp",iCh,iCh,iRad)) ,pT1);
75 pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iOut_Temp",iCh,iCh,iRad)),pT2);
abb5f786 76 }//radiators loop
43480497 77 }//chambers loop
abb5f786 78}//SimMap()
79//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ab5ca5d6 80void DrawInput(TMap *pDcsMap)
abb5f786 81{
ab5ca5d6 82 TCanvas *c=new TCanvas("cc","Input data",600,600); c->Divide(3,3);
43480497 83
ab5ca5d6 84 AliDCSValue *pVal; Int_t cnt;
abb5f786 85
86 for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
87 if(iCh==6) c->cd(1); if(iCh==5) c->cd(2);
88 if(iCh==4) c->cd(4); if(iCh==3) c->cd(5); if(iCh==2) c->cd(6);
89 if(iCh==1) c->cd(8); if(iCh==0) c->cd(9);
90
56d2de52 91 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
92 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 93 TGraph *pGrHV=new TGraph; pGrHV->SetMarkerStyle(5); TIter nextHV(pHV);
94 TGraph *pGrP =new TGraph; pGrP ->SetMarkerStyle(5); TIter nextP (pP );
43480497 95
ab5ca5d6 96 for(Int_t iRad=0;iRad<3;iRad++){
97 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);
98 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);
99 TGraph *pGrT1=new TGraph; pGrT1->SetMarkerStyle(5);
100 TGraph *pGrT2=new TGraph; pGrT2->SetMarkerStyle(5);
101 cnt=0; while((pVal=(AliDCSValue*)nextT1())) pGrT1->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat());
102 cnt=0; while((pVal=(AliDCSValue*)nextT2())) pGrT2->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat());
103 pGrT1->Draw("AP"); pGrT2->Draw("same");
104 }//radiators loop
105 }//chambers loop
106}//DrawInput()
abb5f786 107//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
108void DrawOutput()
109{
9cc1a411 110// AliCDBManager::Instance()->SetDefaultStorage("local://$HOME/CDB"); AliCDBManager::Instance()->SetRun(0);
111 AliCDBManager::Instance()->SetDefaultStorage("local://$HOME"); AliCDBManager::Instance()->SetRun(0);
56d2de52 112 AliCDBEntry *pQthreEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Qthre");
113 AliCDBEntry *pNmeanEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Nmean");
114 AliCDBEntry *pDaqSigEnt=AliCDBManager::Instance()->Get("HMPID/Calib/DaqSig");
abb5f786 115
56d2de52 116 if(!pQthreEnt || !pNmeanEnt || !pDaqSigEnt) return;
abb5f786 117
a0e5c1b9 118 TObjArray *pNmean =(TObjArray*)pNmeanEnt ->GetObject();
119 TObjArray *pQthre =(TObjArray*)pQthreEnt ->GetObject();
a0e5c1b9 120 TObjArray *pDaqSig=(TObjArray*)pDaqSigEnt->GetObject();
121
abb5f786 122 TF1 *pRad0,*pRad1,*pRad2;
ab5ca5d6 123 TCanvas *c2=new TCanvas("c2","Output"); c2->Divide(3,3);
abb5f786 124
ab5ca5d6 125 TH1F *pSig[7];
43480497 126
43480497 127 for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
ab5ca5d6 128 TMatrix *pM=(TMatrix*)pDaqSig->At(iCh);
129
130 pSig[iCh]=new TH1F(Form("sig%i",iCh),"Sigma;[QDC]",100,-5,20); //pSig[iCh]->SetLineColor(iCh+kRed);
131 for(Int_t padx=0;padx<160;padx++) for(Int_t pady=0;pady<144;pady++) pSig[iCh]->Fill((*pM)(padx,pady));
132
133 c2->cd(7); if(iCh==0) pSig[iCh]->Draw(); else pSig[iCh]->Draw("same");
134
abb5f786 135 if(iCh==6) c2->cd(1); if(iCh==5) c2->cd(2);
136 if(iCh==4) c2->cd(4); if(iCh==3) c2->cd(5); if(iCh==2) c2->cd(6);
137 if(iCh==1) c2->cd(8); if(iCh==0) c2->cd(9);
138
139 TF1 *pRad0=(TF1*)pNmean->At(iCh*3+0); pRad0->Draw(); pRad0->GetXaxis()->SetTimeDisplay(kTRUE); pRad0->GetYaxis()->SetRangeUser(1.28,1.3);
140 TF1 *pRad1=(TF1*)pNmean->At(iCh*3+1); pRad1->Draw("same");
141 TF1 *pRad2=(TF1*)pNmean->At(iCh*3+2); pRad2->Draw("same");
ab5ca5d6 142 }//chambers loop
143}//DrawOutput()
56d2de52 144//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++