Bool_t RecoParamWithTPCDistortions(AliCDBManager *man) { // check methods exist if (!AliRecoParam::Class()->GetMethodAny("SuggestRunEventSpecie")) return kFALSE; if (!AliTPCRecoParam::Class()->GetMethodAny("GetUseCorrectionMap")) return kFALSE; // get event specie from GRP AliCDBEntry *grpe = man->Get("GRP/GRP/Data"); if (!grpe) return kFALSE; AliGRPObject *grp = (AliGRPObject *)grpe->GetObject(); AliRecoParam::EventSpecie_t evs = AliRecoParam::SuggestRunEventSpecie(grp->GetRunType(), grp->GetBeamType(), grp->GetLHCState()); // get TPC RecoParam for event specie AliCDBEntry *pare = man->Get("TPC/Calib/RecoParam"); if (!pare) return kFALSE; TObjArray *parl = (TObjArray *)pare->GetObject(); AliTPCRecoParam *par = NULL; for (Int_t i = parl->GetEntriesFast(); i--;) { AliTPCRecoParam *p = (AliTPCRecoParam *)parl->UncheckedAt(i); if (!p || !(p->GetEventSpecie() & evs)) continue; par = p; break; } // check if use correction map if (!par->GetUseCorrectionMap()) return kFALSE; return kTRUE; }
Bool_t ChangeRunRange(const char* objectPath, int run1=0, int run2=AliCDBRunRange::Infinity(), const char* inputOCDB="alien://folder=/alice/data/2013/OCDB", const char* outputOCDB="alien://folder=/alice/cern.ch/user/l/laphecet/OCDB2013") { AliCDBManager* man = AliCDBManager::Instance(); man->SetDefaultStorage(inputOCDB); AliCDBEntry* e = man->Get(objectPath,AliCDBRunRange::Infinity()); if (!e) { cout << Form("ERROR : could not get %s from %s",objectPath,inputOCDB) << endl; return kFALSE; } e->GetId().SetRunRange(run1,run2); AliCDBMetaData* md = e->GetMetaData(); md->SetResponsible("L. Aphecetche and P. Pillot"); // to insure we have no $Id$ in the metadata fields (see https://savannah.cern.ch/bugs/?95527) man->SetDefaultStorage(outputOCDB); return man->Put(e->GetObject(),e->GetId(),e->GetMetaData()); }
//_________________________________________________________________________________________________ void GetTimeRange(Int_t runNumber, time_t& start, time_t& end) { AliCDBManager::Instance()->SetRun(runNumber); AliCDBEntry* e = AliCDBManager::Instance()->Get("GRP/GRP/Data"); AliGRPObject* grp = static_cast<AliGRPObject*>(e->GetObject()); start = grp->GetTimeStart(); end = grp->GetTimeEnd(); TDatime dstart(start); TDatime dend(end); dstart.Set(dstart.GetYear(),dstart.GetMonth(),dstart.GetDay(),dstart.GetHour(),0,0); dend.Set(dend.GetYear(),dend.GetMonth(),dend.GetDay(),dend.GetHour()+1,0,0); std::cout << TDatime(start).AsString() << std::endl; std::cout << TDatime(end).AsString() << std::endl; std::cout << dstart.AsString() << std::endl; std::cout << dend.AsString() << std::endl; start = dstart.Convert(kFALSE); end = dend.Convert(kFALSE); }
void PrintAlignment() { AliCDBManager* cdb = AliCDBManager::Instance(); cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); AliCDBEntry* align = cdb->Get("FMD/Align/Data"); if (!align) { Error("PrintAlignment","didn't alignment data from CDB"); return; } TClonesArray* array = dynamic_cast<TClonesArray*>(align->GetObject()); if (!array) { Warning("PrintAlignement", "Invalid align data from CDB"); return; } Int_t nAlign = array->GetEntries(); for (Int_t i = 0; i < nAlign; i++) { AliAlignObjParams* a = static_cast<AliAlignObjParams*>(array->At(i)); Double_t ang[3]; Double_t trans[3]; a->GetAngles(ang); a->GetTranslation(trans); std::cout << a->GetVolPath() << "\n" << " translation: " << "(" << std::setw(12) << trans[0] << "," << std::setw(12) << trans[1] << "," << std::setw(12) << trans[2] << ")\n" << " rotation: " << "(" << std::setw(12) << ang[0] << "," << std::setw(12) << ang[1] << "," << std::setw(12) << ang[2] << ")" << std::endl; // a->Print(); } }
Float_t SetEnergyFromGRP() { AliCDBEntry *cdbe = AliCDBManager::Instance()->Get("GRP/GRP/Data"); AliGRPObject *grpd = dynamic_cast<AliGRPObject*>(cdbe->GetObject()); return (grpd->GetBeamEnergy() * 2.); }
void DefaultSpecificStorage(AliCDBManager *man, Int_t mode) { AliCDBEntry *cdbe = man->Get("GRP/GRP/Data"); if (!cdbe) return NULL; AliGRPObject *grp = (AliGRPObject *)cdbe->GetObject(); TDatime date = grp->GetTimeStart(); Int_t year = date.GetYear(); const Char_t *Raw = Form("alien://Folder=/alice/data/%d/OCDB", year); const Char_t *Ideal = "alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/"; const Char_t *Residual = "alien://Folder=/alice/simulation/2008/v4-15-Release/Residual/"; const Char_t *Full = "alien://Folder=/alice/simulation/2008/v4-15-Release/Full/"; // for AD hack const Char_t *Raw2015 = "alien://Folder=/alice/data/2015/OCDB"; // DEFAULT SPECIFIC OBJECTS const Char_t *SpecificStorageList[][3] = { // path sim rec // // ITS "ITS/Align/Data", Ideal, Residual, // ok "ITS/Calib/SPDSparseDead", Full, Residual, // ok ? // TPC "TPC/Calib/ClusterParam", Ideal, Residual, // ok! "TPC/Calib/RecoParam", Residual, Residual, // ok! "TPC/Calib/TimeGain", Ideal, Residual, // ok! "TPC/Calib/Correction", Ideal, Residual, // ok! // MUON "MUON/Align/Data", Full, NULL, // ok! // ZDC "ZDC/Align/Data", Ideal, Ideal, // ok "ZDC/Calib/Pedestals", Ideal, Ideal // added (11.12.2017) }; const Int_t nSpecificStorages = sizeof(SpecificStorageList) / (3 * sizeof(Char_t *)); // set specific storages for (Int_t isto = 0; isto < nSpecificStorages; isto++) { if (SpecificStorageList[isto][mode+1]) { printf("Setting specific storage: %s -> %s\n", SpecificStorageList[isto][0], SpecificStorageList[isto][mode+1]); man->SetSpecificStorage(SpecificStorageList[isto][0], SpecificStorageList[isto][mode+1]); } } // EXTRA SPECIFIC OBJECTS IF NO DISTORTIONS if (!RecoParamWithTPCDistortions(man)) { printf("Not using TPC distortions, need extra specific storages\n"); NoDistortionSpecificStorage(man, mode); } // Run-1 settings if (year < 2015) { man->SetSpecificStorage("AD/Calib/QAParam", Raw2015); const Char_t *muonHack[2] = {Ideal, Residual}; man->SetSpecificStorage("MUON/Align/Data", muonHack[mode]); } }
void PatchCDB(const char* runlist, const char* runlist1400, const char* srcOCDBPath="alien://folder=/alice/data/2016/OCDB", const char* destOCDBPath="alien://folder=/alice/cern.ch/user/l/laphecet/OCDBCH3L") { // function to patch the OCDB MUON/Calib/HV for the swap of CH3L Q2S1 and Q2S2 // runlist = full list of runs where Chamber03Left/Quad2Sect1 has an HV problem (trips, too low, plus the 1400 V // below) // runlist1400 = list of runs where Chamber03Left/Quad2Sect1 was struggling at 1400 V // for the runs in runlist1400, the HV will be forced to zero for that sector // note that Chamber03Left/Quad2Sect1 = Chamber02Left/Quad1Sect0 in DCS alias world AliAnalysisTriggerScalers ts(runlist,srcOCDBPath); std::vector<int> vrunlist = ts.GetRunList(); AliAnalysisTriggerScalers ts1400(runlist1400,srcOCDBPath); std::vector<int> vrunlist1400 = ts1400.GetRunList(); AliCDBManager* man = AliCDBManager::Instance(); TObjString sector2("MchHvLvLeft/Chamber02Left/Quad1Sect0.actual.vMon"); TObjString sector1("MchHvLvLeft/Chamber02Left/Quad1Sect1.actual.vMon"); for ( auto r : vrunlist ) { man->SetDefaultStorage(srcOCDBPath); man->SetRun(r); std::cout << "Run " << r << std::endl; AliCDBEntry* entry = man->Get("MUON/Calib/HV"); TMap* hvmap = static_cast<TMap*>(entry->GetObject()->Clone()); TPair* p1 = hvmap->RemoveEntry(§or2); if ( std::find(vrunlist1400.begin(),vrunlist1400.end(),r) != vrunlist1400.end() ) { TObjArray* a1 = static_cast<TObjArray*>(p1->Value()); AliDCSValue* first = static_cast<AliDCSValue*>(a1->First()); AliDCSValue* last = static_cast<AliDCSValue*>(a1->Last()); a1->Delete(); a1->Add(new AliDCSValue(0.0f,first->GetTimeStamp())); a1->Add(new AliDCSValue(0.0f,last->GetTimeStamp())); } TPair* p2 = hvmap->RemoveEntry(§or1); hvmap->Add(new TObjString(sector2),p2->Value()); hvmap->Add(new TObjString(sector1),p1->Value()); delete p1->Key(); delete p2->Key(); man->SetDefaultStorage(destOCDBPath); hvmap->SetUniqueID( hvmap->GetUniqueID() | ( 1 << 9 ) ); AliMUONCDB::WriteToCDB(hvmap,"MUON/Calib/HV",r,r,"Patched for CH3L Quad2Sect1 vs 0 swapping","L. Aphecetche"); man->ClearCache(); } }
//______________________________________________________________________________ void ChangeRecoParam(Int_t startRun,const char* fromURI,const char* toURI) { AliCDBManager::Instance()->SetDefaultStorage(fromURI); AliCDBManager::Instance()->SetRun(startRun); AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam"); AliMpCDB::LoadAll(); if (!entry) return; TObject* o = entry->GetObject(); if (!o) { cout << "Could not get recoparams ? Oups" << endl; return; } if ( o->IsA() != TObjArray::Class() ) { cout << "This code only works with TObjArray recoparams. Sorry" << endl; return; } TObjArray* array = static_cast<TObjArray*>(o); for ( Int_t i = 0; i <= array->GetLast(); ++i ) { AliDetectorRecoParam* p = static_cast<AliDetectorRecoParam*>(array->At(i)); // if (AliRecoParam::Convert(p->GetEventSpecie())==AliRecoParam::kLowMult) // { // cout << Form("array[%d]=%s %s %s",i, // p ? p->ClassName() : "", // p ? AliRecoParam::GetEventSpecieName(AliRecoParam::Convert(p->GetEventSpecie())) :"", // p ? ( p->IsDefault() ? "default" : "") : "" ) << endl; // p->Print(""); AliMUONRecoParam* rp = dynamic_cast<AliMUONRecoParam*>(p); if (!rp) { cout << "OUPS. OUPS" << endl; return; } // rp->SetHVLimit(2,1580); UInt_t mask = rp->PadGoodnessMask(); mask |= ( (1<<7) << 24 ); rp->SetPadGoodnessMask(mask); rp->Print(""); } AliCDBManager::Instance()->SetDefaultStorage(toURI); AliMUONCDB::WriteToCDB(array, "MUON/Calib/RecoParam", startRun, AliCDBRunRange::Infinity(), "reconstruction parameters for MUON, patched to take into account the bit for bus patch removed online by PAR", "L. Aphecetche"); }
void makeDecalibCDB(Int_t firstRun, Int_t lastRun, Float_t decalib = 0.065) { //Generates a random decalibration factors O(1) //to be applied in the anchor run simulations with raw:// . //If decalib<0, no decalibration generated, all factors=1. //Run range is [firstRun,lastRun] and gaussian sigma = decalib. //Author: Boris Polishchuk. AliCDBManager::Instance()->SetDefaultStorage("raw://"); AliCDBManager::Instance()->SetRun(firstRun); TString emcPath("PHOS/Calib/EmcGainPedestals"); AliCDBEntry* entryEmc = AliCDBManager::Instance()->Get(emcPath.Data(),-1); AliPHOSEmcCalibData* clb=0; if(entryEmc) clb = (AliPHOSEmcCalibData*)entryEmc->GetObject(); else { printf("CDB entry not found. Exit.\n"); return; } if(!clb) { printf("Calibration parameters for PHOS EMC not found.\n"); return; } printf("\t\tEMC calibration object found: FirstRun=%d LastRun=%d Version=%d SubVersion=%d\n", entryEmc->GetId().GetFirstRun(), entryEmc->GetId().GetLastRun(), entryEmc->GetId().GetVersion(),entryEmc->GetId().GetSubVersion()); TRandom rn; rn.SetSeed(0); //the seed is set to the current machine clock Float_t adcChannelEmc; for(Int_t module=1; module<6; module++) { for(Int_t column=1; column<57; column++) { for(Int_t row=1; row<65; row++) { if(decalib<0.) adcChannelEmc = 1.; else adcChannelEmc =rn.Gaus(1.,decalib); clb->SetADCchannelEmcDecalib(module,column,row,adcChannelEmc); } } } AliCDBManager::Instance()->SetDefaultStorage("local://./"); AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage(); AliCDBMetaData *md = new AliCDBMetaData(); AliCDBId id(emcPath.Data(),firstRun,lastRun); storage->Put(clb,id, md); }
TMap* ReadDCSAliasMap() { // Open a file that contains DCS input data // The CDB framework is used to open the file, this means the file is located // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data // The file contains an AliCDBEntry that contains a TMap with the DCS structure. // An explanation of the structure can be found in CreateDCSAliasMap() AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) ->Get("DET/DCS/Data", 0); return dynamic_cast<TMap*> (entry->GetObject()); }
//______________________________________________________________________________ void ChangeRecoParam(Int_t startRun=195767,const char* outputOCDB="alien://folder=/alice/cern.ch/user/l/laphecet/OCDB") { AliCDBManager::Instance()->SetDefaultStorage("raw://"); AliCDBManager::Instance()->SetRun(99999999); AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam"); if (!entry) return; TObject* o = entry->GetObject(); if (!o) { cout << "Could not get recoparams ? Oups" << endl; return; } if ( o->IsA() != TObjArray::Class() ) { cout << "This code only works with TObjArray recoparams. Sorry" << endl; return; } TObjArray* array = static_cast<TObjArray*>(o); for ( Int_t i = 0; i <= array->GetLast(); ++i ) { AliDetectorRecoParam* p = static_cast<AliDetectorRecoParam*>(array->At(i)); if (AliRecoParam::Convert(p->GetEventSpecie())==AliRecoParam::kLowMult) { cout << Form("array[%d]=%s %s %s",i, p ? p->ClassName() : "", p ? AliRecoParam::GetEventSpecieName(AliRecoParam::Convert(p->GetEventSpecie())) :"", p ? ( p->IsDefault() ? "default" : "") : "" ) << endl; p->Print(""); AliMUONRecoParam* rp = dynamic_cast<AliMUONRecoParam*>(p); if (!rp) { cout << "OUPS. OUPS" << endl; return; } rp->SetHVLimit(1,-99999); rp->SetPadGoodnessMask(0x400be93); rp->Print(""); } } AliCDBManager::Instance()->SetDefaultStorage(outputOCDB); AliMUONCDB::WriteToCDB(array, "MUON/Calib/RecoParam", startRun, AliCDBRunRange::Infinity(), "reconstruction parameters for MUON, patched for event size limits (for DQM)", "L. Aphecetche"); }
AliTOFTriggerMask * ReadCDBEntryTriggerMask(Int_t run, const Char_t *defaultStorage = "raw://", const Char_t *specificStorage = NULL) { AliCDBManager *cdb = AliCDBManager::Instance(); cdb->SetDefaultStorage(defaultStorage); if (specificStorage) cdb->SetSpecificStorage("TRIGGER/TOF/TriggerMask", specificStorage); cdb->SetRun(run); AliCDBEntry *cdbe = cdb->Get("TRIGGER/TOF/TriggerMask"); AliTOFTriggerMask *triggerMaskObj = (AliTOFTriggerMask *)cdbe->GetObject(); return triggerMaskObj; }
//______________________________________________________________________________ void ChangeConfig(Int_t startRun, const char* fromURI,const char* toURI) { AliCDBManager::Instance()->SetDefaultStorage(fromURI); AliCDBManager::Instance()->SetRun(startRun); AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/Config"); AliMpCDB::LoadAll(); if (!entry) return; TObject* o = entry->GetObject(); if (!o) { cout << "Could not get config ? Oups" << endl; return; } AliMUONVStore* config = static_cast<AliMUONVStore*>(o); AliMUONVStore* newConfig = static_cast<AliMUONVStore*>(config->Create()); TIter next(config->CreateIterator()); AliMUONVCalibParam* p; while ( ( p = static_cast<AliMUONVCalibParam*>(next()))) { Int_t detElemId = p->ID0(); Int_t manuId = p->ID1(); Int_t bpid = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId); AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(bpid); if ( bpid == 301 ) continue; if ( bpid == 302 ) continue; if ( bpid == 303 ) continue; if ( bpid == 313 ) continue; if ( bpid == 314 ) continue; if ( bpid == 315 ) continue; newConfig->Add(p->Clone()); } AliCDBManager::Instance()->SetDefaultStorage(toURI); AliMUONCDB::WriteToCDB(newConfig, "MUON/Calib/Config", startRun, startRun, "Config for MUON, patched for test removal of bus patches 301,302,303 L. Aphecetche"); }
//__________________________________________________________ void AliTRDCheckPedestal(const Int_t runNr){ // Establish grid connection if(!TGrid::Connect("alien://")){printf("F-No grid connection\n");return;} // Set the storage to the OCDB of this runNr. It will be like // alien://folder=/alice/data/2016/OCDB AliCDBManager *man = AliCDBManager::Instance(); man->SetDefaultStorageFromRun(runNr); // We derive the reference storage from it const AliCDBStorage *stor = man->GetDefaultStorage(); TString folder = stor->GetBaseFolder(); folder.ReplaceAll("OCDB","Reference"); man->SetDefaultStorage(Form("alien://folder=%s",folder.Data())); // Set the run number man->SetRun(runNr); // We abuse the folder name to derive the year TString yearString(folder); yearString.ReplaceAll("/alice/data/",""); yearString.ReplaceAll("/Reference/",""); const Int_t year = yearString.Atoi(); printf("W-Experimental: Derived year %d from storage folder\n",year); // The reference data is stored per Local Data Concentrator std::vector<Int_t> LDCvec = GetLDCVector(year); // Loop over LDCs for(std::vector<Int_t>::iterator LDCit = LDCvec.begin();LDCit!=LDCvec.end();LDCit++){ const TString padstatus = Form("TRD/DAQData/PadStatus%d",*LDCit); AliCDBEntry *entry = AliCDBManager::Instance()->Get(padstatus.Data()); AliTRDCalibPadStatus *calpadstatus = dynamic_cast<AliTRDCalibPadStatus *>(entry->GetObject()); if(!calpadstatus){printf("E-Can not find %s in %s \n",padstatus.Data(),folder.Data());continue;} //Create the noise pad with the RMS values of each channel AliTRDCalPad *noisePad = calpadstatus->CreateCalPad(); // LDC -> SM mapping std::vector<Int_t> SMvec = GetSMVector(year,*LDCit); for(std::vector<Int_t>::iterator SMit=SMvec.begin();SMit!=SMvec.end();SMit++){ const TString padstatussm = Form("PadNoise-LDC%d-SM%02d",*LDCit,*SMit); TCanvas *cpadstatusm = new TCanvas(padstatussm.Data(),padstatussm.Data(),50,50,600,800); cpadstatusm->Divide(3,2); // Draw each layer (or here plane) const Float_t zRange[2]={0.,0.2}; for(Int_t iLayer = 0;iLayer<6;iLayer++){ cpadstatusm->cd(iLayer+1); noisePad->MakeHisto2DSmPl(*SMit,iLayer,0,0,zRange[0],zRange[1],-1)->Draw("colz"); } cpadstatusm->SaveAs(Form("%s.pdf",cpadstatusm->GetName())); } // Loop over SMs of this LDC } // End of loop over LDCs } // End of void AliTRDcheckPedestal
//______________________________________________________________________________ void ChangeITSRecoParam(Int_t startRun=157560,const char* outputOCDB="alien://folder=/alice/cern.ch/user/l/laphecet/OCDB") { AliCDBManager::Instance()->SetDefaultStorage("raw://"); AliCDBManager::Instance()->SetRun(startRun); AliCDBEntry* entry = AliCDBManager::Instance()->Get("ITS/Calib/RecoParam"); if (!entry) return; TObject* o = entry->GetObject(); if (!o) { cout << "Could not get recoparams ? Oups" << endl; return; } if ( o->IsA() != TObjArray::Class() ) { cout << "This code only works with TObjArray recoparams. Sorry" << endl; return; } TObjArray* array = static_cast<TObjArray*>(o); for ( Int_t i = 0; i <= array->GetLast(); ++i ) { AliDetectorRecoParam* p = static_cast<AliDetectorRecoParam*>(array->At(i)); if (AliRecoParam::Convert(p->GetEventSpecie())==AliRecoParam::kLowMult) { cout << Form("array[%d]=%s %s %s",i, p ? p->ClassName() : "", p ? AliRecoParam::GetEventSpecieName(AliRecoParam::Convert(p->GetEventSpecie())) :"", p ? ( p->IsDefault() ? "default" : "") : "" ) << endl; AliITSRecoParam* rp = dynamic_cast<AliITSRecoParam*>(p); if (!rp) { cout << "OUPS. OUPS" << endl; return; } rp->SetVertexer(4); // should be fast (i.e. MC) vertexer (an enum would be better for sure) } } AliCDBManager::Instance()->SetDefaultStorage(outputOCDB); AliMUONCDB::WriteToCDB(array, "ITS/Calib/RecoParam", startRun, AliCDBRunRange::Infinity(), "reconstruction parameters for ITS, patched for fake vertex finder", "L. Aphecetche"); }
ReadRecoParam(const Int_t runNumber) { // Read the array of PHOS recoparam objects from OCDB and // print its content to stdout AliCDBManager::Instance()->SetDefaultStorage("raw://"); AliCDBManager::Instance()->SetRun(runNumber); AliCDBEntry* cdbEntry = AliCDBManager::Instance()->Get("PHOS/Calib/RecoParam"); AliCDBMetaData *md = cdbEntry->GetMetaData(); printf("Responsible: %s\n",md->GetResponsible()); printf("MD Comment : %s\n",md->GetComment()); TObjArray* arrayRecoParam = (TObjArray*)cdbEntry->GetObject(); AliPHOSRecoParam *rp = 0; for (Int_t i=0; i<arrayRecoParam->GetEntries(); i++) { rp = (AliPHOSRecoParam*)arrayRecoParam->At(i); printf("Recoparam %d: event specie = %d\n", i,rp->GetEventSpecie()); printf("\tEMCClusteringThreshold = %g\n",rp->GetEMCClusteringThreshold()); printf("\tEMCLocalMaxCut = %g\n",rp->GetEMCLocalMaxCut()); printf("\tEMCRawDigitThreshold = %g\n",rp->GetEMCRawDigitThreshold()); printf("\tEMCMinE = %g\n",rp->GetEMCMinE()); printf("\tEMCLogWeight = %g\n",rp->GetEMCLogWeight()); printf("\tEMCSampleQualityCut = %g\n",rp->GetEMCSampleQualityCut()); printf("\tEMCEcoreRadius = %g\n",rp->GetEMCEcoreRadius()); printf("\tEMCEcore2ESD = %d\n",rp->EMCEcore2ESD()); printf("\tEMCSubtractPedestals = %d\n",rp->EMCSubtractPedestals()); printf("\tEMCToUnfold = %d\n",rp->EMCToUnfold()); printf("\tEMCfitter version = %s\n",rp->EMCFitterVersion()); printf("\tEMCEnergyCorrectionOn = %d\n",rp->GetEMCEnergyCorrectionOn()); printf("\tGlobalAltroOffset = %f\n",rp->GetGlobalAltroOffset()); printf("\tGlobalAltroThreshold = %d\n",rp->GetGlobalAltroThreshold()); printf("\tTimeGateAmpThresh = %g\n",rp->GetTimeGateAmpThresh()); printf("\tTimeGateLow = %g\n",rp->GetTimeGateLow()); printf("\tTimeGateHigh = %g\n",rp->GetTimeGateHigh()); printf("\tNonlinearityCorrectionVersion = %s\n",rp->GetNonlinearityCorrectionVersion()); } }
UpdateRecoParam(const Int_t runNumber) { // Read the array of PHOS recoparam objects from OCDB and update // EMC fitter version to "v4". // Write the updated object to OCDB. // Yuri Kharlov. 9.12.2011 // /* $Id$ */ AliCDBManager::Instance()->SetDefaultStorage("raw://"); AliCDBManager::Instance()->SetRun(runNumber); AliCDBEntry* cdbEntry = AliCDBManager::Instance()->Get("PHOS/Calib/RecoParam"); AliCDBMetaData *md = cdbEntry->GetMetaData(); cout << "Responsible: " << md->GetResponsible() << endl; cout << "MD Comment : " << md->GetComment() << endl; TObjArray* arrayRecoParam = (TObjArray*)cdbEntry->GetObject(); cout << "N recoparam = " << arrayRecoParam->GetEntries() << endl; AliPHOSRecoParam *rp = 0; for (Int_t i=0; i<arrayRecoParam->GetEntries(); i++) { rp = (AliPHOSRecoParam*)arrayRecoParam->At(i); printf("RP %d: event specie = %d, fitter version = %s\n", i,rp->GetEventSpecie(),rp->EMCFitterVersion()); rp->SetEMCFitterVersion("v4"); } // Writing new recoparam to OCDB AliCDBManager* cdb = AliCDBManager::Instance(); cdb->SetDefaultStorage("local://OCDB"); AliCDBMetaData *md= new AliCDBMetaData(); md->SetResponsible("Yuri Kharlov"); md->SetComment("PHOS recoparameters: EMC fitter version is updated to v4"); AliCDBId id("PHOS/Calib/RecoParam",167690,AliCDBRunRange::Infinity()); cdb->Put(arrayRecoParam,id, md); }
void getT0RecoParam(Int_t run) { // Read calibration coefficients into the Calibration DB // Arguments: AliCDBManager* man = AliCDBManager::Instance(); man->SetDefaultStorage("raw://"); // man->SetDefaultStorage("local:///home/alla/alice/Jul14/OCDB/"); man->SetRun(run); AliCDBEntry *entry = AliCDBManager::Instance()->Get("T0/Calib/RecoParam"); AliT0RecoParam* recoParam = 0x0; cout<<" entry "<< entry<<endl; if(entry) { // load recoParam according OCDB content (single or array) // if (!(recoParam = dynamic_cast<AliT0RecoParam*>(entry->GetObject()))) { TObjArray* recoParamArray = static_cast<TObjArray*>(entry->GetObject()); cout<<" TObjArray* recoParamArray "<<recoParamArray->GetEntriesFast()<<endl; for(Int_t ie = 0; ie < recoParamArray->GetEntriesFast()-1; ie++) { recoParam = static_cast<AliT0RecoParam*>(recoParamArray->UncheckedAt(ie)); cout<<ie<<endl; cout<<" eq "<<recoParam->GetEq()<<endl; // recoParam->Dump(); cout<<" cfd range "<<recoParam->GetLow(300)<<" amplitude "<<recoParam->GetLow(200)<<" "<<recoParam->GetHigh(200)<<endl; for (int i=0; i<500; i++) if( recoParam->GetLow(i) !=0) cout<<i<<" low "<<recoParam->GetLow(i)<<" "<<endl; for (int i=0; i<500; i++) if( recoParam->GetHigh(i) !=50000) cout<<i<<" high "<<recoParam->GetHigh(i)<<endl; recoParam = 0x0; } } else cout<<" no entry "<<endl; }
void MakeAllDETsFullMisAlignment(Char_t* CDBstorage = "local://$HOME/FullMisAlignment", Bool_t partialGeom=kFALSE){ // Make full misalignment objects for all detectors // Pass different "CDBstorage" argument if needed (e.g. to fill // conditions' data base on alien) or set it to null string to have // the objects saved locally on file // This macro defines the default name and place for the detector-macros // in charge of producing the full misalignment objects as // $ALICE_ROOT/DET/MakeDETFullMisAlignment.C // const char* macroname="MakeAllDETsFullMisAlignment.C"; TString strStorage(CDBstorage); if(strStorage.IsNull()){ gSystem->Setenv("TOCDB","kFALSE"); }else{ gSystem->Setenv("TOCDB","kTRUE"); gSystem->Setenv("STORAGE",strStorage.Data()); gSystem->Setenv("ARVERSION",ALIROOT_VERSION); } if(partialGeom){ gSystem->Setenv("REALSETUP","kTRUE"); }else{ gSystem->Setenv("REALSETUP","kFALSE"); } // Load geometry from CDB updating it if we are producing the // alignment objects for the CDB AliCDBManager* cdb = AliCDBManager::Instance(); if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); cdb->SetRun(0); if(strStorage.IsNull()){ //if we produce the objects into a file AliGeomManager::LoadGeometry(); //load geom from default CDB storage }else{ // if we produce the objects in a CDB storage // update geometry in it Info(macroname,"Updating geometry in CDB storage %s",strStorage.Data()); gROOT->ProcessLine(".L $ALICE_ROOT/GRP/UpdateCDBIdealGeom.C"); if(partialGeom){ UpdateCDBIdealGeom(strStorage.Data(),"$ALICE_ROOT/macros/Config_PDC06.C"); }else{ UpdateCDBIdealGeom(strStorage.Data(),"$ALICE_ROOT/macros/Config.C"); } // load the same geometry from given CDB storage AliCDBPath path("GRP","Geometry","Data"); AliCDBStorage* storage = cdb->GetStorage(strStorage.Data()); AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun()); if(!entry) Fatal(macroname,"Couldn't load geometry data from CDB!"); entry->SetOwner(0); TGeoManager* geom = (TGeoManager*) entry->GetObject(); if (!geom) Fatal(macroname,"Couldn't find TGeoManager in the specified CDB entry!"); AliGeomManager::SetGeometry(geom); } // run macro for non-sensitive modules // (presently generates only FRAME alignment objects) gSystem->Exec("aliroot -b -q $ALICE_ROOT/GRP/MakeSTRUCTFullMisAlignment.C"); // run macros for sensitive modules TString sModules="ACORDE,EMCAL,FMD,HMPID,ITS,MUON,PMD,PHOS,T0,TRD,TPC,TOF,VZERO,ZDC"; TObjArray *detArray = sModules.Tokenize(','); TIter iter(detArray); TObjString *ostr; TString exec_det_macro; while((ostr = (TObjString*) iter.Next())){ TString str(ostr->String()); exec_det_macro="aliroot -b -q $ALICE_ROOT/"; exec_det_macro+=str; exec_det_macro+="/Make"; exec_det_macro+=str; exec_det_macro+="FullMisAlignment.C"; gSystem->Exec(exec_det_macro.Data()); } return; }
//_____________________________________________________________________________ void readCDB (TObject *task1, Int_t runNumber) { Float_t zero_timecdb[24]={0}; Float_t *timecdb = zero_timecdb; Float_t cfdvalue[24][5]; for(Int_t i=0; i<24; i++) for (Int_t i0=0; i0<5; i0++) cfdvalue[i][i0] = 0; Float_t zero_shiftcdb[4]={0}; Float_t *shiftcdb = zero_shiftcdb; AliT0CalibOffsetChannelsTask *mytask = (AliT0CalibOffsetChannelsTask*)task1; AliCDBManager* man = AliCDBManager::Instance(); AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming"); if (!entry) ::Fatal("AddTaskT0Calib", "CTP timing parameters are not found in OCDB !"); AliCTPTimeParams *ctpParams = (AliCTPTimeParams*)entry->GetObject(); Float_t l1Delay = (Float_t)ctpParams->GetDelayL1L0()*25.0; AliCDBEntry *entry1 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign"); if (!entry1) ::Fatal("AddTaskT0Calib", "CTP time-alignment is not found in OCDB !"); AliCTPTimeParams *ctpTimeAlign = (AliCTPTimeParams*)entry1->GetObject(); l1Delay += ((Float_t)ctpTimeAlign->GetDelayL1L0()*25.0); AliCDBEntry *entry4 = AliCDBManager::Instance()->Get("GRP/Calib/LHCClockPhase"); if (!entry4) ::Fatal("AddTaskT0Calib", "LHC clock-phase shift is not found in OCDB !"); AliLHCClockPhase *phase = (AliLHCClockPhase*)entry4->GetObject(); Float_t fGRPdelays = l1Delay - phase->GetMeanPhase(); AliCDBEntry* entryGRP = AliCDBManager::Instance()->Get("GRP/GRP/Data"); AliGRPObject* grpData = dynamic_cast<AliGRPObject*>(entryGRP->GetObject()); if (!grpData) { ::Error("AddTaskT0Calib","Failed to get GRP data for run %d",runNumber); return; } TString LHCperiod = grpData->GetLHCPeriod(); Bool_t isLHC10b = LHCperiod.Contains("LHC10b"); Bool_t isLHC10c = LHCperiod.Contains("LHC10c"); // AliCDBEntry* entryGRP = AliCDBManager::Instance()->Get("GRP/GRP/Data"); // AliGRPObject* grpData = dynamic_cast<AliGRPObject*>(entryGRP->GetObject()); UInt_t timeStart = grpData->GetTimeStart(); UInt_t timeEnd = grpData->GetTimeEnd(); mytask->SetStartEndTime(timeStart,timeEnd); cout<<"T0 start time "<<timeStart<<" end time "<<timeEnd<<endl; ::Info("AddTaskT0Calib","LHCperiod:%s ---> isLHC10b:%d isLHC10c:%d", LHCperiod.Data(),(Int_t)isLHC10b, (Int_t)isLHC10c); if(isLHC10b || isLHC10c) mytask-> SetRefPMT(12,2); AliCDBEntry *entryCalib0 = man->Get("T0/Calib/Latency"); if(!entryCalib0) { ::Error("AddTastT0Calib","Cannot find any AliCDBEntry for [Calib, Latency]!"); return; } AliT0CalibLatency *calibda=(AliT0CalibLatency*)entryCalib0->GetObject(); Float_t fLatencyL1 = calibda->GetLatencyL1(); Float_t fLatencyHPTDC = calibda->GetLatencyHPTDC(); AliCDBEntry *entryCalib1 = man->Get("T0/Calib/TimeDelay"); if(!entryCalib1) { ::Error("AddTaskT0Calib","Cannot find any AliCDBEntry for [Calib, TimeDelay]!"); return; } else { AliT0CalibTimeEq *clb = (AliT0CalibTimeEq*)entryCalib1->GetObject(); timecdb = clb->GetTimeEq(); for(Int_t i=0; i<24; i++) for (Int_t i0=0; i0<5; i0++){ cfdvalue[i][i0] = clb->GetCFDvalue(i, i0); } } for (Int_t i=0; i<24; i++) { Float_t cfdmean = cfdvalue[i][0]; if( cfdvalue[i][0] < 500 || cfdvalue[i][0] > 50000) cfdmean = ( 1000.*fLatencyHPTDC - 1000.*fLatencyL1 + 1000.*fGRPdelays)/24.4; mytask->SetCFDvalue(i, cfdmean); mytask->SetTimeEq(i, timecdb[i]); } AliCDBEntry *entryCalib2 = man->Get("T0/Calib/TimeAdjust"); if(!entryCalib2) { ::Error("AddTaskT0Calib","Cannot find any AliCDBEntry for [Calib, TimeAdjust]!"); } else { AliT0CalibSeasonTimeShift *clb1 = (AliT0CalibSeasonTimeShift*)entryCalib2->GetObject(); shiftcdb = clb1->GetT0Means(); } for (Int_t i=0; i<4; i++) mytask->SetT0Means(i,shiftcdb[i]); }
/// /// Main method /// /// \param year: year to set geometry and run range /// \param printAll: verbosity checks /// void SetOCDBFromRun1(Int_t year = 2010, Bool_t printAll = kFALSE) { TGrid::Connect("alien://"); Int_t run = 182325; //2012 if(year == 2010) run = 134908; if(year == 2011) run = 159582; AliCDBManager* man = AliCDBManager::Instance(); man->SetDefaultStorage("raw://"); man->SetRun(run); AliCDBStorage *storage = man->GetDefaultStorage(); // Instantiate EMCAL geometry for the first time AliEMCALGeometry * geom; if (year == 2010) geom = AliEMCALGeometry::GetInstance("EMCAL_FIRSTYEARV1"); // 2010 else geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1"); // 2011-2012-2013 //else geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETE12SMV1_DCAL_8SM"); // Run2 const Int_t nSM = geom->GetNumberOfSuperModules(); // Get the final OCDB object AliEMCALCalibData* cparam = (AliEMCALCalibData*) (storage->Get("EMCAL/Calib/Data", run)->GetObject()); // Access OCDB file with the first version of the calibration TString first = "Run177115_999999999_v2_s0.root"; if(year==2010) first = "Run113461_999999999_v3_s0.root"; if(year==2011) first = "Run144484_999999999_v3_s0.root"; TFile * f = TFile::Open(Form("alien:///alice/data/%d/OCDB/EMCAL/Calib/Data/%s",year,first.Data()),"READ"); AliCDBEntry * cdb = (AliCDBEntry*) f->Get("AliCDBEntry"); AliEMCALCalibData* cparam1 = (AliEMCALCalibData*) cdb->GetObject(); // New OCDB container AliEMCALCalibData *cparamnew=new AliEMCALCalibData("EMCAL"); // Do the comparison Float_t param = -1; Float_t param1 = -1; Int_t iCol = -1, iRow = -1, iSM =-1, iMod = -1,iIphi =-1,iIeta = -1; for(Int_t i=0;i < nSM*24*48; i++) { //printf("AbsID %d\n",i); geom->GetCellIndex(i,iSM,iMod,iIphi,iIeta); geom->GetCellPhiEtaIndexInSModule(iSM,iMod, iIphi, iIeta,iRow,iCol); Float_t param = -1; if( cparam ) param = cparam ->GetADCchannel(iSM,iCol,iRow); Float_t param1 = -1; if( cparam1 ) param1 = cparam1->GetADCchannel(iSM,iCol,iRow); if (printAll) printf("ID %d, col %d, row %d, sm %d final %1.4f, first %1.4f\n", i,iCol,iRow,iSM,param, param1); cparamnew->SetADCchannel (iSM,iCol,iRow,param ); cparamnew->SetADCchannelOnline(iSM,iCol,iRow,param1); } // Create OCDB File AliCDBMetaData md; md.SetComment("Calibration after calibration with pi0, store also first online calibration"); md.SetBeamPeriod(0); md.SetResponsible("Gustavo Conesa"); md.SetAliRootVersion(gSystem->Getenv("ARVERSION")); // Careful, select here the first run where this calibration is valid Int_t firstRun = 172439; // 2012-13 if(year == 2010) firstRun = 113461; if(year == 2011) firstRun = 144484; AliCDBId id("EMCAL/Calib/Data",firstRun,AliCDBRunRange::Infinity()); // create in EMCAL/Calib/Data DBFolder AliCDBManager* man2 = AliCDBManager::Instance(); AliCDBStorage* loc = man2->GetStorage(Form("local://%d",year)); loc->Put(cparamnew, id, &md); }
void MakeACORDEZeroMisAlignment(){ // Create TClonesArray of zero misalignment objects for ACORDE // const char* macroname = "MakeACORDEZeroMisAlignment.C"; // Activate CDB storage and load geometry from CDB AliCDBManager* cdb = AliCDBManager::Instance(); if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); cdb->SetRun(0); AliCDBStorage* storage; //load geom from local file till ACORDE is not switched on by default in standard config-files if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){ TString Storage = gSystem->Getenv("STORAGE"); if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) { Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data()); return; } storage = cdb->GetStorage(Storage.Data()); if(!storage){ Error(macroname,"Unable to open storage %s\n",Storage.Data()); return; } AliCDBPath path("GRP","Geometry","Data"); AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun()); if(!entry) Fatal(macroname,"Could not get the specified CDB entry!"); entry->SetOwner(0); TGeoManager* geom = (TGeoManager*) entry->GetObject(); AliGeomManager::SetGeometry(geom); }else{ AliGeomManager::LoadGeometry(); //load geom from default CDB storage } // AliGeomManager::LoadGeometry("geometry.root"); TClonesArray *array = new TClonesArray("AliAlignObjParams",64); TClonesArray &alobj = *array; TRandom *rnd = new TRandom(4321); Int_t j = 0; Double_t dx=0, dy=0, dz=0, dpsi=0, dtheta=0, dphi=0; // RS = local // sigma translation // sigma rotation TString symname; TString basename = "ACORDE/Array"; Int_t iIndex=0; AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex); for (Int_t imod=0; imod<60; imod++){ symname = basename; symname += imod; new(alobj[j++]) AliAlignObjParams(symname, volid, dx, dy, dz,dpsi, dtheta, dphi, kFALSE); } if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){ // save on file const char* filename = "ACORDEZeroMisalignment.root"; TFile f(filename,"RECREATE"); if(!f){ Error(macroname,"cannot open file for output\n"); return; } Info(macroname,"Saving alignment objects to the file %s", filename); f.cd(); f.WriteObject(array,"ACORDEAlignObjs","kSingleKey"); f.Close(); }else{ // save in CDB storage AliCDBMetaData* md = new AliCDBMetaData(); md->SetResponsible("E. Cuautle & M. Rodriguez"); md->SetComment("Zero misalignment for ACORDE"); md->SetAliRootVersion(gSystem->Getenv("$ARVERSION")); AliCDBId id("ACORDE/Align/Data",0,AliCDBRunRange::Infinity()); storage->Put(array,id,md); } array->Delete(); }
void MakeTRDFullMisAlignment(){ // Create TClonesArray of full misalignment objects for TRD // Expects to read objects for FRAME // TClonesArray *array = new TClonesArray("AliAlignObjParams",1000); const char* macroname = "MakeTRDFullMisAlignment.C"; // Activate CDB storage and load geometry from CDB AliCDBManager* cdb = AliCDBManager::Instance(); if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); cdb->SetRun(0); AliCDBStorage* storage; TString Storage; if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){ Storage = gSystem->Getenv("STORAGE"); if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) { Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data()); return; } storage = cdb->GetStorage(Storage.Data()); if(!storage){ Error(macroname,"Unable to open storage %s\n",Storage.Data()); return; } AliCDBPath path("GRP","Geometry","Data"); AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun()); if(!entry) Fatal(macroname,"Could not get the specified CDB entry!"); entry->SetOwner(0); TGeoManager* geom = (TGeoManager*) entry->GetObject(); AliGeomManager::SetGeometry(geom); }else{ AliGeomManager::LoadGeometry(); //load geom from default CDB storage } // load FRAME full misalignment objects (if needed, the macro // for FRAME has to be ran in advance) and apply them to geometry AliCDBPath fpath("GRP","Align","Data"); AliCDBEntry *eFrame; if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){ Info(macroname,"Loading FRAME alignment objects from CDB storage %s", Storage.Data()); eFrame = storage->Get(fpath.GetPath(),cdb->GetRun()); }else{ eFrame = cdb->Get(fpath.GetPath()); } if(!eFrame) Fatal(macroname,"Could not get the specified CDB entry!"); TClonesArray* arFrame = (TClonesArray*) eFrame->GetObject(); arFrame->Sort(); Int_t nvols = arFrame->GetEntriesFast(); Bool_t flag = kTRUE; for(Int_t j=0; j<nvols; j++) { AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j); if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE; } if(!flag) Fatal(macroname,"Error in the application of FRAME objects"); // Sigmas for the chambers Double_t smdx = 0.3; // 3 mm Double_t smdy = 0.3; // 3 mm Double_t smdz = 0.3; // 3 mm Double_t smrx = 0.4 / 1000.0 / TMath::Pi()*180; // 0.4 mrad Double_t smry = 2.0 / 1000.0 / TMath::Pi()*180; // 2.0 mrad Double_t smrz = 0.4 / 1000.0 / TMath::Pi()*180; // 0.4 mrad // Truncation for the chambers Double_t cutSmdx = 3.0 * smdx; Double_t cutSmdy = 3.0 * smdy; Double_t cutSmdz = 3.0 * smdz; // Sigmas for the chambers Double_t chdx = 0.05; // 0.5 mm Double_t chdy = 0.1; // 1.0 mm Double_t chdz = 0.007; // 70 microns Double_t chrx = 0.0005 / 1000.0 / TMath::Pi()*180; // 0 mrad Double_t chry = 0.0005 / 1000.0 / TMath::Pi()*180; // 0 mrad Double_t chrz = 0.3 / 1000.0 / TMath::Pi()*180; // 0.3 mrad // Truncation for the chambers Double_t cutChdx = 1.0 * chdx; Double_t cutChdy = 1.0 * chdy; Double_t cutChdz = 0.14 * chdz; Int_t sActive[18]={1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1}; Double_t dx,dy,dz,rx,ry,rz; Int_t j=0; UShort_t volid; const char *symname; // create the supermodules' alignment objects for (int iSect; iSect<18; iSect++) { TString sm_symname(Form("TRD/sm%02d",iSect)); dx = AliMathBase::TruncatedGaus(0.0,smdx,cutSmdx); dy = AliMathBase::TruncatedGaus(0.0,smdy,cutSmdy); dz = AliMathBase::TruncatedGaus(0.0,smdz,cutSmdz); rx = gRandom->Rndm() * 2.0*smrx - smrx; ry = gRandom->Rndm() * 2.0*smry - smry; rz = gRandom->Rndm() * 2.0*smrz - smrz; if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue; new((*array)[j++]) AliAlignObjParams(sm_symname.Data(),0,dx,dy,dz,rx,ry,rz,kFALSE); } // apply supermodules' alignment objects Int_t smCounter=0; for(Int_t iSect=0; iSect<18; iSect++){ if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue; AliAlignObjParams* smobj = (AliAlignObjParams*)array->UncheckedAt(smCounter++); if(!smobj->ApplyToGeometry()){ Fatal(macroname,Form("application of full misalignment object for sector %d failed!",iSect)); return; } } // create the chambers' alignment objects ran = new TRandom(4357); Int_t chId; for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) { chId=-1; for (Int_t iSect = 0; iSect < 18; iSect++){ for (Int_t iCh = 0; iCh < 5; iCh++) { dx = AliMathBase::TruncatedGaus(0.0,chdx,cutChdx); dy = AliMathBase::TruncatedGaus(0.0,chdy,cutChdy); dz = AliMathBase::TruncatedGaus(0.0,chdz,cutChdz); rx = gRandom->Rndm() * 2.0*chrx - chrx; ry = gRandom->Rndm() * 2.0*chry - chry; rz = gRandom->Rndm() * 2.0*chrz - chrz; chId++; if ((iSect==13 || iSect==14 || iSect==15) && iCh==2) continue; volid = AliGeomManager::LayerToVolUID(iLayer,chId); if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue; symname = AliGeomManager::SymName(volid); new((*array)[j++]) AliAlignObjParams(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE); } } } if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){ // save on file const char* filename = "TRDfullMisalignment.root"; TFile f(filename,"RECREATE"); if(!f){ Error(macroname,"cannot open file for output\n"); return; } Info(macroname,"Saving alignment objects to the file %s", filename); f.cd(); f.WriteObject(array,"TRDAlignObjs","kSingleKey"); f.Close(); }else{ // save in CDB storage Info(macroname,"Saving alignment objects in CDB storage %s", Storage.Data()); AliCDBMetaData* md = new AliCDBMetaData(); md->SetResponsible("Dariusz Miskowiec"); md->SetComment("Full misalignment for TRD"); md->SetAliRootVersion(gSystem->Getenv("ARVERSION")); AliCDBId id("TRD/Align/Data",0,AliCDBRunRange::Infinity()); storage->Put(array,id,md); } array->Delete(); }
void PlotPedestalsvsTime(Int_t year=2011, Int_t firstRun=141820, Int_t lastRun=146900, Int_t ipedGainChain=0) { TGrid::Connect("alien:",0,0,"t"); gSystem->Exec(Form("gbbox find \"/alice/data/%d/OCDB/ZDC/Calib/Pedestals/\" \"Run*.root\" > calibAlienFiles.txt",year)); FILE* listruns=fopen("calibAlienFiles.txt","r"); const int kNchannels=24; TGraphErrors* graph[24]; for(Int_t i=0; i<kNchannels; i++){ graph[i] = new TGraphErrors(0); char name[50], title[50]; sprintf(name,"graph%d",i); sprintf(title,"Pedestal ch.%d vs. run#",i); graph[i]->SetName("graph"); graph[i]->SetTitle("title"); } Char_t filnam[200], filnamalien[200]; Int_t iPoint=0; Int_t nrun, nrun2, nv, ns; while(!feof(listruns)){ int st = fscanf(listruns,"%s\n",filnam); Char_t directory[100]; sprintf(directory,"/alice/data/%d",year); if(!strstr(filnam,directory)) continue; sscanf(filnam,"/alice/data/%d/OCDB/ZDC/Calib/Pedestals/Run%d_%d_v%d_s%d.root",&year,&nrun,&nrun2,&nv,&ns); if(nrun<firstRun) continue; if(nrun>lastRun) continue; sprintf(filnamalien,"alien://%s",filnam); printf("Opening file: %s\n",filnam); TFile *f = TFile::Open(filnamalien); AliCDBEntry *entry = (AliCDBEntry*)f->Get("AliCDBEntry"); AliZDCPedestals *calibdata = dynamic_cast<AliZDCPedestals*> (entry->GetObject()); for(int i=0; i<kNchannels; i++){ if(ipedGainChain==0){ graph[i]->SetPoint(iPoint, (Double_t)nrun, calibdata->GetMeanPed(i)); graph[i]->SetPointError(iPoint, 0., calibdata->GetMeanPedWidth(i)); } else{ graph[i]->SetPoint(iPoint, (Double_t)nrun, calibdata->GetMeanPed(i+kNchannels)); graph[i]->SetPointError(iPoint, 0., calibdata->GetMeanPedWidth(i+kNchannels)); } } iPoint++; f->Close(); } TFile *outfile=new TFile(Form("PedCalib%dVsTime.root",year),"recreate"); outfile->cd(); for(int i=0; i<kNchannels; i++) graph[i]->Write(); outfile->Close(); //*********************************************************** // #### ROOT initialization gROOT->Reset(); gStyle->SetCanvasColor(10); gStyle->SetFrameFillColor(10); gStyle->SetOptTitle(0); gStyle->SetOptStat(1111); gStyle->SetOptFit(0); gStyle->SetTitleTextColor(4); gStyle->SetStatTextColor(4); gStyle->SetStatX(0.92); gStyle->SetStatY(0.92); gStyle->SetLineColor(1); gStyle->SetPalette(1); gStyle->SetPadTopMargin(0.05); gStyle->SetPadRightMargin(0.05); gStyle->SetPadBottomMargin(0.09); gStyle->SetPadLeftMargin(0.09); gStyle->SetTitleOffset(1.1,"Y"); // ************************************************************* TCanvas *cHadPeds = new TCanvas("cHadPeds","Hadronic ZDC pedestals",0,0,1000,800); cHadPeds->Divide(5,4); for(int ic=0; ic<5; ic++){ // *** ZNC pedestals cHadPeds->cd(ic+1); // TH1F *haxis1=0; if(ipedGainChain==0){ if(ic==0) haxis1 = gPad->DrawFrame(firstRun-100, 80, lastRun+100, 100); else haxis1 = gPad->DrawFrame(firstRun-100, 50, lastRun+100, 70); } else{ if(ic==0) haxis1 = gPad->DrawFrame(firstRun-100, 500, lastRun+100, 800); else haxis1 = gPad->DrawFrame(firstRun-100, 300, lastRun+100, 600); } haxis1->GetXaxis()->SetNoExponent(); haxis1->SetXTitle("RUN no."); haxis1->SetYTitle("ZNC pedestals"); // graph[ic]->SetMarkerStyle(20); graph[ic]->SetMarkerColor(kBlue); graph[ic]->Draw("P, SAME"); // *** ZPC pedestals cHadPeds->cd(ic+6); // TH1F *haxis2=0; if(ipedGainChain==0) haxis2= gPad->DrawFrame(firstRun-100, 55, lastRun+100, 85); else haxis2 = gPad->DrawFrame(firstRun-100, 400, lastRun+100, 700); haxis2->GetXaxis()->SetNoExponent(); haxis2->SetXTitle("RUN no."); haxis2->SetYTitle("ZPC pedestals"); // graph[ic+5]->SetMarkerStyle(21); graph[ic+5]->SetMarkerColor(kBlue+3); graph[ic+5]->Draw("P, SAME"); // *** ZNA pedestals cHadPeds->cd(ic+11); // TH1F *haxis3=0; if(ipedGainChain==0) haxis3 = gPad->DrawFrame(firstRun-100, 35, lastRun+100, 85); else haxis3 = gPad->DrawFrame(firstRun-100, 300, lastRun+100, 700); haxis3->GetXaxis()->SetNoExponent(); haxis3->SetXTitle("RUN no."); haxis3->SetYTitle("ZNA pedestals"); // graph[ic+12]->SetMarkerStyle(20); graph[ic+12]->SetMarkerColor(kRed); graph[ic+12]->Draw("P, SAME"); // *** ZPA pedestals cHadPeds->cd(ic+16); // TH1F *haxis4=0; if(ipedGainChain==0) haxis4 = gPad->DrawFrame(firstRun-100, 40, lastRun+100, 80); else haxis4 = gPad->DrawFrame(firstRun-100, 300, lastRun+100, 600); haxis4->GetXaxis()->SetNoExponent(); haxis4->SetXTitle("RUN no."); haxis4->SetYTitle("ZPA pedestals"); // graph[ic+17]->SetMarkerStyle(21); graph[ic+17]->SetMarkerColor(kRed+1); graph[ic+17]->Draw("P, SAME"); } cHadPeds->SaveAs("ZDCPedvsTime1.gif"); cHadPeds->SaveAs("ZDCPedvsTime1.C"); TCanvas *cothPeds = new TCanvas("cothPeds","ZEM + Ref. pedestals",800,0,600,600); cothPeds->Divide(2,2); for(int ic=0; ic<2; ic++){ // *** ZEM pedestals cothPeds->cd(ic+1); // TH1F *haxis5=0; if(ipedGainChain==0) haxis5 = gPad->DrawFrame(firstRun-100, 30, lastRun+20, 70); else haxis5 = gPad->DrawFrame(firstRun-100, 250, lastRun+100, 550); haxis5->GetXaxis()->SetNoExponent(); haxis5->SetXTitle("RUN no."); haxis5->SetYTitle("ZEM pedestals"); // graph[ic+10]->SetMarkerStyle(22); graph[ic+10]->SetMarkerColor(kGreen+1); graph[ic+10]->Draw("P, SAME"); // *** Ref. pedestals cothPeds->cd(ic+3); // TH1F *haxis6=0; if(ipedGainChain==0) haxis6 = gPad->DrawFrame(firstRun-100, 50, lastRun+100, 90); else haxis6 = gPad->DrawFrame(firstRun-100, 400, lastRun+100, 700); haxis6->GetXaxis()->SetNoExponent(); haxis6->SetXTitle("RUN no."); haxis6->SetYTitle("PMRef. pedestals"); // graph[ic+22]->SetMarkerStyle(23); graph[ic+22]->SetMarkerColor(kGreen+4); graph[ic+22]->Draw("P, SAME"); } cothPeds->SaveAs("ZDCPedvsTime2.gif"); cothPeds->SaveAs("ZDCPedvsTime2.C"); }
Int_t retreiveCalibrationData(Int_t fRunNumber) { AliCDBManager * man = AliCDBManager::Instance() ; man->SetDefaultStorage("raw://") ; //man->SetDefaultStorage("local://$ALICE_ROOT/OCDB") ; man->SetRun(fRunNumber) ; AliCDBEntry * bmEntry = man->Get("PHOS/Calib/EmcBadChannels/") ; // Get the BCM for PHOS phosBcm = (AliPHOSEmcBadChannelsMap*)bmEntry->GetObject(); if (!phosBcm) { std::cerr << "ERROR: Could not get the bad channel map for PHOS" << std::endl; } else { Int_t *tmpList = new Int_t[phosBcm->GetNumOfBadChannels()]; phosBcm->BadChannelIds(tmpList); badChannels.resize(0); for(Int_t n = 0; n < phosBcm->GetNumOfBadChannels(); n++) { badChannels.push_back(tmpList[n]); } } // Get the gains for PHOS AliCDBPath path("PHOS","Calib","EmcGainPedestals"); if (path.GetPath()) { AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path); if (pEntry) { phosCalibData = (AliPHOSEmcCalibData*)pEntry->GetObject(); if (!phosCalibData) { std::cerr << "ERROR: Could not get calibration data for PHOS" << std::endl; return -1; } } else { std::cerr << "ERROR: Could not get CDB entry for PHOS calib data" << std::endl; return -1; } } AliCDBPath geompath("GRP","Geometry","Data"); TGeoManager *geoManager = 0; if(path.GetPath()) { // HLTInfo("configure from entry %s", path.GetPath()); AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(geompath/*,GetRunNo()*/); if (pEntry) { if(geoUtils) { delete geoUtils; geoUtils = 0; } if(!geoManager) geoManager = (TGeoManager*) pEntry->GetObject(); if(geoManager) { geoUtils = new AliPHOSGeoUtils("PHOS", "noCPV"); geom = new AliPHOSGeometry("PHOS", "noCPV"); } else { std::cerr << "can not get gGeoManager from OCDB" << std::endl; } } else { std::cerr << "can not fetch object " << path.GetPath().Data() << " from OCDB" << std::endl; } } AliCDBPath recoPath("PHOS", "Calib", "RecoParam"); if(recoPath.GetPath()) { // HLTInfo("configure from entry %s", path.GetPath()); AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(recoPath/*,GetRunNo()*/); if (pEntry) { TObjArray *paramArray = dynamic_cast<TObjArray*>(pEntry->GetObject()); if(paramArray) { recoParam = dynamic_cast<AliPHOSRecoParam*>((paramArray)->At(0)); } if(!recoParam) { std::cerr << "can not fetch object reconstruction parameters from " << recoPath.GetPath().Data() << std::endl;; return -1; } } else { std::cerr << "can not fetch object " << recoPath.GetPath().Data() << " from OCDB" << std::endl; return -1; } } createBadChannelMap(); return 0; }
void ADTestPreprocessor() { // load library gSystem->Load("$ALICE_ROOT/../src/SHUTTLE/TestShuttle/libTestShuttle"); // create AliTestShuttle instance // The parameters are run, startTime, endTime AliTestShuttle* shuttle = new AliTestShuttle(254487, 0, 323450); // TODO if needed, change location of OCDB and Reference test folders // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB and TestReference AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/OCDB"); AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/OCDB"); printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data()); printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data()); // TODO(1) // // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data, // some fake data has to be created. // // The "fake" input data can be taken using either (a) or (b): // (a) data from a file: Use ReadDCSAliasMap() // the format of the file is explained in ReadDCSAliasMap() // To use it uncomment the following line: // //TMap* dcsAliasMap = ReadDCSAliasMap(); // // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation // To use it uncomment the following line: // TMap* dcsAliasMap = CreateDCSAliasMap(); // now give the alias map to the shuttle shuttle->SetDCSInput(dcsAliasMap); // TODO(2) // // The shuttle can also process files that originate from DCS, DAQ and HLT. // To test it, we provide some local files and locations where these would be found when // the online machinery would be there. // In real life this functions would be produces by the sub-detectors // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle. // // Files are added with the function AliTestShuttle::AddInputFile. The syntax is: // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>) // In this example we add a file originating from the GDC with the id PEDESTALS // Three files originating from different LDCs but with the same id are also added // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow // the "online" naming convention ALICE-INT-2003-039. // shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "PEDESTALS", "GDC0", "file1.root"); // shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC0", "file2a.root"); // shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC1", "file2b.root"); // shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC2", "file2c.root"); // shuttle->AddInputFile(AliShuttleInterface::kHLT, "TPC", "HLTData", "source1", "hlt_file1.root"); shuttle->AddInputFile(AliShuttleInterface::kDAQ, "AD0", "AD0da_results", "source1", "/home/mbroz/AD/Data/db/run000000000_DAQ_test_AD0da_results"); shuttle->AddInputFile(AliShuttleInterface::kDAQ, "AD0", "AD0da_slewing", "source2", "/home/mbroz/AD/Data/db/run000000000_DAQ_test_AD0da_slewing"); // // TODO(3) // // The shuttle can read run type stored in the DAQ logbook. // To test it, we must provide the run type manually. They will be retrieved in the preprocessor // using GetRunType function. shuttle->SetInputRunType("PHYSICS"); // TODO(4) // // The shuttle can read run parameters stored in the DAQ run logbook. // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor // using GetRunParameter function. shuttle->AddInputRunParameter("totalEvents", "30000"); shuttle->AddInputRunParameter("NumberOfGDCs", "15"); shuttle->AddInputRunParameter("LHCBeamMode", "NO BEAM"); // TODO(5) // // This is for preprocessor that require data from HLT. // Since HLT may be switched off, the preprocessor should first query the Run logbook where // the HLT status is stored. SHUTTLE implements a shortcut function (GetHLTStatus) that returns // a bool directly. 1 = HLT ON, 0 = HLT OFF // Bool_t hltStatus=kFALSE; shuttle->SetInputHLTStatus(hltStatus); // TODO(6) // Create the preprocessor that should be tested, it registers itself automatically to the shuttle AliPreprocessor* adPreprocessor = new AliADPreprocessor(shuttle); // Test the preprocessor shuttle->Process(); // TODO(7) // In the preprocessor AliShuttleInterface::Store should be called to put the final // data to the CDB. To check if all went fine have a look at the files produced in // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data // // Check the file which should have been created AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("AD/Calib/Data", 0); if (!chkEntry) { printf("The file is not there. Something went wrong.\n"); return; } AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (chkEntry->GetObject()); // If everything went fine, draw the result if (output) output->Draw(); // }
void makeOCDB(Int_t runNumber, TString targetOCDBstorage="", TString sourceOCDBstorage="raw://", Int_t detectorBitsQualityFlag = -1) { // // extract OCDB entries for detectors participating in the calibration for the current run // gROOT->Macro("$ALICE_PHYSICS/PWGPP/CalibMacros/CPass1/LoadLibraries.C"); gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/CalibMacros/CPass1/ConfigCalibTrain.C"); // switch off log info AliLog::SetClassDebugLevel("AliESDEvent",0); // config GRP printf("runNumber from runCalibTrain = %d\n",runNumber); ConfigCalibTrain(runNumber, sourceOCDBstorage.Data()); // check the presence of the detectors AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data"); AliGRPObject* grpData = dynamic_cast<AliGRPObject*>(entry->GetObject()); if (!grpData) {printf("Failed to get GRP data for run",runNumber); return;} Int_t activeDetectors = grpData->GetDetectorMask(); TString detStr = AliDAQ::ListOfTriggeredDetectors(activeDetectors); printf("Detectors in the data:\n%s\n",detStr.Data()); TString LHCperiod = grpData->GetLHCPeriod(); Bool_t isLHC10 = LHCperiod.Contains("LHC10"); Bool_t isLHC11 = LHCperiod.Contains("LHC11"); Bool_t isLHC12 = LHCperiod.Contains("LHC12"); Bool_t isLHC13 = LHCperiod.Contains("LHC13"); Bool_t isLHC13b = LHCperiod.Contains("LHC13b"); Bool_t isLHC13c = LHCperiod.Contains("LHC13c"); printf("LHCperiod:%s\n isLHC10:%d isLHC11:%d isLHC12:%d isLHC13:%d isLHC13b:%d isLHC13c:%d\n",LHCperiod.Data(),(Int_t)isLHC10,(Int_t)isLHC11,(Int_t)isLHC12,(Int_t)isLHC13,(Int_t)isLHC13b,(Int_t)isLHC13c); // Steering Tasks - set output storage // DefaultStorage set already before - in ConfigCalibTrain.C // Setting the mirror SEs for the default storage TString mirrorsStr("ALICE::CERN::OCDB,ALICE::FZK::SE,ALICE::LLNL::SE"); AliCDBManager::Instance()->SetMirrorSEs(mirrorsStr.Data()); printf("List of mirror SEs set to: \"%s\"\n",mirrorsStr.Data()); // activate target OCDB storage AliCDBStorage* targetStorage = 0x0; if (targetOCDBstorage.Length()==0) { targetOCDBstorage+="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; targetStorage = AliCDBManager::Instance()->GetStorage(targetOCDBstorage.Data()); } else if (targetOCDBstorage.CompareTo("same",TString::kIgnoreCase) == 0 ){ targetStorage = AliCDBManager::Instance()->GetDefaultStorage(); } else { targetStorage = AliCDBManager::Instance()->GetStorage(targetOCDBstorage.Data()); } printf("** targetOCDBstorage: \"%s\"\n",targetOCDBstorage.Data()); // specific storage for TPC/Calib/Correction entry if (gSystem->AccessPathName("TPC", kFileExists)==0) { AliCDBManager::Instance()->SetSpecificStorage("TPC/Calib/Correction","local://"); } // Magnetic field AliMagF* fld = TGeoGlobalMagField::Instance()->GetField(); Double_t bz = fld->SolenoidField(); Bool_t isMagFieldON = kTRUE; if (TMath::Abs(bz)>0) { printf("Mag field is %f --> ON\n", bz); } else { isMagFieldON = kFALSE; printf("Mag field is %f --> OFF\n", bz); } // Quality flags Bool_t TPC_qf = kTRUE; Bool_t TOF_qf = kTRUE; Bool_t TRD_qf = kTRUE; Bool_t T0_qf = kTRUE; Bool_t SDD_qf = kTRUE; Bool_t SPD_qf = kTRUE; Bool_t AD_qf = kTRUE; /* // RS: commenting to sync with working version from alidaq if (detectorBitsQualityFlag != -1){ TPC_qf = ((detectorBitsQualityFlag & AliDAQ::kTPC_QF) == AliDAQ::kTPC_QF)? kTRUE : kFALSE; TOF_qf = ((detectorBitsQualityFlag & AliDAQ::kTOF_QF) == AliDAQ::kTOF_QF)? kTRUE : kFALSE; TRD_qf = ((detectorBitsQualityFlag & AliDAQ::kTRD_QF) == AliDAQ::kTRD_QF)? kTRUE : kFALSE; T0_qf = ((detectorBitsQualityFlag & AliDAQ::kT0_QF) == AliDAQ::kT0_QF)? kTRUE : kFALSE; SDD_qf = ((detectorBitsQualityFlag & AliDAQ::kSDD_QF) == AliDAQ::kSDD_QF)? kTRUE : kFALSE; SPD_qf = ((detectorBitsQualityFlag & AliDAQ::kSPD_QF) == AliDAQ::kSPD_QF)? kTRUE : kFALSE; AD_qf = ((detectorBitsQualityFlag & AliDAQ::kAD_QF) == AliDAQ::kAD_QF)? kTRUE : kFALSE; } */ Printf("Quality flags: detectorBitsQualityFlag = %d, TPC = %d, TOF = %d, TRD = %d, T0 = %d, SDD = %d, SPD = %d, AD = %d", detectorBitsQualityFlag, (Int_t)TPC_qf, (Int_t)TOF_qf, (Int_t)TRD_qf, (Int_t)T0_qf, (Int_t)SDD_qf, (Int_t)SPD_qf, (Int_t)AD_qf); // =========================================================================== // ===| TPC part |============================================================ // AliTPCPreprocessorOffline *procesTPC = 0; if (detStr.Contains("TPC") && TPC_qf){ Printf("\n******* Calibrating TPC *******"); // ===| set up residual storage |=========================================== TString targetStorageResidual="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; // --- check for overwrites const TString targetStorageResidualEnv(gSystem->Getenv("targetStorageResidual")); if (!targetStorageResidualEnv.IsNull()) targetStorageResidual=targetStorageResidualEnv; AliCDBStorage *residualStorage = AliCDBManager::Instance()->GetStorage(targetStorageResidual.Data()); // ===| set up TPC calibration object |===================================== procesTPC = new AliTPCPreprocessorOffline; // ---| set up gain calibratin type |--------------------------------------- // // default is Combined Calibration + Residual QA in CPass1 // will be overwritte by mergeMakeOCDB.byComponent.perStage.sh // NOTE: This must be consistent to the settings in runCPass*.sh (runCalibTrain.C) // procesTPC->SetGainCalibrationType(AliTPCPreprocessorOffline::kResidualGainQA); // --- check for overwrites from environment variable // const TString sGainTypeFromEnv(gSystem->Getenv("TPC_CPass1_GainCalibType")); if (!sGainTypeFromEnv.IsNull()) { if (!procesTPC->SetGainCalibrationType(sGainTypeFromEnv)) { ::Fatal("makeOCDB","Could not set up gain calibration type from environment variable TPC_CPass1_GainCalibType: %s",sGainTypeFromEnv.Data()); } ::Info("makeOCDB","Setting gain calibration type from environment variable TPC_CPass1_GainCalibType: %d", Int_t(procesTPC->GetGainCalibrationType())); } // ---| switch on parameter validation |------------------------------------ procesTPC->SetTimeGainRange(0.5,5.0); procesTPC->SetMaxVDriftCorr(0.2); procesTPC->SetMinTracksVdrift(10000); procesTPC->SwitchOnValidation(); // ===| Run calibration |=================================================== // // ---| Make time gain calibration |---------------------------------------- if (isMagFieldON) procesTPC->CalibTimeGain("CalibObjects.root", runNumber, runNumber, targetStorage, residualStorage); // ---| Make vdrift calibration |------------------------------------------- procesTPC->CalibTimeVdrift("CalibObjects.root",runNumber, runNumber, residualStorage); } else { Printf("\n******* NOT Calibrating TPC: detStr = %s, TPC_qf = %d *******", detStr.Data(), (Int_t)TPC_qf); } // =========================================================================== // ===| TOF part |============================================================ // AliTOFAnalysisTaskCalibPass0 *procesTOF=0; if (detStr.Contains("TOF") && detStr.Contains("TPC") && TOF_qf){ procesTOF = new AliTOFAnalysisTaskCalibPass0; Printf("\n******* Calibrating TOF *******"); if (isMagFieldON) procesTOF->ProcessOutput("CalibObjects.root", targetStorage); else { printf("Not calibrating TOF in case of mag field OFF\n"); } } else { Printf("\n******* NOT Calibrating TOF: detStr = %s, TOF_qf = %d *******", detStr.Data(), (Int_t)TOF_qf); } // T0 part AliT0PreprocessorOffline *procesT0= 0; if (detStr.Contains("T0") && T0_qf) { Printf("\n******* Calibrating T0 *******"); procesT0 = new AliT0PreprocessorOffline; // Make calibration of channels offset procesT0->setDArun(100000); procesT0->Process("CalibObjects.root",runNumber, runNumber, targetStorage); } else { Printf("\n******* NOT Calibrating T0: detStr = %s, T0_qf = %d *******", detStr.Data(), (Int_t)T0_qf); } //TRD part AliTRDPreprocessorOffline *procesTRD = 0; if (detStr.Contains("TRD") && detStr.Contains("TPC") && TRD_qf){ Printf("\n******* Calibrating TRD *******"); procesTRD = new AliTRDPreprocessorOffline; if(isLHC10 || isLHC13b || isLHC13c) procesTRD->SetSwitchOnChamberStatus(kFALSE); procesTRD->SetLinearFitForVdrift(kTRUE); procesTRD->SetMinStatsVdriftT0PH(600*10); procesTRD->SetMinStatsVdriftLinear(50); procesTRD->SetMinStatsGain(600); procesTRD->SetLimitValidateNoData(100); procesTRD->SetLimitValidateBadCalib(90); procesTRD->SetMinTimeOffsetValidate(-2.1); procesTRD->SetAlternativeDriftVelocityFit(kTRUE); if((!isLHC10) && (!isLHC11) && (!isLHC12) && (!isLHC13)) { printf("Run II\n"); procesTRD->SetT0Shift1(0.2524132);// release the condition on the first bin and last bins } procesTRD->Init("CalibObjects.root"); Int_t versionVdriftUsed = procesTRD->GetVersionVdriftUsed(); Int_t subversionVdriftUsed = procesTRD->GetSubVersionVdriftUsed(); Int_t versionGainUsed = procesTRD->GetVersionGainUsed(); Int_t subversionGainUsed = procesTRD->GetSubVersionGainUsed(); Int_t versionExBUsed = procesTRD->GetVersionExBUsed(); Int_t subversionExBUsed = procesTRD->GetSubVersionExBUsed(); printf("version and subversion vdrift %d and %d\n",versionVdriftUsed,subversionVdriftUsed); printf("version and subversion gain %d and %d\n",versionGainUsed,subversionGainUsed); printf("version and subversion exb %d and %d\n",versionExBUsed,subversionExBUsed); procesTRD->Process("CalibObjects.root",runNumber,runNumber,targetStorage); } else { Printf("\n******* NOT Calibrating TRD: detStr = %s, TRD_qf = %d *******", detStr.Data(), (Int_t)TRD_qf); } // switched OFF at CPass1 in any case /* //Mean Vertex AliMeanVertexPreprocessorOffline * procesMeanVtx=0; if (detStr.Contains("ITSSPD") && SPD_qf) { Printf("\n******* Calibrating MeanVertex *******"); procesMeanVtx = new AliMeanVertexPreprocessorOffline; procesMeanVtx->ProcessOutput("CalibObjects.root", targetStorage, runNumber); } else { Printf("\n******* NOT Calibrating MeanVertex: detStr = %s, SPD_qf = %d *******", detStr.Data(), (Int_t)SPD_qf); } */ AliAnalysisTaskADCalib *procesAD = NULL; if (detStr.Contains("AD") && AD_qf) { Printf("\n******* Calibrating AD *******"); procesAD = new AliAnalysisTaskADCalib; procesAD->ProcessOutput("CalibObjects.root", targetStorage, runNumber); } else { Printf("\n******* NOT Calibrating AD: detStr = %s, AD_qf = %d*******", detStr.Data(), (Int_t)AD_qf); } // // Print calibration status into the stdout // Int_t trdStatus = (procesTRD) ? procesTRD->GetStatus():0; Int_t tofStatus = (procesTOF) ? procesTOF->GetStatus():0; Int_t t0Status = (procesT0) ? procesT0->GetStatus():0; Int_t tpcStatus = (procesTPC) ? procesTPC->GetStatus():0; Int_t adStatus = (procesAD) ? procesAD->GetStatus():0; // printf("\n"); printf("******* CPass1 calibration status *******\n"); printf("TRD calibration status=%d\n",trdStatus); printf("TOF calibration status=%d\n",tofStatus); printf("TPC calibration status=%d\n",tpcStatus); printf("T0 calibration status=%d\n",t0Status); printf("AD calibration status=%d\n",adStatus); TTreeSRedirector *pcstream = new TTreeSRedirector("cpassStat.root","recreate"); printCalibStat(runNumber, "CalibObjects.root",pcstream); delete pcstream; return; }
//void PlotNoiseBaseline(Int_t run, Int_t sm, Int_t det, const char * pathdatabase="local:///d/alice12/bailhache/TestShuttle/database/", const char * pathreferencefile="local:///d/alice12/bailhache/TestShuttle/reference") //void PlotNoiseBaseline(Int_t run=34529, Int_t sm=0, Int_t det=0, const char * pathdatabase="alien://Folder=/alice/data/2008/LHC08b/OCDB/", const char * pathreferencedatabase="alien://Folder=/alice/data/2008/LHC08b/Reference/") //void PlotNoiseBaseline(Int_t run=1, Int_t sm=0, Int_t det=0, const char * pathdatabase="local:///d/alice12/bailhache/AliAnalysisTask/v4-13-Head/SHUTTLE/TestShuttle/TestCDB/", const char * pathreferencedatabase="local:///d/alice12/bailhache/AliAnalysisTask/v4-13-Head/SHUTTLE/TestShuttle/TestReference/") void AliTRDplotNoiseBaseline(Int_t run=34529, Int_t sm=0, Int_t det=0, const char * pathdatabase="alien://Folder=/alice/data/2008/LHC08b/OCDB/", const char * pathreferencedatabase="alien://Folder=/alice/data/2008/LHC08b/Reference/") { //TGrid::Connect("alien://",0,0,"t"); AliCDBManager *CDB = AliCDBManager::Instance(); CDB->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); CDB->SetSpecificStorage("TRD/Calib/PadNoise",pathdatabase); CDB->SetSpecificStorage("TRD/Calib/DetNoise",pathdatabase); CDB->SetSpecificStorage("TRD/Calib/PadStatus",pathdatabase); CDB->SetRun(run); AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); //const AliTRDCalDet *u = cal->GetNoiseDet(); AliTRDCalDet *u = new AliTRDCalDet("u","u"); for(Int_t k = 0; k < 540; k++){ u->SetValue(k,10.0); } //Style //************************ gStyle->SetPalette(1); gStyle->SetOptStat(1111); gStyle->SetPadBorderMode(0); gStyle->SetCanvasColor(10); gStyle->SetPadLeftMargin(0.13); gStyle->SetPadRightMargin(0.13); //Build the Cal Pad //******************************** Int_t smi = sm*30; AliTRDCalPad *ki = new AliTRDCalPad("testnoise","testnoise"); for(Int_t k = 0; k < 540; k++){ ki->SetCalROC(k,(AliTRDCalROC *) cal->GetNoiseROC(k)); } // padstatus 2D Int_t smn = (Int_t) det/30; if((smn==0) || (smn==1) || (smn==2) || (smn==9) || (smn==10) || (smn==11)) smn = 1; if((smn==3) || (smn==4) || (smn==5) || (smn==12) || (smn==13) || (smn==14)) smn = 2; if((smn==6) || (smn==7) || (smn==8) || (smn==15) || (smn==16) || (smn==17)) smn = 3; TString name("TRD/DAQData/PadStatus"); name += smn; //name += 3; AliCDBEntry *entrypadstatus = AliCDBManager::Instance()->Get("TRD/Calib/PadStatus",run); if(!entrypadstatus) return; AliTRDCalPadStatus *lo = (AliTRDCalPadStatus *)entrypadstatus->GetObject(); AliCDBEntry *entryo = AliCDBManager::Instance()->GetStorage(pathreferencedatabase)->Get(name, run); if(!entryo) return; AliTRDCalibPadStatus *calpad = (AliTRDCalibPadStatus *) entryo->GetObject(); if(!calpad) return; // Plot //*********** // noise 2D TCanvas *cnoise = new TCanvas((const char*)"noise1",(const char*)"noise1",50,50,600,800); cnoise->Divide(3,2); cnoise->cd(1); ((TH2F *)ki->MakeHisto2DSmPl(sm,0,u,0,0.0,3.5,-1))->Draw("colz"); cnoise->cd(2); ((TH2F *)ki->MakeHisto2DSmPl(sm,1,u,0,0.0,3.5,-1))->Draw("colz"); cnoise->cd(3); ((TH2F *)ki->MakeHisto2DSmPl(sm,2,u,0,0.0,3.5,-1))->Draw("colz"); cnoise->cd(4); ((TH2F *)ki->MakeHisto2DSmPl(sm,3,u,0,0.0,3.5,-1))->Draw("colz"); cnoise->cd(5); ((TH2F *)ki->MakeHisto2DSmPl(sm,4,u,0,0.0,3.5,-1))->Draw("colz"); cnoise->cd(6); ((TH2F *)ki->MakeHisto2DSmPl(sm,5,u,0,0.0,3.5,-1))->Draw("colz"); // Pad Status TCanvas *cpadstatus = new TCanvas((const char*)"padstatus",(const char*)"padstatus",50,50,600,800); cpadstatus->Divide(3,2); cpadstatus->cd(1); ((TH2F *)lo->MakeHisto2DSmPl(sm,0))->Draw("colz"); cpadstatus->cd(2); ((TH2F *)lo->MakeHisto2DSmPl(sm,1))->Draw("colz"); cpadstatus->cd(3); ((TH2F *)lo->MakeHisto2DSmPl(sm,2))->Draw("colz"); cpadstatus->cd(4); ((TH2F *)lo->MakeHisto2DSmPl(sm,3))->Draw("colz"); cpadstatus->cd(5); ((TH2F *)lo->MakeHisto2DSmPl(sm,4))->Draw("colz"); cpadstatus->cd(6); ((TH2F *)lo->MakeHisto2DSmPl(sm,5))->Draw("colz"); // reference data TCanvas *cpoui = new TCanvas((const char*)"cpoui",(const char*)"cpoui",50,50,600,800); cpoui->cd(); ((TH2F *)calpad->GetHisto(det))->Draw("lego"); AliTRDCalROC *ouip = calpad->GetCalRocMean(det); TCanvas *cpouilo = new TCanvas((const char*)"cpouilo",(const char*)"cpouilo",50,50,600,800); cpouilo->Divide(2,1); cpouilo->cd(1); ((TH1F *)ouip->MakeHisto1D(8.5,10.5,-1,10.0))->Draw(); //((TH1F *)ouip->MakeHisto1D(0.85,1.05,-1))->Draw(); cpouilo->cd(2); ((TH2F *)ouip->MakeHisto2D(8.5,10.5,-1,10.0))->Draw("colz"); //((TH2F *)ouip->MakeHisto2D(0.85,1.05,-1))->Draw("colz"); AliTRDCalROC *ouiphy = calpad->GetCalRocRMS(det); TCanvas *cpouiloh = new TCanvas((const char*)"cpouiloh",(const char*)"cpouiloh",50,50,600,800); cpouiloh->Divide(2,1); cpouiloh->cd(1); ((TH1F *)ouiphy->MakeHisto1D(0.1,4.5,-1,10.0))->Draw(); //((TH1F *)ouiphy->MakeHisto1D(0.01,0.45,-1))->Draw(); cpouiloh->cd(2); ((TH2F *)ouiphy->MakeHisto2D(0.1,4.5,-1,10.0))->Draw("colz"); //((TH2F *)ouiphy->MakeHisto2D(0.01,0.45,-1))->Draw("colz"); }
void MakeTRDResMisAlignment(){ // Create TClonesArray of residual misalignment objects for TRD // const char* macroname = "MakeTRDResMisAlignment.C"; TClonesArray *array = new TClonesArray("AliAlignObjParams",1000); TClonesArray &alobj = *array; // Activate CDB storage and load geometry from CDB AliCDBManager* cdb = AliCDBManager::Instance(); if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); cdb->SetRun(0); AliCDBStorage* storage; if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){ TString Storage = gSystem->Getenv("STORAGE"); if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) { Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data()); return; } storage = cdb->GetStorage(Storage.Data()); if(!storage){ Error(macroname,"Unable to open storage %s\n",Storage.Data()); return; } AliCDBPath path("GRP","Geometry","Data"); AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun()); if(!entry) Fatal(macroname,"Could not get the specified CDB entry!"); entry->SetOwner(0); TGeoManager* geom = (TGeoManager*) entry->GetObject(); AliGeomManager::SetGeometry(geom); } else { AliGeomManager::LoadGeometry(); //load geom from default CDB storage } // sigmas for the chambers Double_t chdx = 0.002; // 20 microns Double_t chdy = 0.003; // 30 microns Double_t chdz = 0.007; // 70 microns Double_t chrx = 0.0005 / 1000.0 / TMath::Pi()*180; // 0 mrad Double_t chry = 0.0005 / 1000.0 / TMath::Pi()*180; // 0 mrad Double_t chrz = 0.1 / 1000.0 / TMath::Pi()*180; // 0.1 mrad // Truncation for the chambers Double_t cutChdx = 3.0 * chdx; Double_t cutChdy = 3.0 * chdy; Double_t cutChdz = 0.14 * chdz; Int_t sActive[18]={1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1}; Double_t dx=0.,dy=0.,dz=0.,rx=0.,ry=0.,rz=0.; Int_t j=0; UShort_t volid; const char* symname; // create the supermodules' alignment objects for (Int_t iSect=0; iSect<18; iSect++) { TString sm_symname(Form("TRD/sm%02d",iSect)); if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue; new((*array)[j++]) AliAlignObjParams(sm_symname.Data(),0,dx,dy,dz,rx,ry,rz,kTRUE); } // create the chambers' alignment objects Int_t chId; for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) { chId=-1; for (Int_t iSect = 0; iSect < 18; iSect++){ for (Int_t iCh = 0; iCh < 5; iCh++) { dx = AliMathBase::TruncatedGaus(0.0,chdx,cutChdx); dy = AliMathBase::TruncatedGaus(0.0,chdy,cutChdy); dz = AliMathBase::TruncatedGaus(0.0,chdz,cutChdz); rx = gRandom->Rndm() * 2.0*chrx - chrx; ry = gRandom->Rndm() * 2.0*chry - chry; rz = gRandom->Rndm() * 2.0*chrz - chrz; chId++; if ((iSect==13 || iSect==14 || iSect==15) && iCh==2) continue; volid = AliGeomManager::LayerToVolUID(iLayer,chId); if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue; symname = AliGeomManager::SymName(volid); new(alobj[j++]) AliAlignObjParams(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE); } } } if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) { // save on file const char* filename = "TRDresidualMisalignment.root"; TFile f(filename,"RECREATE"); if(!f){ Error(macroname,"cannot open file for output\n"); return; } Info(macroname,"Saving alignment objects to the file %s", filename); f.cd(); f.WriteObject(array,"TRDAlignObjs","kSingleKey"); f.Close(); } else { // save in CDB storage AliCDBMetaData* md = new AliCDBMetaData(); md->SetResponsible("Dariusz Miskowiec"); md->SetComment("Residual misalignment for TRD"); md->SetAliRootVersion(gSystem->Getenv("ARVERSION")); AliCDBId id("TRD/Align/Data",0,AliCDBRunRange::Infinity()); storage->Put(array,id,md); } array->Delete(); }
const AliEventInfo* GetEventInfo() { // Fill the event info object AliCentralTrigger *aCTP = NULL; if (AliEveEventManager::AssertRawReader()) { fEventInfo.SetEventType(AliEveEventManager::AssertRawReader()->GetType()); ULong64_t mask = AliEveEventManager::AssertRawReader()->GetClassMask(); fEventInfo.SetTriggerMask(mask); UInt_t clmask = AliEveEventManager::AssertRawReader()->GetDetectorPattern()[0]; fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask)); aCTP = new AliCentralTrigger(); TString configstr(""); if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB printf("No trigger configuration found in OCDB! The trigger configuration information will not be used!"); // delete aCTP; return 0; } aCTP->SetClassMask(mask); aCTP->SetClusterMask(clmask); if (AliEveEventManager::AssertRunLoader()) { AliCentralTrigger* rlCTP = AliEveEventManager::AssertRunLoader()->GetTrigger(); if (rlCTP) { rlCTP->SetClassMask(mask); rlCTP->SetClusterMask(clmask); } } } else { fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent); if (AliEveEventManager::AssertRunLoader() && (!AliEveEventManager::AssertRunLoader()->LoadTrigger())) { aCTP = AliEveEventManager::AssertRunLoader()->GetTrigger(); fEventInfo.SetTriggerMask(aCTP->GetClassMask()); // get inputs from actp - just get AliESDEvent *esdEvent = AliEveEventManager::Instance()->GetESD(); if(esdEvent) { AliESDHeader* esdheader = esdEvent->GetHeader(); esdheader->SetL0TriggerInputs(aCTP->GetL0TriggerInputs()); esdheader->SetL1TriggerInputs(aCTP->GetL1TriggerInputs()); esdheader->SetL2TriggerInputs(aCTP->GetL2TriggerInputs()); fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask())); } else { cout<<"tpc_raw -- no ESD event"<<endl; } } else { printf("No trigger can be loaded! The trigger information will not be used!"); return 0; } } AliTriggerConfiguration *config = aCTP->GetConfiguration(); if (!config) { printf("No trigger configuration has been found! The trigger configuration information will not be used!"); // if (AliEveEventManager::AssertRawReader()) delete aCTP; return 0; } TString declTriggerClasses; // Load trigger aliases and declare the trigger classes included in aliases AliCDBEntry * entry = AliCDBManager::Instance()->Get("GRP/CTP/Aliases"); if (entry) { THashList * lst = dynamic_cast<THashList*>(entry->GetObject()); if (lst) { lst->Sort(kFALSE); // to avoid problems with substrings if (AliEveEventManager::AssertRawReader()) AliEveEventManager::AssertRawReader()->LoadTriggerAlias(lst); // Now declare all the triggers present in the aliases TIter iter(lst); TNamed *nmd = 0; while((nmd = dynamic_cast<TNamed*>(iter.Next()))){ declTriggerClasses += " "; declTriggerClasses += nmd->GetName(); } } else { printf("Cannot cast the object with trigger aliases to THashList!"); } } else { printf("No OCDB entry for the trigger aliases!"); } // Load trigger classes for this run UChar_t clustmask = 0; TString trclasses; ULong64_t trmask = fEventInfo.GetTriggerMask(); const TObjArray& classesArray = config->GetClasses(); Int_t nclasses = classesArray.GetEntriesFast(); for( Int_t iclass=0; iclass < nclasses; iclass++ ) { AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass); if (trclass && trclass->GetMask()>0) { Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMask())); if (AliEveEventManager::AssertESD()) AliEveEventManager::AssertESD()->SetTriggerClass(trclass->GetName(),trindex); if (AliEveEventManager::AssertRawReader()) AliEveEventManager::AssertRawReader()->LoadTriggerClass(trclass->GetName(),trindex); if (trmask & (1ull << trindex)) { trclasses += " "; trclasses += trclass->GetName(); trclasses += " "; clustmask |= trclass->GetCluster()->GetClusterMask(); } } } fEventInfo.SetTriggerClasses(trclasses); if (!aCTP->CheckTriggeredDetectors()) { // if (AliEveEventManager::AssertRawReader()) delete aCTP; cout<<"Check trigger detectors failed"<<endl; return 0; } // if (AliEveEventManager::AssertRawReader()) delete aCTP; // everything went ok, return pointer return (&fEventInfo); }