74 Charge_Vs_Path =
new TH3F (
"Charge_Vs_Path" ,
"Charge_Vs_Path" ,
P_NBins,
P_Min,
P_Max,
Path_NBins,
Path_Min,
Path_Max,
Charge_NBins,
Charge_Min,
Charge_Max);
92 if( strcmp(
algoMode.c_str(),
"MultiJob")==0){
97 }
else if( strcmp(
algoMode.c_str(),
"WriteOnDB")==0){
99 Charge_Vs_Path = (TH3F*)(Input->FindObjectAny(
"Charge_Vs_Path"))->Clone();
101 }
else if(strcmp(
algoMode.c_str(),
"CalibTree")==0){
107 Charge_Vs_Path = (TH3F*)(Input->FindObjectAny(
"Charge_Vs_Path"))->Clone();
120 unsigned track_index = 0;
129 const vector<TrajectoryMeasurement> & measurements = traj.
measurements();
130 for(vector<TrajectoryMeasurement>::const_iterator it = measurements.begin(); it!=measurements.end(); it++){
132 if( !trajState.
isValid())
continue;
136 if(!recHit || !recHit->
isValid())
continue;
138 float cosine = trackDirection.
z()/trackDirection.
mag();
149 if(!thit.isValid())
return;
152 if(!clus.isValid())
return;
157 }
else if(clus.isStrip() && !thit.isMatched()){
158 auto& detUnit = *(recHit->
detUnit());
160 if( cluster.amplitudes().size()>
MaxNrStrips) {
return; }
163 float pathLen = 10.0*detUnit.surface().bounds().thickness()/fabs(cosine);
165 float charge = chargeAbs/pathLen;
169 }
else if(clus.isStrip() && thit.isMatched()){
171 if(!matchedHit)
return;
174 auto& detUnitM = *(gdet->
monoDet());
176 if( clusterM.amplitudes().size()>
MaxNrStrips) {
return; }
179 float pathLen = 10.0*detUnitM.surface().bounds().thickness()/fabs(cosine);
181 float charge = chargeAbs/pathLen;
188 if( clusterS.amplitudes().size()>
MaxNrStrips) {
return; }
191 pathLen = 10.0*detUnitS.surface().bounds().thickness()/fabs(cosine);
193 charge = chargeAbs/pathLen;
207 unsigned int NEvent = 0;
210 TChain*
tree =
new TChain(
"gainCalibrationTree/tree");
213 TString EventPrefix(
"");
214 TString EventSuffix(
"");
216 TString TrackPrefix(
"track");
217 TString TrackSuffix(
"");
219 TString CalibPrefix(
"GainCalibration");
220 TString CalibSuffix(
"");
222 unsigned int eventnumber = 0; tree->SetBranchAddress(EventPrefix +
"event" + EventSuffix, &eventnumber ,
nullptr);
223 unsigned int runnumber = 0; tree->SetBranchAddress(EventPrefix +
"run" + EventSuffix, &runnumber ,
nullptr);
224 std::vector<bool>* TrigTech =
nullptr; tree->SetBranchAddress(EventPrefix +
"TrigTech" + EventSuffix, &TrigTech ,
nullptr);
226 std::vector<double>* trackchi2ndof =
nullptr; tree->SetBranchAddress(TrackPrefix +
"chi2ndof" + TrackSuffix, &trackchi2ndof ,
nullptr);
227 std::vector<float>* trackp =
nullptr; tree->SetBranchAddress(TrackPrefix +
"momentum" + TrackSuffix, &trackp ,
nullptr);
228 std::vector<float>* trackpt =
nullptr; tree->SetBranchAddress(TrackPrefix +
"pt" + TrackSuffix, &trackpt ,
nullptr);
229 std::vector<double>* tracketa =
nullptr; tree->SetBranchAddress(TrackPrefix +
"eta" + TrackSuffix, &tracketa ,
nullptr);
230 std::vector<double>* trackphi =
nullptr; tree->SetBranchAddress(TrackPrefix +
"phi" + TrackSuffix, &trackphi ,
nullptr);
231 std::vector<unsigned int>* trackhitsvalid =
nullptr; tree->SetBranchAddress(TrackPrefix +
"hitsvalid" + TrackSuffix, &trackhitsvalid,
nullptr);
233 std::vector<int>* trackindex =
nullptr; tree->SetBranchAddress(CalibPrefix +
"trackindex" + CalibSuffix, &trackindex ,
nullptr);
234 std::vector<unsigned int>* rawid =
nullptr; tree->SetBranchAddress(CalibPrefix +
"rawid" + CalibSuffix, &rawid ,
nullptr);
235 std::vector<unsigned short>* firststrip =
nullptr; tree->SetBranchAddress(CalibPrefix +
"firststrip" + CalibSuffix, &firststrip ,
nullptr);
236 std::vector<unsigned short>* nstrips =
nullptr; tree->SetBranchAddress(CalibPrefix +
"nstrips" + CalibSuffix, &nstrips ,
nullptr);
237 std::vector<unsigned int>*
charge =
nullptr; tree->SetBranchAddress(CalibPrefix +
"charge" + CalibSuffix, &charge ,
nullptr);
238 std::vector<float>*
path =
nullptr; tree->SetBranchAddress(CalibPrefix +
"path" + CalibSuffix, &path ,
nullptr);
239 std::vector<unsigned char>*
amplitude =
nullptr; tree->SetBranchAddress(CalibPrefix +
"amplitude" + CalibSuffix, &litude ,
nullptr);
240 std::vector<double>* gainused =
nullptr; tree->SetBranchAddress(CalibPrefix +
"gainused" + CalibSuffix, &gainused ,
nullptr);
242 printf(
"Number of Events = %i + %i = %i\n",NEvent,(
unsigned int)tree->GetEntries(),(
unsigned int)(NEvent+tree->GetEntries()));NEvent+=tree->GetEntries();
243 printf(
"Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n");
244 printf(
"Looping on the Tree :");
245 int TreeStep = tree->GetEntries()/50;
if(TreeStep<=1)TreeStep=1;
246 for (
unsigned int ientry = 0; ientry < tree->GetEntries(); ientry++) {
247 if(ientry%TreeStep==0){printf(
".");fflush(
stdout);}
248 tree->GetEntry(ientry);
250 int FirstAmplitude = 0;
251 for(
unsigned int c=0;
c<(*path).size();
c++){
252 FirstAmplitude+=(*nstrips)[
c];
253 int t = (*trackindex)[
c];
254 if((*trackpt)[
t]<5)
continue;
255 if((*trackhitsvalid)[
t]<5)
continue;
260 auto &
gain = gains[(*firststrip)[
c]/128];
261 for(
unsigned int s=0;
s<(*nstrips)[
c];
s++){
262 int StripCharge = (*amplitude)[FirstAmplitude-(*nstrips)[
c]+
s];
264 StripCharge=(
int)(StripCharge/
gain);
265 if(StripCharge>=1024){
267 }
else if(StripCharge>=254){
271 Charge += StripCharge;
274 Charge = (*charge)[
c];
278 double ClusterChargeOverPath = ( (double) Charge )/(*path)[
c] ;
288 auto obj = std::make_unique<PhysicsTools::Calibration::HistogramD3D>(
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void algoAnalyze(const edm::Event &, const edm::EventSetup &) override
const GeomDetUnit * monoDet() const
friend struct const_iterator
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
SiStripCluster const & monoCluster() const
LocalVector localDirection() const
void algoEndJob() override
LocalVector localMomentum() const
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
DataContainer const & measurements() const
SiStripCluster const & stripCluster() const
double eta() const
pseudorapidity of momentum vector
void algoAnalyzeTheTree(const edm::EventSetup &iSetup)
std::unique_ptr< PhysicsTools::Calibration::HistogramD3D > getNewObject() override
const GeomDet * det() const
unsigned int MinTrackHits
unsigned int offsetDU(SubDetector sid) const
double pt() const
track transverse momentum
void processHit(const TrackingRecHit *recHit, float trackMomentum, float &cosine, const TrajectoryStateOnSurface &trajState)
std::vector< std::string > VInputFiles
std::string m_calibrationPath
~DeDxDiscriminatorLearner() override
void algoBeginJob(const edm::EventSetup &) override
SiStripCluster const & stereoCluster() const
virtual const GeomDetUnit * detUnit() const
unsigned short found() const
Number of valid hits on track.
virtual OmniClusterRef const & firstClusterRef() const =0
edm::EDGetTokenT< TrajTrackAssociationCollection > m_trajTrackAssociationTag
const_iterator begin() const
first iterator over the map (read only)
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
const GeomDetUnit * stereoDet() const
std::vector< std::vector< float > > calibGains
DeDxDiscriminatorLearner(const edm::ParameterSet &)