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