LCOV - code coverage report
Current view: top level - MUON/MUONrec - AliMUONTrackerConditionDataMaker.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 296 0.3 %
Date: 2016-06-14 17:26:59 Functions: 1 20 5.0 %

          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             : // $Id$
      17             : 
      18             : #include "AliMUONTrackerConditionDataMaker.h"
      19             : 
      20             : ///\class AliMUONTrackerConditionDataMaker
      21             : ///
      22             : /// Producer of AliMUONVTrackerData from OCDB or Ascii file condition data
      23             : ///
      24             : /// \author Laurent Aphecetche, Subatech
      25             : 
      26             : ///\cond CLASSIMP
      27          18 : ClassImp(AliMUONTrackerConditionDataMaker)
      28             : ///\endcond
      29             : 
      30             : #include "AliCDBManager.h"
      31             : #include "AliCDBStorage.h"
      32             : #include "AliDCSValue.h"
      33             : #include "AliLog.h"
      34             : #include "AliMpArrayI.h"
      35             : #include "AliMpConstants.h"
      36             : #include "AliMpDCSNamer.h"
      37             : #include "AliMpDDLStore.h"
      38             : #include "AliMpDEManager.h"
      39             : #include "AliMpDetElement.h"
      40             : #include "AliMpManuIterator.h"
      41             : #include "AliMUON2DMap.h"
      42             : #include "AliMUONCalibParamND.h"
      43             : #include "AliMUONCalibParamNF.h"
      44             : #include "AliMUONCalibParamNI.h"
      45             : #include "AliMUONCalibrationData.h"
      46             : #include "AliMUONDigitCalibrator.h"
      47             : #include "AliMUONPadStatusMaker.h"
      48             : #include "AliMUONPadStatusMapMaker.h"
      49             : #include "AliMUONRejectList.h"
      50             : #include "AliMUONTrackerData.h"
      51             : #include "AliMUONTrackerDataSourceTypes.h"
      52             : #include "AliMUONTrackerIO.h"
      53             : #include "Riostream.h"
      54             : #include "TClass.h"
      55             : #include "TMap.h"
      56             : #include "TObjString.h"
      57             : #include "TString.h"
      58             : #include "TSystem.h"
      59             : #include <sstream>
      60             : 
      61             : //_____________________________________________________________________________
      62             : AliMUONTrackerConditionDataMaker::AliMUONTrackerConditionDataMaker():
      63           0 : AliMUONVTrackerDataMaker(),
      64           0 : fData(0x0),
      65           0 : fSource(""),
      66           0 : fIsOwnerOfData(kTRUE)
      67           0 : {
      68             :   /// default ctor to be able to stream
      69           0 : }
      70             : 
      71             : //_____________________________________________________________________________
      72             : AliMUONTrackerConditionDataMaker::AliMUONTrackerConditionDataMaker(Int_t runNumber, const char* ocdbPath, const char* type):
      73           0 : AliMUONVTrackerDataMaker(),
      74           0 : fData(0x0),
      75           0 : fSource(Form("%s-%010d-%s",ocdbPath,runNumber,type)),
      76           0 : fIsOwnerOfData(kTRUE)
      77           0 : {
      78             :   /// ctor from OCDB
      79             : 
      80           0 :   AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
      81             : 
      82           0 :         AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
      83             : 
      84           0 :   Int_t startOfValidity;
      85             : 
      86           0 :   if ( AliMUONTrackerDataSourceTypes::IsRejectList(type) )
      87             :   {
      88           0 :     AliMUONRejectList* rl = AliMUONCalibrationData::CreateRejectList(runNumber,&startOfValidity);
      89             : 
      90           0 :     if (rl)
      91             :     {
      92           0 :       fData = new AliMUONTrackerData(Form("RL%d",startOfValidity),"RejectList",*rl);
      93           0 :     }
      94             : 
      95           0 :     delete rl;
      96           0 :   }
      97             :   else
      98             :   {
      99           0 :     AliMUONVStore* store = CreateStore(runNumber,ocdbPath,type,startOfValidity);
     100             : 
     101           0 :     AliDebug(1,Form("runNumber=%d ocdbPath=%s type=%s startOfValidity=%d store=%p",
     102             :                     runNumber,ocdbPath,type,startOfValidity,store));
     103           0 :     if ( store )
     104             :     {
     105           0 :       fData = CreateData(type,*store,startOfValidity);
     106           0 :     }
     107             : 
     108           0 :     AliDebug(1,Form("runNumber=%d ocdbPath=%s type=%s startOfValidity=%d store=%p",
     109             :                     runNumber,ocdbPath,type,startOfValidity,store));
     110             : 
     111           0 :     delete store;
     112             :   }
     113             : 
     114           0 :   if ( fData )
     115             :   {
     116           0 :     TString shortName(fData->GetName());
     117           0 :     TString cdbPath(ocdbPath);
     118             : 
     119           0 :     shortName = type;
     120             : 
     121           0 :     shortName += Form("%d",startOfValidity);
     122             : 
     123           0 :     shortName += "(";
     124             : 
     125           0 :     if ( cdbPath.Contains("cvmfs/alice") )
     126             :     {
     127           0 :       shortName += "cvmfs";
     128             :     }
     129           0 :     else if ( cdbPath.BeginsWith("alien") && cdbPath.Contains("/alice/data") )
     130             :     {
     131           0 :       shortName += "alien";
     132             :     }
     133           0 :     else if ( cdbPath.BeginsWith("alien") && cdbPath.Contains("user") )
     134             :     {
     135           0 :       shortName.ReplaceAll("/alice.cern.ch/user/","...");
     136             :     }
     137             :     else
     138             :     {
     139           0 :       shortName += cdbPath;
     140             :     }
     141             : 
     142           0 :     shortName += ")";
     143             : 
     144             : 
     145           0 :     fData->SetName(shortName);
     146           0 :   }
     147             : 
     148           0 :   AliCDBManager::Instance()->SetDefaultStorage(storage);
     149           0 : }
     150             : 
     151             : //_____________________________________________________________________________
     152             : AliMUONTrackerConditionDataMaker::AliMUONTrackerConditionDataMaker(const char* filename, const char* type):
     153           0 : AliMUONVTrackerDataMaker(),
     154           0 : fData(0x0),
     155           0 : fSource(Form("%s-%s",filename,type)),
     156           0 : fIsOwnerOfData(kTRUE)
     157           0 : {
     158             :   /// ctor from an ASCII file
     159             : 
     160           0 :   TString sFilename(gSystem->ExpandPathName(filename));
     161             : 
     162           0 :   std::ifstream in(sFilename.Data());
     163           0 :   if (in.good())
     164             :   {
     165           0 :     std::ostringstream stream;
     166           0 :     char line[1024];
     167           0 :     while ( in.getline(line,1024) )
     168             :     {
     169           0 :       stream << line << "\n";
     170             :     }
     171             : 
     172           0 :     in.close();
     173             : 
     174           0 :     Int_t dummy;
     175             : 
     176           0 :     AliMUONVStore* store = CreateStore(-1,stream.str().c_str(),type,dummy);
     177             : 
     178           0 :     if ( store )
     179             :     {
     180           0 :       fData = CreateData(type,*store,dummy);
     181           0 :     }
     182           0 :     delete store;
     183           0 :   }
     184           0 : }
     185             : 
     186             : //_____________________________________________________________________________
     187             : AliMUONTrackerConditionDataMaker::AliMUONTrackerConditionDataMaker(const char* data, const char* type, Bool_t) :
     188           0 : AliMUONVTrackerDataMaker(),
     189           0 : fData(0x0),
     190           0 : fSource(Form("direct-%s",type)),
     191           0 : fIsOwnerOfData(kTRUE)
     192             : 
     193           0 : {
     194             :   /// ctor from a string containing the ASCII data
     195             :   /// the last parameter is there just to distinguish this ctor from the previous one
     196             : 
     197           0 :   Int_t dummy;
     198             : 
     199           0 :   AliMUONVStore* store = CreateStore(-1,data,type,dummy);
     200             : 
     201           0 :   if ( store )
     202             :   {
     203           0 :     fData = CreateData(type,*store,dummy);
     204           0 :   }
     205           0 :   delete store;
     206             : 
     207           0 : }
     208             : 
     209             : //_____________________________________________________________________________
     210             : AliMUONTrackerConditionDataMaker::~AliMUONTrackerConditionDataMaker()
     211           0 : {
     212             :   /// dtor
     213           0 :   if ( fIsOwnerOfData ) delete fData;
     214           0 : }
     215             : 
     216             : 
     217             : //_____________________________________________________________________________
     218             : AliMUONVTrackerData*
     219             : AliMUONTrackerConditionDataMaker::CreateData(const char* type, AliMUONVStore& store, Int_t startOfValidity)
     220             : {
     221             :   /// Create the data source
     222             :   AliMUONVTrackerData* data(0x0);
     223             : 
     224           0 :   if ( AliMUONTrackerDataSourceTypes::IsConfig(type ) )
     225             :   {
     226           0 :     data = new AliMUONTrackerData(Form("%s%d",AliMUONTrackerDataSourceTypes::ShortNameForConfig(),startOfValidity),"Configuration",1);
     227           0 :     data->SetDimensionName(0,"there");
     228           0 :     data->DisableChannelLevel();
     229           0 :   }
     230           0 :   else if ( AliMUONTrackerDataSourceTypes::IsHV(type) )
     231             :   {
     232           0 :     data = new AliMUONTrackerData(Form("%s%d",AliMUONTrackerDataSourceTypes::ShortNameForHV(),startOfValidity),"High Voltages",1); //,!isSingleEvent);
     233           0 :                 data->SetDimensionName(0,"HV");
     234           0 :   }
     235           0 :   else if ( AliMUONTrackerDataSourceTypes::IsLV(type) )
     236             :   {
     237           0 :     data = new AliMUONTrackerData(Form("%s%d",AliMUONTrackerDataSourceTypes::ShortNameForLV(),startOfValidity),"Low Voltages",3); //,!isSingleEvent);
     238           0 :                 data->SetDimensionName(0,"ann"); // analog negative
     239           0 :     data->SetDimensionName(1,"dig"); // digital
     240           0 :     data->SetDimensionName(2,"anp"); // analog positive
     241           0 :   }
     242           0 :   else if ( AliMUONTrackerDataSourceTypes::IsOccupancy(type) )
     243             :   {
     244           0 :     data = new AliMUONTrackerData(Form("%s%d",AliMUONTrackerDataSourceTypes::ShortNameForOccupancy(),startOfValidity),"OccupancyMap",store);
     245           0 :     data->SetDimensionName(0,"One");
     246           0 :     return data; // important to return now to avoid the data->Add(store) later on...
     247             :   }
     248           0 :   else if ( AliMUONTrackerDataSourceTypes::IsPedestals(type) )
     249             :   {
     250           0 :     data  = new AliMUONTrackerData(Form("%s%d",AliMUONTrackerDataSourceTypes::ShortNameForPedestals(),startOfValidity),"Pedestals",2,kTRUE);
     251           0 :     data->SetDimensionName(0,"Mean");
     252           0 :     data->SetDimensionName(1,"Sigma");
     253           0 :   }
     254           0 :   else if ( AliMUONTrackerDataSourceTypes::IsStatus(type) )
     255             :   {
     256           0 :     data = new AliMUONTrackerData(Form("%s%d",AliMUONTrackerDataSourceTypes::ShortNameForStatus(),startOfValidity),"Status",1,kTRUE);
     257           0 :     data->SetDimensionName(0,"Bits");
     258           0 :   }
     259           0 :   else if ( AliMUONTrackerDataSourceTypes::IsStatusMap(type) )
     260             :   {
     261           0 :     data = new AliMUONTrackerData(Form("%s%d",AliMUONTrackerDataSourceTypes::ShortNameForStatusMap(),startOfValidity),"Status map",2,kTRUE);
     262           0 :     data->SetDimensionName(0,"Bits");
     263           0 :     data->SetDimensionName(1,"Dead");
     264           0 :   }
     265             : 
     266           0 :   if (!data)
     267             :   {
     268           0 :     AliErrorClass(Form("Could not create data for type=%s",type));
     269           0 :     return 0x0;
     270             :   }
     271             : 
     272           0 :   data->Add(store);
     273             : 
     274           0 :   return data;
     275           0 : }
     276             : 
     277             : //_____________________________________________________________________________
     278             : AliMUONVStore*
     279             : AliMUONTrackerConditionDataMaker::CreateHVStore(TMap& m)
     280             : {
     281             :   /// Create a store from hv values
     282             : 
     283           0 :   AliMUONVStore* store = new AliMUON2DMap(kTRUE);
     284             : 
     285           0 :   TIter next(&m);
     286             :   TObjString* s;
     287           0 :   AliMpDCSNamer hvNamer("TRACKER");
     288             : 
     289           0 :   while ( ( s = static_cast<TObjString*>(next()) ) )
     290             :   {
     291           0 :     TString name(s->String());
     292             : 
     293           0 :     Int_t hvIndex = hvNamer.DCSIndexFromDCSAlias(name.Data());
     294             : 
     295           0 :     Int_t detElemId = hvNamer.DetElemIdFromDCSAlias(name.Data());
     296             : 
     297           0 :     if ( hvIndex >= 0 && detElemId < 0 )
     298             :     {
     299             :       // skip switches
     300           0 :       continue;
     301             :     }
     302             : 
     303           0 :     if ( !AliMpDEManager::IsValidDetElemId(detElemId) )
     304             :     {
     305           0 :       AliErrorClass(Form("Got an invalid DE = %d from alias = %s",
     306             :                          detElemId,name.Data()));
     307           0 :       continue;
     308             :     }
     309             : 
     310           0 :     Int_t nPCBs = hvNamer.NumberOfPCBs(detElemId);
     311           0 :     Int_t indexMin = nPCBs ? 0 : hvIndex;
     312           0 :     Int_t indexMax = nPCBs ? nPCBs : hvIndex+1;
     313             : 
     314           0 :     AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
     315             : 
     316           0 :     for ( int i = indexMin ; i < indexMax; ++i )
     317             :     {
     318             :       Float_t switchValue(1.0);
     319             : 
     320           0 :       if ( nPCBs )
     321             :       {
     322           0 :         TString switchName(hvNamer.DCSSwitchAliasName(detElemId,i));
     323             : 
     324           0 :         TPair* p = static_cast<TPair*>(m.FindObject(switchName.Data()));
     325           0 :         TObjArray* a = static_cast<TObjArray*>(p->Value());
     326             : 
     327           0 :         switchValue = AliMUONPadStatusMaker::SwitchValue(*a);
     328           0 :       }
     329             : 
     330           0 :       const AliMpArrayI* manus = de->ManusForHV(i);
     331             : 
     332           0 :       if (!manus) continue;
     333             : 
     334           0 :       TPair* p = static_cast<TPair*>(m.FindObject(name.Data()));
     335           0 :       TObjArray* a = static_cast<TObjArray*>(p->Value());
     336           0 :       TIter n2(a);
     337             :       AliDCSValue* v;
     338             :       Float_t hvValue(0);
     339             :       Int_t n(0);
     340             :       Int_t noff(0);
     341             : 
     342           0 :       while ( ( v = static_cast<AliDCSValue*>(n2()) ) )
     343             :       {
     344           0 :         hvValue += v->GetFloat();
     345           0 :         if ( v->GetFloat() < AliMpDCSNamer::TrackerHVOFF() ) ++noff;
     346           0 :         ++n;
     347             :       }
     348           0 :       hvValue *= switchValue;
     349             : 
     350           0 :       if ( n ) hvValue /= n;
     351             : 
     352           0 :       if (noff>0 && noff<n)
     353             :       {
     354             :         // that's a trip
     355             :         hvValue = -1.0;
     356           0 :       }
     357             : 
     358           0 :       Int_t nofChannels(AliMpConstants::ManuNofChannels());
     359             : 
     360           0 :       for ( Int_t k = 0 ; k < manus->GetSize(); ++k )
     361             :       {
     362           0 :         Int_t manuId = manus->GetValue(k);
     363           0 :         AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(store->FindObject(detElemId,manuId));
     364           0 :         if ( ! param )
     365             :         {
     366           0 :           param = new AliMUONCalibParamND(1,nofChannels,detElemId,manuId,0);
     367           0 :           store->Add(param);
     368             :         }
     369           0 :         for ( Int_t j = 0 ; j < nofChannels; ++j )
     370             :         {
     371           0 :           param->SetValueAsDouble(j,0,hvValue);
     372             :         }
     373             :       }
     374           0 :     }
     375           0 :   }
     376             : 
     377             :   return store;
     378             : 
     379           0 : }
     380             : 
     381             : //_____________________________________________________________________________
     382             : AliMUONVStore*
     383             : AliMUONTrackerConditionDataMaker::CreateLVStore(TMap& m)
     384             : {
     385             :   /// Create a store from low voltage values
     386             : 
     387           0 :   AliMUONVStore* store = new AliMUON2DMap(kTRUE);
     388             : 
     389           0 :   TIter next(&m);
     390             :   TObjString* s;
     391           0 :   AliMpDCSNamer hvNamer("TRACKER");
     392             : 
     393           0 :   while ( ( s = static_cast<TObjString*>(next()) ) )
     394             :   {
     395           0 :     TString name(s->String());
     396             : 
     397             :     Int_t index(0);
     398             : 
     399           0 :     if ( name.Contains("ann") ) index = 0;
     400           0 :     if ( name.Contains("dig") ) index = 1;
     401           0 :     if ( name.Contains("anp") ) index = 2;
     402             : 
     403           0 :     Int_t* detElemId(0x0);
     404           0 :     Int_t numberOfDetectionElements;
     405           0 :     AliMp::PlaneType planeType;
     406             : 
     407           0 :     hvNamer.DecodeDCSMCHLVAlias(name.Data(), detElemId, numberOfDetectionElements, planeType);
     408             : 
     409           0 :     if (planeType != AliMp::kBendingPlane)
     410             :     {
     411           0 :       std::cout << "cool " << detElemId[0] << std::endl;
     412             :     }
     413             :     // compute the value to be associated with that alias : either the mean
     414             :     // or zero if a trip is detected
     415             :     Float_t lvValue(0.0);
     416             : 
     417           0 :     TPair* p = static_cast<TPair*>(m.FindObject(name.Data()));
     418           0 :     TObjArray* a = static_cast<TObjArray*>(p->Value());
     419           0 :     TIter n2(a);
     420             :     AliDCSValue* v;
     421             :     Int_t n(0);
     422             :     Int_t noff(0);
     423             : 
     424           0 :     while ( ( v = static_cast<AliDCSValue*>(n2()) ) )
     425             :     {
     426           0 :       lvValue += v->GetFloat();
     427           0 :       if ( v->GetFloat() < AliMpDCSNamer::TrackerLVOFF() ) ++noff;
     428           0 :       ++n;
     429             :     }
     430             : 
     431           0 :     if ( n ) lvValue /= n;
     432             : 
     433           0 :     if (noff>0 && noff<n)
     434             :     {
     435             :       // that's a trip
     436             :       lvValue = -1.0;
     437           0 :     }
     438             : 
     439           0 :     Int_t nofChannels(AliMpConstants::ManuNofChannels());
     440             : 
     441             :     // now assign this LV value to all the manus of the relevant plane(s)
     442             :     // of the detection element(s)
     443             : 
     444           0 :     for ( int i = 0; i < numberOfDetectionElements; ++i )
     445             :     {
     446           0 :       AliMpManuIterator manuIterator;
     447           0 :       Int_t de, manuId;
     448             : 
     449             :       //std::cout << Form("DE %04d planeType %d value %g",detElemId[i],planeType,lvValue) << std::endl;
     450             : 
     451           0 :       while (manuIterator.Next(de,manuId))
     452             :       {
     453           0 :         if ( de != detElemId[i] ) continue;
     454           0 :         if ( de < 500 )
     455             :         {
     456           0 :           if ( planeType == AliMp::kNonBendingPlane &&
     457           0 :              ( ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) ) == 0 ) ) continue;
     458           0 :              if ( planeType == AliMp::kBendingPlane &&
     459           0 :                 ( ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) ) != 0 ) ) continue;
     460             :         }
     461           0 :         AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(store->FindObject(de,manuId));
     462           0 :         if ( ! param )
     463             :         {
     464           0 :           param = new AliMUONCalibParamND(3,nofChannels,de,manuId,0);
     465           0 :           store->Add(param);
     466             :         }
     467           0 :         for ( Int_t j = 0 ; j < nofChannels; ++j )
     468             :         {
     469           0 :           param->SetValueAsDouble(j,index,lvValue);
     470             :         }
     471             :       }
     472             : 
     473           0 :     }
     474           0 :     delete[] detElemId;
     475           0 :   }
     476             : 
     477             :   return store;
     478           0 : }
     479             : 
     480             : //_____________________________________________________________________________
     481             : AliMUONVStore*
     482             : AliMUONTrackerConditionDataMaker::CreateStatusStore(Int_t runNumber)
     483             : {
     484             :   /// Get the status store
     485             : 
     486           0 :   AliMUONDigitCalibrator calibrator(runNumber);
     487             : 
     488           0 :   AliMUONVStore* sm = new AliMUON2DMap(kTRUE);
     489             : 
     490           0 :   AliMpManuIterator it;
     491           0 :   Int_t detElemId, manuId;
     492             : 
     493           0 :   while (it.Next(detElemId,manuId))
     494             :   {
     495           0 :     AliMUONVCalibParam* np = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),detElemId,manuId);
     496           0 :     for ( Int_t i = 0; i < np->Size(); ++i )
     497             :     {
     498           0 :       Int_t value = calibrator.PadStatus(detElemId,manuId,i);
     499           0 :       np->SetValueAsInt(i,0,value); // "raw" value of the status
     500             :     }
     501           0 :     sm->Add(np);
     502             :   }
     503             : 
     504             :   return sm;
     505           0 : }
     506             : 
     507             : //_____________________________________________________________________________
     508             : AliMUONVStore*
     509             : AliMUONTrackerConditionDataMaker::CreateStatusMapStore(Int_t runNumber)
     510             : {
     511             :   /// Get the status map, and polish it a bit for representation purposes
     512             : 
     513           0 :   AliMUONDigitCalibrator calibrator(runNumber);
     514             : 
     515           0 :   AliMUONVStore* sm = new AliMUON2DMap(kTRUE);
     516             : 
     517           0 :   AliMpManuIterator it;
     518           0 :   Int_t detElemId, manuId;
     519             : 
     520           0 :   while (it.Next(detElemId,manuId))
     521             :   {
     522           0 :     AliMUONVCalibParam* np = new AliMUONCalibParamNI(2,AliMpConstants::ManuNofChannels(),detElemId,manuId);
     523           0 :     for ( Int_t i = 0; i < np->Size(); ++i )
     524             :     {
     525           0 :       Int_t value = calibrator.StatusMap(detElemId,manuId,i);
     526           0 :       Int_t channelIsDead = ( value & AliMUONPadStatusMapMaker::SelfDeadMask() );
     527           0 :       np->SetValueAsInt(i,0,value); // "raw" value of the status map
     528           0 :       np->SetValueAsInt(i,1,channelIsDead); // simple 0 or 1 for this channel
     529             :     }
     530           0 :     sm->Add(np);
     531             :   }
     532             : 
     533             :   return sm;
     534           0 : }
     535             : 
     536             : //_____________________________________________________________________________
     537             : AliMUONVStore*
     538             : AliMUONTrackerConditionDataMaker::CreateStore(Int_t runNumber,
     539             :                                               const char* source,
     540             :                                               const char* type,
     541             :                                               Int_t& startOfValidity)
     542             : {
     543             :   /// Create the store by reading it from OCDB or from an ASCII file
     544             : 
     545             :   AliMUONVStore* store(0x0);
     546             : 
     547           0 :   startOfValidity = 0;
     548             : 
     549           0 :   Bool_t ocdb = (runNumber>=0);
     550             : 
     551           0 :   if ( AliMUONTrackerDataSourceTypes::IsConfig(type) )
     552             :   {
     553             :     AliMUONVStore* tmp(0x0);
     554           0 :     if ( ocdb )
     555             :     {
     556           0 :       tmp = AliMUONCalibrationData::CreateConfig(runNumber,&startOfValidity);
     557           0 :     }
     558             :     else
     559             :     {
     560           0 :       tmp = new AliMUON2DMap(kTRUE);
     561           0 :       AliMUONTrackerIO::DecodeConfig(source,*tmp);
     562             :     }
     563           0 :     if ( tmp )
     564             :     {
     565           0 :       store = ExpandConfig(*tmp);
     566           0 :     }
     567           0 :     delete tmp;
     568           0 :   }
     569           0 :   else if ( AliMUONTrackerDataSourceTypes::IsOccupancy(type) )
     570             :   {
     571           0 :     if ( ocdb )
     572             :     {
     573           0 :       store = AliMUONCalibrationData::CreateOccupancyMap(runNumber,&startOfValidity);
     574           0 :       if (store) store = static_cast<AliMUONVStore*>(store->Clone());
     575             :     }
     576             :     else
     577             :     {
     578           0 :       store = new AliMUON2DMap(kTRUE);
     579           0 :       AliMUONTrackerIO::DecodeOccupancy(source,*store);
     580             :     }
     581             :   }
     582           0 :   else if ( AliMUONTrackerDataSourceTypes::IsPedestals(type) )
     583             :   {
     584           0 :     if ( ocdb )
     585             :     {
     586           0 :       store = AliMUONCalibrationData::CreatePedestals(runNumber,&startOfValidity);
     587           0 :     }
     588             :     else
     589             :     {
     590           0 :       store = new AliMUON2DMap(kTRUE);
     591           0 :       AliMUONTrackerIO::DecodePedestals(source,*store);
     592             :     }
     593             :   }
     594             : 
     595             :   /// Below are source that can only be accessed from OCDB
     596           0 :   if (!store && !ocdb)
     597             :   {
     598           0 :     return 0x0;
     599             :   }
     600             : 
     601           0 :   if ( AliMUONTrackerDataSourceTypes::IsHV(type) )
     602             :   {
     603           0 :     TMap* m = AliMUONCalibrationData::CreateHV(runNumber,&startOfValidity);
     604           0 :                 store = CreateHVStore(*m);
     605           0 :     delete m;
     606           0 :   }
     607           0 :   if ( AliMUONTrackerDataSourceTypes::IsLV(type) )
     608             :   {
     609           0 :     TMap* m = AliMUONCalibrationData::CreateLV(runNumber,&startOfValidity);
     610           0 :                 store = CreateLVStore(*m);
     611           0 :     delete m;
     612           0 :   }
     613           0 :   else if ( AliMUONTrackerDataSourceTypes::IsStatus(type) )
     614             :   {
     615           0 :     store = CreateStatusStore(runNumber);
     616           0 :   }
     617           0 :   else if ( AliMUONTrackerDataSourceTypes::IsStatusMap(type) )
     618             :   {
     619           0 :     store = CreateStatusMapStore(runNumber);
     620           0 :   }
     621             : 
     622           0 :   return store;
     623           0 : }
     624             : 
     625             : //_____________________________________________________________________________
     626             : AliMUONVStore*
     627             : AliMUONTrackerConditionDataMaker::ExpandConfig(const AliMUONVStore& manuConfig)
     628             : {
     629             :   /// Convert the config from manu level to channel level (just to
     630             :   /// be able to add it correctly to the trackerdata...)
     631             : 
     632           0 :   AliMUONVStore* store = manuConfig.Create();
     633             : 
     634           0 :   TIter next(manuConfig.CreateIterator());
     635             :   AliMUONVCalibParam* p;
     636             : 
     637           0 :   while ( ( p = static_cast<AliMUONVCalibParam*>(next()) ) )
     638             :   {
     639           0 :     AliMUONVCalibParam* c = new AliMUONCalibParamNF(1,AliMpConstants::ManuNofChannels(),p->ID0(),p->ID1(),0.0);
     640             : 
     641           0 :     AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(p->ID0());
     642             : 
     643           0 :     for ( Int_t i = 0; i < c->Size(); ++i )
     644             :     {
     645           0 :       if ( de->IsExistingChannel(p->ID1(),i) )
     646             :       {
     647           0 :         c->SetValueAsFloat(i,0,1.0);
     648             :       }
     649             :     }
     650             : 
     651           0 :     store->Add(c);
     652             :   }
     653             :   return store;
     654           0 : }
     655             : 
     656             : //_____________________________________________________________________________
     657             : Long64_t
     658             : AliMUONTrackerConditionDataMaker::Merge(TCollection*)
     659             : {
     660             :   /// Merge
     661           0 :   AliError("Not implemented. Does it have sense ?");
     662           0 :   return 0;
     663             : }

Generated by: LCOV version 1.11