LCOV - code coverage report
Current view: top level - PMD/PMDbase - AliPMDPreprocessor.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 265 0.4 %
Date: 2016-06-14 17:26:59 Functions: 1 14 7.1 %

          Line data    Source code
       1             : /***************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /*********************************************
      17             :  
      18             :  *   PMD Preproccessor Source Code      *
      19             :     
      20             :     
      21             :      0 --> Run Successesfully
      22             :      1 --> No pmd Alias is available
      23             :  
      24             : **********************************************/
      25             :  
      26             : 
      27             : #include <TFile.h>
      28             : #include <TTimeStamp.h>
      29             : #include <TObjString.h>
      30             : #include <TTree.h>
      31             : 
      32             : #include "AliLog.h"
      33             : #include "AliShuttleInterface.h"
      34             : #include "AliCDBMetaData.h"
      35             : #include "AliPMDCalibData.h"
      36             : #include "AliPMDHotData.h"
      37             : #include "AliPMDMeanSm.h"
      38             : #include "AliPMDPedestal.h"
      39             : #include "AliPMDPreprocessor.h"
      40             : 
      41          12 : ClassImp(AliPMDPreprocessor)
      42             : 
      43             : AliPMDPreprocessor::AliPMDPreprocessor(AliShuttleInterface* shuttle) :
      44           0 :   AliPreprocessor("PMD", shuttle)
      45           0 : {
      46           0 :   AddRunType("PHYSICS");
      47           0 :   AddRunType("PEDESTAL");
      48           0 : }
      49             : 
      50             : //________________________________________________________ 
      51             : AliPMDPreprocessor::~AliPMDPreprocessor()
      52           0 : {
      53             :   
      54           0 : }
      55             : 
      56             : //________________________________________________________ 
      57             : void AliPMDPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
      58             : {
      59           0 :   AliPreprocessor::Initialize(run, startTime, endTime);
      60             :   
      61           0 :   AliInfo(Form("\nRun       : %d \nStart Time: %s \nEnd Time  : %s", run,
      62             :                TTimeStamp(startTime).AsString(),
      63             :                TTimeStamp(endTime).AsString()));
      64             :   
      65           0 :   fRun = run;
      66           0 :   fStartTime = startTime;
      67           0 :   fEndTime   = endTime;
      68             : 
      69           0 : }
      70             : 
      71             : //________________________________________________________ 
      72             : Bool_t AliPMDPreprocessor::ProcessDAQ()
      73             : {
      74           0 :   TString sRunType = GetRunType();
      75           0 :   Log(Form("RunType %s",sRunType.Data()));
      76           0 :   if (sRunType !="PHYSICS" || sRunType != "PEDESTAL") 
      77             :     {
      78           0 :       return kFALSE;
      79             :     }
      80           0 :   return kTRUE;
      81           0 : }
      82             : 
      83             : //________________________________________________________ 
      84             : Bool_t AliPMDPreprocessor::StorePmdPED()
      85             : {
      86             :   
      87           0 :   AliPMDPedestal *pedestal = new AliPMDPedestal();
      88           0 :   TList* gfsPmdPed = GetFileSources(kDAQ, "PMD_PED.root");
      89             :   
      90           0 :   if(!gfsPmdPed) 
      91             :     {
      92           0 :       Log(Form("PMDPED: No Shuttle List for PMD PED "));
      93           0 :       return kFALSE;
      94             :     }
      95             :   else
      96             :     {
      97           0 :       AliInfo("PMDPED: Here's the list of sources for PMD_PED.root");
      98           0 :       gfsPmdPed->Print();
      99             :       
     100           0 :       TIter iter(gfsPmdPed);
     101             :       TObjString* srcPed;
     102           0 :       TString nameOfFile;
     103             :       UInt_t resultPmdPed = 0;
     104             :       
     105           0 :       while((srcPed = dynamic_cast<TObjString*> (iter.Next())))
     106             :         {
     107           0 :           nameOfFile = GetFile(kDAQ, "PMD_PED.root", srcPed->GetName());
     108           0 :           if(nameOfFile.Length() == 0) 
     109             :             {
     110           0 :               Log(Form("PMDPED: Error retrieving file from source %s failed!", srcPed->GetName()));
     111           0 :               delete gfsPmdPed;
     112           0 :               return kFALSE;
     113             :             }
     114             :           
     115           0 :           Log(Form("PMDPED: File with id PMD_PED.root got from %s", srcPed->GetName()));
     116             :           
     117           0 :           Int_t det, sm, row, col;
     118           0 :           Float_t mean, rms;
     119             :           
     120           0 :           TFile *opnFile= new TFile(nameOfFile.Data());
     121           0 :           if(!opnFile || !opnFile->IsOpen()) 
     122             :             {
     123           0 :               Log(Form("PMDPED: Error opening file with Id PMD_PED.root from source %s!", srcPed->GetName()));
     124           0 :               return kFALSE;
     125             :             } 
     126             :           
     127           0 :           TTree *tree = dynamic_cast<TTree *> (opnFile->Get("ped"));
     128           0 :           if (!tree) 
     129             :             {
     130           0 :               Log("PMDPED: Could not find object \"ped\" in PED file!");
     131           0 :                return kFALSE;
     132             :             }
     133             :           
     134           0 :           tree->SetBranchAddress("det",  &det);
     135           0 :           tree->SetBranchAddress("sm",   &sm);
     136           0 :           tree->SetBranchAddress("row",  &row);
     137           0 :           tree->SetBranchAddress("col",  &col);
     138           0 :           tree->SetBranchAddress("mean", &mean);
     139           0 :           tree->SetBranchAddress("rms",  &rms);
     140             :           
     141           0 :           Int_t nEntries = (Int_t) tree->GetEntries();
     142           0 :           for(Int_t i = 0; i < nEntries; i++)
     143             :             {
     144           0 :               tree->GetEntry(i);
     145           0 :               pedestal->SetPedMeanRms(det,sm,row,col,mean,rms);
     146             :             }
     147           0 :           opnFile->Close();
     148           0 :           delete opnFile;
     149           0 :         }
     150             :       
     151           0 :       AliCDBMetaData mdPED;
     152           0 :       mdPED.SetBeamPeriod(0);
     153           0 :       mdPED.SetResponsible("Satyajit Jena");
     154           0 :       mdPED.SetComment("PMDPED: PMD preprocessor");
     155             :       
     156           0 :       resultPmdPed = Store("Calib","Ped", pedestal, &mdPED,0,kTRUE);
     157           0 :       delete pedestal;
     158           0 :       if(resultPmdPed==0)
     159             :         {
     160           0 :           Log("PMDPED: Error storing");                        
     161           0 :           return kFALSE;
     162             :         }
     163             :       else
     164             :         {
     165           0 :           return kTRUE;
     166             :         }
     167             : 
     168           0 :     } 
     169             :  
     170           0 : }
     171             : 
     172             : //________________________________________________________
     173             : Bool_t AliPMDPreprocessor::StorePmdGAIN()
     174             : {
     175           0 : TList* gfsPmdGain = GetFileSources(kDAQ, "PMDGAINS.root");
     176             : 
     177           0 : if(!gfsPmdGain)
     178             :     {
     179           0 :       Log(Form("PMDGAIN: No sources found for PMDGAINS.root!"));
     180           0 :       return kFALSE;
     181             :     }    
     182             :   else
     183             :     {
     184           0 :       AliInfo("PMDGAIN: Here's the list of sources for PMDGAINS.root");
     185           0 :       gfsPmdGain->Print();
     186             :       
     187           0 :       TIter iter(gfsPmdGain);
     188             :       TObjString* source;
     189           0 :       TString nameOfFile;
     190             :       UInt_t result = 0;
     191             :  
     192           0 :       while((source = dynamic_cast<TObjString*> (iter.Next())))
     193             :         {
     194           0 :           nameOfFile = GetFile(kDAQ, "PMDGAINS.root", source->GetName());
     195           0 :           if(nameOfFile.Length() == 0) 
     196             :             {
     197           0 :               Log(Form("PMDGAIN: Error retrieving file from source %s failed!", source->GetName()));
     198           0 :               delete gfsPmdGain;
     199           0 :               return kFALSE;
     200             :             }
     201             :           
     202           0 :           Log(Form("PMDGAIN: File with id PMDGAINS.root got from %s", source->GetName()));
     203             :           
     204           0 :           Int_t det, sm, row, col;
     205           0 :           Float_t gain;
     206             :           
     207           0 :           TFile *opnFile = new TFile(nameOfFile.Data());
     208           0 :           if (!opnFile || !opnFile->IsOpen()) 
     209             :             {
     210           0 :               Log(Form("PMDGAIN: Error opening file with Id PMDGAINS.root from source %s!", source->GetName()));
     211           0 :               return kFALSE;
     212             :             }
     213             :           
     214           0 :           TTree *tree = dynamic_cast<TTree *> (opnFile->Get("ic"));
     215           0 :           if (!tree) 
     216             :             {
     217           0 :               Log("PMDGAIN: Could not find object \"ic\" in DAQ file!");
     218           0 :               return kFALSE;
     219             :             }
     220             :           
     221           0 :           tree->SetBranchAddress("det",  &det);
     222           0 :           tree->SetBranchAddress("sm",   &sm);
     223           0 :           tree->SetBranchAddress("row",  &row);
     224           0 :           tree->SetBranchAddress("col",  &col);
     225           0 :           tree->SetBranchAddress("gain", &gain);
     226             :           
     227           0 :           Int_t nEntries = (Int_t) tree->GetEntries();
     228           0 :           AliPMDCalibData *calibda = new AliPMDCalibData();
     229             :           
     230           0 :           for(Int_t i = 0; i < nEntries; i++)
     231             :             {
     232           0 :               tree->GetEntry(i);
     233           0 :               calibda->SetGainFact(det,sm,row,col,gain);
     234             :             }
     235           0 :           opnFile->Close();
     236           0 :           delete opnFile;
     237             :           
     238           0 :           AliCDBMetaData mdGAIN;
     239           0 :           mdGAIN.SetBeamPeriod(0);
     240           0 :           mdGAIN.SetResponsible("Satyajit Jena");
     241           0 :           mdGAIN.SetComment("PMDGAIN: PMD GAIN Data");
     242           0 :           result = Store("Calib","Gain", calibda, &mdGAIN);
     243           0 :           delete calibda;
     244           0 :         }
     245             :       
     246           0 :       if (result==0)
     247             :         {
     248           0 :           Log("PMDGAIN: Error storing");                        
     249           0 :           return kFALSE;
     250             :         }
     251             :       else
     252             :         {
     253           0 :           return kTRUE;
     254             :         }
     255             :       
     256           0 :     }
     257           0 : }
     258             : 
     259             : 
     260             : //___________________________________________________
     261             : Bool_t AliPMDPreprocessor::StorePmdHOT()
     262             : {
     263             :   
     264           0 :   AliPMDHotData *hotda = new AliPMDHotData();
     265           0 :   TList* fsPmdHot = GetFileSources(kDAQ, "PMD_HOT.root");
     266             :   
     267           0 :   if(!fsPmdHot) 
     268             :     {
     269           0 :       Log(Form("PMDHOT: No sources found for PMD_HOT.root!"));
     270           0 :       return kFALSE;
     271             :     }
     272             :   else
     273             :     {
     274           0 :       AliInfo("PMDHOT: Here's the list of sources for PMD_HOT.root");
     275           0 :       fsPmdHot->Print();
     276             :       
     277           0 :       TIter iter(fsPmdHot);
     278             :       TObjString* source;
     279             :       UInt_t hotresult = 0;
     280           0 :       TString nameOfFile;
     281             : 
     282           0 :       while((source = dynamic_cast<TObjString*> (iter.Next())))
     283             :         {
     284           0 :           nameOfFile = GetFile(kDAQ, "PMD_HOT.root", source->GetName());
     285           0 :           if(nameOfFile.Length() == 0) 
     286             :             {
     287           0 :               Log(Form("PMDHOT: Error retrieving file from source %s failed!", source->GetName()));
     288           0 :               delete fsPmdHot;
     289           0 :               return kFALSE;
     290             :             }
     291             :           
     292           0 :           Log(Form("PMDHOT: File with id PMD_HOT.root got from %s", source->GetName()));
     293             :           
     294           0 :           Int_t det, sm, row, col;
     295           0 :           Float_t flag;
     296             :           
     297           0 :           TFile *opnFile = new TFile(nameOfFile.Data());
     298           0 :           if(!opnFile || !opnFile->IsOpen()) 
     299             :             {
     300           0 :               Log(Form("PMDHOT: Error opening file with Id PMD_HOT.root from source %s!", source->GetName()));
     301           0 :               return kFALSE;
     302             :             } 
     303             : 
     304           0 :           TTree *tree = dynamic_cast<TTree *> (opnFile->Get("hot"));
     305           0 :           if (!tree) 
     306             :             {
     307           0 :               Log("PMDHOT: Could not find object \"hot\" in DAQ file!");
     308           0 :               return kFALSE;
     309             :             }
     310             :           
     311           0 :           tree->SetBranchAddress("det",  &det);
     312           0 :           tree->SetBranchAddress("sm",   &sm);
     313           0 :           tree->SetBranchAddress("row",  &row);
     314           0 :           tree->SetBranchAddress("col",  &col);
     315           0 :           tree->SetBranchAddress("flag", &flag);
     316             :           
     317           0 :           Int_t nEntries = (Int_t) tree->GetEntries();
     318           0 :           for(Int_t j = 0; j < nEntries; j++)
     319             :             {
     320           0 :               tree->GetEntry(j);
     321           0 :               hotda->SetHotChannel(det,sm,row,col,flag);
     322             :             }
     323           0 :           opnFile->Close();
     324           0 :           delete opnFile;
     325           0 :         }
     326             :       
     327           0 :       AliCDBMetaData metaData;
     328           0 :       metaData.SetBeamPeriod(0);
     329           0 :       metaData.SetResponsible("Satyajit Jena");
     330           0 :       metaData.SetComment("PMDHOT: PMD preprocessor");
     331           0 :       hotresult = Store("Calib","Hot", hotda, &metaData);
     332           0 :       delete hotda;
     333           0 :       if(hotresult==0)
     334             :         {
     335           0 :           Log("PMDHOT: Error storing");                        
     336           0 :           return kFALSE;
     337             :         }
     338             :       else
     339             :         {
     340           0 :           return kTRUE;
     341             :         }
     342             :       
     343           0 :     }
     344           0 : }
     345             : 
     346             : //________________________________________________________
     347             : Bool_t AliPMDPreprocessor::StorePmdMEAN()
     348             : {
     349           0 :   AliPMDMeanSm *smmeanda = new AliPMDMeanSm();
     350           0 :   TList* gfsPmdMean = GetFileSources(kDAQ, "PMD_MEAN_SM.root");
     351             :   
     352           0 :   if(!gfsPmdMean) 
     353             :     {
     354           0 :       Log(Form("PMDMEAN: No sources found for PMD_MEAN_SM.root!"));
     355           0 :       return kFALSE;
     356             :     }
     357             :   else
     358             :     {
     359           0 :       AliInfo("PMDMEAN: Here's the list of sources for PMD_MEAN_SM.root");
     360           0 :       gfsPmdMean->Print();
     361             :       
     362           0 :       TIter iter(gfsPmdMean);
     363             :       TObjString* sourc;
     364             :       UInt_t storeMeanData = 0;
     365           0 :       TString filenam;
     366             :       
     367           0 :       while((sourc=dynamic_cast<TObjString*> (iter.Next())))
     368             :         {
     369           0 :           filenam = GetFile(kDAQ, "PMD_MEAN_SM.root", sourc->GetName());
     370           0 :           if(filenam.Length() == 0) 
     371             :             {
     372           0 :               Log(Form("PMDMEAN: Error retrieving file from source %s failed!", sourc->GetName()));
     373           0 :               delete gfsPmdMean;
     374           0 :               return kFALSE;
     375             :             }
     376             :           
     377           0 :           Log(Form("PMDMEAN: File with id PMD_MEAN_SM.root got from %s", sourc->GetName()));
     378             :           
     379           0 :           Int_t det = 0, sm = 0;
     380           0 :           Float_t smmean = 0.;
     381             :           
     382           0 :           TFile *opnFile = new TFile(filenam.Data());
     383           0 :           if(!opnFile || !opnFile->IsOpen()) 
     384             :             {
     385           0 :               Log(Form("PMDMEAN: Error opening file with Id PMD_MEAN_SM.root from source %s!", sourc->GetName()));
     386           0 :               return kFALSE;
     387             :             }
     388             :           
     389           0 :           TTree *tree = dynamic_cast<TTree *> (opnFile->Get("mean"));
     390           0 :           if (!tree) 
     391             :             {
     392           0 :               Log("PMDMEAN: Could not find object \"hot\" in DAQ file!");
     393           0 :               return kFALSE;
     394             :             }
     395             :           
     396           0 :           tree->SetBranchAddress("det",  &det);
     397           0 :           tree->SetBranchAddress("sm",   &sm);
     398           0 :           tree->SetBranchAddress("smmean", &smmean);
     399             :           
     400           0 :           Int_t nEntries = (Int_t) tree->GetEntries();
     401           0 :           for(Int_t j = 0; j < nEntries; j++)
     402             :             {
     403           0 :               tree->GetEntry(j);
     404           0 :               smmeanda->SetMeanSm(det,sm,smmean);
     405             :             }
     406           0 :           opnFile->Close();
     407           0 :           delete opnFile;
     408           0 :         }
     409             :       
     410           0 :       AliCDBMetaData mdMEAN;
     411           0 :       mdMEAN.SetBeamPeriod(0);
     412           0 :       mdMEAN.SetResponsible("Satyajit Jena");
     413           0 :       mdMEAN.SetComment("PMDMEAN: PMD preprocessor");
     414             :       
     415           0 :       storeMeanData = Store("Calib","SMMEAN", smmeanda, &mdMEAN);
     416           0 :       delete smmeanda;
     417             : 
     418           0 :       if(storeMeanData==0)
     419             :         {
     420           0 :           Log("PMDMEAN: Error storing");                        
     421           0 :           return kFALSE;
     422             :         }
     423             :       else
     424             :         {
     425           0 :           return kTRUE;
     426             :         }
     427           0 :     }
     428             :   
     429           0 : }
     430             : 
     431             : //_____________________________________________________________
     432             : Bool_t AliPMDPreprocessor::StorePmdDCS(TMap *sDaqAM)
     433             : {
     434             :         
     435           0 :   AliCDBMetaData mdDCS;
     436           0 :   mdDCS.SetResponsible("Satyajit Jena");
     437           0 :   mdDCS.SetComment("DCS data for PMD");
     438             : 
     439             :   Bool_t resStore = kFALSE;
     440           0 :   resStore = StoreReferenceData("DCS","Data",sDaqAM,&mdDCS);
     441             : 
     442           0 :   if(resStore == 0)
     443             :     {
     444           0 :       Log("PMDDP: Error storing");                        
     445           0 :       return kFALSE;
     446             :     }
     447             :   else
     448             :     {
     449           0 :       return kTRUE;
     450             :     }
     451             : 
     452           0 : }
     453             : 
     454             : //_____________________________________________________________________
     455             : 
     456             : UInt_t AliPMDPreprocessor::Process(TMap* pmdDaqAliasMap)
     457             : {
     458             :   
     459           0 :   if(!pmdDaqAliasMap)
     460             :     {
     461           0 :       return 1;
     462             :     }
     463             :   
     464           0 :   TString runType = GetRunType();
     465             : 
     466           0 :   if(runType == "PEDESTAL")
     467             :     {
     468             :  
     469           0 :       Log(Form("------------------ PMD Pedestal --------------"));
     470           0 :       Bool_t pmdPed = StorePmdPED();
     471           0 :       if(!pmdPed)
     472             :         {
     473           0 :           Log(Form("ERROR:  Couldn't write PMD pedestal file"));
     474           0 :           return 1;
     475             :         }
     476             :       else
     477             :         {
     478           0 :           Log(Form("Storing of PMD Pedestal File is Successful"));
     479           0 :           return 0;
     480             :         }
     481             :     } 
     482             :   
     483           0 :   else if (runType == "PHYSICS")
     484             :       {
     485           0 :         Log(Form("------------------- PMD GAIN----------------"));    
     486           0 :         Bool_t pmdGAIN = StorePmdGAIN();
     487           0 :         if (!pmdGAIN)
     488             :           {
     489           0 :             Log(Form("ERROR:  Couldn't write PMD GAIN file"));
     490             :            
     491             :           }
     492             :         else
     493             :           {
     494           0 :             Log(Form("Storing of PMD GAIN File is Successful"));
     495             :            
     496             :           }
     497             :         
     498           0 :         Log(Form("------------------- PMD HOT ----------------"));
     499           0 :         Bool_t pmdHOT = StorePmdHOT();
     500           0 :         if (!pmdHOT)
     501             :           {
     502           0 :             Log(Form("ERROR:  Couldn't write PMD HOT file"));
     503             :            
     504             :           }
     505             :         else
     506             :           {
     507           0 :             Log(Form("Storing of PMD HOT File is Successful"));
     508             :            
     509             :           }
     510             :         
     511           0 :         Log(Form("------------------- SM MEAN ----------------"));
     512           0 :         Bool_t pmdMEAN = StorePmdMEAN();
     513           0 :         if (!pmdMEAN)
     514             :           {
     515           0 :             Log(Form("ERROR:  Couldn't write PMD SM MEAN file"));
     516             :            
     517             :           }
     518             :         else
     519             :           {
     520           0 :             Log(Form("Storing of PMD SM MEAN File is Successful"));
     521             :            
     522             :           }
     523             :         
     524           0 :         Log(Form("------------------- DCS DP -----------------"));
     525           0 :         Bool_t pmdDCS = StorePmdDCS(pmdDaqAliasMap);
     526           0 :         if (!pmdDCS)
     527             :           {
     528           0 :             Log(Form("ERROR:  Couldn't write PMD DCS DP file"));
     529             :            
     530             :           }
     531             :         else
     532             :           {
     533           0 :             Log(Form("Storing of PMD DCS dp is Successul"));
     534             :            
     535             :           }
     536             :         
     537           0 :         if (pmdGAIN || pmdHOT || pmdMEAN || pmdDCS) 
     538           0 :           return 0;
     539             :         else 
     540           0 :           return 1;
     541             :         
     542             :       }
     543           0 :   return 2;
     544           0 : }
     545             : 
     546             : 

Generated by: LCOV version 1.11