LCOV - code coverage report
Current view: top level - ITS/ITSrec - AliITSPreprocessorSSD.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 99 1.0 %
Date: 2016-06-14 17:26:59 Functions: 1 5 20.0 %

          Line data    Source code
       1             : //
       2             : // Author: Enrico Fragiacomo
       3             : // Date: 13/10/2006
       4             : // 
       5             : // SHUTTLE preprocessing class for SSD calibration files
       6             : 
       7             : /* $Id$ */
       8             : 
       9             : #include "AliITSPreprocessorSSD.h"
      10             :  
      11             : #include "AliCDBMetaData.h"
      12             : #include "AliLog.h"
      13             : #include "TFile.h"
      14             : 
      15             : #include <TTimeStamp.h>
      16             : #include <TObjString.h>
      17             : 
      18             : #include "AliITSRawStreamSSD.h"
      19             : #include "AliITSNoiseSSDv2.h"
      20             : #include "AliITSPedestalSSDv2.h"
      21             : #include "AliITSBadChannelsSSDv2.h"
      22             : #include <Riostream.h>
      23             : 
      24             : 
      25             : const Int_t AliITSPreprocessorSSD::fgkNumberOfSSD = 1698;
      26             : 
      27         116 : ClassImp(AliITSPreprocessorSSD)
      28             : 
      29             : //-----------------------------------------------------------------------
      30             : AliITSPreprocessorSSD::AliITSPreprocessorSSD(AliShuttleInterface* shuttle) :
      31           0 :   AliPreprocessor("SSD", shuttle)
      32           0 : {
      33             :   // constructor
      34             : 
      35           0 :   AddRunType("ELECTRONICS_CALIBRATION_RUN");
      36           0 :   AddRunType("PEDESTAL");
      37           0 :   AddRunType("PHYSICS");
      38             : 
      39           0 : }
      40             : 
      41             : //______________________________________________________________________________________________
      42             : void AliITSPreprocessorSSD::Initialize(Int_t run, UInt_t startTime,
      43             :         UInt_t endTime)
      44             : {
      45             :   // initialize
      46             : 
      47           0 :   AliPreprocessor::Initialize(run, startTime, endTime);
      48             :   
      49           0 :   Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
      50           0 :                TTimeStamp(startTime).AsString(),
      51           0 :                TTimeStamp(endTime).AsString()));
      52             :   
      53           0 : }
      54             : 
      55             : //______________________________________________________________________________________________
      56             : UInt_t AliITSPreprocessorSSD::Process(TMap* /*dcsAliasMap*/)
      57             : {
      58             : 
      59             :   // Note. To be modified: dcsAliasMap is not needed but I can not get rid
      60             :   // of it unless the base class AliPreprocessor is modified accordingly.
      61             : 
      62             :   //  TObjArray calib_array(fgkNumberOfSSD); 
      63             :   //TObjArray badch_array(fgkNumberOfSSD); 
      64             :   //TObjArray ped_array(fgkNumberOfSSD); 
      65             :   //Float_t noise=0, gain=0;
      66             :   
      67             :   //---------------------------------------
      68             :   // initialize the calibration objects
      69           0 :   AliITSNoiseSSDv2 *calib = new AliITSNoiseSSDv2();
      70           0 :   AliITSBadChannelsSSDv2 *badch = new AliITSBadChannelsSSDv2();
      71           0 :   AliITSPedestalSSDv2 *pedel = new AliITSPedestalSSDv2();
      72             :   
      73           0 :   TString runType = GetRunType();
      74           0 :   if(runType == "ELECTRONICS_CALIBRATION_RUN") {
      75             :     
      76             :   }
      77           0 :   else if(runType == "PEDESTAL") {
      78             : 
      79           0 :     TList* list = GetFileSources(kDAQ, "CALIBRATION");
      80           0 :     if (list && list->GetEntries() > 0)
      81             :       {
      82           0 :         Log("The following sources produced files with the id CALIBRATION");
      83           0 :         list->Print();
      84             :         
      85             :         // create iterator over list of LDCs (provides list of TObjString)
      86           0 :         TIter next(list);
      87             :         TObjString *ok;
      88             :         
      89             :         // expect to iterate 3 times (LDC0, LDC1, LDC2)
      90           0 :         while ( (ok = (TObjString*) next()) ) {                               
      91             :           
      92           0 :           TString key = ok->String();
      93             :           
      94           0 :           TString fileName = GetFile(kDAQ, "CALIBRATION", key.Data());
      95           0 :           if (fileName.Length() > 0) {
      96             :             
      97           0 :             Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
      98             :             
      99           0 :             TFile *f = new TFile(fileName.Data());
     100           0 :             if(!f || !f->IsOpen()){
     101           0 :                 Log("Error opening file!");
     102           0 :                 delete list;
     103           0 :                 return 2;
     104             :             }
     105             :             
     106           0 :             AliITSNoiseSSDv2 *cal; 
     107           0 :             f->GetObject("AliITSNoiseSSDv2;1", cal); 
     108           0 :             if(!cal) {
     109           0 :                 Log("File does not contain expected data for the noise!");
     110           0 :                 delete list;
     111           0 :                 return 3;
     112             :             }       
     113           0 :             AliITSPedestalSSDv2 *ped;
     114           0 :             f->GetObject("AliITSPedestalSSDv2;1", ped); 
     115           0 :             if(!ped) {
     116           0 :                 Log("File does not contain expected data for the pedestals!");
     117           0 :                 delete list;
     118           0 :                 return 5;
     119             :             }       
     120           0 :             AliITSBadChannelsSSDv2 *bad;
     121           0 :             f->GetObject("AliITSBadChannelsSSDv2;1", bad); 
     122           0 :             if(!bad) {
     123           0 :                 Log("File does not contain expected data for bad channels  !");
     124           0 :                 delete list;
     125           0 :                 return 4;
     126             :             }       
     127             : 
     128           0 :             for(Int_t module=0; module<fgkNumberOfSSD; module++) {
     129           0 :               for(Int_t strip=0; strip<768; strip++) {
     130           0 :                 if(cal->GetNoiseP(module,strip)) 
     131           0 :                   calib->AddNoiseP(module,strip,cal->GetNoiseP(module,strip));
     132           0 :                 if(cal->GetNoiseN(module,strip)) 
     133           0 :                   calib->AddNoiseN(module,strip,cal->GetNoiseN(module,strip));
     134           0 :                 if(ped->GetPedestalP(module,strip)) 
     135           0 :                   pedel->AddPedestalP(module,strip,
     136           0 :                                       ped->GetPedestalP(module,strip));
     137           0 :                 if(ped->GetPedestalN(module,strip)) 
     138           0 :                   pedel->AddPedestalN(module,strip,
     139           0 :                                       ped->GetPedestalN(module,strip));
     140           0 :                 if(bad->GetBadChannelP(module,strip)) 
     141           0 :                   badch->AddBadChannelP(module,strip,
     142           0 :                                          bad->GetBadChannelP(module,strip));
     143           0 :                 if(bad->GetBadChannelN(module,strip)) 
     144           0 :                   badch->AddBadChannelN(module,strip,
     145           0 :                                          bad->GetBadChannelN(module,strip));
     146             :               }
     147             :             }
     148             : 
     149           0 :             f->Close(); delete f;        
     150             :                 
     151           0 :           } else {
     152           0 :                 Log("GetFile error!");
     153           0 :                 delete list;
     154           0 :                 return 6;
     155             :           } // if filename
     156           0 :         } // end iteration over LDCs
     157             :         
     158           0 :         delete list;
     159           0 :       } else {
     160           0 :           Log("GetFileSources error!");
     161           0 :           if(list) delete list;
     162           0 :           return 7;
     163             :       } // if list
     164             :     
     165             :     //Now we have to store the final CDB file
     166           0 :     AliCDBMetaData metaData;
     167           0 :     metaData.SetBeamPeriod(0);
     168           0 :     metaData.SetResponsible("Enrico Fragiacomo");
     169           0 :     metaData.SetComment("Fills noise, pedestal and bad channels TObjArray");
     170             :     
     171           0 :       if(!Store("Calib", "NoiseSSD", (TObject *)calib, &metaData, 0, 1)) {
     172           0 :         Log("no store");
     173           0 :         return 1;
     174             :       }  
     175             :       
     176           0 :       if(!Store("Calib", "BadChannelsSSD", (TObject*)badch, &metaData, 0, 1)) {
     177           0 :         Log("no store");
     178           0 :         return 1;
     179             :       }  
     180             :       
     181           0 :       if(!StoreReferenceData("Ref","PedestalSSD",  (TObject*)pedel, &metaData)) {
     182           0 :         Log("no store");
     183           0 :         return 1;
     184             :       }
     185             :          
     186           0 :   } // end if pedestal run
     187             :   else {
     188           0 :     Log("Nothing to do");
     189           0 :     return 0;
     190             :   }
     191             :   
     192           0 :   Log("Database updated");
     193           0 :   return 0; // 0 means success
     194             : 
     195           0 : }
     196             : 

Generated by: LCOV version 1.11