16 Int_t NofMax=0; Int_t recur255=1; Int_t recur254=1;
17 bool MaxOnStart=
false;
bool MaxInMiddle=
false, MaxOnEnd =
false;
20 if(ampls.size()!=1 && ((ampls[0]>ampls[1])
21 || (ampls.size()>2 && ampls[0]==ampls[1] && ampls[1]>ampls[2] && ampls[0]!=254 && ampls[0]!=255)
22 || (ampls.size()==2 && ampls[0]==ampls[1] && ampls[0]!=254 && ampls[0]!=255)) ){
23 NofMax=NofMax+1; MaxOnStart=
true; }
27 for (
unsigned int i =1;
i < ampls.size()-1U;
i++) {
28 if( (ampls[
i]>ampls[
i-1] && ampls[
i]>ampls[
i+1])
29 || (ampls.size()>3 &&
i>0 &&
i<ampls.size()-2U && ampls[
i]==ampls[
i+1] && ampls[
i]>ampls[
i-1] && ampls[
i]>ampls[
i+2] && ampls[
i]!=254 && ampls[
i]!=255) ){
30 NofMax=NofMax+1; MaxInMiddle=
true; MaxPos=
i;
32 if(ampls[
i]==255 && ampls[
i]==ampls[
i-1]) {
34 MaxPos=
i-(recur255/2);
35 if(ampls[
i]>ampls[
i+1]){NofMax=NofMax+1;MaxInMiddle=
true;}
37 if(ampls[
i]==254 && ampls[
i]==ampls[
i-1]) {
39 MaxPos=
i-(recur254/2);
40 if(ampls[
i]>ampls[
i+1]){NofMax=NofMax+1;MaxInMiddle=
true;}
46 if(ampls[ampls.size()-1]>ampls[ampls.size()-2]
47 || (ampls.size()>2 && ampls[ampls.size()-1]==ampls[ampls.size()-2] && ampls[ampls.size()-2]>ampls[ampls.size()-3] )
48 || ampls[ampls.size()-1]==255){
49 NofMax=NofMax+1; MaxOnEnd=
true; }
52 if(ampls.size()==1){ NofMax=1;}
73 Float_t C_M=0.0; Float_t C_D=0.0; Float_t C_Mn=10000; Float_t C_Dn=10000; Float_t C_Mnn=10000; Float_t C_Dnn=10000;
75 Float_t coeff1=1.7; Float_t coeff2=2.0;
76 Float_t coeffn=0.10; Float_t coeffnn=0.02; Float_t
noise=4.0;
81 C_M=(Float_t)ampls[0]; C_D=(Float_t)ampls[1];
82 if(ampls.size()<3) shapecdtn=
true ;
83 else if(ampls.size()==3){C_Dn=(Float_t)ampls[2] ;
if(C_Dn<=coeff1*coeffn*C_D+coeff2*coeffnn*C_M+2*noise || C_D==255) shapecdtn=
true;}
84 else if(ampls.size()>3){ C_Dn=(Float_t)ampls[2]; C_Dnn=(Float_t)ampls[3] ;
85 if((C_Dn<=coeff1*coeffn*C_D+coeff2*coeffnn*C_M+2*noise || C_D==255)
86 && C_Dnn<=coeff1*coeffn*C_Dn+coeff2*coeffnn*C_D+2*
noise){
92 C_M=(Float_t)ampls[ampls.size()-1]; C_D=(Float_t)ampls[ampls.size()-2];
93 if(ampls.size()<3) shapecdtn=
true ;
94 else if(ampls.size()==3){C_Dn=(Float_t)ampls[0] ;
if(C_Dn<=coeff1*coeffn*C_D+coeff2*coeffnn*C_M+2*noise || C_D==255) shapecdtn=
true;}
95 else if(ampls.size()>3){C_Dn=(Float_t)ampls[ampls.size()-3] ; C_Dnn=(Float_t)ampls[ampls.size()-4] ;
96 if((C_Dn<=coeff1*coeffn*C_D+coeff2*coeffnn*C_M+2*noise || C_D==255)
97 && C_Dnn<=coeff1*coeffn*C_Dn+coeff2*coeffnn*C_D+2*noise){
102 if(MaxInMiddle==
true){
103 C_M=(Float_t)ampls[MaxPos];
104 int LeftOfMaxPos=MaxPos-1;
if(LeftOfMaxPos<=0)LeftOfMaxPos=0;
105 int RightOfMaxPos=MaxPos+1;
if(RightOfMaxPos>=(
int)ampls.size())RightOfMaxPos=ampls.size()-1;
107 if(ampls[LeftOfMaxPos]<ampls[RightOfMaxPos]){ C_D=(Float_t)ampls[RightOfMaxPos]; C_Mn=(Float_t)ampls[LeftOfMaxPos];CDPos=RightOfMaxPos;}
else{ C_D=(Float_t)ampls[LeftOfMaxPos]; C_Mn=(Float_t)ampls[RightOfMaxPos];CDPos=LeftOfMaxPos;}
108 if(C_Mn<coeff1*coeffn*C_M+coeff2*coeffnn*C_D+2*noise || C_M==255){
109 if(ampls.size()==3) shapecdtn=
true ;
110 else if(ampls.size()>3){
112 if(ampls.size()-CDPos-1==0){
115 if(ampls.size()-CDPos-1==1){
116 C_Dn=(Float_t)ampls[CDPos+1];
119 if(ampls.size()-CDPos-1>1){
120 C_Dn=(Float_t)ampls[CDPos+1];
121 C_Dnn=(Float_t)ampls[CDPos+2];
124 C_Mnn=(Float_t)ampls[MaxPos-2];
126 else if(MaxPos<2) C_Mnn=0;
133 C_Dn=(Float_t)ampls[0];
137 C_Dn=(Float_t)ampls[CDPos-1];
138 C_Dnn=(Float_t)ampls[CDPos-2];
140 if(ampls.size()-LeftOfMaxPos>1 && MaxPos+2<(int)(ampls.size())-1){
141 C_Mnn=(Float_t)ampls[MaxPos+2];
144 if((C_Dn<=coeff1*coeffn*C_D+coeff2*coeffnn*C_M+2*noise || C_D==255)
145 && C_Mnn<=coeff1*coeffn*C_Mn+coeff2*coeffnn*C_M+2*noise
146 && C_Dnn<=coeff1*coeffn*C_Dn+coeff2*coeffnn*C_D+2*
noise) {
154 if(ampls.size()==1){shapecdtn=
true;}
168 if ( calibGains.empty() ) {
169 for(
unsigned int i=0;
i<Ampls.size();
i++){
170 int calibratedCharge = Ampls[
i];
171 charge+=calibratedCharge;
172 if(calibratedCharge>=254)nSatStrip++;
176 for(
unsigned int i=0;
i<Ampls.size();
i++){
177 int calibratedCharge = Ampls[
i];
179 auto & gains = calibGains[detUnit.
index()-m_off];
180 calibratedCharge = (int)(calibratedCharge / gains[(cluster->
firstStrip()+
i)/128] );
181 if ( calibratedCharge>=255 ) {
182 if ( calibratedCharge>=1025 )
183 calibratedCharge=255;
185 calibratedCharge=254;
188 charge+=calibratedCharge;
189 if(calibratedCharge>=254)nSatStrip++;
198 auto const & dus = tkGeom.
detUnits();
199 calibGains.resize(dus.size()-m_off);
201 TChain* t1 =
new TChain(
"SiStripCalib/APVGain");
202 t1->Add(m_calibrationPath.c_str());
204 unsigned int tree_DetId;
205 unsigned char tree_APVId;
207 t1->SetBranchAddress(
"DetId" ,&tree_DetId );
208 t1->SetBranchAddress(
"APVId" ,&tree_APVId );
209 t1->SetBranchAddress(
"Gain" ,&tree_Gain );
211 for (
unsigned int ientry = 0; ientry < t1->GetEntries(); ientry++) {
212 t1->GetEntry(ientry);
214 if(gains.size()<(size_t)(tree_APVId+1)){gains.resize(tree_APVId+1);}
215 gains[tree_APVId] = tree_Gain;
224 if( strcmp(Reccord.c_str(),
"SiStripDeDxMip_3D_Rcd")==0){
226 }
else if(strcmp(Reccord.c_str(),
"SiStripDeDxPion_3D_Rcd")==0){
228 }
else if(strcmp(Reccord.c_str(),
"SiStripDeDxKaon_3D_Rcd")==0){
230 }
else if(strcmp(Reccord.c_str(),
"SiStripDeDxProton_3D_Rcd")==0){
232 }
else if(strcmp(Reccord.c_str(),
"SiStripDeDxElectron_3D_Rcd")==0){
235 throw cms::Exception(
"WrongReccord for dEdx") <<
"The reccord : " << Reccord <<
"is unknown\n";
238 float xmin = deDxMapHandle->rangeX().min;
239 float xmax = deDxMapHandle->rangeX().max;
240 float ymin = deDxMapHandle->rangeY().min;
241 float ymax = deDxMapHandle->rangeY().max;
242 float zmin = deDxMapHandle->rangeZ().min;
243 float zmax = deDxMapHandle->rangeZ().max;
245 if(Prob_ChargePath)
delete Prob_ChargePath;
246 Prob_ChargePath =
new TH3F (
"Prob_ChargePath" ,
"Prob_ChargePath" , deDxMapHandle->numberOfBinsX(),
xmin,
xmax, deDxMapHandle->numberOfBinsY() ,
ymin,
ymax, deDxMapHandle->numberOfBinsZ(),
zmin,
zmax);
248 if(strcmp(ProbabilityMode.c_str(),
"Accumulation")==0){
249 for(
int i=0;
i<=Prob_ChargePath->GetXaxis()->GetNbins()+1;
i++){
250 for(
int j=0;
j<=Prob_ChargePath->GetYaxis()->GetNbins()+1;
j++){
252 for(
int k=0;
k<=Prob_ChargePath->GetZaxis()->GetNbins()+1;
k++){ Ni+=deDxMapHandle->binContent(
i,
j,
k);}
253 for(
int k=0;
k<=Prob_ChargePath->GetZaxis()->GetNbins()+1;
k++){
255 for(
int l=0;
l<=
k;
l++){ tmp+=deDxMapHandle->binContent(
i,
j,
l);}
257 Prob_ChargePath->SetBinContent (
i,
j,
k, tmp/Ni);
259 Prob_ChargePath->SetBinContent (
i,
j,
k, 0);
264 }
else if(strcmp(ProbabilityMode.c_str(),
"Integral")==0){
265 for(
int i=0;
i<=Prob_ChargePath->GetXaxis()->GetNbins()+1;
i++){
266 for(
int j=0;
j<=Prob_ChargePath->GetYaxis()->GetNbins()+1;
j++){
268 for(
int k=0;
k<=Prob_ChargePath->GetZaxis()->GetNbins()+1;
k++){ Ni+=deDxMapHandle->binContent(
i,
j,
k);}
269 for(
int k=0;
k<=Prob_ChargePath->GetZaxis()->GetNbins()+1;
k++){
270 float tmp = deDxMapHandle->binContent(
i,
j,
k);
272 Prob_ChargePath->SetBinContent (
i,
j,
k, tmp/Ni);
274 Prob_ChargePath->SetBinContent (
i,
j,
k, 0);
280 throw cms::Exception(
"WrongConfig for dEdx") <<
"The ProbabilityMode: " << ProbabilityMode <<
"is unknown\n";
288 if(FirstStrip==0 )
return true;
289 if(FirstStrip==128 )
return true;
290 if(FirstStrip==256 )
return true;
291 if(FirstStrip==384 )
return true;
292 if(FirstStrip==512 )
return true;
293 if(FirstStrip==640 )
return true;
295 if(FirstStrip<=127 && FirstStrip+ClusterSize>127)
return true;
296 if(FirstStrip<=255 && FirstStrip+ClusterSize>255)
return true;
297 if(FirstStrip<=383 && FirstStrip+ClusterSize>383)
return true;
298 if(FirstStrip<=511 && FirstStrip+ClusterSize>511)
return true;
299 if(FirstStrip<=639 && FirstStrip+ClusterSize>639)
return true;
301 if(FirstStrip+ClusterSize==127 )
return true;
302 if(FirstStrip+ClusterSize==255 )
return true;
303 if(FirstStrip+ClusterSize==383 )
return true;
304 if(FirstStrip+ClusterSize==511 )
return true;
305 if(FirstStrip+ClusterSize==639 )
return true;
306 if(FirstStrip+ClusterSize==767 )
return true;
313 if (dynamic_cast<const StripGeomDetUnit*>(it)==0 && dynamic_cast<const PixelGeomDetUnit*>(it)==0) {
314 edm::LogInfo(
"DeDxTools::IsFarFromBorder") <<
"this detID doesn't seem to belong to the Tracker" << std::endl;
322 const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
323 const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
325 double DistFromBorder = 1.0;
329 if(trapezoidalBounds)
331 std::array<const float, 4>
const &
parameters = (*trapezoidalBounds).parameters();
332 HalfLength = parameters[3];
335 }
else if(rectangularBounds){
341 if (fabs(HitLocalPos.y())+HitLocalError.
yy() >= (HalfLength - DistFromBorder) )
return false;
const TrackerGeomDet * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
virtual float length() const =0
LocalPoint localPosition() const
const Bounds & bounds() const
uint16_t firstStrip() const
const Plane & surface() const
The nominal surface of the GeomDet.
LocalError positionError() const
const LocalTrajectoryError & localError() const
std::vector< std::vector< double > > tmp
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::LocalCoordinateSystemTag > LocalPoint
point in local coordinate system
const std::vector< uint8_t > & amplitudes() const
const DetUnitContainer & detUnits() const
Returm a vector of all GeomDetUnit.