]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/Hshuttle.C
TPCNoiseMapComponent included into build (Kelly)
[u/mrichter/AliRoot.git] / HMPID / Hshuttle.C
index ea20715d1f972b0adddff4a573538b44f066e029..5970e92df8628df72ac7bdd82e1746eb3331f847 100644 (file)
-void Hshuttle()
+  void Hshuttle(Int_t runTime=1500)
+{// this macro is to simulate the functionality of SHUTTLE.
+  gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
+//  AliTestShuttle::SetMainCDB(TString("local://$HOME/CDB"));
+  AliTestShuttle::SetMainCDB(TString("local://$HOME"));
+  
+  TMap *pDcsMap = new TMap;       pDcsMap->SetOwner(1);          //DCS archive map
+  
+  AliTestShuttle* pShuttle = new AliTestShuttle(0,0,1000000);   
+  pShuttle->SetInputRunType("PHYSICS");
+//  pShuttle->SetInputRunType("PEDESTAL_RUN");
+  SimPed();   for(Int_t ldc=1;ldc<=2;ldc++) pShuttle->AddInputFile(AliTestShuttle::kDAQ,"HMP","pedestals",Form("LDC%i",ldc),Form("HmpidPeds%i.tar",ldc));
+  SimMap(pDcsMap,runTime); pShuttle->SetDCSInput(pDcsMap);                                    //DCS map
+  
+  AliPreprocessor* pp = new AliHMPIDPreprocessor(pShuttle); pShuttle->Process();  delete pp;  //here goes preprocessor 
+
+  DrawInput(pDcsMap); DrawOutput();
+  gSystem->Exec("rm -rf HmpidPedDdl*.txt");
+  gSystem->Exec("rm -rf HmpidPeds*.tar");
+}//Hshuttle()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void SimPed()
+{
+  Int_t iDDLmin=0,iDDLmax=13;
+  Int_t nSigmas = 3;             // value stored in the ddl files of pedestals
+  ofstream out;
+  for(Int_t ddl=iDDLmin;ddl<=iDDLmax;ddl++){
+    out.open(Form("HmpidPedDdl%02i.txt",ddl));
+    out << nSigmas <<endl;
+    for(Int_t row=1;row<=24;row++)
+      for(Int_t dil=1;dil<=10;dil++)
+        for(Int_t adr=0;adr<=47;adr++){
+          Float_t mean  = 150+200*gRandom->Rndm();
+          Float_t sigma = 1+0.3*gRandom->Gaus();
+          Int_t inhard=((Int_t(mean))<<9)+Int_t(mean+nSigmas*sigma);
+          out << Form("%2i %2i %2i %5.2f %5.2f %x\n",row,dil,adr,mean,sigma,inhard);
+        }
+
+    out.close();
+  }
+  Printf("HMPID - All %i DDL pedestal files created successfully",iDDLmax-iDDLmin+1);
+  gSystem->Exec("tar cf HmpidPeds1.tar HmpidPedDdl00.txt HmpidPedDdl01.txt HmpidPedDdl02.txt HmpidPedDdl03.txt HmpidPedDdl04.txt HmpidPedDdl05.txt HmpidPedDdl06.txt");
+  gSystem->Exec("tar cf HmpidPeds2.tar HmpidPedDdl07.txt HmpidPedDdl08.txt HmpidPedDdl09.txt HmpidPedDdl10.txt HmpidPedDdl11.txt HmpidPedDdl12.txt HmpidPedDdl13.txt");
+  Printf("HMPID - 2 tar files (HmpidPeds1-2) created (size 2273280 bytes)");
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void SimMap(TMap *pDcsMap,Int_t runTime=1500)
 {
-// this macro is to simulate the functionality of SHUTTLE.
-// Here the list of DCS aliases is created and packed in TMap of structure "alias name" - TObjArray of AliDCSValue    
-  TMultiGraph *pMG[7]; for(Int_t i=0;i<7;i++) {pMG[i]=new TMultiGraph; pMG[i]->SetTitle("T,grad C;time");}
-  TGraph      *pGr[21];for(Int_t i=0;i<21;i++){pGr[i]=new TGraph;      pGr[i]->SetMarkerStyle(i%3+24); pGr[i]->SetMarkerColor(i%3+2); pMG[i/3]->Add(pGr[i]);}    
-  TMap        *pDcsMap = new TMap;       pDcsMap->SetOwner(1);          //DCS archive map
+  Int_t stepTime=100; //time interval between measurements
+  Int_t startTime=0;
   
+  TObjArray *pHV[7];
   for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
+    TObjArray *pPCH4=new TObjArray;  pPCH4->SetOwner(1);
+    TObjArray *pPenv=new TObjArray;  pPenv->SetOwner(1);
+    pHV[iCh]=new TObjArray; pHV[iCh]->SetOwner(1);
+    for(Int_t time=0;time<runTime;time+=stepTime) {
+       pPCH4->Add(new AliDCSValue((Float_t)4.0,time));               //sample CH4 pressure [mBar] differential respect to atm
+       pPenv->Add(new AliDCSValue((Float_t)1000.0 ,time));               //also atm. pressure set to the same value
+//       pHV[iCh]->Add(new AliDCSValue((Float_t)(1930+iCh*20),time));   //sample chamber HV [V]
+       pHV[iCh]->Add(new AliDCSValue((Float_t)(2050),time));   //sample chamber HV [V]
+    }
+    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
+    pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_ENV/HMP_ENV_PENV.actual.value"                                               )),pPenv);         //atm pressure
+    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
+    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
+    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 
+    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 
+    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 
+    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 
+
     for(Int_t iRad=0;iRad<3;iRad++){//radiators loop
-      TObjArray* pValLst  = new TObjArray;  pValLst->SetOwner(1);                
-      Int_t iPoint=0;
-      for (Int_t time=0;time<1000;time+=50) {
-        AliDCSValue*    pVal = new AliDCSValue(Float_t(iCh*3+iRad+0.1*gRandom->Gaus()), time);         //sample new data point 
-        pValLst->Add(pVal);                                                                            //add it to the list
-        pGr[3*iCh+iRad]->SetPoint(iPoint++,time,pVal->GetFloat());                                     //and also to the graph  
-      }
-      pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iIn_Temp",iCh,iCh,iRad)),pValLst); 
-      pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iOut_Temp",iCh,iCh,iRad)),pValLst);
+      TObjArray *pT1=new TObjArray; pT1->SetOwner(1);
+      TObjArray *pT2=new TObjArray; pT2->SetOwner(1);
+      for (Int_t time=0;time<runTime;time+=stepTime)  pT1->Add(new AliDCSValue(13,time));  //sample inlet temperature                    Nmean=1.292 @ 13 degrees
+      for (Int_t time=0;time<runTime;time+=stepTime)  pT2->Add(new AliDCSValue(14,time));  //sample outlet temperature
+      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 
+      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
     }//radiators loop
   }//chambers loop
+}//SimMap()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void DrawInput(TMap *pDcsMap)
+{
+  TCanvas *c=new TCanvas("cc","Input data",600,600);    c->Divide(3,3);
   
-  AliTestShuttle::SetOCDBStorage("local://$HOME/tstCDB");  
-  AliCDBManager::Instance()->SetDefaultStorage("local://$HOME/tstCDB"); // initialize location of CDB
-      
-  gSystem->Load("libTestShuttle.so"); 
-  Int_t iRun=1;   
-  AliTestShuttle* pShuttle = new AliTestShuttle(iRun,0,100000);   
-  pShuttle->SetDCSInput(pDcsMap);                                                    //DCS map
-  AliPreprocessor* pp = new AliHMPIDPreprocessor(pShuttle);                           //actual ipreprocessor is created here
-  pShuttle->Process();                                                               //run SHUTTLE simulator
-  delete pp;
+  AliDCSValue *pVal; Int_t cnt;
   
-    
-  AliCDBEntry *pTempEn=AliCDBManager::Instance()->Get("HMPID/DCS/RadTemp",iRun);
-  if(!pTempEn) {Printf("ERROR file is not retrieved!!!");return;}
-
-  TObjArray *pTempLst=(TObjArray*)pTempEn->GetObject(); TF1 *pRad0,*pRad1,*pRad2;  
-  TCanvas *pC=new TCanvas; pC->Divide(3,3);
   for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
-    if(iCh==6) pC->cd(1);  if(iCh==5) pC->cd(2);                          //this is just to see the input
-    if(iCh==4) pC->cd(4);  if(iCh==3) pC->cd(5);  if(iCh==2) pC->cd(6);
-                           if(iCh==1) pC->cd(8);  if(iCh==0) pC->cd(9); 
-    pMG[iCh]->Draw("ap"); pMG[iCh]->GetXaxis()->SetTimeDisplay(kTRUE);
-    pRad0=(TF1*)pTempLst->At(iCh*3+0); pRad0->Draw("same");
-    pRad1=(TF1*)pTempLst->At(iCh*3+1); pRad1->Draw("same");
-    pRad2=(TF1*)pTempLst->At(iCh*3+2); pRad2->Draw("same");
-  }  
-  
-  AliCDBEntry *pIdxEn=AliCDBManager::Instance()->Get("HMPID/DCS/MeanIdx",iRun);
-  if(!pIdxEn) {Printf("ERROR file is not retrieved!!!");return;}
-
-  TObjArray *pIdxLst=(TObjArray*)pIdxEn->GetObject(); TF1 *pRad0,*pRad1,*pRad2;  
-  TCanvas *pC=new TCanvas("c2","Ref Idx"); pC->Divide(3,3);
+    if(iCh==6) c->cd(1);  if(iCh==5) c->cd(2);                          
+    if(iCh==4) c->cd(4);  if(iCh==3) c->cd(5);  if(iCh==2) c->cd(6);
+                          if(iCh==1) c->cd(8);  if(iCh==0) c->cd(9); 
+                          
+    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
+    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
+    TGraph *pGrHV=new TGraph; pGrHV->SetMarkerStyle(5); TIter nextHV(pHV);
+    TGraph *pGrP =new TGraph; pGrP ->SetMarkerStyle(5); TIter nextP (pP );
+    
+    for(Int_t iRad=0;iRad<3;iRad++){
+      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);
+      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);
+      TGraph *pGrT1=new TGraph; pGrT1->SetMarkerStyle(5); 
+      TGraph *pGrT2=new TGraph; pGrT2->SetMarkerStyle(5); 
+      cnt=0; while((pVal=(AliDCSValue*)nextT1())) pGrT1->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat());
+      cnt=0; while((pVal=(AliDCSValue*)nextT2())) pGrT2->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat());
+      pGrT1->Draw("AP");  pGrT2->Draw("same");
+    }//radiators loop
+  }//chambers loop  
+}//DrawInput()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void DrawOutput()
+{
+//  AliCDBManager::Instance()->SetDefaultStorage("local://$HOME/CDB"); AliCDBManager::Instance()->SetRun(0);
+  AliCDBManager::Instance()->SetDefaultStorage("local://$HOME"); AliCDBManager::Instance()->SetRun(0);
+  AliCDBEntry *pQthreEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Qthre");
+  AliCDBEntry *pNmeanEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Nmean");
+  AliCDBEntry *pDaqSigEnt=AliCDBManager::Instance()->Get("HMPID/Calib/DaqSig");
+  
+  if(!pQthreEnt || !pNmeanEnt || !pDaqSigEnt) return;
+  
+  TObjArray *pNmean =(TObjArray*)pNmeanEnt ->GetObject(); 
+  TObjArray *pQthre =(TObjArray*)pQthreEnt ->GetObject(); 
+  TObjArray *pDaqSig=(TObjArray*)pDaqSigEnt->GetObject();
+   
+  TF1 *pRad0,*pRad1,*pRad2;  
+  TCanvas *c2=new TCanvas("c2","Output"); c2->Divide(3,3);
+  
+  TH1F *pSig[7];
+  
   for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
-    if(iCh==6) pC->cd(1);  if(iCh==5) pC->cd(2);                          //this is just to see the input
-    if(iCh==4) pC->cd(4);  if(iCh==3) pC->cd(5);  if(iCh==2) pC->cd(6);
-                           if(iCh==1) pC->cd(8);  if(iCh==0) pC->cd(9); 
-    pRad0=(TF1*)pIdxLst->At(iCh*3+0); pRad0->Draw();  pRad0->GetXaxis()->SetTimeDisplay(kTRUE); pRad0->GetYaxis()->SetRangeUser(1.28,1.3);
-    pRad1=(TF1*)pIdxLst->At(iCh*3+1); pRad1->Draw("same");
-    pRad2=(TF1*)pIdxLst->At(iCh*3+2); pRad2->Draw("same");
-  }    
-}//Hshuttle()
+    TMatrix *pM=(TMatrix*)pDaqSig->At(iCh);
+    
+    pSig[iCh]=new TH1F(Form("sig%i",iCh),"Sigma;[QDC]",100,-5,20); //pSig[iCh]->SetLineColor(iCh+kRed);
+    for(Int_t padx=0;padx<160;padx++) for(Int_t pady=0;pady<144;pady++) pSig[iCh]->Fill((*pM)(padx,pady));
+    
+    c2->cd(7);    if(iCh==0) pSig[iCh]->Draw(); else pSig[iCh]->Draw("same");
+    
+    if(iCh==6) c2->cd(1);  if(iCh==5) c2->cd(2);                          
+    if(iCh==4) c2->cd(4);  if(iCh==3) c2->cd(5);  if(iCh==2) c2->cd(6);
+                           if(iCh==1) c2->cd(8);  if(iCh==0) c2->cd(9); 
+                          
+    TF1 *pRad0=(TF1*)pNmean->At(iCh*3+0); pRad0->Draw();  pRad0->GetXaxis()->SetTimeDisplay(kTRUE); pRad0->GetYaxis()->SetRangeUser(1.28,1.3);
+    TF1 *pRad1=(TF1*)pNmean->At(iCh*3+1); pRad1->Draw("same");
+    TF1 *pRad2=(TF1*)pNmean->At(iCh*3+2); pRad2->Draw("same");
+  }//chambers loop    
+}//DrawOutput()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++