Commit 3368c2ca authored by Shaun Roe's avatar Shaun Roe Committed by Graeme Stewart
Browse files

update for new EDM, minor changes to accessors for covariance matrix (TRT_CalibAlgs-00-01-02)

parent ea4ecdb5
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRT_CALIBALGS_TRTCALIBRATIONMGR_H
#define TRT_CALIBALGS_TRTCALIBRATIONMGR_H
#include <string>
#include <vector>
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ServiceHandle.h"
#include "StoreGate/DataHandle.h"
//#include "TrkTrack/Track.h"
//#include "TRT_ConditionsTools/TRTCalDbTool.h"
class EventInfo;
namespace TRT{
class TrackInfo;
}
namespace Trk{
class ITrackSelectorTool;
class ITrackFitter;
}
class IFillAlignTrkInfo;
class ITRTCalibrator;
class IAccumulator;
class IFitTool;
class ITRT_CalDbSvc;
/**
@class TRTCalibrationMgr
This algorithm controls the flow of the TRT calibration.
Documentation being updated (Jan 2009)
The calculation of t0 from the timeresidual histogram is made in the
following way: First it is checked where the maximum bin is located.
If its absolute value is bigger then 5 ns NO fit is made, but the
histogram mean value is used for Dt0 instead (this was just taken from
previous versions and I have never really questioned the reason for
it). If the highest bin is lower than 5 ns a normal gaussian fit is
made and Dt0 is set to the mean of that. The new t0 is then the old t0
+ Dt0.
@author Chafik, Johan, Alex
*/
class TRTCalibrationMgr: public AthAlgorithm
{
public:
TRTCalibrationMgr(const std::string& name, ISvcLocator* pSvcLocator);
~TRTCalibrationMgr(void);
StatusCode initialize(void);
StatusCode execute(void);
StatusCode finalize(void);
private:
ToolHandleArray<IFillAlignTrkInfo> m_TrackInfoTools;
ToolHandleArray<ITRTCalibrator> m_TRTCalibTools;
ToolHandleArray<IAccumulator> m_AccumulatorTools;
ToolHandleArray<IFitTool> m_FitTools;
ToolHandle<Trk::ITrackFitter> m_trackFitter;
ServiceHandle<ITRT_CalDbSvc> m_trtcaldbSvc ;
bool m_dorefit;
bool m_docalibrate;
bool m_writeConstants;
int m_ntrk;
const DataHandle<EventInfo> m_EventInfo;
ToolHandle<Trk::ITrackSelectorTool> m_trackSelector; //!< Tool handle to the Trk::ITrackSelectorTool
std::vector<std::string> m_TrkCollections;
unsigned int m_max_ntrk;
};
#endif // TRT_CALIBALGS_TRTCALIBRATIONMGR_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// TRT_StrawStatus.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef INDETTRT_STRAWSTATUS_H
#define INDETTRT_STRAWSTATUS_H
// Gaudi includes
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/ServiceHandle.h"
#include "GaudiKernel/ToolHandle.h"
#include "TrkToolInterfaces/IUpdator.h"
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
class AtlasDetectorID;
class Identifier;
class TRT_ID;
class ITRT_StrawNeighbourSvc;
class ITRT_StrawStatusSummarySvc ;
class ITRT_HWMappingSvc;
class ITRT_DCS_ConditionsSvc;
namespace Trk {
class ITrackHoleSearchTool;
}
namespace InDet
{
/** @class TRT_StrawStatus
This algorithm finds dead or hot TRT straws / chips / boards based on
occupancy and hits on track.
To be used in calibration stream (to mask off dead regions before processing)
@author Sasa Fratina <sasa.fratina@cern.ch>
*/
class TRT_StrawStatus : public AthAlgorithm
{
public:
/** Standard Athena-Algorithm Constructor */
TRT_StrawStatus(const std::string& name, ISvcLocator* pSvcLocator);
/** Default Destructor */
~TRT_StrawStatus();
/** standard Athena-Algorithm method */
StatusCode initialize();
/** standard Athena-Algorithm method */
StatusCode execute();
/** standard Athena-Algorithm method */
StatusCode finalize();
private:
void clear();
// void detailedReportResults();
void reportResults();
void printDetailedInformation();
/** function that returns straw index (in range 0-5481; 0-1641 for barrel, the rest for endcap)
same convention as for TRT_monitoring (copied from there) */
void myStrawIndex(Identifier id, int *index);
int barrelStrawNumber(int strawNumber, int strawlayerNumber, int LayerNumber);
int endcapStrawNumber( int strawNumber, int strawLayerNumber, int LayerNumber );
/** returns index of hardware units: board, chip, pad
private fix for now, will call TRTStrawNeighbourSvc when available
number boards 0-9 barrel, 0-19 endcap (first 12 on A wheels, ordering from smaller to larger |z|)
number chips 0-103 barrel, 0-239 endcap
number pads: chips x 2 */
// void myHardwareMapping(Identifier id, int &board, int &chip, int &pad);
int m_nBarrelStraws; // 1642
int m_nEndcapStraws; // 3840
int m_nAllStraws; // 1642+3840=5484
int m_nBarrelBoards; // 9
int m_nEndcapBoards; // 20
int m_nAllBoards; // 29
int m_nBarrelChips; // 104
int m_nEndcapChips; // 240
int m_nAllChips; // 344
int m_nBarrelPads; // 2 x N of chips
int m_nEndcapPads;
int m_nAllPads;
int m_nEvents; // count N of processed events, needed for normalization
int m_runNumber;
/** accumulate hits, last index: 0 - all hits, 1 - hits on track, 2 - all HT (TR) hits, 3 - HT (TR) hits on track */
int m_accumulateHits[2][32][5482][6];
const TRT_ID *m_TRTHelper;
ServiceHandle<ITRT_HWMappingSvc> m_mapSvc;
ServiceHandle<ITRT_DCS_ConditionsSvc> m_DCSSvc;
ServiceHandle<ITRT_StrawNeighbourSvc> m_TRTStrawNeighbourSvc;
ServiceHandle<ITRT_StrawStatusSummarySvc> m_TRTStrawStatusSummarySvc;
ToolHandle<Trk::ITrackHoleSearchTool> m_trt_hole_finder;
ToolHandle<Trk::IUpdator> m_updator;
double m_locR_cut;
std::string m_tracksName;
std::string m_fileName;
int m_skipBusyEvents;
// int m_accumulateStrawWordFlag;
// int m_accumulateStrawWord[2][32][5482][28];
/** member variables for algorithm properties: */
// int/double/bool m_propertyName;
int m_printDetailedInformation;
};
} // end of namespace
#endif
package TRT_CalibAlgs
author Wouter Hulsbergen <Wouter.Hulsbergen@cern.ch>
author Chafik Driouichi <chafik@nbi.dk>
author Sasa Fratina <sasa.fratina@cern.ch>
use AthenaBaseComps AthenaBaseComps-* Control
use StoreGate StoreGate-* Control
use AtlasPolicy AtlasPolicy-*
use GaudiInterface GaudiInterface-* External
use TrkToolInterfaces TrkToolInterfaces-* Tracking/TrkTools
private
use VxVertex VxVertex-* Tracking/TrkEvent
use EventInfo EventInfo-* Event
use DataModel DataModel-* Control
use TRT_CalibData TRT_CalibData-* InnerDetector/InDetCalibEvent
use TRT_CalibTools TRT_CalibTools-* InnerDetector/InDetCalibTools
use TRT_ConditionsData TRT_ConditionsData-* InnerDetector/InDetConditions
use TRT_ConditionsServices TRT_ConditionsServices-* InnerDetector/InDetConditions
use CommissionEvent CommissionEvent-* Commission
use TrkTrack TrkTrack-* Tracking/TrkEvent
use TrkParameters TrkParameters-* Tracking/TrkEvent
use TrkFitterInterfaces TrkFitterInterfaces-* Tracking/TrkFitter
use TRT_TrackHoleSearch TRT_TrackHoleSearch-* InnerDetector/InDetRecTools
# add for TRT_StrawStatus
use Identifier Identifier-* DetectorDescription
use InDetIdentifier InDetIdentifier-* InnerDetector/InDetDetDescr
use InDetRawData InDetRawData-* InnerDetector/InDetRawEvent
use InDetPrepRawData InDetPrepRawData-* InnerDetector/InDetRecEvent
use InDetRIO_OnTrack InDetRIO_OnTrack-* InnerDetector/InDetRecEvent
use AtlasROOT AtlasROOT-* External
public
apply_pattern declare_joboptions files="*.py"
apply_tag ROOTMathLibs
apply_pattern component_library
library TRT_CalibAlgs *.cxx components/*.cxx
#####################################################################################################
## ##
## General configuration file for the TRT Calibration ##
## If you don't know how to setup, please visit Twiki: ##
## TRTOfflineCalibration ##
## ##
## This Script requieres: ##
## -Permission to use the idcalib AFS account ##
## -Permission to use the batch queue atlasidcal ##
## -Special C++ code to do merging and calibration: ##
## ##
## Please report problems, bugs, comments, ... to: ##
## Johan Lundqvist <johan.lundquistNOSPAMnbi.dk> ##
## Alejandro Alonso <alejandro.alonsoNOSPAMhep.lu.se> ##
## ##
#####################################################################################################
# === e-mail address of user
UserMail = joahn.lundquist@nbi.dk
# === Select ESD or RAW
DataType = ESD
Inputdir = castor:/castor/cern.ch/grid/atlas/tzero/prod1/perm/data10_7TeV/physics_MinBias/0152166/data10_7TeV.00152166.physics_MinBias.recon.ESD.f236
Inputpattern = *
# === If "True" this one overrides both data types RAW and ESD
#For MC
IsCosmicMC = False
#For Real Data:
IsCosmic = False
IsSingleBeam = False
IsCollision = True
# === DB tags (NOT NEEDED TO SETUP; THEY WILL AUTOSETUP when running from ESDs)
RTtag = TrtCalibRt-bootstrap-01
T0tag = TrtCalibT0-bootstrap-01
IOVstart = 76702
IOVend = 76702
DetDescVer = ATLAS-GEO-10-00-00
GLtag = COMCOND-ES1PST-002-00
# === Selects which jobs to submit. If "False" the shell scripts are still generated
SubmitRecJobs = True
SubmitMergeJobs = True
SubmitCalJobs = True
SubmitCnvJobs = True
# === Set the job prefix to be used in the lxbatch job name. Important to run different calibrations at the same time, note that the .sh files don't change the name!!
JobPrefix =
Tag =
# === Set directories
Workdir = /afs/cern.ch/user/i/idcalib/w0/TRT_Calibration/batch/johantest/Beamdata/testarea
WorkdirRec = /afs/cern.ch/user/i/idcalib/w0/TRT_Calibration/shifterCollisions2010_30march/testarea/
Calibdir = /afs/cern.ch/user/i/idcalib/w0/TRT_Calibration/batch/johantest/Beamdata/testarea/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/share
WWWdir = /afs/cern.ch/user/i/idcalib/w0/TRT_Calibration/www/CalibrationRunList
# === ATLAS sw release
#Release = 15.5.4.12,AtlasTier0,32,runtime
#ReleaseRec = 15.5.4.12,AtlasTier0,32,runtime
#Release = 15.6.3.1,AtlasProduction,32,runtime
#ReleaseRec = 15.6.3.1,AtlasProduction,32,runtime
#Release = 15.6.3.3,AtlasProduction,32,runtime
#ReleaseRec = 15.6.3.3,AtlasProduction,32,runtime
Release = 15.6.3.3,AtlasProduction,32,runtime
ReleaseRec = 15.6.7.8,AtlasProduction,32,runtime
# === Magnetic field (This will be autosetup on initiazation)
MagnetOn = True
# === Athena log output
GetLog = True
OutputLevel = INFO
# === Job control
CleanRRoot = False
CleanCRoot = False
CleanCTxt = False
CleanCLog = False
Batchqueue = atlasidcal
DoAthenaCalib = True
UseHist = True
MaxParallel = 35
StartIter = 0
NumIter = 1
# === Selects from where to load the calib constants for the first iteration
#StartConst = /afs/cern.ch/user/i/idcalib/w0/TRT_Calibration/shifterCosmicsJanuary2010/calibout_final_143657.txt
StartConst = db
# === Set calibration parameters
MinT0 = 500
MinRT = 10000
UsePol0 = False
FloatPol3 = True
UseChipRef = True
UseHist = True
#RtRelation = dines
RtRelation = basic
RtBinning = t
SplitAC = True
DoRt = detector
RTglobalValues = line:'-3 -1 -1 -1 -1 : 0 0.000000e+00 8.123064e-02 -1.417874e-03 1.676736e-05'
#RTglobalValues = file:/afs/cern.ch/user/j/johan/johantest/Cosmics/MCBinned.txt
#If you don't want to perform Rt calibration, the Rt relation to be used has to be given in the previous line
DoT0 = straw
T0globalValues = line:'-3 -1 -1 -1 -1 : 20 0.0'
#T0globalValues = file:/afs/cern.ch/user/j/johan/shifter/batch_91007_RtFixed/input/calibout_04.txt
#If you don't want to perform T0 calibration, the global T0 to be used has to be given in the previous line
#MeanT0 is used only in cosmic data, to keep the average T0 fixed. Note, it requieres the script NormalizeT0.py inside package /TRTCalibration
#If you dont want to do it, set this value to 0
MeanT0 = 0
#Setup subdetectors to be calibrated
doEc-2 = True
doEc2 = True
doBA-1 = True
doBA1 = True
# === Just renew the www links
Relink = False
//
// ATLAS Style, based on a style file from BaBar
//
#include <iostream>
#include "AtlasStyle.h"
#include "TROOT.h"
void SetAtlasStyle ()
{
static TStyle* atlasStyle = 0;
std::cout << "\nApplying ATLAS style settings...\n" << std::endl ;
if ( atlasStyle==0 ) atlasStyle = AtlasStyle();
gROOT->SetStyle("ATLAS");
gROOT->ForceStyle();
}
TStyle* AtlasStyle()
{
TStyle *atlasStyle = new TStyle("ATLAS","Atlas style");
// use plain black on white colors
Int_t icol=0; // WHITE
atlasStyle->SetFrameBorderMode(icol);
atlasStyle->SetFrameFillColor(icol);
atlasStyle->SetCanvasBorderMode(icol);
atlasStyle->SetCanvasColor(icol);
atlasStyle->SetPadBorderMode(icol);
atlasStyle->SetPadColor(icol);
atlasStyle->SetStatColor(icol);
//atlasStyle->SetFillColor(icol); // don't use: white fill color for *all* objects
// set the paper & margin sizes
atlasStyle->SetPaperSize(20,26);
// set margin sizes
atlasStyle->SetPadTopMargin(0.05);
atlasStyle->SetPadRightMargin(0.05);
atlasStyle->SetPadBottomMargin(0.16);
atlasStyle->SetPadLeftMargin(0.16);
// set title offsets (for axis label)
atlasStyle->SetTitleXOffset(1.4);
atlasStyle->SetTitleYOffset(1.4);
// use large fonts
//Int_t font=72; // Helvetica italics
Int_t font=42; // Helvetica
Double_t tsize=0.05;
atlasStyle->SetTextFont(font);
atlasStyle->SetTextSize(tsize);
atlasStyle->SetLabelFont(font,"x");
atlasStyle->SetTitleFont(font,"x");
atlasStyle->SetLabelFont(font,"y");
atlasStyle->SetTitleFont(font,"y");
atlasStyle->SetLabelFont(font,"z");
atlasStyle->SetTitleFont(font,"z");
atlasStyle->SetLabelSize(tsize,"x");
atlasStyle->SetTitleSize(tsize,"x");
atlasStyle->SetLabelSize(tsize,"y");
atlasStyle->SetTitleSize(tsize,"y");
atlasStyle->SetLabelSize(tsize,"z");
atlasStyle->SetTitleSize(tsize,"z");
// use bold lines and markers
atlasStyle->SetMarkerStyle(20);
atlasStyle->SetMarkerSize(1.2);
atlasStyle->SetHistLineWidth(2.);
atlasStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
// get rid of X error bars
//atlasStyle->SetErrorX(0.001);
// get rid of error bar caps
atlasStyle->SetEndErrorSize(0.);
// do not display any of the standard histogram decorations
atlasStyle->SetOptTitle(0);
//atlasStyle->SetOptStat(1111);
atlasStyle->SetOptStat(0);
//atlasStyle->SetOptFit(1111);
atlasStyle->SetOptFit(0);
// put tick marks on top and RHS of plots
atlasStyle->SetPadTickX(1);
atlasStyle->SetPadTickY(1);
return atlasStyle;
}
//
// @file AtlasStyle.h
//
// ATLAS Style, based on a style file from BaBar
//
//
// @author M.Sutton
//
// Copyright (C) 2010 Atlas Collaboration
//
// $Id: AtlasStyle.h, v0.0 Thu 25 Mar 2010 10:34:20 CET $
#ifndef __ATLASSTYLE_H
#define __ATLASSTYLE_H
#include "TStyle.h"
void SetAtlasStyle();
TStyle* AtlasStyle();
#endif // __ATLASSTYLE_H
from ROOT import *
ROOT.gROOT.LoadMacro("AtlasStyle.C")
#SetAtlasStyle()
import os,sys,time,glob,fnmatch
def collisioncalib(config,inputfiles,calibconstants,calpart,calsettings):
# print "Loading from CalibCollisionTemplate.py"
# print "Based on Thjis jO: "
ostring="""
# Collision JOs
#
#--------------------------------------------------------------
# Control
#--------------------------------------------------------------
# --- Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL )
OutputLevel = INFO
# --- produce an atlantis data file
doJiveXML = False
# --- run the Virtual Point 1 event visualisation
doVP1 = False
# --- controls what is written out. ESD includes AOD, so it's normally enough
doWriteESD = False
doWriteAOD = False
# --- read BS - please look at the default input file(s) to know the det descr and cond tag
doReadBS = False
###doReadBS = True
# --- do auditors ?
doAuditors = True
import os
if os.environ['CMTCONFIG'].endswith('-dbg'):
# --- do EDM monitor (debug mode only)
doEdmMonitor = True
# --- write out a short message upon entering or leaving each algorithm
doNameAuditor = True
else:
doEdmMonitor = False
doNameAuditor = False
#--------------------------------------------------------------
# detector description version: both RDO and BS default use this
#--------------------------------------------------------------
DetDescrVersion = '%s'""" % config["DetDescVer"]
ostring+="""
#--------------------------------------------------------------
# load Global Flags and set defaults (import the new jobProperty globalflags)
#--------------------------------------------------------------
import AthenaCommon.SystemOfUnits as Units
from AthenaCommon.GlobalFlags import globalflags
# --- default is atlas geometry
globalflags.DetGeo = 'atlas'
# --- set defaults
globalflags.DataSource = 'data'
# --- BS default input uses this
if 'doReadBS' in dir() and doReadBS:
globalflags.InputFormat = 'bytestream'
globalflags.ConditionsTag = '%s'""" % config['GLtag']
ostring+="""
else:
globalflags.DataSource = 'data'
globalflags.InputFormat = 'pool'
globalflags.DetDescrVersion = DetDescrVersion
globalflags.ConditionsTag = '%s'""" % config["GLtag"]
ostring+="""
# --- printout
globalflags.print_JobProperties()
if len(globalflags.ConditionsTag())!=0:
from IOVDbSvc.CondDB import conddb
conddb.setGlobalTag(globalflags.ConditionsTag())