1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
#!/bin/bash
#
# Author: Ph Gras. CEA/IRFU - Saclay
#
binpath="`readlink -f "$0"`"
bindir="`dirname "$binpath"`"
function sigHdl(){
if [ -e $TMPFILE ]; then
rm "$TMPFILE"
fi
exit 0
}
trap sigHdl SIGKILL SIGABRT SIGQUIT SIGTERM SIGPIPE SIGINT
# Note that we use `"$@"' to let each command-line parameter expand to a
# separate word. The quotes around `$@' are essential!
# We need TEMP as the `eval set --' would nuke the return value of getopt.
temp=`getopt -o hs:n:N:p:Adqgfrle: --long help,l1axmin:,l1axmax:,no-l1a-history,local-file,fed-size,feds: \
-n 'dumpRaw' -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$temp"
function help(){
echo "usage: dumpRaw [OPTIONS...] {run_num|file_name}
Dump ECAL raw data running DumpRaw module of CMSSW. CMSSW environment must be setup beforehand (see scramv1 runtime).
OPTIONS:
-h displays this help on usage
-s N specifies number of event to skip (default 0)
-n N specifies number of events to process including skipped ones
-N N specifies number of events to process excluding skipped ones.
To be used in place of -n option.
-e event1,event2,... processes events with ID event1, event2, ...
-p N prescale factor (only supported for .lmf file)
-A skip ADC count dump
-q no dump
-d runs EBDigiAna
-l runs ListCollection
--fed-size runs FedSize
-g runs within gdb debugger
-f --local-file file_name is a local file
-r execute eval \`scramv1 runtime -sh\` in directory of $0.
--no-l1a-history Disable display of L1A, BX and orbit counter history
--l1axmin lower bound on l1a for histogramming
--l1aymin upper bound on l1a for histogramming
--feds FED ID range. Format first:last. E.g. for every ECAL DCCs: 601:654
"
}
nskip=0
nevts=-1
dump="True"
dumpAdc="True"
prog=DumpRaw
l1axmin=1
l1axmax=600
fedmin=601
fedmax=654
prescale=1
fedmin=601
fedmax=654
unset nevts_
l1aHist="True"
unset prefix
unset gdb
unset cmsswdir
unset eventList
while true ; do
case "$1" in
-h|--help) help; exit 0;;
-s) nskip="$2"; shift 2;;
-n) nevts="$2"; shift 2;;
-N) nevts_="$2"; shift 2;;
-p) prescale="$2"; shift 2;;
-A) dumpAdc="False"; shift;;
-d) prog="EBDigiAna"; shift;;
-l) prog="ListCollection";shift;;
--fed-size) prog="FedSize";shift;;
-q) dump="False"; shift;;
-g) gdb="gdb --args"; shift;;
-f|--local-file) prefix="file:"; shift;;
--l1axmin) l1axmin="$2"; shift 2;;
--l1axmax) l1axmax="$2"; shift 2;;
--no-l1a-history) l1aHist="False"; shift;;
--feds) eval `echo $2 | sed 's/\([[:digit:]]\+\):\([[:digit:]]\)/fedmin=\1 fedmax=\2/'`; shift 2;;
-r) cmsswdir="$bindir"; shift;;
-e) eventList="$2"; shift 2;;
--) shift ; break ;; #end of options. It remains only the args.
*) echo "Internal error!" ; exit 1 ;;
esac
done
[ -n "$nevts_" ] && nevts=$((nskip+nevts_))
if [ -z "$cmsswdir" -a -z "$CMSSW_BASE" ]; then
echo "CMSSW environment not set (CMSSW_BASE variable not found). Setting CMSSW environment for $bindir area (scramv1 runtime)."
cmsswdir="$bindir"
fi
if [ -n "$cmsswdir" ]; then
eval `(cd "$cmsswdir" && scramv1 runtime -sh)`
fi
TMPFILE=`mktemp -t dumpRaw.XXXXXXX`
mv "$TMPFILE" "$TMPFILE.py"
TMPFILE="$TMPFILE.py"
if [ -z $TMPFILE ]; then
echo 'Failed to create a temporary file!'
exit 1
fi
if [ -n "$1" ]; then
if [ X"$1" = X-h -o X"$1" = X-h ];then
echo "Usage: dumpRaw [datasetpath]
for a local file, prefix the path by file:// or -f
-s N skip N events
-n N process N evnts
+a skip ADC count dump
"
exit 0;
fi
if [ $1 == "-f" ]; then
dataset="file://$2"
else
dataset="$1"
fi
else
echo -n "Dataset/P5 run number: "
read dataset
fi
echo $dataset | egrep -q '^[[:digit:]]+$'
if [ X$? = X0 ]; then #run number was provided instead of dataset name
# local daq old format:
# dataset=`printf file:/local_data/daq/p5/P5_Co.%08d.A.0.0.root $dataset`
# for P5 local daq:
dataset=`printf /local_data/daq/p5/ecal_local.%08d.0001.A.storageManager.0.*.dat $dataset`
#dataset=`printf /local_data/daq/p5/CalPrivateGlobal.%08d.0001.A.storageManager.0.*.dat $dataset`
dataset=`ls $dataset`
dataset=`echo $dataset | sed 's/[^[:space:]]*/'\''file:\0'\''/g' | tr ' ' ,`
else
dataset="'${prefix}${dataset}'"
fi
if [ -z "$dataset" ]; then
echo 'A data set name is required!'
exit 1
fi
format=`echo "$dataset" | sed 's/.*\.\(.*\)'\''/\1/'`
if [ X$format != Xlmf -a X$prescale != X1 ]; then
echo "Prescale is not supported for $format file"
exit 1
fi
cat > "$TMPFILE" <<EOF
import FWCore.ParameterSet.Config as cms
process = cms.Process("TEST")
EOF
if [ "X$format" = Xroot ]; then
cat >> "$TMPFILE" <<EOF
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring( $dataset ),
)
EOF
elif [ "X$format" = Xlmf ]; then
cat >> "$TMPFILE" <<EOF
process.load("CalibCalorimetry.EcalLaserSorting.LmfSource_cfi")
process.source.fileNames = cms.vstring( $dataset )
process.source.preScale = cms.uint32( $prescale )
process.source.orderedRead = cms.bool(True)
process.source.verbosity = cms.untracked.int32(0)
process.source.firstLuminosityBlockForEachRun = cms.untracked.VLuminosityBlockID()
EOF
else
cat >> "$TMPFILE" <<EOF
process.source = cms.Source("NewEventStreamFileReader",
fileNames = cms.untracked.vstring( $dataset )
)
EOF
fi
cat >> "$TMPFILE" <<EOF
process.MessageLogger = cms.Service("MessageLogger",
cout = cms.untracked.PSet(
threshold = cms.untracked.string('WARNING'),
default = cms.untracked.PSet(
limit = cms.untracked.int32(0)
)
),
destinations = cms.untracked.vstring('cout')
)
EOF
if [ X$prog = XDumpRaw ];then
if [ X$l1aHist = XTrue ]; then
cat >> "$TMPFILE" <<EOF
process.load('EventFilter.ScalersRawToDigi.ScalersRawToDigi_cfi')
process.scalersRawToDigi.scalersInputTag = 'rawDataCollector'
EOF
cmssw_path="process.scalersRawToDigi*"
else
cmssw_path=""
fi
cmssw_path="${cmssw_path}process.dumpRaw"
cat >> "$TMPFILE" <<EOF
process.load("EventFilter.EcalRawToDigi.EcalDumpRaw_cfi")
process.dumpRaw.fedRawDataCollectionTag = "source"
process.dumpRaw.l1aMinX = $l1axmin
process.dumpRaw.l1aMaxX = $l1axmax
process.dumpRaw.first_event = $((nskip+1))
process.dumpRaw.last_event = cms.untracked.int32($((nskip+nevts)))
process.dumpRaw.dumpAdc = $dumpAdc
process.dumpRaw.dump = $dump
process.dumpRaw.l1aHistory = $l1aHist
process.dumpRaw.beg_fed_id = $fedmin
process.dumpRaw.end_fed_id = $fedmax
process.dumpRaw.eventList = [ $eventList ]
process.dumpRaw.beg_fed_id = $fedmin
process.dumpRaw.end_fed_id = $fedmax
process.p = cms.Path($cmssw_path)
EOF
elif [ X$prog = XListCollection ]; then
cat >> "$TMPFILE" <<EOF
process.load("pgras.ListCollection.ListCollection_cfi")
process.p = cms.Path(process.listColl)
EOF
elif [ X$prog = XFedSize ]; then
cat >> "$TMPFILE" <<EOF
process.load("pgras.FedSize.FedSize_cfi")
process.fedSize.verbosity = 2
process.p = cms.Path(process.fedSize)
process.TFileService = cms.Service("TFileService",
fileName = cms.string("fedsize.root"))
EOF
else
cat >> "$TMPFILE" <<EOF
process.load("EventFilter.EcalRawToDigi.EcalUnpackerData_cfi")
process.load("pgras.EBDigiAna.EBDigiAna_cfi")
process.load("Geometry.EcalMapping.EcalMapping_cfi")
process.load("Geometry.EcalMapping.EcalMappingRecord_cfi")
process.p = cms.Path(process.ecalEBunpacker*process.ebDigiAna)
EOF
fi
EXE=cmsRun
which $EXE > /dev/null
if [ $? != 0 ]; then
echo "$EXE not found in PATH. Has the CMSSW environment been set with scramv1 runtime command?"
exit 1
fi
$gdb "$EXE" $TMPFILE
if [ $? != 0 ]; then
cat 1>&2 <<EOF
********************************************************************************
In case of \"ProductNotFound\" exception (see above) about type
"FEDRawDataCollection", try to run with the option --no-l1a-history.
********************************************************************************
EOF
fi
#"$EXE" $TMPFILE
#rm $TMPFILE
|